Merge pull request #15663 from s-hadinger/haspmota

Rename OpenHASP to HASPmota
This commit is contained in:
s-hadinger 2022-05-20 22:10:06 +02:00 committed by GitHub
commit 9ed7af1e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 153 additions and 153 deletions

View File

@ -52,9 +52,9 @@ be_extern_native_module(crc);
be_extern_native_module(lv);
be_extern_native_module(lv_extra);
be_extern_native_module(lv_tasmota);
#ifdef USE_LVGL_OPENHASP
be_extern_native_module(openhasp);
#endif // USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
be_extern_native_module(haspmota);
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL
/* user-defined modules declare start */
@ -137,9 +137,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
&be_native_module(lv),
&be_native_module(lv_extra),
&be_native_module(lv_tasmota),
#ifdef USE_LVGL_OPENHASP
&be_native_module(openhasp),
#endif // USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
&be_native_module(haspmota),
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL
#ifdef USE_ENERGY_SENSOR
&be_native_module(energy),

View File

@ -1,10 +1,10 @@
/********************************************************************
* Tasmota OpenHASP solidified
* Tasmota HASPmota solidified
*******************************************************************/
#include "be_constobj.h"
#ifdef USE_LVGL
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_arc;
@ -5847,39 +5847,10 @@ void be_load_lvh_qrcode_class(bvm *vm) {
be_pop(vm, 1);
}
/********************************************************************
** Solidified function: _anonymous_
********************************************************************/
be_local_closure(openhasp__anonymous_, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("OpenHASP"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: do_action
********************************************************************/
be_local_closure(OpenHASP_do_action, /* name */
be_local_closure(HASPmota_do_action, /* name */
be_nested_proto(
10, /* nstack */
3, /* argc */
@ -5991,7 +5962,7 @@ be_local_closure(OpenHASP_do_action, /* name */
/********************************************************************
** Solidified function: pages_list_sorted
********************************************************************/
be_local_closure(OpenHASP_pages_list_sorted, /* name */
be_local_closure(HASPmota_pages_list_sorted, /* name */
be_nested_proto(
8, /* nstack */
2, /* argc */
@ -6071,7 +6042,7 @@ be_local_closure(OpenHASP_pages_list_sorted, /* name */
/********************************************************************
** Solidified function: get_page_cur
********************************************************************/
be_local_closure(OpenHASP_get_page_cur, /* name */
be_local_closure(HASPmota_get_page_cur, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
@ -6101,7 +6072,7 @@ be_local_closure(OpenHASP_get_page_cur, /* name */
/********************************************************************
** Solidified function: start
********************************************************************/
be_local_closure(OpenHASP_start, /* name */
be_local_closure(HASPmota_start, /* name */
be_nested_proto(
11, /* nstack */
3, /* argc */
@ -6131,7 +6102,7 @@ be_local_closure(OpenHASP_start, /* name */
/* K16 */ be_nested_str_literal("font_embedded"),
/* K17 */ be_nested_str_literal("robotocondensed"),
/* K18 */ be_nested_str_literal("montserrat"),
/* K19 */ be_nested_str_literal("theme_openhasp_init"),
/* K19 */ be_nested_str_literal("theme_haspmota_init"),
/* K20 */ be_const_int(0),
/* K21 */ be_nested_str_literal("color"),
/* K22 */ be_const_int(16711935),
@ -6263,7 +6234,7 @@ be_local_closure(OpenHASP_start, /* name */
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(OpenHASP_init, /* name */
be_local_closure(HASPmota_init, /* name */
be_nested_proto(
5, /* nstack */
1, /* argc */
@ -6297,7 +6268,7 @@ be_local_closure(OpenHASP_init, /* name */
/********************************************************************
** Solidified function: register_event
********************************************************************/
be_local_closure(OpenHASP_register_event, /* name */
be_local_closure(HASPmota_register_event, /* name */
be_nested_proto(
13, /* nstack */
3, /* argc */
@ -6373,7 +6344,7 @@ be_local_closure(OpenHASP_register_event, /* name */
/********************************************************************
** Solidified function: parse_page
********************************************************************/
be_local_closure(OpenHASP_parse_page, /* name */
be_local_closure(HASPmota_parse_page, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -6465,7 +6436,7 @@ be_local_closure(OpenHASP_parse_page, /* name */
/********************************************************************
** Solidified function: deinit
********************************************************************/
be_local_closure(OpenHASP_deinit, /* name */
be_local_closure(HASPmota_deinit, /* name */
be_nested_proto(
5, /* nstack */
1, /* argc */
@ -6512,7 +6483,7 @@ be_local_closure(OpenHASP_deinit, /* name */
/********************************************************************
** Solidified function: page_dir_to
********************************************************************/
be_local_closure(OpenHASP_page_dir_to, /* name */
be_local_closure(HASPmota_page_dir_to, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
@ -6573,7 +6544,7 @@ be_local_closure(OpenHASP_page_dir_to, /* name */
/********************************************************************
** Solidified function: _load
********************************************************************/
be_local_closure(OpenHASP__load, /* name */
be_local_closure(HASPmota__load, /* name */
be_nested_proto(
14, /* nstack */
2, /* argc */
@ -6668,7 +6639,7 @@ be_local_closure(OpenHASP__load, /* name */
/********************************************************************
** Solidified function: parse
********************************************************************/
be_local_closure(OpenHASP_parse, /* name */
be_local_closure(HASPmota_parse, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -6722,7 +6693,7 @@ be_local_closure(OpenHASP_parse, /* name */
/********************************************************************
** Solidified function: sort
********************************************************************/
be_local_closure(OpenHASP_sort, /* name */
be_local_closure(HASPmota_sort, /* name */
be_nested_proto(
6, /* nstack */
1, /* argc */
@ -6778,7 +6749,7 @@ be_local_closure(OpenHASP_sort, /* name */
/********************************************************************
** Solidified function: parse_obj
********************************************************************/
be_local_closure(OpenHASP_parse_obj, /* name */
be_local_closure(HASPmota_parse_obj, /* name */
be_nested_proto(
20, /* nstack */
3, /* argc */
@ -7022,7 +6993,7 @@ be_local_closure(OpenHASP_parse_obj, /* name */
/********************************************************************
** Solidified function: event_dispatch
********************************************************************/
be_local_closure(OpenHASP_event_dispatch, /* name */
be_local_closure(HASPmota_event_dispatch, /* name */
be_nested_proto(
9, /* nstack */
2, /* argc */
@ -7090,27 +7061,27 @@ be_local_closure(OpenHASP_event_dispatch, /* name */
/********************************************************************
** Solidified class: OpenHASP
** Solidified class: HASPmota
********************************************************************/
be_local_class(OpenHASP,
be_local_class(HASPmota,
10,
NULL,
be_nested_map(43,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("lvh_textarea", 41), be_const_class(be_class_lvh_textarea) },
{ be_const_key_literal("scr", -1), be_const_var(3) },
{ be_const_key_literal("event_dispatch", 16), be_const_closure(OpenHASP_event_dispatch_closure) },
{ be_const_key_literal("event_dispatch", 16), be_const_closure(HASPmota_event_dispatch_closure) },
{ be_const_key_literal("lvh_bar", -1), be_const_class(be_class_lvh_bar) },
{ be_const_key_literal("lvh_img", -1), be_const_class(be_class_lvh_img) },
{ be_const_key_literal("event", -1), be_const_var(8) },
{ be_const_key_literal("do_action", 33), be_const_closure(OpenHASP_do_action_closure) },
{ be_const_key_literal("pages_list_sorted", -1), be_const_closure(OpenHASP_pages_list_sorted_closure) },
{ be_const_key_literal("do_action", 33), be_const_closure(HASPmota_do_action_closure) },
{ be_const_key_literal("pages_list_sorted", -1), be_const_closure(HASPmota_pages_list_sorted_closure) },
{ be_const_key_literal("lvh_btnmatrix", 42), be_const_class(be_class_lvh_btnmatrix) },
{ be_const_key_literal("start", -1), be_const_closure(OpenHASP_start_closure) },
{ be_const_key_literal("init", 5), be_const_closure(OpenHASP_init_closure) },
{ be_const_key_literal("start", -1), be_const_closure(HASPmota_start_closure) },
{ be_const_key_literal("init", 5), be_const_closure(HASPmota_init_closure) },
{ be_const_key_literal("lvh_scr", -1), be_const_class(be_class_lvh_scr) },
{ be_const_key_literal("parse_page", -1), be_const_closure(OpenHASP_parse_page_closure) },
{ be_const_key_literal("register_event", 24), be_const_closure(OpenHASP_register_event_closure) },
{ be_const_key_literal("parse_page", -1), be_const_closure(HASPmota_parse_page_closure) },
{ be_const_key_literal("register_event", 24), be_const_closure(HASPmota_register_event_closure) },
{ be_const_key_literal("lvh_roller", 34), be_const_class(be_class_lvh_roller) },
{ be_const_key_literal("lvh_page", 11), be_const_class(be_class_lvh_page) },
{ be_const_key_literal("lvh_page_cur_idx", -1), be_const_var(6) },
@ -7118,13 +7089,13 @@ be_local_class(OpenHASP,
{ be_const_key_literal("hres", 38), be_const_var(1) },
{ be_const_key_literal("dark", -1), be_const_var(0) },
{ be_const_key_literal("lvh_label", 37), be_const_class(be_class_lvh_label) },
{ be_const_key_literal("deinit", 14), be_const_closure(OpenHASP_deinit_closure) },
{ be_const_key_literal("page_dir_to", -1), be_const_closure(OpenHASP_page_dir_to_closure) },
{ be_const_key_literal("parse_obj", -1), be_const_closure(OpenHASP_parse_obj_closure) },
{ be_const_key_literal("deinit", 14), be_const_closure(HASPmota_deinit_closure) },
{ be_const_key_literal("page_dir_to", -1), be_const_closure(HASPmota_page_dir_to_closure) },
{ be_const_key_literal("parse_obj", -1), be_const_closure(HASPmota_parse_obj_closure) },
{ be_const_key_literal("lvh_spinner", -1), be_const_class(be_class_lvh_spinner) },
{ be_const_key_literal("_load", -1), be_const_closure(OpenHASP__load_closure) },
{ be_const_key_literal("_load", -1), be_const_closure(HASPmota__load_closure) },
{ be_const_key_literal("lvh_qrcode", -1), be_const_class(be_class_lvh_qrcode) },
{ be_const_key_literal("parse", -1), be_const_closure(OpenHASP_parse_closure) },
{ be_const_key_literal("parse", -1), be_const_closure(HASPmota_parse_closure) },
{ be_const_key_literal("lvh_pages", 2), be_const_var(5) },
{ be_const_key_literal("lvh_line", -1), be_const_class(be_class_lvh_line) },
{ be_const_key_literal("lvh_switch", -1), be_const_class(be_class_lvh_switch) },
@ -7132,32 +7103,61 @@ be_local_class(OpenHASP,
{ be_const_key_literal("r16", -1), be_const_var(4) },
{ be_const_key_literal("def_templ_name", -1), be_nested_str_literal("pages.jsonl") },
{ be_const_key_literal("lvh_obj", 19), be_const_class(be_class_lvh_obj) },
{ be_const_key_literal("sort", 23), be_const_static_closure(OpenHASP_sort_closure) },
{ be_const_key_literal("sort", 23), be_const_static_closure(HASPmota_sort_closure) },
{ be_const_key_literal("lvh_dropdown", -1), be_const_class(be_class_lvh_dropdown) },
{ be_const_key_literal("lvh_checkbox", -1), be_const_class(be_class_lvh_checkbox) },
{ be_const_key_literal("lvh_slider", -1), be_const_class(be_class_lvh_slider) },
{ be_const_key_literal("vres", -1), be_const_var(2) },
{ be_const_key_literal("lvh_btn", -1), be_const_class(be_class_lvh_btn) },
{ be_const_key_literal("event_cb", -1), be_const_var(9) },
{ be_const_key_literal("get_page_cur", -1), be_const_closure(OpenHASP_get_page_cur_closure) },
{ be_const_key_literal("get_page_cur", -1), be_const_closure(HASPmota_get_page_cur_closure) },
})),
be_str_literal("OpenHASP")
be_str_literal("HASPmota")
);
/********************************************************************
** Solidified module: openhasp
** Solidified function: _anonymous_
********************************************************************/
be_local_module(openhasp,
"openhasp",
be_local_closure(haspmota__anonymous_, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("HASPmota"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified module: haspmota
********************************************************************/
be_local_module(haspmota,
"haspmota",
be_nested_map(2,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("OpenHASP", -1), be_const_class(be_class_OpenHASP) },
{ be_const_key_literal("init", 0), be_const_closure(openhasp__anonymous__closure) },
{ be_const_key_literal("HASPmota", -1), be_const_class(be_class_HASPmota) },
{ be_const_key_literal("init", -1), be_const_closure(haspmota__anonymous__closure) },
}))
);
BE_EXPORT_VARIABLE be_define_const_native_module(openhasp);
BE_EXPORT_VARIABLE be_define_const_native_module(haspmota);
/********************************************************************/
#endif // USE_LVGL_OPENHASP
#endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL

View File

@ -8,7 +8,7 @@
*********************/
#include "../lvgl.h" /*To see all the widgets*/
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
#include "misc/lv_gc.h"
/*********************
@ -625,7 +625,7 @@ static void style_init(void)
* GLOBAL FUNCTIONS
**********************/
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
{
/*This trick is required only to avoid the garbage collection of
@ -658,7 +658,7 @@ lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary,
return (lv_theme_t *)&theme;
}
bool lv_theme_openhasp_is_inited(void)
bool lv_theme_haspmota_is_inited(void)
{
return inited;
}

View File

@ -1,5 +1,5 @@
/**
* @file lv_theme_openhasp.h
* @file lv_theme_haspmota.h
*
*/
@ -40,9 +40,9 @@ typedef enum {
* @param font pointer to a font to use.
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
bool lv_theme_openhasp_is_inited(void);
bool lv_theme_haspmota_is_inited(void);
/**********************
* MACROS

View File

@ -9,7 +9,7 @@
#include "lvgl.h"
#include "be_mapping.h"
#include "lv_berry.h"
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm);
@ -163,9 +163,9 @@ const be_ntv_func_def_t lv_func[] = {
{ "theme_get_font_normal", { (const void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_font_small", { (const void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_from_obj", { (const void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" } },
{ "theme_haspmota_init", { (const void*) &lv_theme_haspmota_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_haspmota_is_inited", { (const void*) &lv_theme_haspmota_is_inited, "b", "" } },
{ "theme_mono_init", { (const void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" } },
{ "theme_openhasp_init", { (const void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_openhasp_is_inited", { (const void*) &lv_theme_openhasp_is_inited, "b", "" } },
{ "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } },
{ "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } },
{ "timer_create", { (const void*) &lv_timer_create, "lv.lv_timer", "^lv_timer_cb^i." } },

View File

@ -1151,7 +1151,7 @@ void lv_textarea_cursor_left(lv_obj_t * obj)
void lv_textarea_cursor_down(lv_obj_t * obj)
void lv_textarea_cursor_up(lv_obj_t * obj)
// ../../LVGL_assets/src/lv_theme_openhasp.h
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_openhasp_is_inited(void)
// ../../LVGL_assets/src/lv_theme_haspmota.h
lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_haspmota_is_inited(void)

View File

@ -741,7 +741,7 @@ print("""/********************************************************************
#include "lvgl.h"
#include "be_mapping.h"
#include "lv_berry.h"
#include "lv_theme_openhasp.h"
#include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm);

View File

@ -78,7 +78,7 @@ lv_fun_globs = [
#"**/*.h",
]
headers_names = list_files(lv_src_prefix, lv_fun_globs)
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_openhasp.h"])
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_haspmota.h"])
# headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor
# unit test

View File

@ -0,0 +1,5 @@
# generate all haspmota tapp files
rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
cp haspmota.tapp ../haspmota
cp haspmota_demo.tapp ../haspmota

View File

@ -0,0 +1,7 @@
# start haspmota
# package with
# rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
import haspmota
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> haspmota.start())

View File

@ -1,19 +1,19 @@
# OpenHASP compatibility module
# HASPMota - OpenHASP compatibility module
#
# use `import openhasp` and set the JSONL definitions in `pages.jsonl`
# use `import haspmota` and set the JSONL definitions in `pages.jsonl`
#
# As an optimization `0 #- lv.PART_MAIN | lv.STATE_DEFAULT -#` is replaced with `0`
#
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
# rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
#################################################################################
# How to solidify (needs an ESP32 with PSRAM)
#-
import path
path.remove("openhasp.bec")
path.remove("haspmota.bec")
import solidify
var openhasp
load('openhasp.be')
var haspmota
load('haspmota.be')
var classes = [
"page", "obj", "scr",
@ -23,12 +23,12 @@ var classes = [
"qrcode"
]
for c:classes
solidify.dump(openhasp.OpenHASP.("lvh_"+c), true)
solidify.dump(haspmota.HASPmota.("lvh_"+c), true)
end
solidify.dump(openhasp, true)
solidify.dump(haspmota, true)
-#
var openhasp = module("openhasp")
var haspmota = module("haspmota")
#################################################################################
#################################################################################
@ -37,7 +37,7 @@ var openhasp = module("openhasp")
# Provide a mapping for virtual members
# Stores the associated page and object id
#
# Adds specific virtual members used by OpenHASP
# Adds specific virtual members used by HASPmota
#################################################################################
#################################################################################
class lvh_obj
@ -62,7 +62,7 @@ class lvh_obj
# and the Berry or LVGL attribute to set
#
# We try to map directly an attribute to the LVGL
# Ex: OpenHASP attribute `w` is mapped to LVGL `width`
# Ex: HASPmota attribute `w` is mapped to LVGL `width`
#
# If mapping is null, we use set_X and get_X from our own class
static _attr_map = {
@ -150,7 +150,7 @@ class lvh_obj
var _lv_obj # native lvgl object
var _lv_label # sub-label if exists
var _page # parent page object
var _action # value of the OpenHASP `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
var _action # value of the HASPmota `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
#====================================================================
# Rule engine to map value and text to rules
@ -242,10 +242,10 @@ class lvh_obj
end
#====================================================================
# init OpenHASP object from its jsonl definition
# init HASPmota object from its jsonl definition
#
# arg1: LVGL parent object (used to create a sub-object)
# arg2: `jline` JSONL definition of the object from OpenHASP template (used in sub-classes)
# arg2: `jline` JSONL definition of the object from HASPmota template (used in sub-classes)
# arg3: (opt) LVGL object if it already exists and was created prior to init()
#====================================================================
def init(parent, page, jline, obj)
@ -323,7 +323,7 @@ class lvh_obj
# the callback avoids doing anything sophisticated in the cb
# defer the actual action to the Tasmota event loop
# print("-> CB fired","self",self,"obj",obj,"event",event.tomap(),"code",event.code)
var oh = self._page._oh # openhasp global object
var oh = self._page._oh # haspmota global object
var code = event.code # materialize to a local variable, otherwise the value can change (and don't capture event object)
if self.action != "" && code == lv.EVENT_CLICKED
# if clicked and action is declared, do the page change event
@ -507,7 +507,7 @@ class lvh_obj
#====================================================================
# `text_font`
#
# For OpenHASP compatiblity, default to "robotocondensed-latin1"
# For HASPmota compatiblity, default to "robotocondensed-latin1"
# However we propose an extension to allow for other font names
#
# Arg1: (int) font size for `robotocondensed-latin1`
@ -1104,7 +1104,7 @@ class lvh_dropdown : lvh_obj
end
end
# direction needs a conversion from OpenHASP numbers and LVGL's
# direction needs a conversion from HASPmota numbers and LVGL's
def set_direction(t)
# 0 = down, 1 = up, 2 = left, 3 = right
self._lv_obj.set_dir(self._dir[int(t)])
@ -1119,7 +1119,7 @@ class lvh_dropdown : lvh_obj
return -1
end
# show_selected (bool) is a OpenHASP addition
# show_selected (bool) is a HASPmota addition
# only meaningful if set to `true`, setting to false requires a call to `set_text`
def set_show_selected(t)
if t
@ -1159,22 +1159,22 @@ class lvh_page
var _obj_id # (map) of `lvh_obj` objects by id numbers
var _page_id # (int) id number of this page
var _lv_scr # (lv_obj) lvgl screen object
var _oh # OpenHASP global object
# openhasp attributes for page are on item `#0`
var _oh # HASPmota global object
# haspmota attributes for page are on item `#0`
var prev, next, back # (int) id values for `prev`, `next`, `back` buttons
#====================================================================
# `init`
#
# arg1: `page_number` (int) OpenHASP page id
# arg1: `page_number` (int) HASPmota page id
# defaults to `1` if not specified
# page 0 is special, visible on all pages. Internally uses `layer_top`
# arg2: `oh` global OpenHASP monad object
# page_number: openhasp page number, defaults to `1` if not specified
# arg2: `oh` global HASPmota monad object
# page_number: haspmota page number, defaults to `1` if not specified
#====================================================================
def init(page_number, oh)
import global
self._oh = oh # memorize OpenHASP parent object
self._oh = oh # memorize HASPmota parent object
# if no parameter, default to page #1
page_number = int(page_number)
@ -1283,17 +1283,17 @@ end
#################################################################################
#
# class `OpenHASP` to initialize the OpenHASP parsing
# class `HASPmota` to initialize the HASPmota parsing
#
#################################################################################
# main class controller, meant to be a singleton and the only externally used class
class OpenHASP
class HASPmota
var dark # (bool) use dark theme?
var hres, vres # (int) resolution
var scr # (lv_obj) default LVGL screen
var r16 # (lv_font) robotocondensed fonts size 16
# openhasp objects
# haspmota objects
var lvh_pages # (list of lvg_page) list of pages
var lvh_page_cur_idx # (int) current page index number
# regex patterns
@ -1376,8 +1376,8 @@ class OpenHASP
self.r16 = lv.font_embedded("montserrat", 14) # TODO what if does not exist
end
# set the theme for OpenHASP
var th2 = lv.theme_openhasp_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16)
# set the theme for HASPmota
var th2 = lv.theme_haspmota_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16)
self.scr.get_disp().set_theme(th2)
self.scr.set_style_bg_color(self.dark ? lv.color(0x000000) : lv.color(0xFFFFFF),0) # set background to white
# apply theme to layer_top, but keep it transparent
@ -1675,7 +1675,7 @@ class OpenHASP
return
end
# extract openhasp class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
# extract haspmota class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
# extract parent
var parent_lvgl
var parent_id = int(jline.find("parentid"))
@ -1746,20 +1746,20 @@ class OpenHASP
end
end
end
openhasp.OpenHASP = OpenHASP
haspmota.HASPmota = HASPmota
#################################################################################
# General module initilization
#################################################################################
# automatically instanciate the OpenHASP() monad
# automatically instanciate the HASPmota() monad
# note: value is cached in the module cache
# and is returned whenever you call `import openhasp` again
# and is returned whenever you call `import haspmota` again
# This means that the object is never garbage collected
#
openhasp.init = def (m) # `init(m)` is called during first `import openhasp`
var oh = m.OpenHASP
haspmota.init = def (m) # `init(m)` is called during first `import haspmota`
var oh = m.HASPmota
return oh()
end
return openhasp
return haspmota

View File

@ -1,5 +1,5 @@
# OpenHASP demo
# rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
# rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
if !tasmota.memory().contains("psram")
print("HSP: Error: OpenHASP demo requires PSRAM")
@ -10,8 +10,8 @@ import lv_tasmota_log
import lv_tasmota_info
import lv_wifi_graph
import openhasp
openhasp.start(false, "openhasp_demo.tapp#pages.jsonl")
import haspmota
haspmota.start(false, "haspmota_demo.tapp#pages.jsonl")
var prev_day = -1
def set_watch()

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -36,16 +36,16 @@
{"page":4,"comment":"---------- Page 4 - fan animation ----------"}
{"id":0,"bg_color":"#0000A0","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#FFFFFF"}
{"id":11,"obj":"img","src":"A:/openhasp_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150}
{"id":11,"obj":"img","src":"A:/haspmota_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150}
{"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
{"page":5,"comment":"---------- Page 5 - fancy watch ----------"}
{"id":0,"bg_color":"#000000","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#000000"}
{"id":10,"obj":"img","src":"A:/openhasp_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240}
{"id":11,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45}
{"id":12,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_min_240.png","auto_size":1}
{"id":13,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10}
{"id":10,"obj":"img","src":"A:/haspmota_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240}
{"id":11,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45}
{"id":12,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_min_240.png","auto_size":1}
{"id":13,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10}
{"id":15,"obj":"label","parentid":10,"x":184,"y":112,"w":18,"h":16,"text":"","align":1,"text_font":"montserrat-14"}

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,6 +1,6 @@
# pre-load widgets so future `import` will be already in memory
# create tapp file with:
# rm rm openhasp_widgets.tapp; zip -j -0 openhasp_widgets.tapp openhasp_widgets/*
# rm rm haspmota_widgets.tapp; zip -j -0 haspmota_widgets.tapp haspmota_widgets/*
import lv_tasmota_log
import lv_tasmota_info
import lv_wifi_graph

View File

@ -1,5 +0,0 @@
# generate all openhasp tapp files
rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
cp openhasp.tapp ../openhasp
cp openhasp_demo.tapp ../openhasp

View File

@ -1,7 +0,0 @@
# start openhasp
# package with
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
import openhasp
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> openhasp.start())

View File

@ -1048,7 +1048,7 @@
// -- LVGL Graphics Library ---------------------------------
//#define USE_LVGL // LVGL Engine, requires Berry (+382KB)
#define USE_LVGL_PSRAM // Allocate LVGL memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
// #define USE_LVGL_OPENHASP // Enable OpenHASP compatiblity and Robotocondensed fonts (+90KB flash)
// #define USE_LVGL_HASPMOTA // Enable OpenHASP compatiblity and Robotocondensed fonts (+90KB flash)
#define USE_LVGL_MAX_SLEEP 10 // max sleep in ms when LVGL is enabled, more than 10ms will make display less responsive
#define USE_LVGL_PNG_DECODER // include a PNG image decoder from file system (+16KB)
//#define USE_LVGL_TOUCHSCREEN // Use virtual touch screen with Berry driver

View File

@ -260,7 +260,7 @@
#ifdef FIRMWARE_LVGL
#undef CODE_IMAGE_STR
#define CODE_IMAGE_STR "lvgl-openhasp"
#define CODE_IMAGE_STR "lvgl-haspmota"
#undef MODULE
#define MODULE WEMOS // [Module] Select default module from tasmota_template.h
@ -276,7 +276,7 @@
#define USE_I2S
#define USE_SPI
#define USE_LVGL
#define USE_LVGL_OPENHASP
#define USE_LVGL_HASPMOTA
#define USE_LVGL_FREETYPE
#undef SET_ESP32_STACK_SIZE
#define SET_ESP32_STACK_SIZE (24 * 1024)

View File

@ -306,7 +306,7 @@ extern "C" {
{ "montserrat", lv_montserrat_fonts },
{ "seg7", lv_seg7_fonts },
{ "unscii", lv_unscii_fonts},
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
{ "robotocondensed", lv_robotocondensed_fonts },
#endif
{ nullptr, nullptr}
@ -355,9 +355,9 @@ extern "C" {
}
int lv0_load_robotocondensed_latin1_font(bvm *vm) {
#ifdef USE_LVGL_OPENHASP
#ifdef USE_LVGL_HASPMOTA
return lv_load_embedded_font(vm, "robotocondensed", 0);
#endif // USE_LVGL_OPENHASP
#endif // USE_LVGL_HASPMOTA
be_raise(vm, kTypeError, nullptr);
}