|
@@ -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;
|
|
|
|
|
@@ -112,7 +115,9 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg,
|
|
|
|
|
|
/* Different menus */
|
|
|
static void lcd_status_screen();
|
|
|
+#if (LANG_MODE != 0)
|
|
|
static void lcd_language_menu();
|
|
|
+#endif
|
|
|
static void lcd_main_menu();
|
|
|
static void lcd_tune_menu();
|
|
|
//static void lcd_move_menu();
|
|
@@ -581,7 +586,7 @@ void lcdui_print_Z_coord(void)
|
|
|
if (custom_message_type == CustomMsg::MeshBedLeveling)
|
|
|
lcd_puts_P(_N("Z --- "));
|
|
|
else
|
|
|
- lcd_printf_P(_N("Z%6.2f "), current_position[Z_AXIS]);
|
|
|
+ lcd_printf_P(_N("Z%6.2f%c"), current_position[Z_AXIS], axis_known_position[Z_AXIS]?' ':'?');
|
|
|
}
|
|
|
|
|
|
#ifdef PLANNER_DIAGNOSTICS
|
|
@@ -617,21 +622,24 @@ void lcdui_print_feedrate(void)
|
|
|
// Print percent done in form "USB---%", " SD---%", " ---%" (7 chars total)
|
|
|
void lcdui_print_percent_done(void)
|
|
|
{
|
|
|
- char sheet[8];
|
|
|
const char* src = is_usb_printing?_N("USB"):(IS_SD_PRINTING?_N(" SD"):_N(" "));
|
|
|
char per[4];
|
|
|
bool num = IS_SD_PRINTING || (PRINTER_ACTIVE && (print_percent_done_normal != PRINT_PERCENT_DONE_INIT));
|
|
|
if (!num || heating_status) // either not printing or heating
|
|
|
{
|
|
|
- eeprom_read_block(sheet, EEPROM_Sheets_base->s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].name, 7);
|
|
|
- sheet[7] = '\0';
|
|
|
- lcd_printf_P(PSTR("%s"),sheet);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sprintf_P(per, num?_N("%3hhd"):_N("---"), calc_percent_done());
|
|
|
- lcd_printf_P(_N("%3S%3s%%"), src, per);
|
|
|
+ const int8_t sheetNR = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
|
|
|
+ const int8_t nextSheet = eeprom_next_initialized_sheet(sheetNR);
|
|
|
+ if ((nextSheet >= 0) && (sheetNR != nextSheet))
|
|
|
+ {
|
|
|
+ char sheet[8];
|
|
|
+ eeprom_read_block(sheet, EEPROM_Sheets_base->s[sheetNR].name, 7);
|
|
|
+ sheet[7] = '\0';
|
|
|
+ lcd_printf_P(PSTR("%-7s"),sheet);
|
|
|
+ return; //do not also print the percentage
|
|
|
+ }
|
|
|
}
|
|
|
+ sprintf_P(per, num?_N("%3hhd"):_N("---"), calc_percent_done());
|
|
|
+ lcd_printf_P(_N("%3S%3s%%"), src, per);
|
|
|
}
|
|
|
|
|
|
// Print extruder status (5 chars total)
|
|
@@ -1100,6 +1108,7 @@ void lcd_commands()
|
|
|
lcd_setstatuspgm(_i("Print paused"));////MSG_PRINT_PAUSED c=20 r=1
|
|
|
lcd_commands_type = LcdCommands::Idle;
|
|
|
lcd_commands_step = 0;
|
|
|
+ long_pause();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1656,9 +1665,8 @@ void lcd_return_to_status()
|
|
|
//! @brief Pause print, disable nozzle heater, move to park position
|
|
|
void lcd_pause_print()
|
|
|
{
|
|
|
- lcd_return_to_status();
|
|
|
stop_and_save_print_to_ram(0.0,0.0);
|
|
|
- long_pause();
|
|
|
+ lcd_return_to_status();
|
|
|
isPrintPaused = true;
|
|
|
if (LcdCommands::Idle == lcd_commands_type)
|
|
|
{
|
|
@@ -2282,6 +2290,9 @@ static void lcd_support_menu()
|
|
|
void lcd_set_fan_check() {
|
|
|
fans_check_enabled = !fans_check_enabled;
|
|
|
eeprom_update_byte((unsigned char *)EEPROM_FAN_CHECK_ENABLED, fans_check_enabled);
|
|
|
+#ifdef FANCHECK
|
|
|
+ if (fans_check_enabled == false) fan_check_error = EFCE_OK; //reset error if fanCheck is disabled during error. Allows resuming print.
|
|
|
+#endif //FANCHECK
|
|
|
}
|
|
|
|
|
|
#ifdef MMU_HAS_CUTTER
|
|
@@ -4926,6 +4937,7 @@ void lcd_wizard() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#if (LANG_MODE != 0)
|
|
|
void lcd_language()
|
|
|
{
|
|
|
lcd_update_enable(true);
|
|
@@ -4945,6 +4957,7 @@ void lcd_language()
|
|
|
else
|
|
|
lang_select(LANG_ID_PRI);
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
static void wait_preheat()
|
|
|
{
|
|
@@ -5053,8 +5066,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?
|
|
@@ -5190,7 +5205,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
|
|
@@ -5827,6 +5844,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);
|
|
@@ -6702,6 +6726,7 @@ static void lcd_test_menu()
|
|
|
static bool fan_error_selftest()
|
|
|
{
|
|
|
#ifdef FANCHECK
|
|
|
+ if (!fans_check_enabled) return 0;
|
|
|
|
|
|
fanSpeed = 255;
|
|
|
#ifdef FAN_SOFT_PWM
|
|
@@ -6732,9 +6757,8 @@ static bool fan_error_selftest()
|
|
|
return 1;
|
|
|
}
|
|
|
#endif
|
|
|
+#endif //FANCHECK
|
|
|
return 0;
|
|
|
-
|
|
|
-#endif //FANCHECK
|
|
|
}
|
|
|
|
|
|
//! @brief Resume paused print
|
|
@@ -6749,10 +6773,10 @@ void lcd_resume_print()
|
|
|
|
|
|
if (fan_error_selftest()) return; //abort if error persists
|
|
|
|
|
|
+ isPrintPaused = false;
|
|
|
restore_print_from_ram_and_continue(0.0);
|
|
|
pause_time += (_millis() - start_pause_print); //accumulate time when print is paused for correct statistics calculation
|
|
|
refresh_cmd_timeout();
|
|
|
- isPrintPaused = false;
|
|
|
SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUMED); //resume octoprint
|
|
|
}
|
|
|
|
|
@@ -6904,7 +6928,7 @@ static void lcd_main_menu()
|
|
|
{
|
|
|
MENU_ITEM_FUNCTION_P(_i("Pause print"), lcd_pause_print);////MSG_PAUSE_PRINT
|
|
|
}
|
|
|
- else
|
|
|
+ else if(isPrintPaused)
|
|
|
{
|
|
|
#ifdef FANCHECK
|
|
|
if((fan_check_error == EFCE_FIXED) || (fan_check_error == EFCE_OK))
|
|
@@ -7156,6 +7180,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();
|
|
|
}
|
|
|
|
|
@@ -7205,6 +7235,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
|
|
@@ -7255,30 +7315,26 @@ static void lcd_sd_updir()
|
|
|
|
|
|
void lcd_print_stop()
|
|
|
{
|
|
|
-//-//
|
|
|
- if(!card.sdprinting)
|
|
|
- {
|
|
|
- SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint
|
|
|
- }
|
|
|
- saved_printing = false;
|
|
|
- saved_printing_type = PRINTING_TYPE_NONE;
|
|
|
+ if (!card.sdprinting) {
|
|
|
+ SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint
|
|
|
+ }
|
|
|
+
|
|
|
+ CRITICAL_SECTION_START;
|
|
|
+
|
|
|
+ // Clear any saved printing state
|
|
|
+ cancel_saved_printing();
|
|
|
cancel_heatup = true;
|
|
|
-#ifdef MESH_BED_LEVELING
|
|
|
- mbl.active = false;
|
|
|
-#endif
|
|
|
- // Stop the stoppers, update the position from the stoppers.
|
|
|
- if (mesh_bed_leveling_flag == false && homing_flag == false)
|
|
|
- {
|
|
|
- planner_abort_hard();
|
|
|
- // Because the planner_abort_hard() initialized current_position[Z] from the stepper,
|
|
|
- // Z baystep is no more applied. Reset it.
|
|
|
- babystep_reset();
|
|
|
- }
|
|
|
- // Clean the input command queue.
|
|
|
+
|
|
|
+ // Abort the planner/queue/sd
|
|
|
+ planner_abort_hard();
|
|
|
cmdqueue_reset();
|
|
|
- lcd_setstatuspgm(_T(MSG_PRINT_ABORTED));
|
|
|
card.sdprinting = false;
|
|
|
card.closefile();
|
|
|
+ st_reset_timer();
|
|
|
+
|
|
|
+ CRITICAL_SECTION_END;
|
|
|
+
|
|
|
+ lcd_setstatuspgm(_T(MSG_PRINT_ABORTED));
|
|
|
stoptime = _millis();
|
|
|
unsigned long t = (stoptime - starttime - pause_time) / 1000; //time in s
|
|
|
pause_time = 0;
|
|
@@ -7492,6 +7548,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;
|
|
@@ -7724,7 +7784,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);
|
|
|
}
|
|
|
|
|
@@ -8133,7 +8196,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();
|
|
@@ -8732,6 +8797,7 @@ void ultralcd_init()
|
|
|
else lcd_autoDeplete = autoDepleteRaw;
|
|
|
|
|
|
}
|
|
|
+ backlight_init();
|
|
|
lcd_init();
|
|
|
lcd_refresh();
|
|
|
lcd_longpress_func = menu_lcd_longpress_func;
|
|
@@ -8880,6 +8946,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
|
|
@@ -8961,6 +9028,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();
|
|
@@ -8978,6 +9046,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)
|
|
@@ -8988,9 +9057,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)();
|
|
|
|