mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Add logging
This commit is contained in:
parent
0523c37598
commit
496a4af2ec
@ -13,7 +13,6 @@
|
|||||||
#include "hasplib.h"
|
#include "hasplib.h"
|
||||||
|
|
||||||
LV_FONT_DECLARE(unscii_8_icon);
|
LV_FONT_DECLARE(unscii_8_icon);
|
||||||
extern lv_font_t* haspFonts[8];
|
|
||||||
extern const char** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map
|
extern const char** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -454,10 +453,8 @@ static lv_font_t* haspPayloadToFont(const char* payload)
|
|||||||
uint8_t var = atoi(payload);
|
uint8_t var = atoi(payload);
|
||||||
|
|
||||||
switch(var) {
|
switch(var) {
|
||||||
case 0:
|
case 0 ... 7:
|
||||||
case 1:
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, robotocondensed_regular_12_nokern);
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
return hasp_get_font(var);
|
return hasp_get_font(var);
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
@ -467,22 +464,25 @@ static lv_font_t* haspPayloadToFont(const char* payload)
|
|||||||
|
|
||||||
#ifdef LV_FONT_CUSTOM_12
|
#ifdef LV_FONT_CUSTOM_12
|
||||||
case 12:
|
case 12:
|
||||||
return LV_THEME_DEFAULT_FONT_SMALL;
|
return &robotocondensed_regular_12_nokern;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LV_FONT_CUSTOM_16
|
#ifdef LV_FONT_CUSTOM_16
|
||||||
case 16:
|
case 16:
|
||||||
return LV_THEME_DEFAULT_FONT_NORMAL;
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, robotocondensed_regular_16_nokern);
|
||||||
|
return &robotocondensed_regular_16_nokern;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LV_FONT_CUSTOM_22
|
#ifdef LV_FONT_CUSTOM_22
|
||||||
case 22:
|
case 22:
|
||||||
return LV_THEME_DEFAULT_FONT_SUBTITLE;
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, robotocondensed_regular_22_nokern);
|
||||||
|
return &robotocondensed_regular_22_nokern;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LV_FONT_CUSTOM_28
|
#ifdef LV_FONT_CUSTOM_28
|
||||||
case 28:
|
case 28:
|
||||||
return LV_THEME_DEFAULT_FONT_TITLE;
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, robotocondensed_regular_28_nokern);
|
||||||
|
return &robotocondensed_regular_28_nokern;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -885,6 +885,7 @@ static void hasp_local_style_attr(lv_obj_t* obj, const char* attr_p, uint16_t at
|
|||||||
case ATTR_TEXT_FONT: {
|
case ATTR_TEXT_FONT: {
|
||||||
lv_font_t* font = haspPayloadToFont(payload);
|
lv_font_t* font = haspPayloadToFont(payload);
|
||||||
if(font) {
|
if(font) {
|
||||||
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, *font);
|
||||||
uint8_t count = 3;
|
uint8_t count = 3;
|
||||||
if(check_obj_type(obj, LV_HASP_ROLLER)) count = my_roller_get_visible_row_count(obj);
|
if(check_obj_type(obj, LV_HASP_ROLLER)) count = my_roller_get_visible_row_count(obj);
|
||||||
lv_obj_set_style_local_text_font(obj, part, state, font);
|
lv_obj_set_style_local_text_font(obj, part, state, font);
|
||||||
|
@ -26,11 +26,9 @@ static bool oobeAutoCalibrate = true;
|
|||||||
#include "lv_qrcode.h"
|
#include "lv_qrcode.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static lv_obj_t * oobepage[2];
|
static lv_obj_t* oobepage[2];
|
||||||
static lv_obj_t * oobekb;
|
static lv_obj_t* oobekb;
|
||||||
extern lv_font_t * defaultFont;
|
lv_obj_t* pwd_ta;
|
||||||
|
|
||||||
lv_obj_t * pwd_ta;
|
|
||||||
|
|
||||||
static inline void oobeSetPage(uint8_t pageid)
|
static inline void oobeSetPage(uint8_t pageid)
|
||||||
{
|
{
|
||||||
@ -38,7 +36,7 @@ static inline void oobeSetPage(uint8_t pageid)
|
|||||||
lv_obj_invalidate(lv_disp_get_layer_sys(NULL));
|
lv_obj_invalidate(lv_disp_get_layer_sys(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gotoPage1_cb(lv_obj_t * event_kb, lv_event_t event)
|
void gotoPage1_cb(lv_obj_t* event_kb, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_RELEASED) {
|
if(event == LV_EVENT_RELEASED) {
|
||||||
lv_obj_set_click(lv_disp_get_layer_sys(NULL), false);
|
lv_obj_set_click(lv_disp_get_layer_sys(NULL), false);
|
||||||
@ -46,7 +44,7 @@ void gotoPage1_cb(lv_obj_t * event_kb, lv_event_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void peek_password_cb(lv_obj_t * obj, lv_event_t event)
|
static void peek_password_cb(lv_obj_t* obj, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||||
lv_obj_set_style_local_value_str(obj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT,
|
lv_obj_set_style_local_value_str(obj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT,
|
||||||
@ -55,13 +53,13 @@ static void peek_password_cb(lv_obj_t * obj, lv_event_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kb_event_cb(lv_obj_t * event_kb, lv_event_t event)
|
static void kb_event_cb(lv_obj_t* event_kb, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_APPLY) {
|
if(event == LV_EVENT_APPLY) {
|
||||||
StaticJsonDocument<256> settings;
|
StaticJsonDocument<256> settings;
|
||||||
char ssid[32] = "";
|
char ssid[32] = "";
|
||||||
char pass[32] = "";
|
char pass[32] = "";
|
||||||
lv_obj_t * obj;
|
lv_obj_t* obj;
|
||||||
|
|
||||||
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)10);
|
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)10);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
@ -92,7 +90,7 @@ static void kb_event_cb(lv_obj_t * event_kb, lv_event_t event)
|
|||||||
// lv_kb_def_event_cb(event_kb, event);
|
// lv_kb_def_event_cb(event_kb, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
static void ta_event_cb(lv_obj_t* ta, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_CLICKED) {
|
if(event == LV_EVENT_CLICKED) {
|
||||||
/* Focus on the clicked text area */
|
/* Focus on the clicked text area */
|
||||||
@ -100,9 +98,9 @@ static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if(event == LV_EVENT_INSERT) {
|
else if(event == LV_EVENT_INSERT) {
|
||||||
const char * str = (const char *)lv_event_get_data();
|
const char* str = (const char*)lv_event_get_data();
|
||||||
if(str[0] == '\n') {
|
if(str[0] == '\n') {
|
||||||
lv_obj_t * obj;
|
lv_obj_t* obj;
|
||||||
|
|
||||||
obj = hasp_find_obj_from_parent_id(oobepage[1], (uint8_t)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
|
||||||
@ -119,12 +117,12 @@ static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oobeSetupQR(const char * ssid, const char * pass)
|
static void oobeSetupQR(const char* ssid, const char* pass)
|
||||||
{
|
{
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
oobepage[0] = lv_obj_create(NULL, NULL);
|
oobepage[0] = lv_obj_create(NULL, NULL);
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
lv_obj_t * container = lv_cont_create(oobepage[0], NULL);
|
lv_obj_t* container = lv_cont_create(oobepage[0], NULL);
|
||||||
lv_obj_set_pos(container, 5, 5);
|
lv_obj_set_pos(container, 5, 5);
|
||||||
// lv_obj_set_style_local_bg_opa(container, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
|
// lv_obj_set_style_local_bg_opa(container, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
|
||||||
// lv_obj_set_style_local_border_opa(container, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
|
// lv_obj_set_style_local_border_opa(container, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
|
||||||
@ -132,10 +130,10 @@ static void oobeSetupQR(const char * ssid, const char * pass)
|
|||||||
#if HASP_USE_QRCODE > 0
|
#if HASP_USE_QRCODE > 0
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR("WIFI:S:%s;T:WPA;P:%s;;"), ssid, pass);
|
snprintf_P(buffer, sizeof(buffer), PSTR("WIFI:S:%s;T:WPA;P:%s;;"), ssid, pass);
|
||||||
|
|
||||||
lv_obj_t * qr = lv_qrcode_create(oobepage[0], 120, LV_COLOR_BLACK, LV_COLOR_WHITE);
|
lv_obj_t* qr = lv_qrcode_create(oobepage[0], 120, LV_COLOR_BLACK, LV_COLOR_WHITE);
|
||||||
lv_qrcode_update(qr, buffer, strlen(buffer));
|
lv_qrcode_update(qr, buffer, strlen(buffer));
|
||||||
|
|
||||||
lv_obj_t * qrlabel = lv_label_create(oobepage[0], NULL);
|
lv_obj_t* qrlabel = lv_label_create(oobepage[0], NULL);
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_OOBE_SCAN_TO_CONNECT));
|
snprintf_P(buffer, sizeof(buffer), PSTR(D_OOBE_SCAN_TO_CONNECT));
|
||||||
lv_label_set_text(qrlabel, buffer);
|
lv_label_set_text(qrlabel, buffer);
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ static void oobeSetupQR(const char * ssid, const char * pass)
|
|||||||
lv_obj_set_size(container, disp->driver.hor_res, disp->driver.ver_res);
|
lv_obj_set_size(container, disp->driver.hor_res, disp->driver.ver_res);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lv_obj_t * aplabel = lv_label_create(container, NULL);
|
lv_obj_t* aplabel = lv_label_create(container, NULL);
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_OOBE_MSG));
|
snprintf_P(buffer, sizeof(buffer), PSTR(D_OOBE_MSG));
|
||||||
lv_label_set_text(aplabel, buffer);
|
lv_label_set_text(aplabel, buffer);
|
||||||
lv_label_set_long_mode(aplabel, LV_LABEL_LONG_BREAK);
|
lv_label_set_long_mode(aplabel, LV_LABEL_LONG_BREAK);
|
||||||
@ -164,28 +162,28 @@ static void oobeSetupQR(const char * ssid, const char * pass)
|
|||||||
|
|
||||||
lv_obj_align(aplabel, container, LV_ALIGN_IN_TOP_MID, 0, 0);
|
lv_obj_align(aplabel, container, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
lv_obj_t * panel = lv_cont_create(container, NULL);
|
lv_obj_t* panel = lv_cont_create(container, NULL);
|
||||||
lv_obj_align(panel, aplabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
lv_obj_align(panel, aplabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
||||||
|
|
||||||
lv_cont_set_fit(panel, LV_FIT_TIGHT);
|
lv_cont_set_fit(panel, LV_FIT_TIGHT);
|
||||||
|
|
||||||
lv_cont_set_layout(panel, LV_LAYOUT_COLUMN_MID);
|
lv_cont_set_layout(panel, LV_LAYOUT_COLUMN_MID);
|
||||||
|
|
||||||
String txt((char *)0);
|
String txt((char*)0);
|
||||||
txt.reserve(64);
|
txt.reserve(64);
|
||||||
|
|
||||||
txt = String(LV_SYMBOL_WIFI) + " " + String(ssid);
|
txt = String(LV_SYMBOL_WIFI) + " " + String(ssid);
|
||||||
lv_obj_t * network = lv_label_create(panel, NULL);
|
lv_obj_t* network = lv_label_create(panel, NULL);
|
||||||
lv_label_set_text(network, txt.c_str());
|
lv_label_set_text(network, txt.c_str());
|
||||||
|
|
||||||
lv_obj_t * password = lv_label_create(panel, NULL);
|
lv_obj_t* password = lv_label_create(panel, NULL);
|
||||||
txt = String(F("\xef\x80\xA3")) + " " + String(pass);
|
txt = String(F("\xef\x80\xA3")) + " " + String(pass);
|
||||||
lv_label_set_text(password, txt.c_str());
|
lv_label_set_text(password, txt.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oobeSetupSsid(void)
|
static void oobeSetupSsid(void)
|
||||||
{
|
{
|
||||||
lv_font_t * defaultfont;
|
lv_font_t* defaultfont;
|
||||||
// #if defined(ARDUINO_ARCH_ESP32)
|
// #if defined(ARDUINO_ARCH_ESP32)
|
||||||
// defaultfont = &lv_font_montserrat_12;
|
// defaultfont = &lv_font_montserrat_12;
|
||||||
// #else
|
// #else
|
||||||
@ -196,7 +194,7 @@ static void oobeSetupSsid(void)
|
|||||||
lv_align_t labelpos;
|
lv_align_t labelpos;
|
||||||
lv_obj_user_data_t udata = {0, 0, 0};
|
lv_obj_user_data_t udata = {0, 0, 0};
|
||||||
|
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
if(disp->driver.hor_res <= disp->driver.ver_res) {
|
if(disp->driver.hor_res <= disp->driver.ver_res) {
|
||||||
leftmargin = 0;
|
leftmargin = 0;
|
||||||
topmargin = -35;
|
topmargin = -35;
|
||||||
@ -227,7 +225,7 @@ static void oobeSetupSsid(void)
|
|||||||
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);
|
||||||
|
|
||||||
lv_obj_t * pwd_icon = lv_btn_create(oobepage[1], NULL);
|
lv_obj_t* pwd_icon = lv_btn_create(oobepage[1], NULL);
|
||||||
lv_obj_set_size(pwd_icon, lv_obj_get_height(pwd_ta), lv_obj_get_height(pwd_ta));
|
lv_obj_set_size(pwd_icon, lv_obj_get_height(pwd_ta), lv_obj_get_height(pwd_ta));
|
||||||
lv_obj_set_pos(pwd_icon, lv_obj_get_x(pwd_ta) + lv_obj_get_width(pwd_ta), lv_obj_get_y(pwd_ta));
|
lv_obj_set_pos(pwd_icon, lv_obj_get_x(pwd_ta) + lv_obj_get_width(pwd_ta), lv_obj_get_y(pwd_ta));
|
||||||
lv_obj_set_style_local_value_str(pwd_icon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_EYE_CLOSE);
|
lv_obj_set_style_local_value_str(pwd_icon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_EYE_CLOSE);
|
||||||
@ -237,7 +235,7 @@ static void oobeSetupSsid(void)
|
|||||||
lv_btn_set_checkable(pwd_icon, true);
|
lv_btn_set_checkable(pwd_icon, true);
|
||||||
|
|
||||||
/* Create the one-line mode text area */
|
/* Create the one-line mode text area */
|
||||||
lv_obj_t * oneline_ta = lv_textarea_create(oobepage[1], pwd_ta);
|
lv_obj_t* oneline_ta = lv_textarea_create(oobepage[1], pwd_ta);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -247,13 +245,13 @@ static void oobeSetupSsid(void)
|
|||||||
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 */
|
||||||
lv_obj_t * pwd_label = lv_label_create(oobepage[1], NULL);
|
lv_obj_t* pwd_label = lv_label_create(oobepage[1], NULL);
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_PASSWORD));
|
snprintf_P(buffer, sizeof(buffer), PSTR(D_PASSWORD));
|
||||||
lv_label_set_text(pwd_label, buffer);
|
lv_label_set_text(pwd_label, buffer);
|
||||||
lv_obj_align(pwd_label, pwd_ta, labelpos, 0, 0);
|
lv_obj_align(pwd_label, pwd_ta, labelpos, 0, 0);
|
||||||
|
|
||||||
/* Create a label and position it above the text box */
|
/* Create a label and position it above the text box */
|
||||||
lv_obj_t * oneline_label = lv_label_create(oobepage[1], NULL);
|
lv_obj_t* oneline_label = lv_label_create(oobepage[1], NULL);
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_SSID));
|
snprintf_P(buffer, sizeof(buffer), PSTR(D_SSID));
|
||||||
lv_label_set_text(oneline_label, buffer);
|
lv_label_set_text(oneline_label, buffer);
|
||||||
lv_obj_align(oneline_label, oneline_ta, labelpos, 0, 0);
|
lv_obj_align(oneline_label, oneline_ta, labelpos, 0, 0);
|
||||||
@ -286,7 +284,7 @@ static void oobeSetupSsid(void)
|
|||||||
lv_keyboard_set_cursor_manage(oobekb, true); /* Automatically show/hide cursors on text areas */
|
lv_keyboard_set_cursor_manage(oobekb, true); /* Automatically show/hide cursors on text areas */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oobe_calibrate_cb(lv_obj_t * ta, lv_event_t event)
|
static void oobe_calibrate_cb(lv_obj_t* ta, lv_event_t event)
|
||||||
{
|
{
|
||||||
if(event == LV_EVENT_CLICKED) {
|
if(event == LV_EVENT_CLICKED) {
|
||||||
if(oobeAutoCalibrate) {
|
if(oobeAutoCalibrate) {
|
||||||
@ -340,7 +338,7 @@ bool oobeSetup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Thist is used for testing only !!
|
// Thist is used for testing only !!
|
||||||
void oobeFakeSetup(const char *, const char *)
|
void oobeFakeSetup(const char*, const char*)
|
||||||
{
|
{
|
||||||
#if HASP_USE_WIFI > 0
|
#if HASP_USE_WIFI > 0
|
||||||
char ssid[32] = "HASP-ABCDEF";
|
char ssid[32] = "HASP-ABCDEF";
|
||||||
|
@ -56,6 +56,7 @@ void setup()
|
|||||||
#if HASP_USE_CONFIG > 0
|
#if HASP_USE_CONFIG > 0
|
||||||
configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart()
|
configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart()
|
||||||
#endif
|
#endif
|
||||||
|
LOG_WARNING(TAG_ATTR, "%s %d %x", __FILE__, __LINE__, &robotocondensed_regular_16_nokern);
|
||||||
|
|
||||||
guiSetup();
|
guiSetup();
|
||||||
debugSetup(); // Init the console
|
debugSetup(); // Init the console
|
||||||
|
Loading…
x
Reference in New Issue
Block a user