mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
lvgl v8 preparations
This commit is contained in:
parent
5470d99c7a
commit
c8ab33232c
@ -581,9 +581,15 @@ typedef void * lv_font_user_data_t;
|
|||||||
* LV_OBJ SETTINGS
|
* LV_OBJ SETTINGS
|
||||||
*==================*/
|
*==================*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t objid:5;
|
||||||
|
uint8_t groupid:3;
|
||||||
|
uint8_t id;
|
||||||
|
} lv_obj_user_data_t;
|
||||||
|
|
||||||
#if LV_USE_USER_DATA
|
#if LV_USE_USER_DATA
|
||||||
/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/
|
/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/
|
||||||
typedef uint8_t lv_obj_user_data_t;
|
//typedef hasp_obj_user_data_t lv_obj_user_data_t;
|
||||||
/*Provide a function to free user data*/
|
/*Provide a function to free user data*/
|
||||||
#define LV_USE_USER_DATA_FREE 0
|
#define LV_USE_USER_DATA_FREE 0
|
||||||
#if LV_USE_USER_DATA_FREE
|
#if LV_USE_USER_DATA_FREE
|
||||||
|
@ -58,23 +58,23 @@ build_flags =
|
|||||||
;-D DISABLE_LOGGING
|
;-D DISABLE_LOGGING
|
||||||
${override.build_flags}
|
${override.build_flags}
|
||||||
-D HASP_VERSION_MAJOR=0
|
-D HASP_VERSION_MAJOR=0
|
||||||
-D HASP_VERSION_MINOR=2
|
-D HASP_VERSION_MINOR=3
|
||||||
-D HASP_VERSION_REVISION=1129
|
-D HASP_VERSION_REVISION=1207
|
||||||
|
|
||||||
; -- Shared library dependencies in all environments
|
; -- Shared library dependencies in all environments
|
||||||
|
; Warning : don't put comments after github links => causes infinite download loop
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/fvanroie/lvgl.git#dev ; lvgl 8.0.0 dev
|
|
||||||
https://github.com/fvanroie/lv_components ;lvgl widgets 8.0.0
|
|
||||||
|
|
||||||
;lvgl/lvgl @ ^7.7.2 ; from PIO library
|
|
||||||
bodmer/TFT_eSPI @ 2.3.4 ; Tft SPI drivers EXACT version 2.3.5 has compile error
|
|
||||||
bxparks/AceButton @ ^1.7.1 ; GPIO button library
|
bxparks/AceButton @ ^1.7.1 ; GPIO button library
|
||||||
bblanchon/ArduinoJson @ ^6.17.2 ; Json(l) parser
|
bblanchon/ArduinoJson @ ^6.17.2 ; Json(l) parser
|
||||||
bblanchon/StreamUtils @ 1.6.0 ; for EEPromStream
|
bblanchon/StreamUtils @ 1.6.0 ; for EEPromStream
|
||||||
knolleary/PubSubClient @ ^2.8.0 ; MQTT client
|
knolleary/PubSubClient @ ^2.8.0 ; MQTT client
|
||||||
;https://github.com/Bodmer/TFT_eSPI.git ; ^2.3.5 needed for DMA
|
git+https://github.com/Bodmer/TFT_eSPI.git ; ztest
|
||||||
https://github.com/fvanroie/ConsoleInput.git
|
git+https://github.com/fvanroie/ConsoleInput.git
|
||||||
https://github.com/andrethomas/TasmotaSlave.git
|
git+https://github.com/andrethomas/TasmotaSlave.git
|
||||||
|
git+https://github.com/fvanroie/lv_components.git
|
||||||
|
git+https://github.com/lvgl/lvgl.git#dev
|
||||||
|
;lvgl/lvgl @ ^7.7.2 ; from PIO library
|
||||||
|
;bodmer/TFT_eSPI @ 2.3.4 ; Tft SPI drivers EXACT version 2.3.5 has compile error
|
||||||
; ------ Unused / Test libraries
|
; ------ Unused / Test libraries
|
||||||
;https://github.com/netwizeBE/TFT_eSPI.git
|
;https://github.com/netwizeBE/TFT_eSPI.git
|
||||||
;Syslog@^2.0.0 ; Obsoleted
|
;Syslog@^2.0.0 ; Obsoleted
|
||||||
@ -130,7 +130,7 @@ build_flags=
|
|||||||
-D ATOMIC_FS_UPDATE ; enabled compressed ota updates
|
-D ATOMIC_FS_UPDATE ; enabled compressed ota updates
|
||||||
-D NO_GLOBAL_HTTPUPDATE ; dont instantiate httpUpdate
|
-D NO_GLOBAL_HTTPUPDATE ; dont instantiate httpUpdate
|
||||||
; -- lvgl build options -----------------------------
|
; -- lvgl build options -----------------------------
|
||||||
-D LV_MEM_SIZE=10240U ; 10kB lvgl memory
|
-D LV_MEM_SIZE=16384U ; 16kB lvgl memory
|
||||||
; -- hasp-lvgl build options ------------------------
|
; -- hasp-lvgl build options ------------------------
|
||||||
-D HASP_USE_WIFI=1
|
-D HASP_USE_WIFI=1
|
||||||
-D HASP_USE_MQTT=1
|
-D HASP_USE_MQTT=1
|
||||||
|
@ -187,7 +187,7 @@ void haspReconnect()
|
|||||||
void haspProgressVal(uint8_t val)
|
void haspProgressVal(uint8_t val)
|
||||||
{
|
{
|
||||||
lv_obj_t * layer = lv_disp_get_layer_sys(NULL);
|
lv_obj_t * layer = lv_disp_get_layer_sys(NULL);
|
||||||
lv_obj_t * bar = hasp_find_obj_from_id(255, 10);
|
lv_obj_t * bar = hasp_find_obj_from_parent_id(get_page_obj(255), (uint8_t)10);
|
||||||
if(layer && bar) {
|
if(layer && bar) {
|
||||||
if(val == 255) {
|
if(val == 255) {
|
||||||
if(!lv_obj_get_hidden(bar)) {
|
if(!lv_obj_get_hidden(bar)) {
|
||||||
@ -212,7 +212,7 @@ void haspProgressVal(uint8_t val)
|
|||||||
// Sets the value string of the global progress bar
|
// Sets the value string of the global progress bar
|
||||||
void haspProgressMsg(const char * msg)
|
void haspProgressMsg(const char * msg)
|
||||||
{
|
{
|
||||||
lv_obj_t * bar = hasp_find_obj_from_id(255, 10);
|
lv_obj_t * bar = hasp_find_obj_from_parent_id(get_page_obj(255), (uint8_t)10);
|
||||||
|
|
||||||
char value_str[10];
|
char value_str[10];
|
||||||
snprintf_P(value_str, sizeof(value_str), PSTR("value_str"));
|
snprintf_P(value_str, sizeof(value_str), PSTR("value_str"));
|
||||||
@ -539,13 +539,14 @@ void haspSetPage(uint8_t pageid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO make this a recursicee function
|
||||||
void hasp_set_group_objects(uint8_t groupid, uint8_t eventid, lv_obj_t * src_obj)
|
void hasp_set_group_objects(uint8_t groupid, uint8_t eventid, lv_obj_t * src_obj)
|
||||||
{
|
{
|
||||||
bool state = dispatch_get_event_state(eventid);
|
bool state = dispatch_get_event_state(eventid);
|
||||||
for(uint8_t page = 0; page < HASP_NUM_PAGES; page++) {
|
for(uint8_t page = 0; page < HASP_NUM_PAGES; page++) {
|
||||||
uint8_t startid = 100 + groupid * 10; // groups start at id 100
|
uint8_t startid = 100 + groupid * 10; // groups start at id 100
|
||||||
for(uint8_t objid = startid; objid < (startid + 10); objid++) {
|
for(uint8_t objid = startid; objid < (startid + 10); objid++) {
|
||||||
lv_obj_t * obj = hasp_find_obj_from_id(page, objid);
|
lv_obj_t * obj = hasp_find_obj_from_parent_id(get_page_obj(page), objid);
|
||||||
if(obj && obj != src_obj) { // skip source object, if set
|
if(obj && obj != src_obj) { // skip source object, if set
|
||||||
lv_obj_set_state(obj, state ? LV_STATE_PRESSED | LV_STATE_CHECKED : LV_STATE_DEFAULT);
|
lv_obj_set_state(obj, state ? LV_STATE_PRESSED | LV_STATE_CHECKED : LV_STATE_DEFAULT);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
#if LVGL_VERSION_MAJOR != 7
|
#if LVGL_VERSION_MAJOR != 7
|
||||||
#include "../lv_components/lv_components.h"
|
#include "../lv_components.h"
|
||||||
#endif
|
#endif
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "lv_conf.h"
|
#include "lv_conf.h"
|
||||||
@ -977,7 +977,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
case ATTR_ID:
|
case ATTR_ID:
|
||||||
return update ? (void)(obj->user_data = (uint8_t)val) : hasp_out_int(obj, attr, obj->user_data);
|
return update ? (void)(obj->user_data.id = (uint8_t)val) : hasp_out_int(obj, attr, obj->user_data.id);
|
||||||
|
|
||||||
case ATTR_VIS:
|
case ATTR_VIS:
|
||||||
return update ? lv_obj_set_hidden(obj, !is_true(payload))
|
return update ? lv_obj_set_hidden(obj, !is_true(payload))
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#if LVGL_VERSION_MAJOR != 7
|
#if LVGL_VERSION_MAJOR != 7
|
||||||
#include "../lv_components/lv_components.h"
|
#include "../lv_components.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp.h"
|
#include "hasp.h"
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
// ##################### Object Finders ########################################################
|
// ##################### Object Finders ########################################################
|
||||||
|
|
||||||
lv_obj_t * hasp_find_obj_from_id(lv_obj_t * parent, uint8_t objid)
|
lv_obj_t * hasp_find_obj_from_parent_id(lv_obj_t * parent, uint8_t objid)
|
||||||
{
|
{
|
||||||
if(objid == 0 || parent == nullptr) return parent;
|
if(objid == 0 || parent == nullptr) return parent;
|
||||||
|
|
||||||
@ -36,10 +36,10 @@ lv_obj_t * hasp_find_obj_from_id(lv_obj_t * parent, uint8_t objid)
|
|||||||
child = lv_obj_get_child(parent, NULL);
|
child = lv_obj_get_child(parent, NULL);
|
||||||
while(child) {
|
while(child) {
|
||||||
/* child found, return it */
|
/* child found, return it */
|
||||||
if(child->user_data && (lv_obj_user_data_t)objid == child->user_data) return child;
|
if(objid == child->user_data.id) return child;
|
||||||
|
|
||||||
/* check grandchildren */
|
/* check grandchildren */
|
||||||
lv_obj_t * grandchild = hasp_find_obj_from_id(child, objid);
|
lv_obj_t * grandchild = hasp_find_obj_from_parent_id(child, objid);
|
||||||
if(grandchild) return grandchild; /* grandchild found, return it */
|
if(grandchild) return grandchild; /* grandchild found, return it */
|
||||||
|
|
||||||
/* check tabs */
|
/* check tabs */
|
||||||
@ -52,7 +52,7 @@ lv_obj_t * hasp_find_obj_from_id(lv_obj_t * parent, uint8_t objid)
|
|||||||
if(tab->user_data && (lv_obj_user_data_t)objid == tab->user_data) return tab; /* tab found, return it */
|
if(tab->user_data && (lv_obj_user_data_t)objid == tab->user_data) return tab; /* tab found, return it */
|
||||||
|
|
||||||
/* check grandchildren */
|
/* check grandchildren */
|
||||||
grandchild = hasp_find_obj_from_id(tab, objid);
|
grandchild = hasp_find_obj_from_parent_id(tab, objid);
|
||||||
if(grandchild) return grandchild; /* grandchild found, return it */
|
if(grandchild) return grandchild; /* grandchild found, return it */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -64,16 +64,17 @@ lv_obj_t * hasp_find_obj_from_id(lv_obj_t * parent, uint8_t objid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_obj_t * hasp_find_obj_from_id(uint8_t pageid, uint8_t objid)
|
// lv_obj_t * hasp_find_obj_from_page_id(uint8_t pageid, uint8_t objid)
|
||||||
{
|
// {
|
||||||
return hasp_find_obj_from_id(get_page_obj(pageid), objid);
|
// return hasp_find_obj_from_parent_id(get_page_obj(pageid), objid);
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool hasp_find_id_from_obj(lv_obj_t * obj, uint8_t * pageid, lv_obj_user_data_t * objid)
|
bool hasp_find_id_from_obj(lv_obj_t * obj, uint8_t * pageid, uint8_t * objid)
|
||||||
{
|
{
|
||||||
if(!get_page_id(obj, pageid)) return false;
|
if(!get_page_id(obj, pageid)) return false;
|
||||||
if(!(obj->user_data > 0)) return false;
|
if(!(obj->user_data.id > 0)) return false;
|
||||||
memcpy(objid, &obj->user_data, sizeof(lv_obj_user_data_t));
|
// memcpy(objid, &obj->user_data.id, sizeof(lv_obj_user_data_t));
|
||||||
|
*objid = obj->user_data.id;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ void hasp_object_tree(lv_obj_t * parent, uint8_t pageid, uint16_t level)
|
|||||||
child = lv_obj_get_child(parent, NULL);
|
child = lv_obj_get_child(parent, NULL);
|
||||||
while(child) {
|
while(child) {
|
||||||
/* child found, process it */
|
/* child found, process it */
|
||||||
if(child->user_data) hasp_object_tree(child, pageid, level + 1);
|
hasp_object_tree(child, pageid, level + 1);
|
||||||
|
|
||||||
/* try next sibling */
|
/* try next sibling */
|
||||||
child = lv_obj_get_child(parent, child);
|
child = lv_obj_get_child(parent, child);
|
||||||
@ -265,33 +266,27 @@ static inline void hasp_send_obj_attribute_txt(lv_obj_t * obj, const char * txt)
|
|||||||
void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
uint8_t eventid;
|
uint8_t eventid;
|
||||||
char buffer[6];
|
|
||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case LV_EVENT_PRESSED:
|
case LV_EVENT_PRESSED:
|
||||||
eventid = HASP_EVENT_DOWN;
|
eventid = HASP_EVENT_DOWN;
|
||||||
memcpy_P(buffer, PSTR("DOWN"), sizeof(buffer));
|
|
||||||
break;
|
break;
|
||||||
case LV_EVENT_CLICKED:
|
case LV_EVENT_CLICKED:
|
||||||
// UP = the same object was release then was pressed and press was not lost!
|
// UP = the same object was release then was pressed and press was not lost!
|
||||||
eventid = HASP_EVENT_UP;
|
eventid = HASP_EVENT_UP;
|
||||||
memcpy_P(buffer, PSTR("UP"), sizeof(buffer));
|
|
||||||
break;
|
break;
|
||||||
case LV_EVENT_SHORT_CLICKED:
|
case LV_EVENT_SHORT_CLICKED:
|
||||||
eventid = HASP_EVENT_SHORT;
|
eventid = HASP_EVENT_SHORT;
|
||||||
memcpy_P(buffer, PSTR("SHORT"), sizeof(buffer));
|
|
||||||
break;
|
break;
|
||||||
case LV_EVENT_LONG_PRESSED:
|
case LV_EVENT_LONG_PRESSED:
|
||||||
eventid = HASP_EVENT_LONG;
|
eventid = HASP_EVENT_LONG;
|
||||||
memcpy_P(buffer, PSTR("LONG"), sizeof(buffer));
|
|
||||||
break;
|
break;
|
||||||
case LV_EVENT_LONG_PRESSED_REPEAT:
|
case LV_EVENT_LONG_PRESSED_REPEAT:
|
||||||
eventid = HASP_EVENT_HOLD;
|
return; // we don't care about hold
|
||||||
memcpy_P(buffer, PSTR("HOLD"), sizeof(buffer));
|
// eventid = HASP_EVENT_HOLD;
|
||||||
break;
|
// break;
|
||||||
case LV_EVENT_PRESS_LOST:
|
case LV_EVENT_PRESS_LOST:
|
||||||
eventid = HASP_EVENT_LOST;
|
eventid = HASP_EVENT_LOST;
|
||||||
memcpy_P(buffer, PSTR("LOST"), sizeof(buffer));
|
|
||||||
break;
|
break;
|
||||||
case LV_EVENT_PRESSING:
|
case LV_EVENT_PRESSING:
|
||||||
case LV_EVENT_FOCUSED:
|
case LV_EVENT_FOCUSED:
|
||||||
@ -312,15 +307,20 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guiCheckSleep();
|
guiCheckSleep(); // wakeup?
|
||||||
|
dispatch_send_object_event(haspGetPage(), (uint8_t)obj->user_data.id, eventid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a press on the system layer is detected
|
||||||
|
* @param obj pointer to a button matrix
|
||||||
|
* @param event type of event that occured
|
||||||
|
*/
|
||||||
|
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
|
{
|
||||||
if(obj == lv_disp_get_layer_sys(NULL)) {
|
if(obj == lv_disp_get_layer_sys(NULL)) {
|
||||||
#if HASP_USE_MQTT > 0
|
guiCheckSleep(); // wakeup?
|
||||||
mqtt_send_state(F("wakeuptouch"), buffer); // TODO: enable wakeuptouch
|
lv_obj_set_click(obj, false); // disable fist click
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
// hasp_send_obj_attribute_event(obj, buffer);
|
|
||||||
dispatch_send_object_event(haspGetPage(), (uint8_t)obj->user_data, eventid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +331,10 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
*/
|
*/
|
||||||
static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) hasp_send_obj_attribute_val(obj, lv_btnmatrix_get_active_btn(obj));
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
guiCheckSleep(); // wakeup?
|
||||||
|
hasp_send_obj_attribute_val(obj, lv_btnmatrix_get_active_btn(obj));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,10 +345,10 @@ static void btnmap_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
guiCheckSleep(); // wakeup?
|
||||||
|
|
||||||
uint16_t row;
|
uint16_t row;
|
||||||
uint16_t col;
|
uint16_t col;
|
||||||
guiCheckSleep();
|
|
||||||
|
|
||||||
if(lv_table_get_pressed_cell(obj, &row, &col) == LV_RES_OK) hasp_send_obj_attribute_val(obj, row);
|
if(lv_table_get_pressed_cell(obj, &row, &col) == LV_RES_OK) hasp_send_obj_attribute_val(obj, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,10 +361,7 @@ static void table_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
// bool toggled = lv_btn_get_state(obj) == LV_BTN_STATE_CHECKED_PRESSED ||
|
guiCheckSleep(); // wakeup?
|
||||||
// lv_btn_get_state(obj) == LV_BTN_STATE_CHECKED_RELEASED;
|
|
||||||
guiCheckSleep();
|
|
||||||
|
|
||||||
hasp_send_obj_attribute_val(obj, lv_checkbox_is_checked(obj));
|
hasp_send_obj_attribute_val(obj, lv_checkbox_is_checked(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,7 +373,10 @@ void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
*/
|
*/
|
||||||
static void switch_event_handler(lv_obj_t * obj, lv_event_t event)
|
static void switch_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) hasp_send_obj_attribute_val(obj, lv_switch_get_state(obj));
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
guiCheckSleep(); // wakeup?
|
||||||
|
hasp_send_obj_attribute_val(obj, lv_switch_get_state(obj));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -444,7 +447,7 @@ static void roller_event_handler(lv_obj_t * obj, lv_event_t event)
|
|||||||
// Used in the dispatcher & hasp_new_object
|
// Used in the dispatcher & hasp_new_object
|
||||||
void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char * attr, const char * payload)
|
void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char * attr, const char * payload)
|
||||||
{
|
{
|
||||||
if(lv_obj_t * obj = hasp_find_obj_from_id(pageid, objid)) {
|
if(lv_obj_t * obj = hasp_find_obj_from_parent_id(get_page_obj(pageid), objid)) {
|
||||||
hasp_process_obj_attribute(obj, attr, payload, strlen(payload) > 0);
|
hasp_process_obj_attribute(obj, attr, payload, strlen(payload) > 0);
|
||||||
} else {
|
} else {
|
||||||
Log.warning(TAG_HASP, F("Unknown object p[%d].b[%d]"), pageid, objid);
|
Log.warning(TAG_HASP, F("Unknown object p[%d].b[%d]"), pageid, objid);
|
||||||
@ -478,7 +481,7 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
lv_obj_t * parent_obj = page;
|
lv_obj_t * parent_obj = page;
|
||||||
if(!config[F("parentid")].isNull()) {
|
if(!config[F("parentid")].isNull()) {
|
||||||
uint8_t parentid = config[F("parentid")].as<uint8_t>();
|
uint8_t parentid = config[F("parentid")].as<uint8_t>();
|
||||||
parent_obj = hasp_find_obj_from_id(page, parentid);
|
parent_obj = hasp_find_obj_from_parent_id(page, parentid);
|
||||||
if(!parent_obj) {
|
if(!parent_obj) {
|
||||||
return Log.warning(TAG_HASP, F("Parent ID p[%u].b[%u] not found, skipping..."), pageid, parentid);
|
return Log.warning(TAG_HASP, F("Parent ID p[%u].b[%u] not found, skipping..."), pageid, parentid);
|
||||||
// parent_obj = page; // don't create on the page instead ??
|
// parent_obj = page; // don't create on the page instead ??
|
||||||
@ -487,11 +490,12 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t objid = config[F("objid")].as<uint8_t>();
|
uint8_t groupid = config[F("groupid")].as<uint8_t>();
|
||||||
uint8_t id = config[F("id")].as<uint8_t>();
|
uint8_t objid = config[F("objid")].as<uint8_t>();
|
||||||
|
uint8_t id = config[F("id")].as<uint8_t>();
|
||||||
|
|
||||||
/* Define Objects*/
|
/* Define Objects*/
|
||||||
lv_obj_t * obj = hasp_find_obj_from_id(parent_obj, id);
|
lv_obj_t * obj = hasp_find_obj_from_parent_id(parent_obj, id);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
return Log.warning(TAG_HASP, F("Object ID %u already exists!"), id);
|
return Log.warning(TAG_HASP, F("Object ID %u already exists!"), id);
|
||||||
}
|
}
|
||||||
@ -585,11 +589,11 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
if(obj) {
|
if(obj) {
|
||||||
lv_obj_t * tab;
|
lv_obj_t * tab;
|
||||||
tab = lv_tabview_add_tab(obj, "tab 1");
|
tab = lv_tabview_add_tab(obj, "tab 1");
|
||||||
lv_obj_set_user_data(tab, id + 1);
|
// lv_obj_set_user_data(tab, id + 1);
|
||||||
tab = lv_tabview_add_tab(obj, "tab 2");
|
tab = lv_tabview_add_tab(obj, "tab 2");
|
||||||
lv_obj_set_user_data(tab, id + 2);
|
// lv_obj_set_user_data(tab, id + 2);
|
||||||
tab = lv_tabview_add_tab(obj, "tab 3");
|
tab = lv_tabview_add_tab(obj, "tab 3");
|
||||||
lv_obj_set_user_data(tab, id + 3);
|
// lv_obj_set_user_data(tab, id + 3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -634,7 +638,7 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
#endif
|
#endif
|
||||||
/* ----- Range Objects ------ */
|
/* ----- Range Objects ------ */
|
||||||
case LV_HASP_SLIDER: {
|
case LV_HASP_SLIDER: {
|
||||||
// obj = lv_slider_create(parent_obj, NULL);
|
// obj = lv_slider_create(parent_obj, NULL);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
lv_slider_set_range(obj, 0, 100);
|
lv_slider_set_range(obj, 0, 100);
|
||||||
lv_obj_set_event_cb(obj, slider_event_handler);
|
lv_obj_set_event_cb(obj, slider_event_handler);
|
||||||
@ -725,7 +729,10 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* id tag the object */
|
/* id tag the object */
|
||||||
lv_obj_set_user_data(obj, id);
|
// lv_obj_set_user_data(obj, id);
|
||||||
|
obj->user_data.id = id;
|
||||||
|
obj->user_data.objid = objid & 0b11111;
|
||||||
|
obj->user_data.groupid = groupid & 0b111;
|
||||||
|
|
||||||
/* do not process these attributes */
|
/* do not process these attributes */
|
||||||
config.remove(F("page"));
|
config.remove(F("page"));
|
||||||
@ -742,7 +749,7 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** testing start **/
|
/** testing start **/
|
||||||
lv_obj_user_data_t temp;
|
uint8_t temp;
|
||||||
if(!hasp_find_id_from_obj(obj, &pageid, &temp)) {
|
if(!hasp_find_id_from_obj(obj, &pageid, &temp)) {
|
||||||
return Log.error(TAG_HASP, F("Lost track of the created object, not found!"));
|
return Log.error(TAG_HASP, F("Lost track of the created object, not found!"));
|
||||||
}
|
}
|
||||||
@ -753,7 +760,7 @@ void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id)
|
|||||||
Log.verbose(TAG_HASP, F(" * p[%u].b[%u] = %s"), pageid, temp, list.type[0]);
|
Log.verbose(TAG_HASP, F(" * p[%u].b[%u] = %s"), pageid, temp, list.type[0]);
|
||||||
|
|
||||||
/* test double-check */
|
/* test double-check */
|
||||||
lv_obj_t * test = hasp_find_obj_from_id(pageid, (uint8_t)temp);
|
lv_obj_t * test = hasp_find_obj_from_parent_id(get_page_obj(pageid), (uint8_t)temp);
|
||||||
if(test != obj) {
|
if(test != obj) {
|
||||||
return Log.error(TAG_HASP, F("Objects DO NOT match!"));
|
return Log.error(TAG_HASP, F("Objects DO NOT match!"));
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ enum lv_hasp_obj_type_t {
|
|||||||
|
|
||||||
void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id);
|
void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id);
|
||||||
|
|
||||||
lv_obj_t * hasp_find_obj_from_id(lv_obj_t * parent, uint8_t objid);
|
lv_obj_t * hasp_find_obj_from_parent_id(lv_obj_t * parent, uint8_t objid);
|
||||||
lv_obj_t * hasp_find_obj_from_id(uint8_t pageid, uint8_t objid);
|
// lv_obj_t * hasp_find_obj_from_page_id(uint8_t pageid, uint8_t objid);
|
||||||
bool hasp_find_id_from_obj(lv_obj_t * obj, uint8_t * pageid, lv_obj_user_data_t * objid);
|
bool hasp_find_id_from_obj(lv_obj_t * obj, uint8_t * pageid, uint8_t * objid);
|
||||||
bool check_obj_type(const char * lvobjtype, lv_hasp_obj_type_t haspobjtype);
|
bool check_obj_type(const char * lvobjtype, lv_hasp_obj_type_t haspobjtype);
|
||||||
bool check_obj_type(lv_obj_t * obj, lv_hasp_obj_type_t haspobjtype);
|
bool check_obj_type(lv_obj_t * obj, lv_hasp_obj_type_t haspobjtype);
|
||||||
void hasp_object_tree(lv_obj_t * parent, uint8_t pageid, uint16_t level);
|
void hasp_object_tree(lv_obj_t * parent, uint8_t pageid, uint16_t level);
|
||||||
@ -64,5 +64,6 @@ void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char * attr, co
|
|||||||
|
|
||||||
void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event);
|
void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event);
|
||||||
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event);
|
void IRAM_ATTR toggle_event_handler(lv_obj_t * obj, lv_event_t event);
|
||||||
|
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#if LVGL_VERSION_MAJOR != 7
|
#if LVGL_VERSION_MAJOR != 7
|
||||||
#include "../lv_components/lv_components.h"
|
#include "../lv_components.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp_object.h"
|
#include "hasp_object.h"
|
||||||
@ -62,14 +62,14 @@ static void kb_event_cb(lv_obj_t * event_kb, lv_event_t event)
|
|||||||
char pass[32];
|
char pass[32];
|
||||||
lv_obj_t * obj;
|
lv_obj_t * obj;
|
||||||
|
|
||||||
obj = hasp_find_obj_from_id(oobepage[1], 10);
|
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)10);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
strncpy(ssid, lv_textarea_get_text(obj), sizeof(ssid));
|
strncpy(ssid, lv_textarea_get_text(obj), sizeof(ssid));
|
||||||
settings[FPSTR(F_CONFIG_SSID)] = ssid;
|
settings[FPSTR(F_CONFIG_SSID)] = ssid;
|
||||||
if(oobekb != NULL) lv_keyboard_set_textarea(oobekb, obj);
|
if(oobekb != NULL) lv_keyboard_set_textarea(oobekb, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = hasp_find_obj_from_id(oobepage[1], 20);
|
obj = hasp_find_obj_from_parent_id(oobepage[1],(uint8_t) 20);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
strncpy(pass, lv_textarea_get_text(obj), sizeof(pass));
|
strncpy(pass, lv_textarea_get_text(obj), sizeof(pass));
|
||||||
settings[FPSTR(F_CONFIG_PASS)] = pass;
|
settings[FPSTR(F_CONFIG_PASS)] = pass;
|
||||||
@ -106,9 +106,9 @@ static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
|||||||
if(str[0] == '\n') {
|
if(str[0] == '\n') {
|
||||||
lv_obj_t * obj;
|
lv_obj_t * obj;
|
||||||
|
|
||||||
obj = hasp_find_obj_from_id(oobepage[1], 10);
|
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)10);
|
||||||
if(ta == obj) { // now ssid, goto pass
|
if(ta == obj) { // now ssid, goto pass
|
||||||
obj = hasp_find_obj_from_id(oobepage[1], 20);
|
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oobekb && obj) {
|
if(oobekb && obj) {
|
||||||
@ -222,7 +222,8 @@ static void oobeSetupSsid(void)
|
|||||||
lv_textarea_set_pwd_mode(pwd_ta, true);
|
lv_textarea_set_pwd_mode(pwd_ta, true);
|
||||||
lv_textarea_set_one_line(pwd_ta, true);
|
lv_textarea_set_one_line(pwd_ta, true);
|
||||||
lv_textarea_set_cursor_hidden(pwd_ta, true);
|
lv_textarea_set_cursor_hidden(pwd_ta, true);
|
||||||
lv_obj_set_user_data(pwd_ta, 20);
|
lv_obj_user_data_t udata = (lv_obj_user_data_t){20, 1, 0};
|
||||||
|
lv_obj_set_user_data(pwd_ta, udata);
|
||||||
lv_obj_set_width(pwd_ta, disp->driver.hor_res - leftmargin - 20 - lv_obj_get_height(pwd_ta));
|
lv_obj_set_width(pwd_ta, disp->driver.hor_res - leftmargin - 20 - lv_obj_get_height(pwd_ta));
|
||||||
lv_obj_set_event_cb(pwd_ta, ta_event_cb);
|
lv_obj_set_event_cb(pwd_ta, ta_event_cb);
|
||||||
lv_obj_align(pwd_ta, NULL, LV_ALIGN_CENTER, leftmargin / 2 - lv_obj_get_height(pwd_ta) / 2, topmargin - voffset);
|
lv_obj_align(pwd_ta, NULL, LV_ALIGN_CENTER, leftmargin / 2 - lv_obj_get_height(pwd_ta) / 2, topmargin - voffset);
|
||||||
@ -242,7 +243,7 @@ static void oobeSetupSsid(void)
|
|||||||
lv_obj_set_style_local_text_font(oneline_ta, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, defaultfont);
|
lv_obj_set_style_local_text_font(oneline_ta, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, defaultfont);
|
||||||
|
|
||||||
lv_textarea_set_pwd_mode(oneline_ta, false);
|
lv_textarea_set_pwd_mode(oneline_ta, false);
|
||||||
lv_obj_set_user_data(oneline_ta, 10);
|
lv_obj_set_user_data(oneline_ta, (lv_obj_user_data_t){10, 1, 0});
|
||||||
lv_obj_align(oneline_ta, pwd_ta, LV_ALIGN_OUT_TOP_MID, 0, topmargin);
|
lv_obj_align(oneline_ta, pwd_ta, LV_ALIGN_OUT_TOP_MID, 0, topmargin);
|
||||||
|
|
||||||
/* Create a label and position it above the text box */
|
/* Create a label and position it above the text box */
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "lv_conf.h" /*To see all the widgets*/
|
#include "lv_conf.h" /*To see all the widgets*/
|
||||||
#include "lv_theme_hasp.h" /*To see all the widgets*/
|
#include "lv_theme_hasp.h" /*To see all the widgets*/
|
||||||
#if LVGL_VERSION_MAJOR != 7
|
#if LVGL_VERSION_MAJOR != 7
|
||||||
#include "../lv_components/lv_components.h"
|
#include "../lv_components.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#if LV_USE_THEME_HASP
|
//#if LV_USE_THEME_HASP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user