|
@@ -19,6 +19,8 @@
|
|
|
#include "lcd.h"
|
|
|
#include "menu.h"
|
|
|
|
|
|
+#include "backlight.h"
|
|
|
+
|
|
|
#include "util.h"
|
|
|
#include "mesh_bed_leveling.h"
|
|
|
#include "mesh_bed_calibration.h"
|
|
@@ -56,6 +58,7 @@ char longFilenameOLD[LONG_FILENAME_LENGTH];
|
|
|
|
|
|
static void lcd_sd_updir();
|
|
|
static void lcd_mesh_bed_leveling_settings();
|
|
|
+static void lcd_backlight_menu();
|
|
|
|
|
|
int8_t ReInitLCD = 0;
|
|
|
|
|
@@ -5060,8 +5063,10 @@ void lcd_wizard(WizState state)
|
|
|
// Make sure EEPROM_WIZARD_ACTIVE is true if entering using different entry point
|
|
|
// other than WizState::Run - it is useful for debugging wizard.
|
|
|
if (state != S::Run) eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1);
|
|
|
-
|
|
|
- while (!end) {
|
|
|
+
|
|
|
+ FORCE_BL_ON_START;
|
|
|
+
|
|
|
+ while (!end) {
|
|
|
printf_P(PSTR("Wizard state: %d\n"), state);
|
|
|
switch (state) {
|
|
|
case S::Run: //Run wizard?
|
|
@@ -5197,7 +5202,9 @@ void lcd_wizard(WizState state)
|
|
|
default: break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ FORCE_BL_ON_END;
|
|
|
+
|
|
|
printf_P(_N("Wizard end state: %d\n"), state);
|
|
|
switch (state) { //final message
|
|
|
case S::Restore: //printer was already calibrated
|
|
@@ -5834,6 +5841,13 @@ static void lcd_settings_menu()
|
|
|
SETTINGS_SD;
|
|
|
SETTINGS_SOUND;
|
|
|
|
|
|
+#ifdef LCD_BL_PIN
|
|
|
+ if (backlightSupport)
|
|
|
+ {
|
|
|
+ MENU_ITEM_SUBMENU_P(_T(MSG_BRIGHTNESS), lcd_backlight_menu);
|
|
|
+ }
|
|
|
+#endif //LCD_BL_PIN
|
|
|
+
|
|
|
if (farm_mode)
|
|
|
{
|
|
|
MENU_ITEM_SUBMENU_P(PSTR("Farm number"), lcd_farm_no);
|
|
@@ -7163,6 +7177,12 @@ static void lcd_tune_menu()
|
|
|
#endif //TMC2130
|
|
|
SETTINGS_MMU_MODE;
|
|
|
SETTINGS_SOUND;
|
|
|
+#ifdef LCD_BL_PIN
|
|
|
+ if (backlightSupport)
|
|
|
+ {
|
|
|
+ MENU_ITEM_SUBMENU_P(_T(MSG_BRIGHTNESS), lcd_backlight_menu);
|
|
|
+ }
|
|
|
+#endif //LCD_BL_PIN
|
|
|
MENU_END();
|
|
|
}
|
|
|
|
|
@@ -7212,6 +7232,36 @@ static void lcd_mesh_bed_leveling_settings()
|
|
|
//SETTINGS_MBL_MODE;
|
|
|
}
|
|
|
|
|
|
+#ifdef LCD_BL_PIN
|
|
|
+static void backlight_mode_toggle()
|
|
|
+{
|
|
|
+ switch (backlightMode)
|
|
|
+ {
|
|
|
+ case BACKLIGHT_MODE_BRIGHT: backlightMode = BACKLIGHT_MODE_DIM; break;
|
|
|
+ case BACKLIGHT_MODE_DIM: backlightMode = BACKLIGHT_MODE_AUTO; break;
|
|
|
+ case BACKLIGHT_MODE_AUTO: backlightMode = BACKLIGHT_MODE_BRIGHT; break;
|
|
|
+ default: backlightMode = BACKLIGHT_MODE_BRIGHT; break;
|
|
|
+ }
|
|
|
+ backlight_save();
|
|
|
+}
|
|
|
+
|
|
|
+static void lcd_backlight_menu()
|
|
|
+{
|
|
|
+ MENU_BEGIN();
|
|
|
+ ON_MENU_LEAVE(
|
|
|
+ backlight_save();
|
|
|
+ );
|
|
|
+
|
|
|
+ MENU_ITEM_BACK_P(_T(MSG_BACK));
|
|
|
+ MENU_ITEM_EDIT_int3_P(_T(MSG_BL_HIGH), &backlightLevel_HIGH, backlightLevel_LOW, 255);
|
|
|
+ MENU_ITEM_EDIT_int3_P(_T(MSG_BL_LOW), &backlightLevel_LOW, 0, backlightLevel_HIGH);
|
|
|
+ MENU_ITEM_TOGGLE_P(_T(MSG_MODE), ((backlightMode==BACKLIGHT_MODE_BRIGHT) ? _T(MSG_BRIGHT) : ((backlightMode==BACKLIGHT_MODE_DIM) ? _T(MSG_DIM) : _T(MSG_AUTO))), backlight_mode_toggle);
|
|
|
+ MENU_ITEM_EDIT_int3_P(_T(MSG_TIMEOUT), &backlightTimer_period, 1, 999);
|
|
|
+
|
|
|
+ MENU_END();
|
|
|
+}
|
|
|
+#endif //LCD_BL_PIN
|
|
|
+
|
|
|
static void lcd_control_temperature_menu()
|
|
|
{
|
|
|
#ifdef PIDTEMP
|
|
@@ -7499,6 +7549,10 @@ bool lcd_selftest()
|
|
|
#if !IR_SENSOR_ANALOG
|
|
|
_delay(2000);
|
|
|
#endif //!IR_SENSOR_ANALOG
|
|
|
+
|
|
|
+ FORCE_BL_ON_START;
|
|
|
+
|
|
|
+ _delay(2000);
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
#if IR_SENSOR_ANALOG
|
|
|
bool bAction;
|
|
@@ -7731,7 +7785,10 @@ bool lcd_selftest()
|
|
|
#ifdef TMC2130
|
|
|
FORCE_HIGH_POWER_END;
|
|
|
#endif // TMC2130
|
|
|
- KEEPALIVE_STATE(NOT_BUSY);
|
|
|
+
|
|
|
+ FORCE_BL_ON_END;
|
|
|
+
|
|
|
+ KEEPALIVE_STATE(NOT_BUSY);
|
|
|
return(_result);
|
|
|
}
|
|
|
|
|
@@ -8140,7 +8197,9 @@ static bool lcd_selfcheck_check_heater(bool _isbed)
|
|
|
static void lcd_selftest_error(TestError testError, const char *_error_1, const char *_error_2)
|
|
|
{
|
|
|
lcd_beeper_quick_feedback();
|
|
|
-
|
|
|
+
|
|
|
+ FORCE_BL_ON_END;
|
|
|
+
|
|
|
target_temperature[0] = 0;
|
|
|
target_temperature_bed = 0;
|
|
|
manage_heater();
|
|
@@ -8739,6 +8798,7 @@ void ultralcd_init()
|
|
|
else lcd_autoDeplete = autoDepleteRaw;
|
|
|
|
|
|
}
|
|
|
+ backlight_init();
|
|
|
lcd_init();
|
|
|
lcd_refresh();
|
|
|
lcd_longpress_func = menu_lcd_longpress_func;
|
|
@@ -8887,6 +8947,7 @@ uint8_t get_message_level()
|
|
|
|
|
|
void menu_lcd_longpress_func(void)
|
|
|
{
|
|
|
+ backlight_wake();
|
|
|
if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z)
|
|
|
{
|
|
|
// disable longpress during re-entry, while homing or calibration
|
|
@@ -8968,6 +9029,7 @@ void menu_lcd_lcdupdate_func(void)
|
|
|
lcd_draw_update = 2;
|
|
|
lcd_oldcardstatus = IS_SD_INSERTED;
|
|
|
lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
|
|
|
+ backlight_wake();
|
|
|
if (lcd_oldcardstatus)
|
|
|
{
|
|
|
card.initsd();
|
|
@@ -8985,6 +9047,7 @@ void menu_lcd_lcdupdate_func(void)
|
|
|
}
|
|
|
}
|
|
|
#endif//CARDINSERTED
|
|
|
+ backlight_update();
|
|
|
if (lcd_next_update_millis < _millis())
|
|
|
{
|
|
|
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
|
|
@@ -8995,9 +9058,14 @@ void menu_lcd_lcdupdate_func(void)
|
|
|
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
|
|
|
lcd_encoder_diff = 0;
|
|
|
lcd_timeoutToStatus.start();
|
|
|
+ backlight_wake();
|
|
|
}
|
|
|
|
|
|
- if (LCD_CLICKED) lcd_timeoutToStatus.start();
|
|
|
+ if (LCD_CLICKED)
|
|
|
+ {
|
|
|
+ lcd_timeoutToStatus.start();
|
|
|
+ backlight_wake();
|
|
|
+ }
|
|
|
|
|
|
(*menu_menu)();
|
|
|
|