From 03cb9eacda83eed290d17cccc42660dd88fcdc5a Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Tue, 11 Jan 2022 21:26:06 +0100 Subject: [PATCH 01/26] initial version of clickable checklist --- radio/src/gui/common/stdlcd/view_text.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 01aada192e0..d3ea252f400 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -30,6 +30,7 @@ #endif constexpr uint32_t TEXT_FILE_MAXSIZE = 2048; +int checklistPosition; static void sdReadTextFile(const char * filename, char lines[TEXT_VIEWER_LINES][LCD_COLS + 1], int & lines_count) { @@ -132,6 +133,7 @@ void menuTextView(event_t event) switch (event) { case EVT_ENTRY: menuVerticalOffset = 0; + checklistPosition = 0; reusableBuffer.viewText.linesCount = 0; sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); break; @@ -143,6 +145,19 @@ void menuTextView(event_t event) menuVerticalOffset--; sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); break; + + case EVT_KEY_BREAK(KEY_ENTER): + if (checklistPosition < reusableBuffer.viewText.linesCount) { + ++checklistPosition; + if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { + ++menuVerticalOffset; + sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); + } + } + else { + popMenu(); + } + break; case EVT_KEY_NEXT_LINE: if (menuVerticalOffset+LCD_LINES-1 >= reusableBuffer.viewText.linesCount) @@ -158,7 +173,8 @@ void menuTextView(event_t event) } for (int i=0; i Date: Tue, 11 Jan 2022 22:30:52 +0100 Subject: [PATCH 02/26] do not display checkboxes for empty lines if checklist is shorter than screen size --- radio/src/gui/common/stdlcd/view_text.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index d3ea252f400..4f0bf0cccd0 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -173,7 +173,8 @@ void menuTextView(event_t event) } for (int i=0; i Date: Tue, 11 Jan 2022 22:40:01 +0100 Subject: [PATCH 03/26] remove checklist exit after completing it cannot exit menu from menuTextView as level above there is while loop that cannot be stopped from thic place in code --- radio/src/gui/common/stdlcd/view_text.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 4f0bf0cccd0..62f72c9da73 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -154,9 +154,6 @@ void menuTextView(event_t event) sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); } } - else { - popMenu(); - } break; case EVT_KEY_NEXT_LINE: From 8a812e8e528d6227f03b69c7d7a9d2b9db513bf9 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Tue, 11 Jan 2022 23:31:50 +0100 Subject: [PATCH 04/26] repair translation.py script to correctly process utf-8 files --- radio/src/translations/translation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/src/translations/translation.py b/radio/src/translations/translation.py index 70e631279b5..b2977fb8ec7 100755 --- a/radio/src/translations/translation.py +++ b/radio/src/translations/translation.py @@ -10,7 +10,7 @@ def add_line(filename, newline, args): print(filename, newline) - with open(filename, "r") as f: + with open(filename, encoding='utf-8', mode='r') as f: lines = f.readlines() newline += "\n" if args.before: @@ -25,7 +25,7 @@ def add_line(filename, newline, args): break else: lines.append(newline) - with open(filename, 'w') as f: + with open(filename, encoding='utf-8', mode='w') as f: f.writelines(lines) From 9d8973281f406b631de9d68421fcfbd35fc05fea Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Tue, 11 Jan 2022 23:32:19 +0100 Subject: [PATCH 05/26] menu entry to enable and disable interactive checklist --- radio/src/datastructs.h | 16 ++++++++-------- radio/src/datastructs_private.h | 1 + radio/src/gui/128x64/model_setup.cpp | 6 ++++++ radio/src/gui/212x64/model_setup.cpp | 6 ++++++ radio/src/gui/common/stdlcd/view_text.cpp | 13 ++++++++++--- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_t12.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_t8.cpp | 1 + .../src/storage/yaml/yaml_datastructs_tlite.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_tpro.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_tx12.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_x10.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_x12s.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_x7.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_x9d.cpp | 1 + radio/src/storage/yaml/yaml_datastructs_x9e.cpp | 1 + .../src/storage/yaml/yaml_datastructs_x9lite.cpp | 1 + .../storage/yaml/yaml_datastructs_x9lites.cpp | 1 + .../src/storage/yaml/yaml_datastructs_xlite.cpp | 1 + .../src/storage/yaml/yaml_datastructs_xlites.cpp | 1 + .../src/storage/yaml/yaml_datastructs_zorro.cpp | 1 + radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cn.h.txt | 1 + radio/src/translations/cz.h.txt | 1 + radio/src/translations/de.h.txt | 1 + radio/src/translations/en.h.txt | 1 + radio/src/translations/es.h.txt | 1 + radio/src/translations/fi.h.txt | 1 + radio/src/translations/fr.h.txt | 1 + radio/src/translations/it.h.txt | 1 + radio/src/translations/nl.h.txt | 1 + radio/src/translations/pl.h.txt | 1 + radio/src/translations/pt.h.txt | 1 + radio/src/translations/se.h.txt | 1 + radio/src/translations/tw.h.txt | 1 + 36 files changed, 62 insertions(+), 11 deletions(-) diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 8da911cf5f2..6a5e7978ca1 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -117,29 +117,29 @@ static inline void check_struct() #if defined(PCBXLITES) CHKSIZE(RadioData, 860); - CHKSIZE(ModelData, 6159); + CHKSIZE(ModelData, 6160); #elif defined(PCBXLITE) CHKSIZE(RadioData, 858); - CHKSIZE(ModelData, 6159); + CHKSIZE(ModelData, 6160); #elif defined(RADIO_TPRO) CHKSIZE(RadioData, 841); - CHKSIZE(ModelData, 6184); + CHKSIZE(ModelData, 6185); #elif defined(PCBX7) CHKSIZE(RadioData, 864); - CHKSIZE(ModelData, 6159); + CHKSIZE(ModelData, 6160); #elif defined(PCBX9E) CHKSIZE(RadioData, 954); - CHKSIZE(ModelData, 6611); + CHKSIZE(ModelData, 6612); #elif defined(PCBX9D) || defined(PCBX9DP) CHKSIZE(RadioData, 896); - CHKSIZE(ModelData, 6603); + CHKSIZE(ModelData, 6604); #elif defined(PCBHORUS) #if defined(PCBX10) CHKSIZE(RadioData, 921); - CHKSIZE(ModelData, 11023); + CHKSIZE(ModelData, 11024); #else CHKSIZE(RadioData, 903); - CHKSIZE(ModelData, 11021); + CHKSIZE(ModelData, 11022); #endif #endif diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index f2cd1fc3206..082eff90aea 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -646,6 +646,7 @@ PACK(struct ModelData { uint8_t extendedLimits:1; uint8_t extendedTrims:1; uint8_t throttleReversed:1; + uint8_t checklistInteractiveBW:8; // might be 1-bit, but have to maintain correct bit-aligment BeepANACenter beepANACenter; MixData mixData[MAX_MIXERS] NO_IDX; LimitData limitData[MAX_OUTPUT_CHANNELS]; diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index ceceb045f22..7a603ba8b93 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -88,6 +88,7 @@ enum MenuModelSetupItems { ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH, ITEM_MODEL_SETUP_PREFLIGHT_LABEL, ITEM_MODEL_SETUP_CHECKLIST_DISPLAY, + ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE, ITEM_MODEL_SETUP_THROTTLE_WARNING, ITEM_MODEL_SETUP_SWITCHES_WARNING1, #if defined(PCBTARANIS) @@ -439,6 +440,7 @@ void menuModelSetup(event_t event) LABEL(PreflightCheck), 0, // Checklist + 0, // Checklist interactive mode 0, // Throttle warning WARN_ROWS @@ -724,6 +726,10 @@ void menuModelSetup(event_t event) case ITEM_MODEL_SETUP_CHECKLIST_DISPLAY: g_model.displayChecklist = editCheckBox(g_model.displayChecklist, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST, attr, event); break; + + case ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE: + g_model.checklistInteractiveBW = editCheckBox(g_model.checklistInteractiveBW, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); + break; case ITEM_MODEL_SETUP_THROTTLE_WARNING: g_model.disableThrottleWarning = !editCheckBox(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLE_WARNING, attr, event); diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index 74efb645189..a2322c280dc 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -73,6 +73,7 @@ enum MenuModelSetupItems { ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH, ITEM_MODEL_SETUP_PREFLIGHT_LABEL, ITEM_MODEL_SETUP_CHECKLIST_DISPLAY, + ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE, ITEM_MODEL_SETUP_THROTTLE_WARNING, ITEM_MODEL_SETUP_SWITCHES_WARNING1, #if defined(PCBX9E) @@ -375,6 +376,7 @@ void menuModelSetup(event_t event) LABEL(PreflightCheck), 0, // Checklist + 0, // Checklist interactive mode 0, // Throttle warning SW_WARN_ROWS, // Switch warning POT_WARN_ROWS, // Pot warning @@ -636,6 +638,10 @@ void menuModelSetup(event_t event) case ITEM_MODEL_SETUP_CHECKLIST_DISPLAY: g_model.displayChecklist = editCheckBox(g_model.displayChecklist, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST, attr, event); break; + + case ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE: + g_model.checklistInteractiveBW = editCheckBox(g_model.checklistInteractiveBW, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); + break; case ITEM_MODEL_SETUP_THROTTLE_WARNING: g_model.disableThrottleWarning = !editCheckBox(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLE_WARNING, attr, event); diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 62f72c9da73..0a955ec83df 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -147,6 +147,7 @@ void menuTextView(event_t event) break; case EVT_KEY_BREAK(KEY_ENTER): + if (g_model.checklistInteractiveBW){ if (checklistPosition < reusableBuffer.viewText.linesCount) { ++checklistPosition; if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { @@ -154,6 +155,7 @@ void menuTextView(event_t event) sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); } } + } break; case EVT_KEY_NEXT_LINE: @@ -170,9 +172,14 @@ void menuTextView(event_t event) } for (int i=0; i Date: Wed, 12 Jan 2022 01:17:04 +0100 Subject: [PATCH 06/26] only when complete interactive checklist is closed --- radio/src/gui/common/stdlcd/model_notes.cpp | 3 +-- radio/src/gui/common/stdlcd/view_text.cpp | 17 ++++++++++++++--- radio/src/opentx.h | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/radio/src/gui/common/stdlcd/model_notes.cpp b/radio/src/gui/common/stdlcd/model_notes.cpp index 47b452b1b56..b61038c1e05 100644 --- a/radio/src/gui/common/stdlcd/model_notes.cpp +++ b/radio/src/gui/common/stdlcd/model_notes.cpp @@ -18,7 +18,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ - #include "opentx.h" void menuModelNotes(event_t event) @@ -28,7 +27,7 @@ void menuModelNotes(event_t event) char *buf = strcat_currentmodelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], 0); strcpy(buf, TEXT_EXT); } - + reusableBuffer.viewText.pushMenu = true; menuTextView(event); } diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 0a955ec83df..03b1de19622 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -108,7 +108,8 @@ void readModelNotes() waitKeysReleased(); event_t event = EVT_ENTRY; - while (event != EVT_KEY_BREAK(KEY_EXIT)) { + reusableBuffer.viewText.pushMenu = false; + while (true) { uint32_t power = pwrCheck(); if (power != e_power_press) { lcdRefreshWait(); @@ -123,6 +124,7 @@ void readModelNotes() } event = getEvent(); WDG_RESET(); + if (reusableBuffer.viewText.checklistComplete) break; } LED_ERROR_END(); @@ -134,6 +136,7 @@ void menuTextView(event_t event) case EVT_ENTRY: menuVerticalOffset = 0; checklistPosition = 0; + reusableBuffer.viewText.checklistComplete = false; reusableBuffer.viewText.linesCount = 0; sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); break; @@ -154,7 +157,11 @@ void menuTextView(event_t event) ++menuVerticalOffset; sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); } - } + } + else { + if (reusableBuffer.viewText.pushMenu == true) popMenu(); + reusableBuffer.viewText.checklistComplete = true; + } } break; @@ -167,7 +174,10 @@ void menuTextView(event_t event) break; case EVT_KEY_BREAK(KEY_EXIT): - popMenu(); + if (!g_model.checklistInteractiveBW || reusableBuffer.viewText.pushMenu == true) { + if (reusableBuffer.viewText.pushMenu == true) popMenu(); + reusableBuffer.viewText.checklistComplete = true; + } break; } @@ -200,6 +210,7 @@ void pushMenuTextView(const char *filename) { if (strlen(filename) < TEXT_FILENAME_MAXLEN) { strcpy(reusableBuffer.viewText.filename, filename); + reusableBuffer.viewText.pushMenu = true; pushMenu(menuTextView); } } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 08e7762baeb..655d242d5e8 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1123,6 +1123,8 @@ union ReusableBuffer char filename[TEXT_FILENAME_MAXLEN]; char lines[NUM_BODY_LINES][LCD_COLS + 1]; int linesCount; + bool checklistComplete; + bool pushMenu; } viewText; struct { From 153fd8ae6ef602b68155e562d1a6e6b162c3a484 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Wed, 12 Jan 2022 15:56:01 +0100 Subject: [PATCH 07/26] config updated & not display checkboxes when entered from "View Notes" --- radio/src/datastructs_private.h | 3 ++- radio/src/gui/128x64/model_setup.cpp | 2 +- radio/src/gui/212x64/model_setup.cpp | 2 +- radio/src/gui/common/stdlcd/view_text.cpp | 8 ++++---- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_t12.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_t8.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_tlite.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_tpro.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_tx12.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x10.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x12s.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x7.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x9d.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x9e.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x9lite.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_x9lites.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_xlite.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_xlites.cpp | 3 ++- radio/src/storage/yaml/yaml_datastructs_zorro.cpp | 3 ++- 20 files changed, 40 insertions(+), 23 deletions(-) diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 082eff90aea..41956a5483c 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -646,7 +646,8 @@ PACK(struct ModelData { uint8_t extendedLimits:1; uint8_t extendedTrims:1; uint8_t throttleReversed:1; - uint8_t checklistInteractiveBW:8; // might be 1-bit, but have to maintain correct bit-aligment + uint8_t checklistInteractive:1; + uint8_t memPadding:7; BeepANACenter beepANACenter; MixData mixData[MAX_MIXERS] NO_IDX; LimitData limitData[MAX_OUTPUT_CHANNELS]; diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 7a603ba8b93..ec452567450 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -728,7 +728,7 @@ void menuModelSetup(event_t event) break; case ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE: - g_model.checklistInteractiveBW = editCheckBox(g_model.checklistInteractiveBW, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); + g_model.checklistInteractive = editCheckBox(g_model.checklistInteractive, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); break; case ITEM_MODEL_SETUP_THROTTLE_WARNING: diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index a2322c280dc..cda1821b1cb 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -640,7 +640,7 @@ void menuModelSetup(event_t event) break; case ITEM_MODEL_SETUP_CHECKLIST_INTERACTIVE: - g_model.checklistInteractiveBW = editCheckBox(g_model.checklistInteractiveBW, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); + g_model.checklistInteractive = editCheckBox(g_model.checklistInteractive, MODEL_SETUP_2ND_COLUMN, y, STR_CHECKLIST_INTERACTIVE, attr, event); break; case ITEM_MODEL_SETUP_THROTTLE_WARNING: diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 03b1de19622..7305c90bcc7 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -150,7 +150,7 @@ void menuTextView(event_t event) break; case EVT_KEY_BREAK(KEY_ENTER): - if (g_model.checklistInteractiveBW){ + if (g_model.checklistInteractive && !reusableBuffer.viewText.pushMenu){ if (checklistPosition < reusableBuffer.viewText.linesCount) { ++checklistPosition; if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { @@ -174,7 +174,7 @@ void menuTextView(event_t event) break; case EVT_KEY_BREAK(KEY_EXIT): - if (!g_model.checklistInteractiveBW || reusableBuffer.viewText.pushMenu == true) { + if (!g_model.checklistInteractive || reusableBuffer.viewText.pushMenu) { if (reusableBuffer.viewText.pushMenu == true) popMenu(); reusableBuffer.viewText.checklistComplete = true; } @@ -182,8 +182,8 @@ void menuTextView(event_t event) } for (int i=0; i Date: Thu, 13 Jan 2022 20:34:27 +0100 Subject: [PATCH 08/26] corrected handling of padding bits in ModelData structure --- radio/src/datastructs_private.h | 2 +- radio/src/storage/yaml/yaml_datastructs_nv14.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_t12.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_t8.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_tlite.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_tpro.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_tx12.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x10.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x12s.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x7.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x9d.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x9e.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x9lite.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_x9lites.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_xlite.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_xlites.cpp | 2 +- radio/src/storage/yaml/yaml_datastructs_zorro.cpp | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 41956a5483c..a414fd21e25 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -647,7 +647,7 @@ PACK(struct ModelData { uint8_t extendedTrims:1; uint8_t throttleReversed:1; uint8_t checklistInteractive:1; - uint8_t memPadding:7; + uint8_t spare2:7 SKIP; // padding to 8-bit aligment BeepANACenter beepANACenter; MixData mixData[MAX_MIXERS] NO_IDX; LimitData limitData[MAX_OUTPUT_CHANNELS]; diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index b7c1ac60b84..584f5cc8754 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -831,7 +831,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_t12.cpp b/radio/src/storage/yaml/yaml_datastructs_t12.cpp index 97a64badbba..42d5403d481 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t12.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t12.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_t8.cpp b/radio/src/storage/yaml/yaml_datastructs_t8.cpp index ef98c34fb7b..573fa1ce6bf 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t8.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t8.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_tlite.cpp b/radio/src/storage/yaml/yaml_datastructs_tlite.cpp index ef98c34fb7b..573fa1ce6bf 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tlite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tlite.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index 1d53a9dc794..25ee05453a4 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -806,7 +806,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_tx12.cpp b/radio/src/storage/yaml/yaml_datastructs_tx12.cpp index d809b779490..762e2f6a078 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tx12.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tx12.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 1b8fea57250..146482a7dc3 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -852,7 +852,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 350579b4aee..7b0fd103749 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -850,7 +850,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x7.cpp b/radio/src/storage/yaml/yaml_datastructs_x7.cpp index ef98c34fb7b..573fa1ce6bf 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x7.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x7.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index e3341034153..65b31d68478 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -813,7 +813,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index 4e7554d4964..c15750984c5 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -852,7 +852,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp index 3ea76985d61..4c37dad0e7c 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp @@ -785,7 +785,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp index 96b7b2781e7..367e2362087 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lites.cpp @@ -795,7 +795,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp index 4a62704180c..9f74cae88b0 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlite.cpp @@ -792,7 +792,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index 7ff4b2ed262..87b679545b8 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -796,7 +796,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), diff --git a/radio/src/storage/yaml/yaml_datastructs_zorro.cpp b/radio/src/storage/yaml/yaml_datastructs_zorro.cpp index 42b6cb58dd8..58c38ce781d 100644 --- a/radio/src/storage/yaml/yaml_datastructs_zorro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_zorro.cpp @@ -800,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_UNSIGNED( "extendedTrims", 1 ), YAML_UNSIGNED( "throttleReversed", 1 ), YAML_UNSIGNED( "checklistInteractive", 1 ), - YAML_UNSIGNED( "memPadding", 7 ), + YAML_PADDING( 7 ), YAML_UNSIGNED( "beepANACenter", 16 ), YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL), YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL), From 708aa86b6df8c5bddafbaab1a675aa1535e0117d Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 16 Jan 2022 22:18:12 +0100 Subject: [PATCH 09/26] add setup entry for colorlcd --- radio/src/gui/colorlcd/model_setup.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 3ede21a88d4..6b9a18cb691 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -1466,6 +1466,11 @@ void ModelSetupPage::build(FormWindow * window) new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(g_model.displayChecklist)); grid.nextLine(); + // Interactive checklist + new StaticText(window, grid.getLabelSlot(true), STR_CHECKLIST_INTERACTIVE, 0, COLOR_THEME_PRIMARY1); + new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(g_model.checklistInteractive)); + grid.nextLine(); + // Throttle warning new StaticText(window, grid.getLabelSlot(true), STR_THROTTLE_WARNING, 0, COLOR_THEME_PRIMARY1); new CheckBox(window, grid.getFieldSlot(), GET_SET_INVERTED(g_model.disableThrottleWarning)); From 9fc8885b469253f56a03cffc9548cf02709e5481 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 22 Jan 2022 02:27:20 +0100 Subject: [PATCH 10/26] fix scrolling of checklist when having exactly number of lines screen can display --- radio/src/gui/colorlcd/view_text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index de7f2cc6fbc..5d1bcbf6cdf 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -291,7 +291,7 @@ void ViewTextWindow::checkEvents() break; CASE_EVT_KEY_NEXT_LINE: - if(textBottom && textVerticalOffset) //(textVerticalOffset + maxScreenLines - 1 >= readLinesCount) + if(textVerticalOffset + maxScreenLines >= readLinesCount) break; else { textVerticalOffset += lineStep; From d8002c2adec11b0845819e18f305e6ca56728bd3 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 22 Jan 2022 03:32:53 +0100 Subject: [PATCH 11/26] initial interactive checklist for colorlcd --- radio/src/gui/colorlcd/view_text.cpp | 46 ++++++++++++++++++++++++---- radio/src/gui/colorlcd/view_text.h | 1 + 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index 5d1bcbf6cdf..b398f6ee04d 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -37,7 +37,7 @@ #define CASE_EVT_START \ case EVT_ENTRY: \ - case EVT_KEY_BREAK(KEY_ENTER): \ + /*case EVT_KEY_BREAK(KEY_ENTER):*/ \ case EVT_KEY_BREAK(KEY_TELEM) void ViewTextWindow::extractNameSansExt() @@ -188,8 +188,9 @@ bool ViewTextWindow::sdReadTextLine(FIL *file, char line[], void ViewTextWindow::buildBody(Window *window) { - GridLayout grid(window); + FormGridLayout grid(window->width()); grid.spacer(); + grid.setLabelWidth(PAGE_LINE_HEIGHT); // width of "first column" for checkboxes int i; // assume average characte is 10 pixels wide, round the string length to tens. @@ -226,10 +227,26 @@ void ViewTextWindow::buildBody(Window *window) loadFirstScreen(); for (i = 0; i < maxScreenLines; i++) { - new DynamicText(window, grid.getSlot(), [=]() { - std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); - return std::string(str); - }); + if (g_model.checklistInteractive || true) { + new DynamicText(window, grid.getLabelSlot(), [=]() { + if (i < checklistPosition-(int)textVerticalOffset) + return std::string("+"); + else if (i == checklistPosition-(int)textVerticalOffset) + return std::string(">"); + else + return std::string(" "); + }); + new DynamicText(window, grid.getFieldSlot(), [=]() { + std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); + return std::string(str); + }); + } + else { + new DynamicText(window, grid.getSlot(), [=]() { + std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); + return std::string(str); + }); + } grid.nextLine(); } } @@ -287,8 +304,25 @@ void ViewTextWindow::checkEvents() CASE_EVT_START: textVerticalOffset = 0; readLinesCount = 0; + checklistPosition = 0; sdReadTextFileBlock(fullPath.c_str(), readLinesCount); break; + + case EVT_KEY_BREAK(KEY_ENTER): + if (g_model.checklistInteractive || true){ + if (checklistPosition < readLinesCount) { + ++checklistPosition; + /*if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { + ++menuVerticalOffset; + sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); + }*/ + } + else { + /*if (reusableBuffer.viewText.pushMenu == true) popMenu(); + reusableBuffer.viewText.checklistComplete = true;*/ + } + } + break; CASE_EVT_KEY_NEXT_LINE: if(textVerticalOffset + maxScreenLines >= readLinesCount) diff --git a/radio/src/gui/colorlcd/view_text.h b/radio/src/gui/colorlcd/view_text.h index 99617019f4e..3b1882e62da 100644 --- a/radio/src/gui/colorlcd/view_text.h +++ b/radio/src/gui/colorlcd/view_text.h @@ -97,6 +97,7 @@ class ViewTextWindow : public Page bool lastLine; uint16_t readCount; int longestLine; + int checklistPosition; #if !READ_FILE_BY_LINE char** lines = nullptr; From 1039b137bd30189c07314f2d479a6c84c4b9e9fc Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 01:18:43 +0100 Subject: [PATCH 12/26] auto scroll the checklist --- radio/src/gui/colorlcd/view_text.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index b398f6ee04d..cc4a630c840 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -312,12 +312,13 @@ void ViewTextWindow::checkEvents() if (g_model.checklistInteractive || true){ if (checklistPosition < readLinesCount) { ++checklistPosition; - /*if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { - ++menuVerticalOffset; - sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); - }*/ + if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { + ++textVerticalOffset; + sdReadTextFileBlock(fullPath.c_str(), readLinesCount); + } } else { + printf("Checklist finish\r\n"); /*if (reusableBuffer.viewText.pushMenu == true) popMenu(); reusableBuffer.viewText.checklistComplete = true;*/ } From 8af8cf0bfc7910dd12c43e9a327db9d895299e21 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 01:40:31 +0100 Subject: [PATCH 13/26] do not make interactive checkist when loaded from menu --- radio/src/gui/colorlcd/view_main_menu.cpp | 2 +- radio/src/gui/colorlcd/view_text.cpp | 19 ++++++++++--------- radio/src/gui/colorlcd/view_text.h | 8 +++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/radio/src/gui/colorlcd/view_main_menu.cpp b/radio/src/gui/colorlcd/view_main_menu.cpp index 22a86d03dae..62ed9e4dfe6 100644 --- a/radio/src/gui/colorlcd/view_main_menu.cpp +++ b/radio/src/gui/colorlcd/view_main_menu.cpp @@ -63,7 +63,7 @@ ViewMainMenu::ViewMainMenu(Window* parent) : if (modelHasNotes()) { carousel->addButton(ICON_MODEL_NOTES, STR_MAIN_MENU_MODEL_NOTES, [=]() -> uint8_t { deleteLater(); - readModelNotes(); + readModelNotes(true); return 0; }); } diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index cc4a630c840..b1e1c6217ea 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -227,7 +227,7 @@ void ViewTextWindow::buildBody(Window *window) loadFirstScreen(); for (i = 0; i < maxScreenLines; i++) { - if (g_model.checklistInteractive || true) { + if ((g_model.checklistInteractive || true) && !fromMenu) { new DynamicText(window, grid.getLabelSlot(), [=]() { if (i < checklistPosition-(int)textVerticalOffset) return std::string("+"); @@ -309,7 +309,7 @@ void ViewTextWindow::checkEvents() break; case EVT_KEY_BREAK(KEY_ENTER): - if (g_model.checklistInteractive || true){ + if ((g_model.checklistInteractive || true) && !fromMenu){ if (checklistPosition < readLinesCount) { ++checklistPosition; if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { @@ -479,16 +479,17 @@ static void replaceSpaceWithUnderscore(std::string& name) #define MODEL_FILE_EXT MODELS_EXT #endif -bool openNotes(const char buf[], std::string modelNotesName) +bool openNotes(const char buf[], std::string modelNotesName, bool fromMenu = false) { if(isFileAvailable(modelNotesName.c_str())) { - new ViewTextWindow(std::string(buf), modelNotesName, ICON_MODEL); + new ViewTextWindow(std::string(buf), modelNotesName, ICON_MODEL, fromMenu); return true; } else { return false; } } -void readModelNotes() + +void readModelNotes(bool fromMenu) { bool notesFound = false; LED_ERROR_BEGIN(); @@ -498,10 +499,10 @@ void readModelNotes() const char buf[] = {MODELS_PATH}; f_chdir((TCHAR*)buf); - notesFound = openNotes(buf, modelNotesName); + notesFound = openNotes(buf, modelNotesName, fromMenu); if(!notesFound) { replaceSpaceWithUnderscore(modelNotesName); - notesFound = openNotes(buf, modelNotesName); + notesFound = openNotes(buf, modelNotesName, fromMenu); } #if !defined(EEPROM) @@ -512,11 +513,11 @@ void readModelNotes() { modelNotesName.erase(index); modelNotesName.append(TEXT_EXT); - notesFound = openNotes(buf, modelNotesName); + notesFound = openNotes(buf, modelNotesName, fromMenu); } if(!notesFound) { replaceSpaceWithUnderscore(modelNotesName); - notesFound = openNotes(buf, modelNotesName); + notesFound = openNotes(buf, modelNotesName, fromMenu); } } #endif diff --git a/radio/src/gui/colorlcd/view_text.h b/radio/src/gui/colorlcd/view_text.h index 3b1882e62da..553eb734694 100644 --- a/radio/src/gui/colorlcd/view_text.h +++ b/radio/src/gui/colorlcd/view_text.h @@ -33,11 +33,12 @@ constexpr uint16_t TEXT_FILE_MAXSIZE = 20480; class ViewTextWindow : public Page { public: - ViewTextWindow(const std::string iPath, const std::string iName, unsigned int icon = ICON_RADIO_SD_MANAGER) : + ViewTextWindow(const std::string iPath, const std::string iName, unsigned int icon = ICON_RADIO_SD_MANAGER, bool fromMenu = false) : Page(icon), path(std::move(iPath)), name(std::move(iName)), - icon(icon) + icon(icon), + fromMenu(fromMenu) { fullPath = path + std::string("/") + name; extractNameSansExt(); @@ -98,6 +99,7 @@ class ViewTextWindow : public Page uint16_t readCount; int longestLine; int checklistPosition; + bool fromMenu; #if !READ_FILE_BY_LINE char** lines = nullptr; @@ -124,4 +126,4 @@ bool isInSetup; }; }; -void readModelNotes(); +void readModelNotes(bool fromMenu = false); From 71a041370793dd5efaa5a3bb240ea160bae597a5 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 02:31:54 +0100 Subject: [PATCH 14/26] checklist enter and exit conditions fixed --- radio/src/gui/colorlcd/view_text.cpp | 25 ++++++++++++++----------- radio/src/gui/colorlcd/view_text.h | 4 ++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index b1e1c6217ea..23f322f8689 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -302,14 +302,10 @@ void ViewTextWindow::checkEvents() */ switch (event) { CASE_EVT_START: - textVerticalOffset = 0; - readLinesCount = 0; - checklistPosition = 0; - sdReadTextFileBlock(fullPath.c_str(), readLinesCount); break; case EVT_KEY_BREAK(KEY_ENTER): - if ((g_model.checklistInteractive || true) && !fromMenu){ + if ((g_model.checklistInteractive || true) && !fromMenu) { if (checklistPosition < readLinesCount) { ++checklistPosition; if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { @@ -318,9 +314,7 @@ void ViewTextWindow::checkEvents() } } else { - printf("Checklist finish\r\n"); - /*if (reusableBuffer.viewText.pushMenu == true) popMenu(); - reusableBuffer.viewText.checklistComplete = true;*/ + Page::onEvent(EVT_KEY_BREAK(KEY_EXIT)); } } break; @@ -345,10 +339,19 @@ void ViewTextWindow::checkEvents() sdReadTextFileBlock(fullPath.c_str(), readLinesCount); break; - - default: + + case EVT_KEY_FIRST(KEY_EXIT): + case EVT_KEY_LONG(KEY_EXIT): + case EVT_KEY_REPT(KEY_EXIT): + case EVT_KEY_BREAK(KEY_EXIT): + if (!((g_model.checklistInteractive || true) && !fromMenu)) { Page::onEvent(event); - break; + } + break; + + default: + Page::onEvent(event); + break; } } Page::checkEvents(); diff --git a/radio/src/gui/colorlcd/view_text.h b/radio/src/gui/colorlcd/view_text.h index 553eb734694..e806a2c9837 100644 --- a/radio/src/gui/colorlcd/view_text.h +++ b/radio/src/gui/colorlcd/view_text.h @@ -47,11 +47,15 @@ class ViewTextWindow : public Page maxPos = 0; maxLines = 0; isInSetup = true; + checklistPosition = 0; + textVerticalOffset = 0; + readLinesCount = 0; //body.setWindowFlags(FORWARD_SCROLL); header.setWindowFlags(NO_SCROLLBAR); buildHeader(&header); buildBody(&body); + sdReadTextFileBlock(fullPath.c_str(), readLinesCount); }; #if READ_FILE_BY_LINE From a34fa573dfe37311f2f793118d547738a27c870b Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 02:35:01 +0100 Subject: [PATCH 15/26] remove unused code --- radio/src/gui/colorlcd/view_text.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index 23f322f8689..95788852127 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -35,11 +35,6 @@ case EVT_KEY_BREAK(KEY_PGUP): \ case EVT_KEY_BREAK(KEY_UP) -#define CASE_EVT_START \ - case EVT_ENTRY: \ - /*case EVT_KEY_BREAK(KEY_ENTER):*/ \ - case EVT_KEY_BREAK(KEY_TELEM) - void ViewTextWindow::extractNameSansExt() { uint8_t nameLength; @@ -301,9 +296,6 @@ void ViewTextWindow::checkEvents() } */ switch (event) { - CASE_EVT_START: - break; - case EVT_KEY_BREAK(KEY_ENTER): if ((g_model.checklistInteractive || true) && !fromMenu) { if (checklistPosition < readLinesCount) { From 72da66b74c4e118688565425d117836a84a4a4dc Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 02:53:45 +0100 Subject: [PATCH 16/26] libopenui updte --- radio/src/thirdparty/libopenui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index bfa6720b9f6..f193395874e 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit bfa6720b9f656c5f65cbcd0b0c577c8f9cd83c36 +Subproject commit f193395874ef6d371ce4fca9c3c222db88d60816 From 0c7ec603fd044d296eabba1b4c0753b756db7888 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 23 Jan 2022 03:27:54 +0100 Subject: [PATCH 17/26] remove debug settings override --- radio/src/gui/colorlcd/view_text.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index f8f3b3885e1..97c718dcf79 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -88,7 +88,7 @@ void ViewTextWindow::buildBody(Window *window) loadFirstScreen(); for (i = 0; i < maxScreenLines; i++) { - if ((g_model.checklistInteractive || true) && !fromMenu) { + if (g_model.checklistInteractive && !fromMenu) { new DynamicText(window, grid.getLabelSlot(), [=]() { if (i < checklistPosition-(int)textVerticalOffset) return std::string("+"); @@ -156,7 +156,7 @@ void ViewTextWindow::checkEvents() switch (event) { case EVT_KEY_BREAK(KEY_ENTER): - if ((g_model.checklistInteractive || true) && !fromMenu) { + if (g_model.checklistInteractive && !fromMenu) { if (checklistPosition < readLinesCount) { ++checklistPosition; if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { @@ -195,7 +195,7 @@ void ViewTextWindow::checkEvents() case EVT_KEY_LONG(KEY_EXIT): case EVT_KEY_REPT(KEY_EXIT): case EVT_KEY_BREAK(KEY_EXIT): - if (!((g_model.checklistInteractive || true) && !fromMenu)) { + if (!(g_model.checklistInteractive && !fromMenu)) { Page::onEvent(event); } break; From b4e65cd47e0d33046f93ab8bd86de5c84361db8f Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Thu, 27 Jan 2022 02:14:42 +0100 Subject: [PATCH 18/26] fix datastruct size after merge --- radio/src/datastructs.h | 16 ++++++++-------- radio/src/datastructs_private.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index c639c78ea35..4f3a3fd18ae 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -117,29 +117,29 @@ static inline void check_struct() #if defined(PCBXLITES) CHKSIZE(RadioData, 860); - CHKSIZE(ModelData, 6160); + CHKSIZE(ModelData, 6161); #elif defined(PCBXLITE) CHKSIZE(RadioData, 858); - CHKSIZE(ModelData, 6160); + CHKSIZE(ModelData, 6161); #elif defined(RADIO_TPRO) CHKSIZE(RadioData, 841); - CHKSIZE(ModelData, 6185); + CHKSIZE(ModelData, 6186); #elif defined(PCBX7) CHKSIZE(RadioData, 864); - CHKSIZE(ModelData, 6160); + CHKSIZE(ModelData, 6161); #elif defined(PCBX9E) CHKSIZE(RadioData, 954); - CHKSIZE(ModelData, 6612); + CHKSIZE(ModelData, 6613); #elif defined(PCBX9D) || defined(PCBX9DP) CHKSIZE(RadioData, 896); - CHKSIZE(ModelData, 6604); + CHKSIZE(ModelData, 6605); #elif defined(PCBHORUS) #if defined(PCBX10) CHKSIZE(RadioData, 921); - CHKSIZE(ModelData, 11024); + CHKSIZE(ModelData, 11025); #else CHKSIZE(RadioData, 903); - CHKSIZE(ModelData, 11022); + CHKSIZE(ModelData, 11023); #endif #endif diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index c22f1ef56de..b36f3628d4d 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -651,7 +651,7 @@ PACK(struct ModelData { uint8_t extendedTrims:1; uint8_t throttleReversed:1; uint8_t checklistInteractive:1; - uint8_t spare2:7 SKIP; // padding to 8-bit aligment + uint8_t spare3:7 SKIP; // padding to 8-bit aligment BeepANACenter beepANACenter; MixData mixData[MAX_MIXERS] NO_IDX; LimitData limitData[MAX_OUTPUT_CHANNELS]; From 086f144475b60995b1656226df2751049afbc9f4 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Thu, 27 Jan 2022 03:54:15 +0100 Subject: [PATCH 19/26] Companion support for interactive checklist --- companion/src/firmwares/edgetx/yaml_modeldata.cpp | 2 ++ companion/src/firmwares/modeldata.h | 1 + companion/src/modeledit/setup.cpp | 7 +++++++ companion/src/modeledit/setup.h | 1 + companion/src/modeledit/setup.ui | 10 ++++++++++ 5 files changed, 21 insertions(+) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 5b41c1bf4ad..f29954005b6 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -740,6 +740,7 @@ Node convert::encode(const ModelData& rhs) node["extendedLimits"] = (int)rhs.extendedLimits; node["extendedTrims"] = (int)rhs.extendedTrims; node["throttleReversed"] = (int)rhs.throttleReversed; + node["checklistInteractive"] = (int)rhs.checklistInteractive; for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) { if (!rhs.flightModeData[i].isEmpty(i)) { @@ -965,6 +966,7 @@ bool convert::decode(const Node& node, ModelData& rhs) node["extendedLimits"] >> rhs.extendedLimits; node["extendedTrims"] >> rhs.extendedTrims; node["throttleReversed"] >> rhs.throttleReversed; + node["checklistInteractive"] >> rhs.checklistInteractive; node["flightModeData"] >> rhs.flightModeData; node["mixData"] >> rhs.mixData; diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 51dadfb71aa..c714159eb47 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -128,6 +128,7 @@ class ModelData { bool extendedLimits; // TODO xml bool extendedTrims; bool throttleReversed; + bool checklistInteractive; FlightModeData flightModeData[CPN_MAX_FLIGHT_MODES]; MixData mixData[CPN_MAX_MIXERS]; LimitData limitData[CPN_MAX_CHNOUT]; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index db7b0a1abaf..bf84a0d921a 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1594,6 +1594,7 @@ void SetupPanel::update() ui->extendedLimits->setChecked(model->extendedLimits); ui->extendedTrims->setChecked(model->extendedTrims); ui->displayText->setChecked(model->displayChecklist); + ui->checklistInteractive->setChecked(model->checklistInteractive); ui->gfEnabled->setChecked(!model->noGlobalFunctions); ui->jitterFilter->setCurrentIndex(model->jitterFilter); @@ -1741,6 +1742,12 @@ void SetupPanel::on_displayText_toggled(bool checked) emit modified(); } +void SetupPanel::on_checklistInteractive_toggled(bool checked) +{ + model->checklistInteractive = checked; + emit modified(); +} + void SetupPanel::on_gfEnabled_toggled(bool checked) { model->noGlobalFunctions = !checked; diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 1d98265e03a..08258f96243 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -181,6 +181,7 @@ class SetupPanel : public ModelPanel void on_throttleWarning_toggled(bool checked); void on_throttleReverse_toggled(bool checked); void on_displayText_toggled(bool checked); + void on_checklistInteractive_toggled(bool checked); void on_gfEnabled_toggled(bool checked); void on_image_currentIndexChanged(int index); void on_trimIncrement_currentIndexChanged(int index); diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index cc46e1939c1..e0534693be4 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -537,6 +537,16 @@ + + + + Qt::LeftToRight + + + Interactive Checklist + + + From 4f11cd818930178c7c02c1029b08f6889c71b25d Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 30 Jan 2022 02:09:03 +0100 Subject: [PATCH 20/26] mark checklist lines as non-checkable with '=' for B&W radios --- radio/src/gui/common/stdlcd/view_text.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 7305c90bcc7..4c9106d3225 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -30,6 +30,7 @@ #endif constexpr uint32_t TEXT_FILE_MAXSIZE = 2048; +constexpr char NON_CHECKABLE_PREFIX = '='; int checklistPosition; static void sdReadTextFile(const char * filename, char lines[TEXT_VIEWER_LINES][LCD_COLS + 1], int & lines_count) @@ -183,9 +184,22 @@ void menuTextView(event_t event) for (int i=0; i Date: Sun, 30 Jan 2022 03:49:25 +0100 Subject: [PATCH 21/26] correctly displaying checkboxes but not updating --- radio/src/gui/colorlcd/view_text.cpp | 57 +++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index 97c718dcf79..ba763835eee 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -35,6 +35,48 @@ case EVT_KEY_BREAK(KEY_PGUP): \ case EVT_KEY_BREAK(KEY_UP) +constexpr char NON_CHECKABLE_PREFIX = '='; + +class CheckBoxStatic : public Window { + public: + CheckBoxStatic(Window * parent, const rect_t & rect, bool checked, bool focus, WindowFlags flags = 0) : + Window(parent, rect, flags, 0), + _checked(checked), + _focus(focus) + { + coord_t size = min(rect.w, rect.h); + setWidth(size); + setHeight(size); + } + +#if defined(DEBUG_WINDOWS) + std::string getName() const override + { + return "CheckBoxStatic"; + } +#endif + + const char * getLabel() const + { + return label.c_str(); + } + + void setLabel(std::string newLabel) + { + label = std::move(newLabel); + } + + void paint(BitmapBuffer * dc) + { + theme->drawCheckBox(dc, _checked, 0, FIELD_PADDING_TOP, _focus); + } + + protected: + std::string label; + bool _checked; + bool _focus; +}; + void ViewTextWindow::extractNameSansExt() { uint8_t nameLength; @@ -53,7 +95,7 @@ void ViewTextWindow::buildBody(Window *window) { FormGridLayout grid(window->width()); grid.spacer(); - grid.setLabelWidth(PAGE_LINE_HEIGHT); // width of "first column" for checkboxes + grid.setLabelWidth(PAGE_LINE_HEIGHT + 3UL * PAGE_LINE_SPACING); // width of "first column" for checkboxes int i; // assume average characte is 10 pixels wide, round the string length to tens. @@ -89,14 +131,11 @@ void ViewTextWindow::buildBody(Window *window) for (i = 0; i < maxScreenLines; i++) { if (g_model.checklistInteractive && !fromMenu) { - new DynamicText(window, grid.getLabelSlot(), [=]() { - if (i < checklistPosition-(int)textVerticalOffset) - return std::string("+"); - else if (i == checklistPosition-(int)textVerticalOffset) - return std::string(">"); - else - return std::string(" "); - }); + if (lines[i][0]) { + printf("Checkbox: %d %d %d", i, i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset); + CheckBoxStatic* chk = new CheckBoxStatic(window, grid.getLabelSlot(), i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset); + chk->invalidate(); + } new DynamicText(window, grid.getFieldSlot(), [=]() { std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); return std::string(str); From 110a4b870d01cc1c5cc663208c0ccec100258b10 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 30 Jan 2022 04:24:03 +0100 Subject: [PATCH 22/26] fixed updating checkboxes --- radio/src/gui/colorlcd/view_text.cpp | 50 ++++++++++++++++++---------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index ba763835eee..bbdcdd21272 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -39,14 +39,19 @@ constexpr char NON_CHECKABLE_PREFIX = '='; class CheckBoxStatic : public Window { public: - CheckBoxStatic(Window * parent, const rect_t & rect, bool checked, bool focus, WindowFlags flags = 0) : + CheckBoxStatic(Window * parent, const rect_t & rect, std::function getChecked, + std::function getFocus, std::function getVisible, WindowFlags flags = 0) : Window(parent, rect, flags, 0), - _checked(checked), - _focus(focus) + _getChecked(getChecked), + _getFocus(getFocus), + _getVisible(getVisible) { coord_t size = min(rect.w, rect.h); setWidth(size); setHeight(size); + _checked = _getChecked(); + _focus = _getFocus(); + _visible = _getVisible(); } #if defined(DEBUG_WINDOWS) @@ -56,25 +61,33 @@ class CheckBoxStatic : public Window { } #endif - const char * getLabel() const - { - return label.c_str(); - } - - void setLabel(std::string newLabel) + void paint(BitmapBuffer * dc) { - label = std::move(newLabel); + if(_visible) + theme->drawCheckBox(dc, _checked, 0, FIELD_PADDING_TOP, _focus); } - void paint(BitmapBuffer * dc) + void checkEvents() override { - theme->drawCheckBox(dc, _checked, 0, FIELD_PADDING_TOP, _focus); + Window::checkEvents(); + bool checked = _getChecked(); + bool focus = _getFocus(); + bool visible = _getVisible(); + if (checked != _checked || focus != _focus || visible != _visible) { + _checked = checked; + _focus = focus; + _visible = visible; + invalidate(); + } } protected: - std::string label; + std::function _getChecked; + std::function _getFocus; + std::function _getVisible; bool _checked; bool _focus; + bool _visible; }; void ViewTextWindow::extractNameSansExt() @@ -131,11 +144,12 @@ void ViewTextWindow::buildBody(Window *window) for (i = 0; i < maxScreenLines; i++) { if (g_model.checklistInteractive && !fromMenu) { - if (lines[i][0]) { - printf("Checkbox: %d %d %d", i, i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset); - CheckBoxStatic* chk = new CheckBoxStatic(window, grid.getLabelSlot(), i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset); - chk->invalidate(); - } + printf("Checkbox: %d %d %d %d\r\n", i, i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset, (int)lines[i][0]); + new CheckBoxStatic(window, grid.getLabelSlot(), + [=]() { return i < checklistPosition-(int)textVerticalOffset;}, + [=]() { return i == checklistPosition-(int)textVerticalOffset;}, + [=]() { return lines[i][0];}); + new DynamicText(window, grid.getFieldSlot(), [=]() { std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); return std::string(str); From 71d8d87428a8912b86e64b14da07f3030ba59f5c Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 30 Jan 2022 04:49:35 +0100 Subject: [PATCH 23/26] corrected checkbox hiding --- radio/src/gui/colorlcd/view_text.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index bbdcdd21272..54f19498505 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -274,7 +274,7 @@ void ViewTextWindow::sdReadTextFileBlock(const char *filename, int &lines_count) int result; char c; unsigned int sz = 0; - int line_length = 1; + int line_length = 0; uint8_t escape = 0; char escape_chars[4] = {0}; int current_line = 0; @@ -282,7 +282,6 @@ void ViewTextWindow::sdReadTextFileBlock(const char *filename, int &lines_count) for (int i = 0; i < maxScreenLines; i++) { memclear(lines[i], maxLineLength + 1); - lines[i][0] = ' '; } result = f_open(&file, (TCHAR *)filename, FA_OPEN_EXISTING | FA_READ); @@ -294,7 +293,7 @@ void ViewTextWindow::sdReadTextFileBlock(const char *filename, int &lines_count) i++) { if (c == '\n' || line_length >= maxLineLength) { ++current_line; - line_length = 1; + line_length = 0; escape = 0; } if (c != '\r' && c != '\n' && current_line >= textVerticalOffset && From 9a8c4c91581b3f29297d36f41b62aeebd63001f5 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 30 Jan 2022 20:44:03 +0100 Subject: [PATCH 24/26] hiding non-checkable lines --- radio/src/gui/colorlcd/view_text.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index 54f19498505..b6f3b0f1bc6 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -144,21 +144,20 @@ void ViewTextWindow::buildBody(Window *window) for (i = 0; i < maxScreenLines; i++) { if (g_model.checklistInteractive && !fromMenu) { - printf("Checkbox: %d %d %d %d\r\n", i, i < checklistPosition-(int)textVerticalOffset, i == checklistPosition-(int)textVerticalOffset, (int)lines[i][0]); new CheckBoxStatic(window, grid.getLabelSlot(), [=]() { return i < checklistPosition-(int)textVerticalOffset;}, [=]() { return i == checklistPosition-(int)textVerticalOffset;}, - [=]() { return lines[i][0];}); + [=]() { return lines[i][0] && lines[i][0]!=NON_CHECKABLE_PREFIX;}); new DynamicText(window, grid.getFieldSlot(), [=]() { - std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); + std::string str = + (lines[i][0]) ? std::string(lines[i]).substr(lines[i][0]==NON_CHECKABLE_PREFIX ? 1 : 0, std::string::npos) : std::string(" "); return std::string(str); }); } else { new DynamicText(window, grid.getSlot(), [=]() { - std::string str = - (lines[i][0]) ? std::string(lines[i]) : std::string(" "); + std::string str = (lines[i][0]) ? std::string(lines[i]) : std::string(" "); return std::string(str); }); } From c050ef885012c2a667b9d3a39417d66251e37b0d Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sun, 30 Jan 2022 23:55:33 +0100 Subject: [PATCH 25/26] correct colorlcd display with non-checkable items --- radio/src/gui/colorlcd/view_text.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index b6f3b0f1bc6..1e23fee6fec 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -143,12 +143,13 @@ void ViewTextWindow::buildBody(Window *window) loadFirstScreen(); for (i = 0; i < maxScreenLines; i++) { - if (g_model.checklistInteractive && !fromMenu) { - new CheckBoxStatic(window, grid.getLabelSlot(), - [=]() { return i < checklistPosition-(int)textVerticalOffset;}, - [=]() { return i == checklistPosition-(int)textVerticalOffset;}, - [=]() { return lines[i][0] && lines[i][0]!=NON_CHECKABLE_PREFIX;}); - + if (g_model.checklistInteractive) { + if (!fromMenu) { + new CheckBoxStatic(window, grid.getLabelSlot(), + [=]() { return i < checklistPosition-(int)textVerticalOffset;}, + [=]() { return i == checklistPosition-(int)textVerticalOffset;}, + [=]() { return lines[i][0] && lines[i][0]!=NON_CHECKABLE_PREFIX;}); + } new DynamicText(window, grid.getFieldSlot(), [=]() { std::string str = (lines[i][0]) ? std::string(lines[i]).substr(lines[i][0]==NON_CHECKABLE_PREFIX ? 1 : 0, std::string::npos) : std::string(" "); From 1454ea7ea389940656457ce5c640b593b13a689d Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Mon, 31 Jan 2022 00:07:15 +0100 Subject: [PATCH 26/26] Process only items visible on screen This is also crucial when it comes to analyse non-checkable items on a checklist, as in this way there is no need to load non-visible items from SD-card --- radio/src/gui/colorlcd/view_text.cpp | 15 ++++++++++----- radio/src/gui/common/stdlcd/view_text.cpp | 12 +++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/radio/src/gui/colorlcd/view_text.cpp b/radio/src/gui/colorlcd/view_text.cpp index 1e23fee6fec..1b89a35a219 100644 --- a/radio/src/gui/colorlcd/view_text.cpp +++ b/radio/src/gui/colorlcd/view_text.cpp @@ -209,12 +209,17 @@ void ViewTextWindow::checkEvents() switch (event) { case EVT_KEY_BREAK(KEY_ENTER): - if (g_model.checklistInteractive && !fromMenu) { + // check if interactive checklist enabled and process only items displayed on screen (cannot mark item that is out of the screen) + if (g_model.checklistInteractive && !fromMenu && checklistPosition-(int)textVerticalOffset >= 0) { if (checklistPosition < readLinesCount) { - ++checklistPosition; - if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { - ++textVerticalOffset; - sdReadTextFileBlock(fullPath.c_str(), readLinesCount); + if (checklistPosition-(int)textVerticalOffset < maxScreenLines) { + do{ + ++checklistPosition; + if (checklistPosition-(int)textVerticalOffset >= maxScreenLines-1 && textVerticalOffset + maxScreenLines < readLinesCount) { + ++textVerticalOffset; + sdReadTextFileBlock(fullPath.c_str(), readLinesCount); + } + }while(checklistPosition < readLinesCount && lines[checklistPosition-(int)textVerticalOffset][0] == NON_CHECKABLE_PREFIX); } } else { diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 4c9106d3225..be119664706 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -151,12 +151,14 @@ void menuTextView(event_t event) break; case EVT_KEY_BREAK(KEY_ENTER): - if (g_model.checklistInteractive && !reusableBuffer.viewText.pushMenu){ + if (g_model.checklistInteractive && !reusableBuffer.viewText.pushMenu && checklistPosition-(int)menuVerticalOffset >= 0){ if (checklistPosition < reusableBuffer.viewText.linesCount) { - ++checklistPosition; - if (checklistPosition-(int)menuVerticalOffset == LCD_LINES-1 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { - ++menuVerticalOffset; - sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); + if (checklistPosition-(int)menuVerticalOffset < LCD_LINES-1) { + ++checklistPosition; + if (checklistPosition-(int)menuVerticalOffset >= LCD_LINES-2 && menuVerticalOffset+LCD_LINES-1 < reusableBuffer.viewText.linesCount) { + ++menuVerticalOffset; + sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount); + } } } else {