Fix LVGL "more" menu user items (#21004)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Malderin 2021-02-07 20:45:14 -03:00 committed by Scott Lahteine
parent 47b872f5d0
commit 1bf469411a
12 changed files with 103 additions and 82 deletions

View File

@ -516,3 +516,10 @@
(defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \
(defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \
(defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N))
#if ENABLED(CUSTOM_USER_MENUS)
#define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define HAS_USER_ITEM(V...) DO(HAS,||,V)
#else
#define HAS_USER_ITEM(N) 0
#endif

View File

@ -35,9 +35,6 @@ using namespace Theme;
#define _USER_ITEM(N) .tag(_ITEM_TAG(N)).button(USER_ITEM_POS(N), _USER_DESC(N))
#define _USER_ACTION(N) case _ITEM_TAG(N): injectCommands_P(PSTR(_USER_GCODE(N))); TERN_(USER_SCRIPT_RETURN, GOTO_SCREEN(StatusScreen)); break;
#define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define HAS_USER_ITEM(V...) DO(HAS,||,V)
void CustomUserMenus::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;

View File

@ -33,8 +33,6 @@
extern lv_group_t * g;
static lv_obj_t * scr;
#define HAS_USER_ITEM(N) (ENABLED(CUSTOM_USER_MENUS) && defined(USER_DESC_##N) && defined(USER_GCODE_##N))
enum {
ID_GCODE = 1,
#if HAS_USER_ITEM(1)

View File

@ -734,4 +734,3 @@
#define MORE_CUSTOM4_TEXT_EN USER_DESC_4
#define MORE_CUSTOM5_TEXT_EN USER_DESC_5
#define MORE_CUSTOM6_TEXT_EN USER_DESC_6
#define MORE_CUSTOM7_TEXT_EN USER_DESC_7

View File

@ -266,4 +266,3 @@
#define MORE_CUSTOM4_TEXT_FR USER_DESC_4
#define MORE_CUSTOM5_TEXT_FR USER_DESC_5
#define MORE_CUSTOM6_TEXT_FR USER_DESC_6
#define MORE_CUSTOM7_TEXT_FR USER_DESC_7

View File

@ -263,4 +263,3 @@
#define MORE_CUSTOM4_TEXT_IT USER_DESC_4
#define MORE_CUSTOM5_TEXT_IT USER_DESC_5
#define MORE_CUSTOM6_TEXT_IT USER_DESC_6
#define MORE_CUSTOM7_TEXT_IT USER_DESC_7

View File

@ -261,11 +261,7 @@
#define MORE_CUSTOM4_TEXT_RU USER_DESC_4
#define MORE_CUSTOM5_TEXT_RU USER_DESC_5
#define MORE_CUSTOM6_TEXT_RU USER_DESC_6
#define MORE_CUSTOM7_TEXT_RU USER_DESC_7
//Malderin translate
//
//
#define EEPROM_STORE_TIPS_RU "Cохранить настройки в EEPROM?"
#define EEPROM_READ_TIPS_RU "читать настройки из EEPROM?"
#define EEPROM_REVERT_TIPS_RU "Cбросить настройки к значениям по умолчанию?"
@ -365,5 +361,3 @@
#define ENCODER_CONF_TITLE_RU "Hастройки принтера>Hастройки энкодера"
#define ENCODER_CONF_TEXT_RU "энкодер используется?"
//end of Malderin translate

View File

@ -501,4 +501,3 @@
#define MORE_CUSTOM4_TEXT_CN USER_DESC_4
#define MORE_CUSTOM5_TEXT_CN USER_DESC_5
#define MORE_CUSTOM6_TEXT_CN USER_DESC_6
#define MORE_CUSTOM7_TEXT_CN USER_DESC_7

View File

@ -272,4 +272,3 @@
#define MORE_CUSTOM4_TEXT_SP USER_DESC_4
#define MORE_CUSTOM5_TEXT_SP USER_DESC_5
#define MORE_CUSTOM6_TEXT_SP USER_DESC_6
#define MORE_CUSTOM7_TEXT_SP USER_DESC_7

View File

@ -499,4 +499,3 @@
#define MORE_CUSTOM4_TEXT_T_CN USER_DESC_4
#define MORE_CUSTOM5_TEXT_T_CN USER_DESC_5
#define MORE_CUSTOM6_TEXT_T_CN USER_DESC_6
#define MORE_CUSTOM7_TEXT_T_CN USER_DESC_7

View File

@ -945,13 +945,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_CN;
more_menu.gcode = MORE_GCODE_CN;
more_menu.entergcode = MORE_ENTER_GCODE_CN;
TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_CN);
TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_CN);
TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_CN);
TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_CN);
TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_CN);
TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_CN);
TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_CN);
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_CN;
#endif
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_CN;
#endif
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_CN;
#endif
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_CN;
#endif
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_CN;
#endif
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_CN;
#endif
// WIFI
wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_CN;
@ -1179,13 +1190,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_T_CN;
more_menu.gcode = MORE_GCODE_T_CN;
more_menu.entergcode = MORE_ENTER_GCODE_T_CN;
TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_T_CN);
TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_T_CN);
TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_T_CN);
TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_T_CN);
TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_T_CN);
TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_T_CN);
TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_T_CN);
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_CN;
#endif
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_CN;
#endif
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_CN;
#endif
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_CN;
#endif
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_CN;
#endif
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_CN;
#endif
// WIFI
wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_T_CN;
@ -1400,13 +1422,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_EN;
more_menu.gcode = MORE_GCODE_EN;
more_menu.entergcode = MORE_ENTER_GCODE_EN;
TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN);
TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN);
TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_EN);
TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_EN);
TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_EN);
TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_EN);
TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_EN);
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
#endif
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
#endif
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
#endif
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
#endif
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
#endif
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
#endif
//
filesys_menu.title = TITLE_FILESYS_EN;
@ -1622,27 +1655,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_RU;
more_menu.gcode = MORE_GCODE_RU;
more_menu.entergcode = MORE_ENTER_GCODE_RU;
#if ENABLED(USER_CMD_1_ENABLE)
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_RU;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_RU;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_RU;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_RU;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_RU;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_RU;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_RU;
#endif
//
filesys_menu.title = TITLE_FILESYS_RU;
filesys_menu.sd_sys = SD_CARD_TEXT_RU;
@ -1954,27 +1984,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_SP;
more_menu.gcode = MORE_GCODE_SP;
more_menu.entergcode = MORE_ENTER_GCODE_SP;
#if ENABLED(USER_CMD_1_ENABLE)
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_SP;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_SP;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_SP;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_SP;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_SP;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_SP;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_SP;
#endif
//
filesys_menu.title = TITLE_FILESYS_SP;
filesys_menu.sd_sys = SD_CARD_TEXT_SP;
@ -2191,27 +2218,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_FR;
more_menu.gcode = MORE_GCODE_FR;
more_menu.entergcode = MORE_ENTER_GCODE_FR;
#if ENABLED(USER_CMD_1_ENABLE)
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_FR;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_FR;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_FR;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_FR;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_FR;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_FR;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_FR;
#endif
//
filesys_menu.title = TITLE_FILESYS_FR;
filesys_menu.sd_sys = SD_CARD_TEXT_FR;
@ -2429,27 +2453,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_IT;
more_menu.gcode = MORE_GCODE_IT;
more_menu.entergcode = MORE_ENTER_GCODE_IT;
#if ENABLED(USER_CMD_1_ENABLE)
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_IT;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_IT;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_IT;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_IT;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_IT;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_IT;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_IT;
#endif
//
filesys_menu.title = TITLE_FILESYS_IT;
filesys_menu.sd_sys = SD_CARD_TEXT_IT;
@ -2667,13 +2688,24 @@ void disp_language_init() {
more_menu.title = TITLE_MORE_EN;
more_menu.gcode = MORE_GCODE_EN;
more_menu.entergcode = MORE_ENTER_GCODE_EN;
TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN);
TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN);
TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_EN);
TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_EN);
TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_EN);
TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_EN);
TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_EN);
#if HAS_USER_ITEM(1)
more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
#endif
#if HAS_USER_ITEM(2)
more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
#endif
#if HAS_USER_ITEM(3)
more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
#endif
#if HAS_USER_ITEM(4)
more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
#endif
#if HAS_USER_ITEM(5)
more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
#endif
#if HAS_USER_ITEM(6)
more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
#endif
//
filesys_menu.title = TITLE_FILESYS_EN;
filesys_menu.sd_sys = SD_CARD_TEXT_EN;

View File

@ -46,7 +46,6 @@ void _lcd_user_gcode(PGM_P const cmd) {
void menu_user() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#define HAS_USER_ITEM(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); });
#if HAS_USER_ITEM(1)
USER_ITEM(1);