From fd9516f520d3e04c86a00f18c3ad0b828f3ba76d Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Sun, 19 Aug 2018 18:34:57 +0200 Subject: [PATCH] Status screen - status message logic simplification added definitions of custom_message_type values removed flag custom_message (previous solution maybe caused displaying of empty status line) fixed in Marlin_main.cpp code "custom_message = _T(MSG_TEMP_CALIBRATION)" --- Firmware/Marlin.h | 5 +- Firmware/Marlin_main.cpp | 44 +-- Firmware/ultralcd.cpp | 665 +++++++++++++++++---------------------- Firmware/ultralcd.h | 170 +++++----- 4 files changed, 396 insertions(+), 488 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 7187ac93..98cf5cab 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -315,9 +315,6 @@ void save_statistics(unsigned long _total_filament_used, unsigned long _total_pr extern unsigned int heating_status; extern unsigned int status_number; extern unsigned int heating_status_counter; -extern bool custom_message; -extern unsigned int custom_message_type; -extern unsigned int custom_message_state; extern char snmm_filaments_used; extern unsigned long PingTime; extern unsigned long NcTime; @@ -364,7 +361,7 @@ extern uint8_t print_percent_done_silent; extern uint32_t print_time_remaining_silent; #define PRINT_TIME_REMAINING_INIT 0xffffffff #define PRINT_PERCENT_DONE_INIT 0xff -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved) extern void calculate_extruder_multipliers(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bed42b16..ac0bbbbe 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -353,12 +353,13 @@ unsigned int status_number = 0; unsigned long total_filament_used; unsigned int heating_status; unsigned int heating_status_counter; -bool custom_message; bool loading_flag = false; -unsigned int custom_message_type; -unsigned int custom_message_state; + + + char snmm_filaments_used = 0; + bool fan_state[2]; int fan_edge_counter[2]; int fan_speed[2]; @@ -3157,8 +3158,7 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif enquecommand(cmd); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message = false; - custom_message_type = 0; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; } @@ -3172,8 +3172,7 @@ void gcode_M701() else { enable_z(); - custom_message = true; - custom_message_type = 2; + custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; #ifdef FILAMENT_SENSOR fsensor_oq_meassure_start(40); @@ -3215,8 +3214,7 @@ void gcode_M701() lcd_setstatuspgm(_T(WELCOME_MSG)); disable_z(); loading_flag = false; - custom_message = false; - custom_message_type = 0; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; #ifdef FILAMENT_SENSOR fsensor_oq_meassure_stop(); @@ -4051,10 +4049,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // setTargetHotend(200, 0); setTargetBed(70 + (start_temp - 30)); - custom_message = true; - custom_message_type = 4; + custom_message_type = CUSTOM_MSG_TYPE_TEMCAL; custom_message_state = 1; - custom_message = _T(MSG_TEMP_CALIBRATION); + lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); current_position[X_AXIS] = PINDA_PREHEAT_X; @@ -4154,10 +4151,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } puts_P(_N("PINDA probe calibration start")); - custom_message = true; - custom_message_type = 4; + custom_message_type = CUSTOM_MSG_TYPE_TEMCAL; custom_message_state = 1; - custom_message = _T(MSG_TEMP_CALIBRATION); + lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = PINDA_PREHEAT_Z; @@ -4223,8 +4219,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } - custom_message_type = 0; - custom_message = false; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); puts_P(_N("Temperature calibration done.")); @@ -4358,11 +4353,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } // Save custom message state, set a new custom message state to display: Calibrating point 9. - bool custom_message_old = custom_message; unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message = true; - custom_message_type = 1; + custom_message_type = CUSTOM_MSG_TYPE_MESHBL; custom_message_state = (MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) + 10; lcd_update(1); @@ -4594,7 +4587,6 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) KEEPALIVE_STATE(NOT_BUSY); // Restore custom message state lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message = custom_message_old; custom_message_type = custom_message_type_old; custom_message_state = custom_message_state_old; mesh_bed_leveling_flag = false; @@ -7804,11 +7796,9 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ enquecommand_front_P((PSTR("G1 Z5"))); return; } - bool custom_message_old = custom_message; unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message = true; - custom_message_type = 1; + custom_message_type = CUSTOM_MSG_TYPE_MESHBL; custom_message_state = (x_points_num * y_points_num) + 10; lcd_update(1); @@ -7958,8 +7948,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ void temp_compensation_start() { - custom_message = true; - custom_message_type = 5; + custom_message_type = CUSTOM_MSG_TYPE_TEMPRE; custom_message_state = PINDA_HEAT_T + 1; lcd_update(2); if (degHotend(active_extruder) > EXTRUDE_MINTEMP) { @@ -7980,9 +7969,8 @@ void temp_compensation_start() { if (custom_message_state == 99 || custom_message_state == 9) lcd_update(2); //force whole display redraw if number of digits changed else lcd_update(1); } - custom_message_type = 0; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; custom_message_state = 0; - custom_message = false; } void temp_compensation_apply() { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ca1398f4..85d735db 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -66,13 +66,17 @@ extern void crashdet_disable(); #endif //TMC2130 - #ifdef SDCARD_SORT_ALPHA - bool presort_flag = false; +bool presort_flag = false; #endif -int lcd_commands_type=LCD_COMMAND_IDLE; -int lcd_commands_step=0; +int lcd_commands_type = LCD_COMMAND_IDLE; +int lcd_commands_step = 0; + +unsigned int custom_message_type = CUSTOM_MSG_TYPE_STATUS; +unsigned int custom_message_state = 0; + + bool isPrintPaused = false; uint8_t farm_mode = 0; int farm_no = 0; @@ -518,24 +522,178 @@ uint8_t menu_item_sdfile(const char* str, const char* str_fn, char* str_fnl) } - - - - - - - -/* - -20x4 |01234567890123456789| - |T 000/000D Z000.0 | - |B 000/000D F100% | - |SD100% T--:-- | - |Status line.........| -*/ -static void lcd_implementation_status_screen() +//Print status line on status screen +void lcdui_print_status_line(void) { - + lcd_set_cursor(0, 3); + + if (IS_SD_PRINTING) + { + if (strcmp(longFilenameOLD, card.longFilename) != 0) + { + memset(longFilenameOLD, '\0', strlen(longFilenameOLD)); + sprintf_P(longFilenameOLD, PSTR("%s"), card.longFilename); + scrollstuff = 0; + } + } + + if (heating_status) + { // If heating flag, show progress of heating + heating_status_counter++; + if (heating_status_counter > 13) + { + heating_status_counter = 0; + } + lcd_set_cursor(7, 3); + lcd_puts_P(PSTR(" ")); + + for (unsigned int dots = 0; dots < heating_status_counter; dots++) + { + lcd_set_cursor(7 + dots, 3); + lcd_print('.'); + } + switch (heating_status) + { + case 1: + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_HEATING)); + break; + case 2: + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_HEATING_COMPLETE)); + heating_status = 0; + heating_status_counter = 0; + break; + case 3: + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_BED_HEATING)); + break; + case 4: + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_BED_DONE)); + heating_status = 0; + heating_status_counter = 0; + break; + default: + break; + } + } + else if ((IS_SD_PRINTING) && (custom_message_type == CUSTOM_MSG_TYPE_STATUS)) + { // If printing from SD, show what we are printing + if(strlen(card.longFilename) > LCD_WIDTH) + { + int inters = 0; + int gh = scrollstuff; + while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0)) + { + if (card.longFilename[gh] == '\0') + { + lcd_set_cursor(gh - scrollstuff, 3); + lcd_print(card.longFilename[gh - 1]); + scrollstuff = 0; + gh = scrollstuff; + inters = 1; + } + else + { + lcd_set_cursor(gh - scrollstuff, 3); + lcd_print(card.longFilename[gh - 1]); + gh++; + } + } + scrollstuff++; + } + else + { + lcd_print(longFilenameOLD); + } + } + else + { // Otherwise check for other special events + switch (custom_message_type) + { + case CUSTOM_MSG_TYPE_STATUS: // Nothing special, print status message normally + lcd_print(lcd_status_message); + break; + case CUSTOM_MSG_TYPE_MESHBL: // If mesh bed leveling in progress, show the status + if (custom_message_state > 10) + { + lcd_set_cursor(0, 3); + lcd_puts_P(PSTR(" ")); + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_CALIBRATE_Z_AUTO)); + lcd_puts_P(PSTR(" : ")); + lcd_print(custom_message_state-10); + } + else + { + if (custom_message_state == 3) + { + lcd_puts_P(_T(WELCOME_MSG)); + lcd_setstatuspgm(_T(WELCOME_MSG)); + custom_message_type = CUSTOM_MSG_TYPE_STATUS; + } + if (custom_message_state > 3 && custom_message_state <= 10 ) + { + lcd_set_cursor(0, 3); + lcd_puts_P(PSTR(" ")); + lcd_set_cursor(0, 3); + lcd_puts_P(_i("Calibration done"));////MSG_HOMEYZ_DONE c=0 r=0 + custom_message_state--; + } + } + break; + case CUSTOM_MSG_TYPE_F_LOAD: // If loading filament, print status + lcd_print(lcd_status_message); + break; + case CUSTOM_MSG_TYPE_PIDCAL: // PID tuning in progress + lcd_print(lcd_status_message); + if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) + { + lcd_set_cursor(10, 3); + lcd_print(itostr3(pid_cycle)); + lcd_print('/'); + lcd_print(itostr3left(pid_number_of_cycles)); + } + break; + case CUSTOM_MSG_TYPE_TEMCAL: // PINDA temp calibration in progress + { + char progress[4]; + lcd_set_cursor(0, 3); + lcd_puts_P(_T(MSG_TEMP_CALIBRATION)); + lcd_set_cursor(12, 3); + sprintf(progress, "%d/6", custom_message_state); + lcd_print(progress); + } + break; + case CUSTOM_MSG_TYPE_TEMPRE: // temp compensation preheat + lcd_set_cursor(0, 3); + lcd_puts_P(_i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 + if (custom_message_state <= PINDA_HEAT_T) + { + lcd_puts_P(PSTR(": ")); + lcd_print(custom_message_state); //seconds + lcd_print(' '); + } + break; + } + } + + // Fill the rest of line to have nice and clean output + for(int fillspace = 0; fillspace < 20; fillspace++) + if ((lcd_status_message[fillspace] <= 31 )) + lcd_print(' '); +} + +void lcdui_print_status_screen(void) +{ +//|01234567890123456789| +//|T 000/000D Z000.0 | +//|B 000/000D F100% | +//|SD100% T--:-- | +//|Status line.........| +//---------------------- + int tHotend=int(degHotend(0) + 0.5); int tTarget=int(degTargetHotend(0) + 0.5); @@ -552,7 +710,7 @@ static void lcd_implementation_status_screen() lcd_set_cursor(LCD_WIDTH - 8-2, 0); #if 1 lcd_puts_P(PSTR(" Z")); - if (custom_message_type == 1) { + if (custom_message_type == CUSTOM_MSG_TYPE_MESHBL) { // In a bed calibration mode. lcd_puts_P(PSTR(" --- ")); } else { @@ -612,7 +770,7 @@ static void lcd_implementation_status_screen() bool print_sd_status = true; #ifdef PINDA_THERMISTOR -// if (farm_mode && (custom_message_type == 4)) +// if (farm_mode && (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL)) if (false) { lcd_set_cursor(0, 2); @@ -677,365 +835,131 @@ if (print_sd_status) return; #endif //DEBUG_DISABLE_LCD_STATUS_LINE - //Print status line - lcd_set_cursor(0, 3); - // If heating in progress, set flag - if (heating_status != 0) { custom_message = true; } + lcdui_print_status_line(); - if (IS_SD_PRINTING) { - if (strcmp(longFilenameOLD, card.longFilename) != 0) - { - memset(longFilenameOLD, '\0', strlen(longFilenameOLD)); - sprintf_P(longFilenameOLD, PSTR("%s"), card.longFilename); - scrollstuff = 0; - } - } - - // If printing from SD, show what we are printing - if ((IS_SD_PRINTING) && !custom_message -#ifdef DEBUG_BUILD - && lcd_status_message[0] == 0 -#endif /* DEBUG_BUILD */ - ) - - { - if(strlen(card.longFilename) > LCD_WIDTH) - { - - int inters = 0; - int gh = scrollstuff; - while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0)) - { - - if (card.longFilename[gh] == '\0') - { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(card.longFilename[gh - 1]); - scrollstuff = 0; - gh = scrollstuff; - inters = 1; - } - else - { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(card.longFilename[gh - 1]); - gh++; - } - - - } - scrollstuff++; - } - else - { - lcd_print(longFilenameOLD); - } - } - - // If not, check for other special events - else - { - - if (custom_message) - { - // If heating flag, show progress of heating. - if (heating_status != 0) - { - heating_status_counter++; - if (heating_status_counter > 13) - { - heating_status_counter = 0; - } - lcd_set_cursor(7, 3); - lcd_puts_P(PSTR(" ")); - - for (unsigned int dots = 0; dots < heating_status_counter; dots++) - { - lcd_set_cursor(7 + dots, 3); - lcd_print('.'); - } - - switch (heating_status) - { - case 1: - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_HEATING)); - break; - case 2: - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_HEATING_COMPLETE)); - heating_status = 0; - heating_status_counter = 0; - custom_message = false; - break; - case 3: - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_BED_HEATING)); - break; - case 4: - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_BED_DONE)); - heating_status = 0; - heating_status_counter = 0; - custom_message = false; - break; - default: - break; - } - } - - // If mesh bed leveling in progress, show the status - - if (custom_message_type == 1) - { - if (custom_message_state > 10) - { - lcd_set_cursor(0, 3); - lcd_puts_P(PSTR(" ")); - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_CALIBRATE_Z_AUTO)); - lcd_puts_P(PSTR(" : ")); - lcd_print(custom_message_state-10); - } - else - { - if (custom_message_state == 3) - { - lcd_puts_P(_T(WELCOME_MSG)); - lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message = false; - custom_message_type = 0; - } - if (custom_message_state > 3 && custom_message_state <= 10 ) - { - lcd_set_cursor(0, 3); - lcd_puts_P(PSTR(" ")); - lcd_set_cursor(0, 3); - lcd_puts_P(_i("Calibration done"));////MSG_HOMEYZ_DONE c=0 r=0 - custom_message_state--; - } - } - - } - // If loading filament, print status - if (custom_message_type == 2) - { - lcd_print(lcd_status_message); - } - // PID tuning in progress - if (custom_message_type == 3) { - lcd_print(lcd_status_message); - if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) { - lcd_set_cursor(10, 3); - lcd_print(itostr3(pid_cycle)); - - lcd_print('/'); - lcd_print(itostr3left(pid_number_of_cycles)); - } - } - // PINDA temp calibration in progress - if (custom_message_type == 4) { - char progress[4]; - lcd_set_cursor(0, 3); - lcd_puts_P(_T(MSG_TEMP_CALIBRATION)); - lcd_set_cursor(12, 3); - sprintf(progress, "%d/6", custom_message_state); - lcd_print(progress); - } - // temp compensation preheat - if (custom_message_type == 5) { - lcd_set_cursor(0, 3); - lcd_puts_P(_i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 - if (custom_message_state <= PINDA_HEAT_T) { - lcd_puts_P(PSTR(": ")); - lcd_print(custom_message_state); //seconds - lcd_print(' '); - - } - } - - - } - else - { - // Nothing special, print status message normally - lcd_print(lcd_status_message); - } - } - - // Fill the rest of line to have nice and clean output - for(int fillspace = 0; fillspace<20;fillspace++) - { - if((lcd_status_message[fillspace] > 31 )) - { - } - else - { - lcd_print(' '); - } - } - } - -/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ - +// Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent static void lcd_status_screen() { - if (firstrun == 1) - { - firstrun = 0; - - if(lcd_status_message_level == 0){ - strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); - lcd_finishstatus(); - } - if (eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 1) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 2) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 3) == 255) + if (firstrun == 1) { - eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); - eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + firstrun = 0; + if(lcd_status_message_level == 0) + { + strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); + lcd_finishstatus(); + } + if (eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 1) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 2) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 3) == 255) + { + eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); + eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + } } - - } - - if (lcd_status_update_delay) - lcd_status_update_delay--; - else - lcd_draw_update = 1; - if (lcd_draw_update) - { - ReInitLCD++; - - - if (ReInitLCD == 30) - { - lcd_refresh(); // to maybe revive the LCD if static electricity killed it. - ReInitLCD = 0 ; - } + if (lcd_status_update_delay) + lcd_status_update_delay--; else + lcd_draw_update = 1; + + + if (lcd_draw_update) { - - if ((ReInitLCD % 10) == 0) - { - lcd_refresh_noclear(); //to maybe revive the LCD if static electricity killed it. - } - - } - - - lcd_implementation_status_screen(); - //lcd_clear(); - - if (farm_mode) - { - farm_timer--; - if (farm_timer < 1) + ReInitLCD++; + if (ReInitLCD == 30) { - farm_timer = 10; - prusa_statistics(0); + lcd_refresh(); // to maybe revive the LCD if static electricity killed it. + ReInitLCD = 0 ; } - switch (farm_timer) + else { - case 8: - prusa_statistics(21); - break; - case 5: - if (IS_SD_PRINTING) + if ((ReInitLCD % 10) == 0) + lcd_refresh_noclear(); //to maybe revive the LCD if static electricity killed it. + } + + lcdui_print_status_screen(); + + if (farm_mode) + { + farm_timer--; + if (farm_timer < 1) { - prusa_statistics(20); + farm_timer = 10; + prusa_statistics(0); } - break; - } - } // end of farm_mode + switch (farm_timer) + { + case 8: + prusa_statistics(21); + break; + case 5: + if (IS_SD_PRINTING) + prusa_statistics(20); + break; + } + } // end of farm_mode + lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ + if (lcd_commands_type != LCD_COMMAND_IDLE) + lcd_commands(); + } // end of lcd_draw_update + bool current_click = LCD_CLICKED; - - - lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ - if (lcd_commands_type != LCD_COMMAND_IDLE) + if (ignore_click) { - lcd_commands(); + if (wait_for_unclick) + { + if (!current_click) + ignore_click = wait_for_unclick = false; + else + current_click = false; + } + else if (current_click) + { + lcd_quick_feedback(); + wait_for_unclick = true; + current_click = false; + } } - - } // end of lcd_draw_update - - bool current_click = LCD_CLICKED; - - if (ignore_click) { - if (wait_for_unclick) { - if (!current_click) { - ignore_click = wait_for_unclick = false; - } - else { - current_click = false; - } - } - else if (current_click) { - lcd_quick_feedback(); - wait_for_unclick = true; - current_click = false; - } - } - - if (current_click && (lcd_commands_type != LCD_COMMAND_STOP_PRINT)) //click is aborted unless stop print finishes - { - menu_depth = 0; //redundant, as already done in lcd_return_to_status(), just to be sure - menu_submenu(lcd_main_menu); - lcd_refresh(); // to maybe revive the LCD if static electricity killed it. - } + if (current_click && (lcd_commands_type != LCD_COMMAND_STOP_PRINT)) //click is aborted unless stop print finishes + { + menu_depth = 0; //redundant, as already done in lcd_return_to_status(), just to be sure + menu_submenu(lcd_main_menu); + lcd_refresh(); // to maybe revive the LCD if static electricity killed it. + } #ifdef ULTIPANEL_FEEDMULTIPLY - // Dead zone at 100% feedrate - if ((feedmultiply < 100 && (feedmultiply + int(lcd_encoder)) > 100) || - (feedmultiply > 100 && (feedmultiply + int(lcd_encoder)) < 100)) - { - lcd_encoder = 0; - feedmultiply = 100; - } - - if (feedmultiply == 100 && int(lcd_encoder) > ENCODER_FEEDRATE_DEADZONE) - { - feedmultiply += int(lcd_encoder) - ENCODER_FEEDRATE_DEADZONE; - lcd_encoder = 0; - } - else if (feedmultiply == 100 && int(lcd_encoder) < -ENCODER_FEEDRATE_DEADZONE) - { - feedmultiply += int(lcd_encoder) + ENCODER_FEEDRATE_DEADZONE; - lcd_encoder = 0; - } - else if (feedmultiply != 100) - { - feedmultiply += int(lcd_encoder); - lcd_encoder = 0; - } + // Dead zone at 100% feedrate + if ((feedmultiply < 100 && (feedmultiply + int(lcd_encoder)) > 100) || + (feedmultiply > 100 && (feedmultiply + int(lcd_encoder)) < 100)) + { + lcd_encoder = 0; + feedmultiply = 100; + } + if (feedmultiply == 100 && int(lcd_encoder) > ENCODER_FEEDRATE_DEADZONE) + { + feedmultiply += int(lcd_encoder) - ENCODER_FEEDRATE_DEADZONE; + lcd_encoder = 0; + } + else if (feedmultiply == 100 && int(lcd_encoder) < -ENCODER_FEEDRATE_DEADZONE) + { + feedmultiply += int(lcd_encoder) + ENCODER_FEEDRATE_DEADZONE; + lcd_encoder = 0; + } + else if (feedmultiply != 100) + { + feedmultiply += int(lcd_encoder); + lcd_encoder = 0; + } #endif //ULTIPANEL_FEEDMULTIPLY - if (feedmultiply < 10) - feedmultiply = 10; - else if (feedmultiply > 999) - feedmultiply = 999; - - /*if (farm_mode && !printer_connected) { - lcd_set_cursor(0, 3); - lcd_puts_P(_i("Printer disconnected"));////MSG_PRINTER_DISCONNECTED c=20 r=1 - }*/ - - -//#define FSENS_FACTOR (2580.8/50) //filament sensor factor [steps / encoder counts] -//#define FSENS_FACTOR (2580.8/45.3) //filament sensor factor [steps / encoder counts] - //lcd_set_cursor(0, 3); - //lcd_print(" "); - //lcd_set_cursor(0, 3); - //lcd_print(pat9125_x); - //lcd_set_cursor(6, 3); - //lcd_print(pat9125_y); - //lcd_set_cursor(12, 3); - //lcd_print(pat9125_b); - + if (feedmultiply < 10) + feedmultiply = 10; + else if (feedmultiply > 999) + feedmultiply = 999; } @@ -1636,7 +1560,6 @@ void lcd_commands() if (lcd_commands_step == 0) { lcd_commands_step = 6; - custom_message = true; } if (lcd_commands_step == 1 && !blocks_queued()) @@ -1644,8 +1567,7 @@ void lcd_commands() lcd_commands_step = 0; lcd_commands_type = 0; lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = 0; - custom_message = false; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; isPrintPaused = false; } if (lcd_commands_step == 2 && !blocks_queued()) @@ -1701,8 +1623,7 @@ void lcd_commands() if (mmu_enabled) setAllTargetHotends(0); manage_heater(); - custom_message = true; - custom_message_type = 2; + custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; lcd_commands_step = 5; } if (lcd_commands_step == 7 && !blocks_queued()) @@ -1732,7 +1653,7 @@ void lcd_commands() if (lcd_commands_type == LCD_COMMAND_FARM_MODE_CONFIRM) /// farm mode confirm { - if (lcd_commands_step == 0) { lcd_commands_step = 6; custom_message = true; } + if (lcd_commands_step == 0) { lcd_commands_step = 6; } if (lcd_commands_step == 1 && !blocks_queued()) { @@ -1775,9 +1696,8 @@ void lcd_commands() char cmd1[30]; if (lcd_commands_step == 0) { - custom_message_type = 3; + custom_message_type = CUSTOM_MSG_TYPE_PIDCAL; custom_message_state = 1; - custom_message = true; lcd_draw_update = 3; lcd_commands_step = 3; } @@ -1810,8 +1730,7 @@ void lcd_commands() } if ((lcd_commands_step == 1) && ((millis()- display_time)>2000)) { //calibration finished message lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = 0; - custom_message = false; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; pid_temp = DEFAULT_PID_TEMP; lcd_commands_step = 0; lcd_commands_type = 0; @@ -2524,7 +2443,7 @@ static void lcd_LoadFilament() { if (degHotend0() > EXTRUDE_MINTEMP) { - custom_message = true; + custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; loading_flag = true; enquecommand_P(PSTR("M701")); //load filament SERIAL_ECHOLN("Loading filament"); @@ -3581,8 +3500,7 @@ void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask) void lcd_temp_cal_show_result(bool result) { - custom_message_type = 0; - custom_message = false; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; disable_x(); disable_y(); disable_z(); @@ -5229,8 +5147,7 @@ static void change_extr_menu(){ //unload filament for single material printer (used in M702 gcode) void unload_filament() { - custom_message = true; - custom_message_type = 2; + custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT)); // extr_unload2(); @@ -5265,8 +5182,7 @@ void unload_filament() lcd_update_enable(true); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message = false; - custom_message_type = 0; + custom_message_type = CUSTOM_MSG_TYPE_STATUS; } @@ -5752,8 +5668,7 @@ static void lcd_colorprint_change() { enquecommand_P(PSTR("M600")); - custom_message = true; - custom_message_type = 2; //just print status message + custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; //just print status message lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); lcd_return_to_status(); lcd_draw_update = 3; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 062d2595..29a13a9c 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -13,100 +13,108 @@ extern void menu_lcd_longpress_func(void); extern void menu_lcd_charsetup_func(void); extern void menu_lcd_lcdupdate_func(void); - // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. - void ultralcd_init(); - void lcd_setstatus(const char* message); - void lcd_setstatuspgm(const char* message); - void lcd_setalertstatuspgm(const char* message); - void lcd_reset_alert_level(); - uint8_t get_message_level(); - void lcd_adjust_z(); - void lcd_pick_babystep(); - void lcd_alright(); - void EEPROM_save_B(int pos, int* value); - void EEPROM_read_B(int pos, int* value); - void lcd_wait_interact(); - void lcd_change_filament(); - void lcd_loading_filament(); - void lcd_change_success(); - void lcd_loading_color(); - void lcd_sdcard_stop(); - void lcd_sdcard_pause(); - void lcd_print_stop(); - void prusa_statistics(int _message, uint8_t _col_nr = 0); - void lcd_confirm_print(); - unsigned char lcd_choose_color(); +// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. +void ultralcd_init(); +void lcd_setstatus(const char* message); +void lcd_setstatuspgm(const char* message); +void lcd_setalertstatuspgm(const char* message); +void lcd_reset_alert_level(); +uint8_t get_message_level(); +void lcd_adjust_z(); +void lcd_pick_babystep(); +void lcd_alright(); +void EEPROM_save_B(int pos, int* value); +void EEPROM_read_B(int pos, int* value); +void lcd_wait_interact(); +void lcd_change_filament(); +void lcd_loading_filament(); +void lcd_change_success(); +void lcd_loading_color(); +void lcd_sdcard_stop(); +void lcd_sdcard_pause(); +void lcd_print_stop(); +void prusa_statistics(int _message, uint8_t _col_nr = 0); +void lcd_confirm_print(); +unsigned char lcd_choose_color(); //void lcd_mylang(); - extern bool lcd_selftest(); +extern bool lcd_selftest(); - void lcd_menu_statistics(); +void lcd_menu_statistics(); extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); extern const char* lcd_display_message_fullscreen_P(const char *msg); - extern void lcd_wait_for_click(); - extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); - // 0: no, 1: yes, -1: timeouted - extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false); - extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false); - // Ask the user to move the Z axis up to the end stoppers and let - // the user confirm that it has been done. - #ifndef TMC2130 - extern bool lcd_calibrate_z_end_stop_manual(bool only_z); - #endif +extern void lcd_wait_for_click(); +extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); +// 0: no, 1: yes, -1: timeouted +extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false); +extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false); +// Ask the user to move the Z axis up to the end stoppers and let +// the user confirm that it has been done. - // Show the result of the calibration process on the LCD screen. - extern void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask); +#ifndef TMC2130 +extern bool lcd_calibrate_z_end_stop_manual(bool only_z); +#endif - extern void lcd_diag_show_end_stops(); +// Show the result of the calibration process on the LCD screen. +extern void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask); + +extern void lcd_diag_show_end_stops(); - - #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) - #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) - #define LCD_MESSAGERPGM(x) lcd_setstatuspgm((x)) - #define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x)) +#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) +#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) +#define LCD_MESSAGERPGM(x) lcd_setstatuspgm((x)) +#define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x)) +// To be used in lcd_commands_type. +#define LCD_COMMAND_IDLE 0 +#define LCD_COMMAND_LOAD_FILAMENT 1 +#define LCD_COMMAND_STOP_PRINT 2 +#define LCD_COMMAND_FARM_MODE_CONFIRM 4 +#define LCD_COMMAND_LONG_PAUSE 5 +#define LCD_COMMAND_LONG_PAUSE_RESUME 6 +#define LCD_COMMAND_PID_EXTRUDER 7 +#define LCD_COMMAND_V2_CAL 8 + +extern int lcd_commands_type; + +#define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable +#define CUSTOM_MSG_TYPE_MESHBL 1 // Mesh bed leveling in progress +#define CUSTOM_MSG_TYPE_F_LOAD 2 // Loading filament in progress +#define CUSTOM_MSG_TYPE_PIDCAL 3 // PID tuning in progress +#define CUSTOM_MSG_TYPE_TEMCAL 4 // PINDA temp calibration +#define CUSTOM_MSG_TYPE_TEMPRE 5 // Temp compensation preheat + +extern unsigned int custom_message_type; +extern unsigned int custom_message_state; + +extern uint8_t farm_mode; +extern int farm_no; +extern int farm_timer; +extern int farm_status; + +#ifdef TMC2130 +#define SILENT_MODE_NORMAL 0 +#define SILENT_MODE_STEALTH 1 +#define SILENT_MODE_OFF SILENT_MODE_NORMAL +#else +#define SILENT_MODE_POWER 0 +#define SILENT_MODE_SILENT 1 +#define SILENT_MODE_AUTO 2 +#define SILENT_MODE_OFF SILENT_MODE_POWER +#endif + +extern int8_t SilentModeMenu; + +extern bool cancel_heatup; +extern bool isPrintPaused; - // To be used in lcd_commands_type. - #define LCD_COMMAND_IDLE 0 - #define LCD_COMMAND_LOAD_FILAMENT 1 - #define LCD_COMMAND_STOP_PRINT 2 - #define LCD_COMMAND_FARM_MODE_CONFIRM 4 - #define LCD_COMMAND_LONG_PAUSE 5 - #define LCD_COMMAND_LONG_PAUSE_RESUME 6 - #define LCD_COMMAND_PID_EXTRUDER 7 - #define LCD_COMMAND_V2_CAL 8 - - extern int lcd_commands_type; - - extern uint8_t farm_mode; - extern int farm_no; - extern int farm_timer; - extern int farm_status; - #ifdef TMC2130 - #define SILENT_MODE_NORMAL 0 - #define SILENT_MODE_STEALTH 1 - #define SILENT_MODE_OFF SILENT_MODE_NORMAL - #else - #define SILENT_MODE_POWER 0 - #define SILENT_MODE_SILENT 1 - #define SILENT_MODE_AUTO 2 - #define SILENT_MODE_OFF SILENT_MODE_POWER - #endif - extern int8_t SilentModeMenu; - - - extern bool cancel_heatup; - extern bool isPrintPaused; - - - void lcd_ignore_click(bool b=true); - void lcd_commands(); - +void lcd_ignore_click(bool b=true); +void lcd_commands(); void change_extr(int extr); @@ -149,8 +157,8 @@ void lcd_temp_calibration_set(); void display_loading(); #if !SDSORT_USES_RAM - void lcd_set_degree(); - void lcd_set_progress(); +void lcd_set_degree(); +void lcd_set_progress(); #endif void lcd_language();