From 9fc42526e71c09415d15472df4acaf5f6bec6372 Mon Sep 17 00:00:00 2001 From: leptun Date: Fri, 18 Oct 2019 12:18:43 +0300 Subject: [PATCH] Backlight always on during calibration --- Firmware/Marlin_main.cpp | 3 +++ Firmware/backlight.cpp | 15 +++++++++++++++ Firmware/backlight.h | 10 ++++++++++ Firmware/ultralcd.cpp | 6 +++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c076c8a0..ff580eeb 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -63,6 +63,7 @@ #include "menu.h" #include "ultralcd.h" +#include "backlight.h" #include "planner.h" #include "stepper.h" @@ -2768,6 +2769,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif // TMC2130 + FORCE_BL_ON_START; // Only Z calibration? if (!onlyZ) { @@ -2956,6 +2958,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif // TMC2130 + FORCE_BL_ON_END; return final_result; } diff --git a/Firmware/backlight.cpp b/Firmware/backlight.cpp index 5ceef595..054c510f 100644 --- a/Firmware/backlight.cpp +++ b/Firmware/backlight.cpp @@ -18,6 +18,21 @@ uint8_t backlightMode = BACKLIGHT_MODE_BRIGHT; int16_t backlightTimer_period = 10; LongTimer backlightTimer; +void force_bl_on(bool section_start) +{ + if (section_start) + { + backlightMode = BACKLIGHT_MODE_BRIGHT; + if (backlightLevel_HIGH < 30) backlightLevel_HIGH = 30; + } + else + { + backlightMode = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_MODE); + backlightLevel_HIGH = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH); + } + backlight_update(); +} + void backlight_save() //saves all backlight data to eeprom. { eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH, (uint8_t)backlightLevel_HIGH); diff --git a/Firmware/backlight.h b/Firmware/backlight.h index fc18dd5e..99d777d9 100644 --- a/Firmware/backlight.h +++ b/Firmware/backlight.h @@ -3,6 +3,8 @@ #define _BACKLIGHT_H #include +#include "Marlin.h" +#include "pins.h" enum Backlight_Mode { @@ -17,6 +19,14 @@ extern uint8_t backlightMode; extern bool backlightSupport; extern int16_t backlightTimer_period; +#ifdef LCD_BL_PIN + #define FORCE_BL_ON_START force_bl_on(true) + #define FORCE_BL_ON_END force_bl_on(false) +#else + #define FORCE_BL_ON_START + #define FORCE_BL_ON_END +#endif +extern void force_bl_on(bool section_start); extern void backlight_update(); extern void backlight_init(); extern void backlightTimer_reset(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 305ba7cb..9d5776c7 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5019,7 +5019,7 @@ 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); - + FORCE_BL_ON_START; while (!end) { printf_P(PSTR("Wizard state: %d\n"), state); switch (state) { @@ -5157,6 +5157,7 @@ void lcd_wizard(WizState state) } } + FORCE_BL_ON_END; printf_P(_N("Wizard end state: %d\n"), state); switch (state) { //final message case S::Restore: //printer was already calibrated @@ -7393,6 +7394,7 @@ bool lcd_selftest() #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif // TMC2130 + FORCE_BL_ON_START; _delay(2000); KEEPALIVE_STATE(IN_HANDLER); @@ -7612,6 +7614,7 @@ bool lcd_selftest() #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif // TMC2130 + FORCE_BL_ON_END; KEEPALIVE_STATE(NOT_BUSY); return(_result); } @@ -8021,6 +8024,7 @@ 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;