@@ -58,11 +58,7 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
5858 if (what & BACKGROUND) {
5959
6060 #define GRID_COLS 4
61- #if ENABLED(TOUCH_UI_PORTRAIT)
62- #define GRID_ROWS 7
63- #else
64- #define GRID_ROWS 6
65- #endif
61+ #define GRID_ROWS TERN (TOUCH_UI_PORTRAIT, 7 , 6 )
6662
6763 cmd.cmd(CLEAR_COLOR_RGB(bg_color))
6864 .cmd(CLEAR(true ,true ,true ))
@@ -77,21 +73,19 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
7773 #if DISABLED(LCD_FYSETC_TFT81050)
7874 .text (BTN_POS (1 ,2 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_LCD_BRIGHTNESS), OPT_RIGHTX | OPT_CENTERY)
7975 #endif
80- .text (BTN_POS (1 ,3 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_SOUND_VOLUME), OPT_RIGHTX | OPT_CENTERY)
81- .text (BTN_POS (1 ,4 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_SCREEN_LOCK), OPT_RIGHTX | OPT_CENTERY);
76+ .text (BTN_POS (1 ,3 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_SOUND_VOLUME), OPT_RIGHTX | OPT_CENTERY);
77+ #if ENABLED(FTDI_LOCK_SCREEN)
78+ cmd.text (BTN_POS (1 ,4 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_SCREEN_LOCK), OPT_RIGHTX | OPT_CENTERY);
79+ #endif
8280 #if DISABLED(TOUCH_UI_NO_BOOTSCREEN)
83- cmd.text (BTN_POS (1 ,5 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_BOOT_SCREEN), OPT_RIGHTX | OPT_CENTERY);
81+ cmd.text (BTN_POS (1 ,5 ), BTN_SIZE (2 ,1 ), GET_TEXT_F (MSG_BOOT_SCREEN), OPT_RIGHTX | OPT_CENTERY);
8482 #endif
8583 #undef EDGE_R
8684 }
8785
8886 if (what & FOREGROUND) {
89- #if defined(FTDI_LOCK_SCREEN) || DISABLED(TOUCH_UI_NO_BOOTSCREEN)
90- #if ENABLED(TOUCH_UI_PORTRAIT)
91- constexpr uint8_t w = 2 ;
92- #else
93- constexpr uint8_t w = 1 ;
94- #endif
87+ #if ENABLED(FTDI_LOCK_SCREEN) || DISABLED(TOUCH_UI_NO_BOOTSCREEN)
88+ constexpr uint8_t w = TERN (TOUCH_UI_PORTRAIT, 2 , 1 );
9589 #endif
9690
9791 cmd.font (font_medium)
@@ -101,7 +95,7 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
10195 .tag (2 ).slider (BTN_POS (3 ,2 ), BTN_SIZE (2 ,1 ), mydata.brightness , 128 )
10296 #endif
10397 .tag (3 ).slider (BTN_POS (3 ,3 ), BTN_SIZE (2 ,1 ), mydata.volume , 0xFF )
104- #ifdef FTDI_LOCK_SCREEN
98+ #if ENABLED( FTDI_LOCK_SCREEN)
10599 .colors (ui_toggle)
106100 .tag (4 ).toggle2 (BTN_POS (3 ,4 ), BTN_SIZE (w,1 ), GET_TEXT_F (MSG_NO), GET_TEXT_F (MSG_YES), LockScreen::is_enabled ())
107101 #endif
@@ -126,7 +120,7 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
126120bool InterfaceSettingsScreen::onTouchEnd (uint8_t tag) {
127121 switch (tag) {
128122 case 1 : GOTO_PREVIOUS (); return true ;
129- #ifdef FTDI_LOCK_SCREEN
123+ #if ENABLED( FTDI_LOCK_SCREEN)
130124 case 4 :
131125 if (!LockScreen::is_enabled ())
132126 LockScreen::enable ();
@@ -185,8 +179,7 @@ void InterfaceSettingsScreen::onIdle() {
185179}
186180
187181void InterfaceSettingsScreen::failSafeSettings () {
188- // Reset settings that may make the printer interface
189- // unusable.
182+ // Reset settings that may make the printer interface unusable.
190183 CLCD::mem_write_32 (CLCD::REG::ROTATE, 0 );
191184 CLCD::default_touch_transform ();
192185 CLCD::default_display_orientation ();
@@ -197,9 +190,7 @@ void InterfaceSettingsScreen::failSafeSettings() {
197190}
198191
199192void InterfaceSettingsScreen::defaultSettings () {
200- #ifdef FTDI_LOCK_SCREEN
201- LockScreen::passcode = 0 ;
202- #endif
193+ TERN_ (FTDI_LOCK_SCREEN, LockScreen::passcode = 0 );
203194 SoundPlayer::set_volume (255 );
204195 CLCD::set_brightness (255 );
205196 UIData::reset_persistent_data ();
@@ -218,11 +209,7 @@ void InterfaceSettingsScreen::saveSettings(char *buff) {
218209
219210 persistent_data_t eeprom;
220211
221- #ifdef FTDI_LOCK_SCREEN
222- eeprom.passcode = LockScreen::passcode;
223- #else
224- eeprom.passcode = 0 ;
225- #endif
212+ eeprom.passcode = TERN0 (FTDI_LOCK_SCREEN, LockScreen::passcode);
226213 eeprom.sound_volume = SoundPlayer::get_volume ();
227214 eeprom.display_brightness = CLCD::get_brightness ();
228215 eeprom.bit_flags = UIData::get_persistent_data ();
@@ -251,7 +238,7 @@ void InterfaceSettingsScreen::loadSettings(const char *buff) {
251238
252239 SERIAL_ECHOLNPGM (" Loading setting from EEPROM" );
253240
254- #ifdef FTDI_LOCK_SCREEN
241+ #if ENABLED( FTDI_LOCK_SCREEN)
255242 LockScreen::passcode = eeprom.passcode ;
256243 #endif
257244 SoundPlayer::set_volume (eeprom.sound_volume );
@@ -282,10 +269,7 @@ void InterfaceSettingsScreen::loadSettings(const char *buff) {
282269 if (success)
283270 success = persistentStore.write_data (0 , data, ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE) == PERSISTENT_STORE_SUCCESS;
284271
285- if (success)
286- StatusScreen::setStatusMessage (GET_TEXT_F (MSG_EEPROM_RESTORED));
287- else
288- StatusScreen::setStatusMessage (GET_TEXT_F (MSG_EEPROM_RESET));
272+ StatusScreen::setStatusMessage (success ? GET_TEXT_F (MSG_EEPROM_RESTORED) : GET_TEXT_F (MSG_EEPROM_RESET));
289273
290274 return success;
291275 }
0 commit comments