checkbox rolo selection

This commit is contained in:
Moirtz Wagner 2025-11-16 16:01:04 +01:00
parent 4240db93d5
commit b487cd1e2e
5 changed files with 166 additions and 82 deletions

View File

@ -638,7 +638,7 @@
#define LV_USE_MENU 0 #define LV_USE_MENU 0
#define LV_USE_MSGBOX 1 #define LV_USE_MSGBOX 0
#define LV_USE_ROLLER 0 /*Requires: lv_label*/ #define LV_USE_ROLLER 0 /*Requires: lv_label*/

View File

@ -306,45 +306,22 @@ void moveRolloDown(lv_event_t *e) {
if (ui_getCurrentScreen() != objects.rolloScr) if (ui_getCurrentScreen() != objects.rolloScr)
return; return;
; ;
uint16_t sel = lv_dropdown_get_selected(objects.deviceDropdown); tahoma.moveSelected(100, 100);
if (sel == tahoma.numDevs) {
// all selected
for (uint8_t i = 0; i < tahoma.numDevs; i++) {
tahoma.sendMove(i, 100, 100);
}
} else {
tahoma.sendMove(sel, 100, 100);
}
} }
void moveRolloMan(lv_event_t *e) { void moveRolloMan(lv_event_t *e) {
if (ui_getCurrentScreen() != objects.rolloPosScr) if (ui_getCurrentScreen() != objects.rolloPosScr)
return; return;
; ;
uint8_t sel = tahoma.getCurrentDev(); tahoma.moveSelected(lv_slider_get_value(objects.rolloPos),
if (sel == tahoma.numDevs) { lv_arc_get_value(objects.rolloRot) / 9);
// all selected
for (uint8_t i = 0; i < tahoma.numDevs; i++) {
tahoma.sendMove(i, lv_slider_get_value(objects.rolloPos), lv_arc_get_value(objects.rolloRot)/9);
}
} else {
tahoma.sendMove(sel, lv_slider_get_value(objects.rolloPos), lv_arc_get_value(objects.rolloRot)/9);
}
} }
void moveRolloUp(lv_event_t *e) { void moveRolloUp(lv_event_t *e) {
if (ui_getCurrentScreen() != objects.rolloScr) if (ui_getCurrentScreen() != objects.rolloScr)
return; return;
; ;
uint16_t sel = lv_dropdown_get_selected(objects.deviceDropdown); tahoma.moveSelected(0, 0);
if (sel == tahoma.numDevs) {
// all selected
for (uint8_t i = 0; i < tahoma.numDevs; i++) {
tahoma.sendMove(i, 0, 0);
}
} else {
tahoma.sendMove(sel, 0, 0);
}
} }
void zoomAniWrapper(void *var, int32_t val) { void zoomAniWrapper(void *var, int32_t val) {
@ -471,6 +448,16 @@ void showMenuScreen(lv_event_t *e) {
objects.rolloPosScr = NULL; objects.rolloPosScr = NULL;
loadScreen(objects.menuScr); loadScreen(objects.menuScr);
} }
void toggleRolloChooser(lv_event_t *e) {
if (lv_obj_has_flag(objects.deviceDropdown, LV_OBJ_FLAG_HIDDEN)) {
lv_obj_remove_flag(objects.deviceDropdown, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_add_flag(objects.deviceDropdown, LV_OBJ_FLAG_HIDDEN);
setRolloListText();
}
}
void showRolloScreen(lv_event_t *e) { void showRolloScreen(lv_event_t *e) {
if (ui_getCurrentScreen() != objects.rolloScr) { if (ui_getCurrentScreen() != objects.rolloScr) {
create_screen_rollos(); create_screen_rollos();
@ -478,11 +465,17 @@ void showRolloScreen(lv_event_t *e) {
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode); update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
} }
for (uint8_t i = 0; i < tahoma.getMyDevices(); i++) { for (uint8_t i = 0; i < tahoma.getMyDevices(); i++) {
lv_dropdown_add_option(objects.deviceDropdown, rolloCheckbox_add(tahoma.devicelist[i].name.c_str(),
tahoma.devicelist[i].name.c_str(), (void *)&(tahoma.devicelist[i]),
LV_DROPDOWN_POS_LAST); tahoma.isDeviceSelected(i));
// lv_dropdown_add_option(objects.deviceDropdown,
// tahoma.devicelist[i].name.c_str(),
// LV_DROPDOWN_POS_LAST);
}; };
lv_dropdown_add_option(objects.deviceDropdown, "Alle", LV_DROPDOWN_POS_LAST); rolloCheckbox_finish();
setRolloListText();
// lv_dropdown_add_option(objects.deviceDropdown, "Alle",
// LV_DROPDOWN_POS_LAST);
objects.debugScr = NULL; objects.debugScr = NULL;
objects.mainScr = NULL; objects.mainScr = NULL;
objects.chartScr = NULL; objects.chartScr = NULL;
@ -496,9 +489,8 @@ void showRolloPosScreen(lv_event_t *e) {
create_screen_rolloPos(); create_screen_rolloPos();
update_status(); update_status();
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode); update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
lv_label_set_text_fmt( // lv_label_set_text_fmt(
objects.debugTxt, "\"%s\"\nmanuell positionieren", // objects.debugTxt, "Gewählte Rollos manuell positionieren");
tahoma.devicelist[tahoma.getCurrentDev()].name.c_str());
Tahoma::rolloCommand_t pos = tahoma.getPos(); Tahoma::rolloCommand_t pos = tahoma.getPos();
lv_slider_set_value(objects.rolloPos, pos.position, LV_ANIM_OFF); lv_slider_set_value(objects.rolloPos, pos.position, LV_ANIM_OFF);
lv_arc_set_value(objects.rolloRot, pos.rotation * 9); lv_arc_set_value(objects.rolloRot, pos.rotation * 9);
@ -531,8 +523,6 @@ void showDebugScreen(lv_event_t *e) {
loadScreen(objects.debugScr); loadScreen(objects.debugScr);
} }
void rebootESP(lv_event_t *e) { ESP.restart(); } void rebootESP(lv_event_t *e) { ESP.restart(); }
void showMainScreen(lv_event_t *e) { void showMainScreen(lv_event_t *e) {
@ -571,8 +561,30 @@ void rotation_changed_cb(lv_event_t *e) {
} }
} }
void setRolloListText(void) {
String txt = "";
for (uint8_t i = 0; i < tahoma.numDevs; i++) {
if (tahoma.devicelist[i].selected) {
txt += tahoma.devicelist[i].name + ", ";
}
}
if (txt.length()) {
txt = txt.substring(0, txt.length() - 2);
} else {
txt = "Rollos wählen";
}
lv_obj_set_style_anim_duration(objects.selDevicesLbl, 70*(lv_text_get_width(txt.c_str(),txt.length(),&symbol_font_12,0)-100), LV_PART_MAIN);
lv_label_set_text(objects.selDevicesLbl, txt.c_str());
}
void rolloChanged(lv_event_t *e) { void rolloChanged(lv_event_t *e) {
tahoma.setCurrentDev(lv_dropdown_get_selected(lv_event_get_target_obj(e))); lv_obj_t *act_cb = (lv_obj_t *)lv_event_get_target(e);
if (act_cb == objects.deviceDropdown)
return;
Tahoma::device_t *active_id =
(Tahoma::device_t *)lv_obj_get_user_data(act_cb);
active_id->selected = lv_obj_has_state(act_cb, LV_STATE_CHECKED);
// tahoma.setCurrentDev(lv_dropdown_get_selected(lv_event_get_target_obj(e)));
} }
void pos_changed_cb(lv_event_t *e) { void pos_changed_cb(lv_event_t *e) {

View File

@ -32,6 +32,8 @@ void draw_event_cb(lv_event_t* e);
void moveRolloDown(lv_event_t* e); void moveRolloDown(lv_event_t* e);
void moveRolloUp(lv_event_t* e); void moveRolloUp(lv_event_t* e);
void moveRolloMan(lv_event_t *e); void moveRolloMan(lv_event_t *e);
void setRolloListText(void);
void toggleRolloChooser(lv_event_t *e);
void checkTahomaActions(void); void checkTahomaActions(void);
void rotation_changed_cb(lv_event_t* e); void rotation_changed_cb(lv_event_t* e);
void pos_changed_cb(lv_event_t *e); void pos_changed_cb(lv_event_t *e);

View File

@ -214,6 +214,38 @@ void create_screen_menu() {
addStatusIcons(parent_obj); addStatusIcons(parent_obj);
} }
void rolloCheckbox_add(const char *txt, void *_tahomaDevice, bool _checked) {
lv_obj_t *obj = lv_checkbox_create(objects.deviceDropdown);
lv_checkbox_set_text(obj, txt);
lv_obj_set_user_data(obj, _tahomaDevice);
lv_obj_set_style_bg_image_src(obj, SYM_CHECK,
LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_set_style_border_color(obj, lv_color_hex(0xff5D636E),
LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(obj, lv_palette_darken(LV_PALETTE_GREEN, 3),
LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_set_style_text_font(obj,&symbol_font_12,LV_STATE_DEFAULT);
if (_checked)
lv_obj_add_state(obj, LV_STATE_CHECKED);
lv_obj_add_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE);
}
void rolloCheckbox_finish(void) {
lv_obj_t *obj = lv_btn_create(objects.deviceDropdown);
lv_obj_set_size(obj, 120, 25);
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_event_cb(obj, toggleRolloChooser, LV_EVENT_RELEASED, NULL);
lv_obj_t *parent_obj = obj;
obj = lv_label_create(parent_obj);
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 4);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_label_set_text(obj, SYM_CHECK);
lv_obj_set_style_text_font(obj, &symbol_font_16,
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
}
void create_screen_rollos() { void create_screen_rollos() {
lv_obj_t *obj = lv_obj_create(0); lv_obj_t *obj = lv_obj_create(0);
objects.rolloScr = obj; objects.rolloScr = obj;
@ -221,7 +253,7 @@ void create_screen_rollos() {
lv_obj_set_size(obj, 240, 240); lv_obj_set_size(obj, 240, 240);
{ {
lv_obj_t *parent_obj = obj; lv_obj_t *parent_obj = obj;
{ /*{
lv_obj_t *obj = lv_dropdown_create(parent_obj); lv_obj_t *obj = lv_dropdown_create(parent_obj);
objects.deviceDropdown = obj; objects.deviceDropdown = obj;
lv_dropdown_set_symbol(obj, SYM_ARROW_DOWN); lv_dropdown_set_symbol(obj, SYM_ARROW_DOWN);
@ -233,8 +265,34 @@ void create_screen_rollos() {
LV_PART_MAIN | LV_STATE_DEFAULT); LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(lv_dropdown_get_list(obj), &symbol_font_12, lv_obj_set_style_text_font(lv_dropdown_get_list(obj), &symbol_font_12,
LV_PART_MAIN | LV_STATE_DEFAULT); LV_PART_MAIN | LV_STATE_DEFAULT);
}*/
{ // rolloChooser BTN
lv_obj_t *obj = lv_btn_create(parent_obj);
lv_obj_set_size(obj, 130, 30);
lv_obj_set_pos(obj, 55, 20);
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_event_cb(obj, toggleRolloChooser, LV_EVENT_RELEASED, NULL);
lv_obj_t *parent_obj = obj;
static lv_anim_t animation_template;
lv_anim_init(&animation_template);
lv_anim_set_repeat_count(&animation_template,LV_ANIM_REPEAT_INFINITE);
lv_anim_set_delay(&animation_template,
500); /*Wait 1 second to start the first scroll*/
lv_anim_set_repeat_delay(&animation_template,
1000); /*Repeat the scroll 3 seconds after the
label scrolls back to the initial position*/
obj = lv_label_create(parent_obj);
lv_obj_set_style_anim(obj, &animation_template, LV_STATE_DEFAULT);
objects.selDevicesLbl = obj;
lv_label_set_long_mode(obj, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_width(obj, 110);
lv_label_set_text(obj, "Rollos wählen");
lv_obj_set_style_text_font(obj, &symbol_font_16,
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
LV_PART_MAIN | LV_STATE_DEFAULT);
} }
{ // UP BTN { // UP BTN
lv_obj_t *obj = lv_btn_create(parent_obj); lv_obj_t *obj = lv_btn_create(parent_obj);
lv_obj_set_size(obj, 120, 60); lv_obj_set_size(obj, 120, 60);
@ -310,6 +368,16 @@ void create_screen_rollos() {
LV_PART_MAIN | LV_STATE_DEFAULT); LV_PART_MAIN | LV_STATE_DEFAULT);
} }
addStatusIcons(parent_obj); addStatusIcons(parent_obj);
{
lv_obj_t *main_cont = lv_obj_create(parent_obj);
objects.deviceDropdown = main_cont;
lv_obj_set_flex_flow(main_cont, LV_FLEX_FLOW_COLUMN);
lv_obj_add_event_cb(main_cont, rolloChanged, LV_EVENT_CLICKED, 0);
lv_obj_add_flag(main_cont, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_size(main_cont, 150, LV_SIZE_CONTENT);
lv_obj_set_style_max_height(main_cont, 200, LV_STATE_DEFAULT);
lv_obj_set_pos(main_cont, 45, 30);
}
} }
// tick_screen_rollos(); // tick_screen_rollos();
} }
@ -557,7 +625,7 @@ void create_screen_rolloPos() {
objects.debugTxt = obj; objects.debugTxt = obj;
lv_obj_align(obj, LV_ALIGN_CENTER, 0, -85); lv_obj_align(obj, LV_ALIGN_CENTER, 0, -85);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_label_set_text(obj, "\"Fenster Rechts\"\nmanuell Positionieren"); lv_label_set_text(obj, "Gewählte Rollos manuell positionieren");
lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_CENTER, lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_CENTER,
LV_PART_MAIN | LV_STATE_DEFAULT); LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(obj, &symbol_font_12, lv_obj_set_style_text_font(obj, &symbol_font_12,

View File

@ -37,6 +37,7 @@ typedef struct _objects_t {
lv_chart_series_t *chart_series; lv_chart_series_t *chart_series;
lv_obj_t *rolloPos; lv_obj_t *rolloPos;
lv_obj_t *rolloRot; lv_obj_t *rolloRot;
lv_obj_t *selDevicesLbl;
} objects_t; } objects_t;
extern objects_t objects; extern objects_t objects;
@ -46,7 +47,7 @@ typedef enum ScreensEnum {
SCREEN_ID_CHART = 1, SCREEN_ID_CHART = 1,
SCREEN_ID_DEBUG = 2, SCREEN_ID_DEBUG = 2,
SCREEN_ID_LEN SCREEN_ID_LEN
}ScreensEnum; } ScreensEnum;
typedef enum ChartsEnum { typedef enum ChartsEnum {
CHART_ID_NONE = 0, CHART_ID_NONE = 0,
@ -54,18 +55,19 @@ typedef enum ChartsEnum {
CHART_ID_HUM = 2, CHART_ID_HUM = 2,
CHART_ID_PRESS = 3, CHART_ID_PRESS = 3,
CHART_ID_LEN CHART_ID_LEN
}ChartsEnum; } ChartsEnum;
void addStatusIcons(lv_obj_t *parent_obj); void addStatusIcons(lv_obj_t *parent_obj);
void create_screen_main(); void create_screen_main();
void create_screen_chart(); void create_screen_chart();
void create_screen_debug(); void create_screen_debug();
void create_screen_menu(); void create_screen_menu();
void rolloCheckbox_add(const char *txt, void *_tahomaDevice, bool _checked);
void rolloCheckbox_finish(void);
void create_screen_rollos(); void create_screen_rollos();
void create_screen_rolloPos(); void create_screen_rolloPos();
void create_screens(); void create_screens();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif