Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HASPmota solidify server-side #20938

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/Tasmota_build_devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ jobs:
run: |
cd lib/libesp32_lvgl/lv_binding_berry
../../libesp32/berry/berry -s -g solidify_all.be
- name: HASPmota Berry Code
run: |
cd lib/libesp32_lvgl/lv_haspmota
../../libesp32/berry/berry -s -g solidify_all.be
- uses: jason2866/[email protected]
with:
name: '["berry_tasmota", "berry_matter", "berry_animate", "berry_lvgl", "berry_header"]'
path: '["./lib/libesp32/berry_tasmota/src/solidify", "./lib/libesp32/berry_matter/src/solidify", "./lib/libesp32/berry_animate/src/solidify", "./lib/libesp32_lvgl/lv_binding_berry/src/solidify", "./lib/libesp32/berry/generate"]'
name: '["berry_tasmota", "berry_matter", "berry_animate", "berry_lvgl", "berry_haspmota", "berry_header"]'
path: '["./lib/libesp32/berry_tasmota/src/solidify", "./lib/libesp32/berry_matter/src/solidify", "./lib/libesp32/berry_animate/src/solidify", "./lib/libesp32_lvgl/lv_binding_berry/src/solidify", "./lib/libesp32_lvgl/lv_haspmota/src/solidify", "./lib/libesp32/berry/generate"]'

push_solidified:
needs: be_solidify
Expand All @@ -69,12 +73,14 @@ jobs:
berry_matter
berry_animate
berry_lvgl
berry_haspmota
berry_header
path: |
./lib/libesp32/berry_tasmota/src/solidify
./lib/libesp32/berry_matter/src/solidify
./lib/libesp32/berry_animate/src/solidify
./lib/libesp32_lvgl/lv_binding_berry/src/solidify
./lib/libesp32_lvgl/lv_haspmota/src/solidify
./lib/libesp32/berry/generate
- uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
- LVGL optimize fonts and add icons (#20880)
- LVGL improved readability of montserrat-10 (#20900)
- HASPmota moved to a distinct library `lv_haspmota`
- HASPmota solidify server-side

### Fixed
- Berry bug when parsing ternary operator (#20839)
Expand Down
99 changes: 99 additions & 0 deletions lib/libesp32_lvgl/lv_haspmota/solidify_all.be
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env -S ../../libesp32/berry/berry -s -g
#
# Berry solidify files

import os
import global
import solidify
import string as string2
import re

import sys
sys.path().push('src/embedded') # allow to import from src/embedded

# globals that need to exist to make compilation succeed
var globs = "path,ctypes_bytes_dyn,tasmota,ccronexpr,gpio,light,webclient,load,MD5,lv,light_state,udp,tcpclientasync,"
"lv_clock,lv_clock_icon,lv_signal_arcs,lv_signal_bars,lv_wifi_arcs_icon,lv_wifi_arcs,"
"lv_wifi_bars_icon,lv_wifi_bars,"
"_lvgl,"
"int64"

for g:string2.split(globs, ",")
global.(g) = nil
end

var prefix_dir = "src/embedded/"
var prefix_out = "src/solidify/"

def sort(l)
# insertion sort
for i:1..size(l)-1
var k = l[i]
var j = i
while (j > 0) && (l[j-1] > k)
l[j] = l[j-1]
j -= 1
end
l[j] = k
end
return l
end

def clean_directory(dir)
var file_list = os.listdir(dir)
for f : file_list
if f[0] == '.' continue end # ignore files starting with `.`
os.remove(dir + f)
end
end

var pattern = "#@\\s*solidify:([A-Za-z0-9_.,]+)"

def parse_file(fname, prefix_out)
print("Parsing: ", fname)
var f = open(prefix_dir + fname)
var src = f.read()
f.close()
# try to compile
var compiled = compile(src)
compiled() # run the compile code to instanciate the classes and modules
# output solidified
var fname_h = string2.split(fname, '.be')[0] + '.h' # take whatever is before the first '.be'
var fout = open(prefix_out + "solidified_" + fname_h, "w")
fout.write(f"/* Solidification of {fname_h} */\n")
fout.write("/********************************************************************\\\n")
fout.write("* Generated code, don't edit *\n")
fout.write("\\********************************************************************/\n")
fout.write('#include "be_constobj.h"\n')

var directives = re.searchall(pattern, src)
# print(directives)

for directive : directives
var object_list = string2.split(directive[1], ',')
var object_name = object_list[0]
var weak = (object_list.find('weak') != nil) # do we solidify with weak strings?
var o = global
var cl_name = nil
var obj_name = nil
for subname : string2.split(object_name, '.')
o = o.(subname)
cl_name = obj_name
obj_name = subname
end
solidify.dump(o, weak, fout, cl_name)
end

fout.write("/********************************************************************/\n")
fout.write("/* End of solidification */\n")
fout.close()
end

clean_directory(prefix_out)

var src_file_list = os.listdir(prefix_dir)
src_file_list = sort(src_file_list)
for src_file : src_file_list
if src_file[0] == '.' continue end
parse_file(src_file, prefix_out)
end
38 changes: 37 additions & 1 deletion lib/libesp32_lvgl/lv_haspmota/src/be_lv_haspmota.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
/********************************************************************
* Tasmota HASPmota solidified
*******************************************************************/
#include "be_constobj.h"

#include "solidify/be_lv_haspmota_solidified.h"
#ifdef USE_LVGL
#ifdef USE_LVGL_HASPMOTA

extern const bclass be_class_lv_page;
extern const bclass be_class_lv_obj;
extern const bclass be_class_lv_scr;
extern const bclass be_class_lv_btn;
extern const bclass be_class_lv_switch;
extern const bclass be_class_lv_checkbox;
extern const bclass be_class_lv_label;
extern const bclass be_class_lv_spinner;
extern const bclass be_class_lv_line;
extern const bclass be_class_lv_img;
extern const bclass be_class_lv_roller;
extern const bclass be_class_lv_btnmatrix;
extern const bclass be_class_lv_bar;
extern const bclass be_class_lv_slider;
extern const bclass be_class_lv_arc;
extern const bclass be_class_lv_led;
extern const bclass be_class_lv_dropdown;
extern const bclass be_class_lv_scale;
extern const bclass be_class_lv_qrcode;
extern const bclass be_class_lv_chart;
extern const bclass be_class_lv_spangroup;
extern const bclass be_class_lv_span;
extern const bclass be_class_lv_button;
extern const bclass be_class_lv_image;
extern const bclass be_class_lv_buttonmatrix;

#include "solidify/solidified_lv_haspmota.h"

#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL
23 changes: 23 additions & 0 deletions lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_0_module.be
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# LVGL prepare for lv_haspmota solidification
# mock `lv` module

lv = module('lv')

import global
tasmota = nil

var classes = [
"page", "obj", "scr",
"btn", "switch", "checkbox",
"label", "spinner", "line", "img", "roller", "btnmatrix",
"bar", "slider", "arc", "textarea", "led", "dropdown",
"scale",
"qrcode", "chart", "spangroup", "span",
# new internal names
"button", "image", "buttonmatrix",
]

for cl: classes
var s = f"class lv_{cl} end lv.{cl} = lv_{cl}"
compile(s)()
end
Loading