From 29e045f50203183888a9ff95fe25017ca4ce8eef Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 15 Jun 2018 20:24:05 +0200 Subject: [PATCH 01/33] Use Timer class for button blanking. Save 74B FLASH and 1B RAM. --- Firmware/ultralcd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b4fbe6f7..184b6572 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -190,7 +190,7 @@ float pid_temp = DEFAULT_PID_TEMP; bool long_press_active = false; static ShortTimer longPressTimer; -unsigned long button_blanking_time = millis(); +static ShortTimer buttonBlanking; bool button_pressed = false; bool menuExiting = false; @@ -7548,8 +7548,8 @@ void lcd_buttons_update() if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release if (READ(BTN_ENC) == 0) { //button is pressed lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; - if (millis() > button_blanking_time) { - button_blanking_time = millis() + BUTTON_BLANKING_TIME; + if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) { + buttonBlanking.start(); if (button_pressed == false && long_press_active == false) { longPressTimer.start(); button_pressed = true; @@ -7565,7 +7565,7 @@ void lcd_buttons_update() } else { //button not pressed if (button_pressed) { //button was released - button_blanking_time = millis() + BUTTON_BLANKING_TIME; + buttonBlanking.start(); if (long_press_active == false) { //button released before long press gets activated newbutton |= EN_C; From 21f9f46698be40c742709d60eda84095487080d3 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Sat, 16 Jun 2018 02:39:47 +0200 Subject: [PATCH 02/33] Use Timer class for lcd_timeoutToStatus. Save 188B FLASH and costs 2B RAM. --- Firmware/cardreader.cpp | 2 +- Firmware/ultralcd.cpp | 76 +++++++++++++++++++++++++---------------- Firmware/ultralcd.h | 6 ++-- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 23d84dab..85daef4a 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -972,7 +972,7 @@ void CardReader::presort() { #endif lcd_update(2); KEEPALIVE_STATE(NOT_BUSY); - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); } void CardReader::flush_presort() { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 184b6572..6c1918ce 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -9,7 +9,6 @@ #include "stepper.h" #include "ConfigurationStore.h" #include -#include "Timer.h" #include "util.h" #include "mesh_bed_leveling.h" @@ -193,6 +192,7 @@ static ShortTimer longPressTimer; static ShortTimer buttonBlanking; bool button_pressed = false; +static bool forceMenuExpire = false; bool menuExiting = false; #ifdef FILAMENT_LCD_DISPLAY @@ -696,7 +696,7 @@ void lcd_commands() float extr = count_e(0.2, width, length); float extr_short_segment = count_e(0.2, width, width); - if (lcd_commands_step>1) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + if (lcd_commands_step>1) lcd_timeoutToStatus.start(); //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen if (lcd_commands_step == 0) { lcd_commands_step = 10; @@ -722,7 +722,7 @@ void lcd_commands() } if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); enquecommand_P(PSTR("G1 Z0.250 F7200.000")); enquecommand_P(PSTR("G1 X50.0 E80.0 F1000.0")); enquecommand_P(PSTR("G1 X160.0 E20.0 F1000.0")); @@ -746,7 +746,7 @@ void lcd_commands() } if (lcd_commands_step == 8 && !blocks_queued() && cmd_buffer_empty()) //draw meander { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); enquecommand_P(PSTR("G1 X50 Y155")); @@ -771,7 +771,7 @@ void lcd_commands() if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); strcpy(cmd1, "G1 X50 Y35 E"); strcat(cmd1, ftostr43(extr)); enquecommand(cmd1); @@ -804,7 +804,7 @@ void lcd_commands() if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 4; i < 8; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -833,7 +833,7 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 8; i < 12; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -862,7 +862,7 @@ void lcd_commands() if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 12; i < 16; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -891,7 +891,7 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("G4 S0")); enquecommand_P(PSTR("G1 E-4 F2100.00000")); @@ -960,7 +960,7 @@ void lcd_commands() float length = 20 - width; float extr = count_e(0.2, width, length); float extr_short_segment = count_e(0.2, width, width); - if(lcd_commands_step>1) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + if(lcd_commands_step>1) lcd_timeoutToStatus.start(); //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen if (lcd_commands_step == 0) { lcd_commands_step = 9; @@ -997,7 +997,7 @@ void lcd_commands() } if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) //draw meander { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); //just opposite direction @@ -1045,7 +1045,7 @@ void lcd_commands() if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 0; i < 4; i++) { strcpy(cmd1, "G1 X70 Y"); @@ -1075,7 +1075,7 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 4; i < 8; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1104,7 +1104,7 @@ void lcd_commands() if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 8; i < 12; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1133,7 +1133,7 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); for (int i = 12; i < 16; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1162,7 +1162,7 @@ void lcd_commands() if (lcd_commands_step == 2 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("M107")); //turn off printer fan enquecommand_P(PSTR("M104 S0")); // turn off temperature @@ -1170,7 +1170,7 @@ void lcd_commands() enquecommand_P(PSTR("G1 Z10 F1300.000")); enquecommand_P(PSTR("G1 X10 Y180 F4000")); //home X axis enquecommand_P(PSTR("M84"));// disable motors - lcd_timeoutToStatus = millis() - 1; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + forceMenuExpire = true; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen lcd_commands_step = 1; } if (lcd_commands_step == 1 && !blocks_queued() && cmd_buffer_empty()) @@ -2378,7 +2378,7 @@ static void _lcd_babystep(int axis, const char *msg) //SERIAL_ECHO("Z baby step: "); //SERIAL_ECHO(menuData.babyStep.babystepMem[2]); // Wait 90 seconds before closing the live adjust dialog. - lcd_timeoutToStatus = millis() + 90000; + lcd_timeoutToStatus.start(); } if (encoderPosition != 0) @@ -3886,7 +3886,7 @@ void lcd_language() lcd_update_enable(true); lcd_implementation_clear(); lcd_goto_menu(lcd_language_menu); - lcd_timeoutToStatus = -1; //infinite timeout + lcd_timeoutToStatus.stop(); //infinite timeout lcdDrawUpdate = 2; while ((currentMenu != lcd_status_screen) && (!lang_is_selected())) { @@ -4278,7 +4278,7 @@ static void lcd_homing_accuracy_menu_advanced_back() static void lcd_homing_accuracy_menu_advanced() { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); START_MENU(); MENU_ITEM(back, PSTR("Homing accuracy"), lcd_homing_accuracy_menu_advanced_back); MENU_ITEM(function, PSTR("Reset def. steps"), lcd_homing_accuracy_menu_advanced_reset); @@ -4359,7 +4359,7 @@ static void lcd_ustep_resolution_reset_def_xyze() static void lcd_ustep_resolution_menu() { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); START_MENU(); MENU_ITEM(back, PSTR("Experimental"), lcd_ustep_resolution_menu_back); MENU_ITEM(function, PSTR("Reset defaults"), lcd_ustep_resolution_reset_def_xyze); @@ -4407,7 +4407,7 @@ static void lcd_ustep_linearity_menu_reset() static void lcd_ustep_linearity_menu() { - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); START_MENU(); MENU_ITEM(back, PSTR("Experimental"), lcd_ustep_linearity_menu_back); MENU_ITEM(function, PSTR("Reset correction"), lcd_ustep_linearity_menu_reset); @@ -7095,7 +7095,7 @@ static void menu_action_setlang(unsigned char lang) lcd_update_enable(true); lcd_implementation_clear(); lcd_goto_menu(lcd_language_menu); - lcd_timeoutToStatus = -1; //infinite timeout + lcd_timeoutToStatus.stop(); //infinite timeout lcdDrawUpdate = 2; } } @@ -7255,7 +7255,7 @@ void lcd_init() //#include static volatile bool lcd_update_enabled = true; -unsigned long lcd_timeoutToStatus = 0; +LongTimer lcd_timeoutToStatus; void lcd_update_enable(bool enabled) { @@ -7267,7 +7267,7 @@ void lcd_update_enable(bool enabled) encoderDiff = 0; // Enabling the normal LCD update procedure. // Reset the timeout interval. - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); // Force the keypad update now. lcd_next_update_millis = millis() - 1; // Full update. @@ -7286,6 +7286,24 @@ void lcd_update_enable(bool enabled) } } } +static inline bool z_menu_expired() +{ + return (currentMenu == lcd_babystep_z + && lcd_timeoutToStatus.expired(LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z)); +} +static inline bool other_menu_expired() +{ + return (currentMenu != lcd_status_screen + && currentMenu != lcd_babystep_z + && lcd_timeoutToStatus.expired(LCD_TIMEOUT_TO_STATUS)); +} +static inline bool forced_menu_expire() +{ + bool retval = (currentMenu != lcd_status_screen + && forceMenuExpire); + forceMenuExpire = false; + return retval; +} void lcd_update(uint8_t lcdDrawUpdateOverride) { @@ -7366,10 +7384,10 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) lcdDrawUpdate = 1; encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; encoderDiff = 0; - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); } - if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + if (LCD_CLICKED) lcd_timeoutToStatus.start(); #endif//ULTIPANEL (*currentMenu)(); @@ -7379,7 +7397,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) #endif #ifdef ULTIPANEL - if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen) + if (z_menu_expired() || other_menu_expired() || forced_menu_expire()) { // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true // to give it a chance to save its state. @@ -7547,7 +7565,7 @@ void lcd_buttons_update() #if BTN_ENC > 0 if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release if (READ(BTN_ENC) == 0) { //button is pressed - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + lcd_timeoutToStatus.start(); if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) { buttonBlanking.start(); if (button_pressed == false && long_press_active == false) { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index a03c5f1d..254a94ae 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -3,6 +3,7 @@ #include "Marlin.h" #include "mesh_bed_calibration.h" +#include "Timer.h" extern int lcd_puts_P(const char* str); extern int lcd_printf_P(const char* format, ...); @@ -94,7 +95,8 @@ extern int lcd_printf_P(const char* format, ...); #define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x)) #define LCD_UPDATE_INTERVAL 100 - #define LCD_TIMEOUT_TO_STATUS 30000 + #define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action. + #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms. #ifdef ULTIPANEL void lcd_buttons_update(); @@ -117,7 +119,7 @@ extern int lcd_printf_P(const char* format, ...); #define LCD_COMMAND_PID_EXTRUDER 7 #define LCD_COMMAND_V2_CAL 8 - extern unsigned long lcd_timeoutToStatus; + extern LongTimer lcd_timeoutToStatus; extern int lcd_commands_type; extern uint8_t farm_mode; From 3248edc1ca610627c2e88366bd76f792d9765958 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 26 Jun 2018 20:12:09 +0200 Subject: [PATCH 03/33] Do not skip bootloader when initiating reset by farm PRUSA RESET command. Set bootloader magic and run flag before watchdog reset in PRUSA RESET command. --- Firmware/Marlin_main.cpp | 2 ++ Firmware/bootapp.h | 1 + 2 files changed, 3 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 225883bf..9e210ebe 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3283,6 +3283,8 @@ void process_commands() // careful! if (farm_mode) { #ifdef WATCHDOG + boot_app_magic = BOOT_APP_MAGIC; + boot_app_flags = BOOT_APP_FLG_RUN; wdt_enable(WDTO_15MS); cli(); while(1); diff --git a/Firmware/bootapp.h b/Firmware/bootapp.h index db5bcc77..cbae89a7 100644 --- a/Firmware/bootapp.h +++ b/Firmware/bootapp.h @@ -17,6 +17,7 @@ #define BOOT_APP_FLG_ERASE 0x01 #define BOOT_APP_FLG_COPY 0x02 #define BOOT_APP_FLG_FLASH 0x04 +#define BOOT_APP_FLG_RUN 0x08 #define BOOT_APP_FLG_USER0 0x80 From d658bf56cf795c4b16b9bbae89135b37cc7069a4 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 11 Jul 2018 18:52:58 +0200 Subject: [PATCH 04/33] ShippingPrep Reset statistics reset by shipping preparation & filament sensor force --- Firmware/Marlin_main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 225883bf..d0375db2 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -848,6 +848,15 @@ void factory_reset(char level, bool quiet) farm_mode = false; eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no); + + eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); + eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + + fsensor_enable(); WRITE(BEEPER, HIGH); _delay_ms(100); From 1357e27b55cc1068651a4bfbd92522916ecc6d51 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 11 Jul 2018 20:45:56 +0200 Subject: [PATCH 05/33] FilamentAutoload setting by shipping preparation --- Firmware/Marlin_main.cpp | 1 + Firmware/fsensor.cpp | 6 ++++++ Firmware/fsensor.h | 3 +++ Firmware/ultralcd.cpp | 4 ++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d0375db2..d45c8e5a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -857,6 +857,7 @@ void factory_reset(char level, bool quiet) eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); fsensor_enable(); + fautoload_set(true); WRITE(BEEPER, HIGH); _delay_ms(100); diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index bebcf810..1e4f17d3 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -86,6 +86,12 @@ void fsensor_disable() FSensorStateMenu = 0; } +void fautoload_set(bool State) +{ + filament_autoload_enabled = State; + eeprom_update_byte((unsigned char *)EEPROM_FSENS_AUTOLOAD_ENABLED, filament_autoload_enabled); +} + void pciSetup(byte pin) { *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin)); // enable pin diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index 0c5543bc..486331a0 100644 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -15,6 +15,9 @@ extern void fsensor_unblock(); extern bool fsensor_enable(); extern void fsensor_disable(); +extern bool filament_autoload_enabled; +extern void fautoload_set(bool State); + //update (perform M600 on filament runout) extern void fsensor_update(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0d3801d8..30335261 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1,5 +1,6 @@ #include "temperature.h" #include "ultralcd.h" +#include "fsensor.h" #ifdef ULTRA_LCD #include "MenuStack.h" #include "Marlin.h" @@ -1845,8 +1846,7 @@ void lcd_set_fan_check() { } void lcd_set_filament_autoload() { - filament_autoload_enabled = !filament_autoload_enabled; - eeprom_update_byte((unsigned char *)EEPROM_FSENS_AUTOLOAD_ENABLED, filament_autoload_enabled); + fautoload_set(!filament_autoload_enabled); } void lcd_unLoadFilament() From d18160cab5783b86882593d6a6eacd34d5a968f5 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Jul 2018 21:58:06 +0200 Subject: [PATCH 06/33] splash screen --- Firmware/Marlin_main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d45c8e5a..3bcc8256 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1152,10 +1152,6 @@ void list_sec_lang_from_external_flash() // are initialized by the main() routine provided by the Arduino framework. void setup() { -#ifdef W25X20CL - // Enter an STK500 compatible Optiboot boot loader waiting for flashing the languages to an external flash memory. - optiboot_w25x20cl_enter(); -#endif lcd_init(); fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream @@ -1163,6 +1159,11 @@ void setup() lcd_splash(); + #ifdef W25X20CL + // Enter an STK500 compatible Optiboot boot loader waiting for flashing the languages to an external flash memory. + optiboot_w25x20cl_enter(); + #endif + #if (LANG_MODE != 0) //secondary language support #ifdef W25X20CL if (w25x20cl_init()) From 29d1052f0e688ed1005d6097099db523594ffd5f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 11 Jul 2018 21:58:49 +0200 Subject: [PATCH 07/33] Save 80B of flash and 8B of RAM and fix compiler warning: sketch/adc.c: In function 'adc_init': sketch/adc.c:20:2: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf(("adc_init\n")); ^ sketch/adc.c:20:2: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default] --- Firmware/adc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/adc.c b/Firmware/adc.c index 5cb88b79..1798b083 100644 --- a/Firmware/adc.c +++ b/Firmware/adc.c @@ -1,8 +1,9 @@ //adc.c #include "adc.h" +#include #include - +#include uint8_t adc_state; uint8_t adc_count; @@ -17,7 +18,7 @@ uint16_t adc_sim_mask; void adc_init(void) { - printf(("adc_init\n")); + printf_P(PSTR("adc_init\n")); adc_sim_mask = 0x00; ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); ADMUX |= (1 << REFS0); From 11aa775322758c63b92710bdd5324ada2ded7f67 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Jul 2018 18:21:05 +0200 Subject: [PATCH 08/33] move in Z before filament loading: intial version --- Firmware/Marlin_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3bcc8256..e0d9b4fb 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3114,6 +3114,14 @@ void gcode_M701() custom_message = true; custom_message_type = 2; + if (current_position[Z_AXIS] < 20) { + lcd_setstatuspgm(_T(MSG_PLEASE_WAIT)); + current_position[Z_AXIS] += 30; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence + st_synchronize(); + lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament and press the knob.")); + } + lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); current_position[E_AXIS] += 70; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence From 9b7cc60b4204837bad258f8c28a229c48a089754 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Jul 2018 19:35:22 +0200 Subject: [PATCH 09/33] filament statistics hotfix, load filament move Z simplified --- Firmware/Marlin_main.cpp | 8 +------- Firmware/ultralcd.cpp | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e0d9b4fb..99526477 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3114,13 +3114,7 @@ void gcode_M701() custom_message = true; custom_message_type = 2; - if (current_position[Z_AXIS] < 20) { - lcd_setstatuspgm(_T(MSG_PLEASE_WAIT)); - current_position[Z_AXIS] += 30; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence - st_synchronize(); - lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament and press the knob.")); - } + if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); current_position[E_AXIS] += 70; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 30335261..64412bc9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2110,7 +2110,7 @@ void lcd_menu_statistics() { if (IS_SD_PRINTING) { - int _met = total_filament_used / 100000; + float _met = ((float)total_filament_used) / (100000.f); int _cm = (total_filament_used - (_met * 100000)) / 10; int _t = (millis() - starttime) / 1000; int _h = _t / 3600; @@ -2125,12 +2125,12 @@ void lcd_menu_statistics() lcd_printf_P(_N( ESC_2J "%S:" - ESC_H(6,1) "%8.2f m\n" + ESC_H(6,1) "%8.2fm \n" "%S :" ESC_H(8,3) "%2dh %02dm %02d" ), _i("Filament used"), - _met, _cm, + _met, _i("Print time"), _h, _m, _s ); From 07f6ddfb698c56da094fd4a538ab9a566a9b9ea5 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Jul 2018 22:34:32 +0200 Subject: [PATCH 10/33] filament loading corrected --- Firmware/Marlin_main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 99526477..97fa26f3 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3114,12 +3114,17 @@ void gcode_M701() custom_message = true; custom_message_type = 2; - if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; + lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); - current_position[E_AXIS] += 70; + current_position[E_AXIS] += 40; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence + st_synchronize(); + if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; + current_position[E_AXIS] += 30; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence + st_synchronize(); current_position[E_AXIS] += 25; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence st_synchronize(); From 2b5e63eb7ffe146da7283d95f37eb0e3c49918eb Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 17:23:50 +0200 Subject: [PATCH 11/33] Fix compiler warnings in language.c and document _SEC_LANG_TABLE macro. --- Firmware/language.c | 6 ++-- Firmware/language.h | 69 +++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Firmware/language.c b/Firmware/language.c index ca3b9e88..79b6cb0a 100644 --- a/Firmware/language.c +++ b/Firmware/language.c @@ -63,7 +63,7 @@ uint8_t lang_select(uint8_t lang) if (lang_check(_SEC_LANG_TABLE)) if (pgm_read_dword(((uint32_t*)(_SEC_LANG_TABLE + 12))) == pgm_read_dword(((uint32_t*)(_PRI_LANG_SIGNATURE)))) //signature valid { - lang_table = _SEC_LANG_TABLE; // set table pointer + lang_table = (lang_table_t*)(_SEC_LANG_TABLE); // set table pointer lang_selected = lang; // set language id } } @@ -138,7 +138,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off if (lang == LANG_ID_SEC) { uint16_t ui = _SEC_LANG_TABLE; //table pointer - memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem + memcpy_P(header, (lang_table_t*)(_SEC_LANG_TABLE), sizeof(lang_table_header_t)); //read table header from progmem if (offset) *offset = ui; return (header->magic == LANG_MAGIC)?1:0; //return 1 if magic valid } @@ -147,7 +147,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off lang--; while (1) { - w25x20cl_rd_data(addr, header, sizeof(lang_table_header_t)); //read table header from xflash + w25x20cl_rd_data(addr, (uint8_t*)(header), sizeof(lang_table_header_t)); //read table header from xflash if (header->magic != LANG_MAGIC) break; //break if not valid if (offset) *offset = addr; if (--lang == 0) return 1; diff --git a/Firmware/language.h b/Firmware/language.h index 569d9f9e..f0cff9a1 100644 --- a/Firmware/language.h +++ b/Firmware/language.h @@ -1,3 +1,4 @@ +/** @file */ //language.h #ifndef LANGUAGE_H #define LANGUAGE_H @@ -22,11 +23,14 @@ #define STRINGIFY_(n) #n #define STRINGIFY(n) STRINGIFY_(n) -//section progmem0 will be used for localized translated strings +/** @def PROGMEM_I2 + * @brief section progmem0 will be used for localized translated strings */ #define PROGMEM_I2 __attribute__((section(".progmem0"))) -//section progmem1 will be used for localized strings in english +/** @def PROGMEM_I1 + * @brief section progmem1 will be used for localized strings in english */ #define PROGMEM_I1 __attribute__((section(".progmem1"))) -//section progmem2 will be used for not localized strings in english +/** @def PROGMEM_N1 + * @brief section progmem2 will be used for not localized strings in english */ #define PROGMEM_N1 __attribute__((section(".progmem2"))) #if (LANG_MODE == 0) //primary language only @@ -43,7 +47,7 @@ #define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];})) #define _n(s) _N(s) -//lang_table_header_t structure - (size= 16byte) +/** @brief lang_table_header_t structure - (size= 16byte) */ typedef struct { uint32_t magic; //+0 @@ -54,67 +58,76 @@ typedef struct uint32_t signature; //+12 } lang_table_header_t; -//lang_table_t structure - (size= 16byte + 2*count) +/** @brief lang_table_t structure - (size= 16byte + 2*count) */ typedef struct { lang_table_header_t header; uint16_t table[]; } lang_table_t; -// Language indices into their particular symbol tables. +/** @name Language indices into their particular symbol tables.*/ +///@{ #define LANG_ID_PRI 0 #define LANG_ID_SEC 1 +///@} -// Language is not defined and it shall be selected from the menu. +/** @def LANG_ID_FORCE_SELECTION + * @brief Language is not defined and it shall be selected from the menu.*/ #define LANG_ID_FORCE_SELECTION 254 -// Language is not defined on a virgin RAMBo board. +/** @def LANG_ID_UNDEFINED + * @brief Language is not defined on a virgin RAMBo board. */ #define LANG_ID_UNDEFINED 255 -// Default language ID, if no language is selected. +/** @def LANG_ID_DEFAULT + * @brief Default language ID, if no language is selected. */ #define LANG_ID_DEFAULT LANG_ID_PRI -// Magic number at begin of lang table. +/** @def LANG_MAGIC + * @brief Magic number at begin of lang table. */ #define LANG_MAGIC 0x4bb45aa5 -// Language codes (ISO639-1) -#define LANG_CODE_XX 0x3f3f //'??' -#define LANG_CODE_EN 0x656e //'en' -#define LANG_CODE_CZ 0x6373 //'cs' -#define LANG_CODE_DE 0x6465 //'de' -#define LANG_CODE_ES 0x6573 //'es' -#define LANG_CODE_IT 0x6974 //'it' -#define LANG_CODE_PL 0x706c //'pl' +/** @name Language codes (ISO639-1)*/ +///@{ +#define LANG_CODE_XX 0x3f3f //!<'??' +#define LANG_CODE_EN 0x656e //!<'en' +#define LANG_CODE_CZ 0x6373 //!<'cs' +#define LANG_CODE_DE 0x6465 //!<'de' +#define LANG_CODE_ES 0x6573 //!<'es' +#define LANG_CODE_IT 0x6974 //!<'it' +#define LANG_CODE_PL 0x706c //!<'pl' +///@} #if defined(__cplusplus) extern "C" { #endif //defined(__cplusplus) -// Currectly active language selection. +/** @brief Currectly active language selection.*/ extern uint8_t lang_selected; #if (LANG_MODE != 0) extern const char _SEC_LANG[LANG_SIZE_RESERVED]; extern const char* lang_get_translation(const char* s); +/** @def _SEC_LANG_TABLE + * @brief Align table to start of 256 byte page */ #define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00) -//extern const uint32_t _PRI_LANG_SIGNATURE; #endif //(LANG_MODE != 0) -//selects language, eeprom is updated in case of success +/** @brief selects language, eeprom is updated in case of success */ extern uint8_t lang_select(uint8_t lang); -//performs checksum test of secondary language data +/** @brief performs checksum test of secondary language data */ extern uint8_t lang_check(uint16_t addr); -//returns total number of languages (primary + all in xflash) +/** @return total number of languages (primary + all in xflash) */ extern uint8_t lang_get_count(void); -//reads lang table header and offset in xflash or progmem +/** @brief reads lang table header and offset in xflash or progmem */ extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset); -//reads lang code from xflash or progmem +/** @brief reads lang code from xflash or progmem */ extern uint16_t lang_get_code(uint8_t lang); -//returns localized language name (text for menu item) +/** @return localized language name (text for menu item) */ extern const char* lang_get_name_by_code(uint16_t code); -//reset language to "LANG_ID_FORCE_SELECTION", epprom is updated +/** @brief reset language to "LANG_ID_FORCE_SELECTION", epprom is updated */ extern void lang_reset(void); -//returns 1 if language is selected +/** @retval 1 language is selected */ extern uint8_t lang_is_selected(void); #ifdef DEBUG_SEC_LANG From fb6aa72de9f9b3cfa5b0d8bebb1343f8c5583861 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 17:38:13 +0200 Subject: [PATCH 12/33] Fix compiler warnings in sm4.c --- Firmware/sm4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index f50591c3..509ac23f 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -3,9 +3,10 @@ #include "sm4.h" #include #include +#include +#include "Arduino.h" #include "boards.h" -#define bool int8_t #define false 0 #define true 1 #include "Configuration_prusa.h" @@ -191,4 +192,4 @@ uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de) } -#endif //NEW_XYZCAL \ No newline at end of file +#endif //NEW_XYZCAL From 2c00f065fdc210fbbe20108c380e5e78d7b72ef8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 18:06:07 +0200 Subject: [PATCH 13/33] Fix error in recovering after power panic. (Function pointer was passed instead of function been called.) It manifested istself as following compiler warnings: sketch/Marlin_main.cpp: In function 'void print_physical_coordinates()': sketch/Marlin_main.cpp:9065:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm[X_AXIS], st_get_position_mm[Y_AXIS], st_get_position_mm[Z_AXIS]); ^ sketch/Marlin_main.cpp:9065:114: warning: pointer to a function used in arithmetic [-Wpointer-arith] printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm[X_AXIS], st_get_position_mm[Y_AXIS], st_get_position_mm[Z_AXIS]); ^ sketch/Marlin_main.cpp:9065:142: warning: pointer to a function used in arithmetic [-Wpointer-arith] printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm[X_AXIS], st_get_position_mm[Y_AXIS], st_get_position_mm[Z_AXIS]); ^ sketch/Marlin_main.cpp:9066:1: warning: pointer offset from symbol maybe incorrect [enabled by default] } ^ _Z18st_get_position_mmh+2 sketch/Marlin_main.cpp:9066:1: warning: pointer offset from symbol maybe incorrect [enabled by default] _Z18st_get_position_mmh+2 sketch/Marlin_main.cpp:9066:1: warning: pointer offset from symbol maybe incorrect [enabled by default] _Z18st_get_position_mmh+1 sketch/Marlin_main.cpp:9066:1: warning: pointer offset from symbol maybe incorrect [enabled by default] _Z18st_get_position_mmh+1 --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4f73e62f..0017c1d5 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9062,7 +9062,7 @@ void print_world_coordinates() void print_physical_coordinates() { - printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm[X_AXIS], st_get_position_mm[Y_AXIS], st_get_position_mm[Z_AXIS]); + printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS)); } void print_mesh_bed_leveling_table() From bc1f416602e21824797239315243b3bfe89d41ed Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 18:26:29 +0200 Subject: [PATCH 14/33] Fix compiler warning symbol __AVR redefined. --- Firmware/uni_avr_rpi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/uni_avr_rpi.h b/Firmware/uni_avr_rpi.h index 6a7200c3..616a5662 100644 --- a/Firmware/uni_avr_rpi.h +++ b/Firmware/uni_avr_rpi.h @@ -1,5 +1,4 @@ // unification for AVR and RPI -#define __AVR #ifdef __AVR //#include "Arduino.h" @@ -29,3 +28,4 @@ void print(int v) { printf("%d", v); } void print(float v) { printf("%f", v); } #endif //RC522_RPI + From 2116262845e9100b575ccf23c17ba3de59cfa45f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 18:46:12 +0200 Subject: [PATCH 15/33] Fix *_MAX_ACCEL integer overflow. --- Firmware/temperature.cpp | 2 +- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 4 ++-- Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 83ead13b..0d7c6a3b 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1473,7 +1473,7 @@ void bed_min_temp_error(void) { } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); -#endif*/ +#endif } #ifdef HEATER_0_USES_MAX6675 diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 2889c4e7..b89b668c 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -96,12 +96,12 @@ #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) //Silent mode limits -#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2 +#define SILENT_MAX_ACCEL 960ul // max axxeleration in silent mode in mm/s^2 #define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2 #define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) //Normal mode limits -#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2 +#define NORMAL_MAX_ACCEL 2500ul // Y-axis max axxeleration in normal mode in mm/s^2 #define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2 #define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) diff --git a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h index f57c6da1..88f0075c 100644 --- a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h @@ -97,12 +97,12 @@ #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) //Silent mode limits -#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2 +#define SILENT_MAX_ACCEL 960ul // max axxeleration in silent mode in mm/s^2 #define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2 #define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) //Normal mode limits -#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2 +#define NORMAL_MAX_ACCEL 2500ul // Y-axis max axxeleration in normal mode in mm/s^2 #define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2 #define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) From 070e6f49e8303a6ae006675d853b9fc2eafe19e6 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Jul 2018 18:56:11 +0200 Subject: [PATCH 16/33] Fix error in sine wave compression algorithm in tmc2130. This problem could manifest itself only for negative function slope, which is not used. --- Firmware/tmc2130.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index bfc720c6..558ea5aa 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -878,7 +878,7 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000) uint8_t x[3] = {255,255,255}; //X segment bounds (MSLUTSEL) uint8_t s = 0; //current segment int8_t b; //encoded bit value - uint8_t dA; //delta value + int8_t dA; //delta value int i; //microstep index uint32_t reg; //tmc2130 register tmc2130_wr_MSLUTSTART(axis, 0, amp); From 9d72062cd71cfca65c4b80e34865a8d0d912e32c Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 17:21:22 +0200 Subject: [PATCH 17/33] Save 82B flash and 1B RAM, fix compiler warning: sketch/ultralcd.cpp:7212:61: warning: integer overflow in expression [-Woverflow] lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000); --- Firmware/ultralcd.cpp | 20 +++++++++++--------- Firmware/ultralcd.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 64379b31..8831d5d2 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -344,7 +344,7 @@ bool lcd_oldcardstatus; #endif //ULTIPANEL menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ -uint32_t lcd_next_update_millis; +ShortTimer lcd_next_update_millis; uint8_t lcd_status_update_delay; bool ignore_click = false; bool wait_for_unclick; @@ -6500,7 +6500,7 @@ bool lcd_selftest() lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); lcd_implementation_clear(); - lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; + lcd_next_update_millis.start(); if (_result) { @@ -7209,7 +7209,7 @@ static bool lcd_selftest_fan_dialog(int _fan) static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) { - lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000); + lcd_next_update_millis.stop(); int _step_block = 0; const char *_indicator = (_progress > _progress_scale) ? "-" : "|"; @@ -7410,6 +7410,7 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, void lcd_init() { lcd_implementation_init(); + lcd_next_update_millis.start(); #ifdef NEWPANEL SET_INPUT(BTN_EN1); @@ -7479,8 +7480,6 @@ void lcd_update_enable(bool enabled) // Enabling the normal LCD update procedure. // Reset the timeout interval. lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; - // Force the keypad update now. - lcd_next_update_millis = millis() - 1; // Full update. lcd_implementation_clear(); #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) @@ -7491,14 +7490,15 @@ void lcd_update_enable(bool enabled) else lcd_set_custom_characters_arrows(); #endif - lcd_update(2); + // Force the keypad update now. + lcd_update(2,true); } else { // Clear the LCD always, or let it to the caller? } } } -void lcd_update(uint8_t lcdDrawUpdateOverride) +void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw) { if (lcdDrawUpdate < lcdDrawUpdateOverride) @@ -7513,6 +7513,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) lcd_buttons_update(); + #if (SDCARDDETECT > 0) if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) { @@ -7538,8 +7539,9 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) } #endif//CARDINSERTED - if (lcd_next_update_millis < millis()) + if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw) { + lcd_next_update_millis.start(); #ifdef DEBUG_BLINK_ACTIVE static bool active_led = false; active_led = !active_led; @@ -7547,6 +7549,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) digitalWrite(LED_PIN, active_led?HIGH:LOW); #endif //DEBUG_BLINK_ACTIVE + #ifdef ULTIPANEL #ifdef REPRAPWORLD_KEYPAD if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) { @@ -7607,7 +7610,6 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) #endif//ULTIPANEL if (lcdDrawUpdate == 2) lcd_implementation_clear(); if (lcdDrawUpdate) lcdDrawUpdate--; - lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; } if (!SdFatUtil::test_stack_integrity()) stack_error(); #ifdef DEBUG_STEPPER_TIMER_MISSED diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index a03c5f1d..1da244f6 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -11,7 +11,7 @@ extern int lcd_printf_P(const char* format, ...); static void lcd_language_menu(); - void lcd_update(uint8_t lcdDrawUpdateOverride = 0); + void lcd_update(uint8_t lcdDrawUpdateOverride = 0, bool forceRedraw = false); // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. void lcd_update_enable(bool enable); void lcd_init(); From 49dd8d83fb791fd98cdf6aea2afc40479e2aaf07 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 18:03:05 +0200 Subject: [PATCH 18/33] Fix indentation in lcd_update() and split some of the preprocessor disabled functionality into separate functions. No change in resulting binary. --- Firmware/ultralcd.cpp | 227 ++++++++++-------- .../ultralcd_implementation_hitachi_HD44780.h | 5 +- 2 files changed, 128 insertions(+), 104 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8831d5d2..0b2a37fd 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2482,8 +2482,8 @@ static void lcd_menu_xyz_skew() //|01234567890123456789| //|Measured skew: N/A | //|--------------------| -//|Slight skew: 0.12°| -//|Severe skew: 0.25°| +//|Slight skew: 0.12d| +//|Severe skew: 0.25d| //---------------------- float angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW)); lcd_printf_P(_N( @@ -7498,126 +7498,149 @@ void lcd_update_enable(bool enabled) } } +static inline void debugBlink() +{ +#ifdef DEBUG_BLINK_ACTIVE + static bool active_led = false; + active_led = !active_led; + pinMode(LED_PIN, OUTPUT); + digitalWrite(LED_PIN, active_led?HIGH:LOW); +#endif //DEBUG_BLINK_ACTIVE +} + +static inline void handleReprapKeyboard() +{ +#ifdef REPRAPWORLD_KEYPAD + if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) + { + reprapworld_keypad_move_z_up(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) + { + reprapworld_keypad_move_z_down(); + } + if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) + { + reprapworld_keypad_move_x_left(); + } + if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) + { + reprapworld_keypad_move_x_right(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) + { + reprapworld_keypad_move_y_down(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) + { + reprapworld_keypad_move_y_up(); + } + if (REPRAPWORLD_KEYPAD_MOVE_HOME) + { + reprapworld_keypad_move_home(); + } +#endif +} + +static inline void readSlowButtons() +{ +#ifdef LCD_HAS_SLOW_BUTTONS + slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context +#endif +} + +/** + * @brief Handle keyboard input and update display + * + * @param lcdDrawUpdateOverride + * @param forceRedraw if true, force redraw of display regardless of timer + */ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw) { - if (lcdDrawUpdate < lcdDrawUpdateOverride) - lcdDrawUpdate = lcdDrawUpdateOverride; + if (lcdDrawUpdate < lcdDrawUpdateOverride) + { + lcdDrawUpdate = lcdDrawUpdateOverride; + } - if (!lcd_update_enabled) - return; - -#ifdef LCD_HAS_SLOW_BUTTONS - slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context -#endif - - lcd_buttons_update(); + if (!lcd_update_enabled) return; + readSlowButtons(); + lcd_buttons_update(); #if (SDCARDDETECT > 0) - if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) - { - lcdDrawUpdate = 2; - lcd_oldcardstatus = IS_SD_INSERTED; - lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. + if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) + { + lcdDrawUpdate = 2; + lcd_oldcardstatus = IS_SD_INSERTED; + lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) - currentMenu == lcd_status_screen + currentMenu == lcd_status_screen #endif - ); + ); - if (lcd_oldcardstatus) - { - card.initsd(); - LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 - //get_description(); - } - else - { - card.release(); - LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0 - } - } -#endif//CARDINSERTED - - if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw) - { - lcd_next_update_millis.start(); -#ifdef DEBUG_BLINK_ACTIVE - static bool active_led = false; - active_led = !active_led; - pinMode(LED_PIN, OUTPUT); - digitalWrite(LED_PIN, active_led?HIGH:LOW); -#endif //DEBUG_BLINK_ACTIVE + if (lcd_oldcardstatus) + { + card.initsd(); + LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 + } + else + { + card.release(); + LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0 + } + } +#endif //(SDCARDDETECT > 0) + if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw) + { + lcd_next_update_millis.start(); + debugBlink(); #ifdef ULTIPANEL -#ifdef REPRAPWORLD_KEYPAD - if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) { - reprapworld_keypad_move_z_up(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) { - reprapworld_keypad_move_z_down(); - } - if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) { - reprapworld_keypad_move_x_left(); - } - if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) { - reprapworld_keypad_move_x_right(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) { - reprapworld_keypad_move_y_down(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) { - reprapworld_keypad_move_y_up(); - } - if (REPRAPWORLD_KEYPAD_MOVE_HOME) { - reprapworld_keypad_move_home(); - } -#endif - if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) - { - if (lcdDrawUpdate == 0) - lcdDrawUpdate = 1; - encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; - encoderDiff = 0; - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; - } + handleReprapKeyboard(); - if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) + { + if (lcdDrawUpdate == 0) lcdDrawUpdate = 1; + encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; + encoderDiff = 0; + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + } + + if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; #endif//ULTIPANEL - (*currentMenu)(); - -#ifdef LCD_HAS_STATUS_INDICATORS - lcd_implementation_update_indicators(); -#endif - -#ifdef ULTIPANEL - if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen) - { - // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true - // to give it a chance to save its state. - // This is useful for example, when the babystep value has to be written into EEPROM. - if (currentMenu != NULL) { - menuExiting = true; (*currentMenu)(); - menuExiting = false; - } - lcd_implementation_clear(); - lcd_return_to_status(); - lcdDrawUpdate = 2; - } + lcd_implementation_update_indicators(); + +#ifdef ULTIPANEL + if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen) + { + // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true + // to give it a chance to save its state. + // This is useful for example, when the babystep value has to be written into EEPROM. + if (currentMenu != NULL) + { + menuExiting = true; + (*currentMenu)(); + menuExiting = false; + } + lcd_implementation_clear(); + lcd_return_to_status(); + lcdDrawUpdate = 2; + } #endif//ULTIPANEL - if (lcdDrawUpdate == 2) lcd_implementation_clear(); - if (lcdDrawUpdate) lcdDrawUpdate--; - } - if (!SdFatUtil::test_stack_integrity()) stack_error(); + if (lcdDrawUpdate == 2) lcd_implementation_clear(); + if (lcdDrawUpdate) lcdDrawUpdate--; + } + if (!SdFatUtil::test_stack_integrity()) stack_error(); #ifdef DEBUG_STEPPER_TIMER_MISSED - if (stepper_timer_overflow_state) stepper_timer_overflow(); + if (stepper_timer_overflow_state) stepper_timer_overflow(); #endif /* DEBUG_STEPPER_TIMER_MISSED */ - lcd_ping(); //check that we have received ping command if we are in farm mode - lcd_send_status(); - if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands(); + lcd_ping(); //check that we have received ping command if we are in farm mode + lcd_send_status(); + if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands(); } void lcd_printer_connected() { diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index 1aa0f303..e3a36313 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -1390,9 +1390,10 @@ static void lcd_implementation_quick_feedback() #endif } -#ifdef LCD_HAS_STATUS_INDICATORS + static void lcd_implementation_update_indicators() { +#ifdef LCD_HAS_STATUS_INDICATORS #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; @@ -1408,8 +1409,8 @@ static void lcd_implementation_update_indicators() ledsprev = leds; } #endif -} #endif +} #ifdef LCD_HAS_SLOW_BUTTONS extern uint32_t blocking_enc; From f620a662110fa883a65f28963b5e1083068047db Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 18:26:52 +0200 Subject: [PATCH 19/33] Use public interface instead of manipulating lcd_next_update_millis timer. --- Firmware/ultralcd.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0b2a37fd..e5b05d80 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6499,8 +6499,7 @@ bool lcd_selftest() } lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); - lcd_implementation_clear(); - lcd_next_update_millis.start(); + lcd_update_enable(true); if (_result) { @@ -7209,7 +7208,7 @@ static bool lcd_selftest_fan_dialog(int _fan) static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) { - lcd_next_update_millis.stop(); + lcd_update_enable(false); int _step_block = 0; const char *_indicator = (_progress > _progress_scale) ? "-" : "|"; From bc99db8233ea65993be31b59c26d2e7626c90d29 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 18:35:42 +0200 Subject: [PATCH 20/33] Fix compiler warning: sketch/uart2.c:48:1: warning: control reaches end of non-void function [-Wreturn-type] --- Firmware/uart2.c | 2 +- Firmware/uart2.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/uart2.c b/Firmware/uart2.c index e12b254a..e6d5c3f8 100644 --- a/Firmware/uart2.c +++ b/Firmware/uart2.c @@ -41,7 +41,7 @@ void uart2_init(void) fdev_setup_stream(uart2io, uart2_putchar, uart2_getchar, _FDEV_SETUP_WRITE | _FDEV_SETUP_READ); //setup uart2 i/o stream } -uint8_t uart2_rx_clr(void) +void uart2_rx_clr(void) { rbuf_w(uart2_ibuf) = 0; rbuf_r(uart2_ibuf) = 0; diff --git a/Firmware/uart2.h b/Firmware/uart2.h index e5455148..95a1bff9 100644 --- a/Firmware/uart2.h +++ b/Firmware/uart2.h @@ -18,7 +18,7 @@ extern FILE _uart2io; extern void uart2_init(void); -extern uint8_t uart2_rx_clr(void); +extern void uart2_rx_clr(void); extern uint8_t uart2_rx_ok(void); @@ -26,4 +26,4 @@ extern uint8_t uart2_rx_ok(void); #if defined(__cplusplus) } #endif //defined(__cplusplus) -#endif //_UART2_H \ No newline at end of file +#endif //_UART2_H From c2517775900485ecccdaf2e882b89691b0795b44 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 18:44:54 +0200 Subject: [PATCH 21/33] Fix compiler warning: In file included from sketch/BlinkM.cpp:5:0: sketch/Marlin.h:422:13: warning: 'void print_time_remaining_init()' declared 'static' but never defined [-Wunused-function] static void print_time_remaining_init(); Make local functions static. Saves 6B of flash. --- Firmware/Marlin.h | 1 - Firmware/Marlin_main.cpp | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 35cce09f..329e8f7c 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -419,7 +419,6 @@ extern void fsensor_init(); //estimated time to end of the print extern uint16_t print_time_remaining(); extern uint8_t print_percent_done(); -static void print_time_remaining_init(); #ifdef HOST_KEEPALIVE_FEATURE diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0017c1d5..11c1c6e3 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -535,8 +535,9 @@ static bool saved_extruder_relative_mode = false; //=============================Routines====================================== //=========================================================================== -void get_arc_coordinates(); -bool setTargetedHotend(int code); +static void get_arc_coordinates(); +static bool setTargetedHotend(int code); +static void print_time_remaining_init(); void serial_echopair_P(const char *s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } From ff56e491e85aede3b1b1be4e17fe62d28bb5dc00 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 18:49:14 +0200 Subject: [PATCH 22/33] Save 2B flash, fix compiler warning: In file included from sketch/ConfigurationStore.cpp:5:0: sketch/ConfigurationStore.h: In function 'uint8_t calibration_status_store(uint8_t)': sketch/ConfigurationStore.h:24:124: warning: no return statement in function returning non-void [-Wreturn-type] inline uint8_t calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } --- Firmware/ConfigurationStore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index facdcca2..79055fdc 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -21,7 +21,7 @@ FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_Prin #endif inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } -inline uint8_t calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } +inline void calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); } #endif//CONFIG_STORE_H From ee366ce3b59180f079efea6bcdb42a253fd5b516 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 19:18:54 +0200 Subject: [PATCH 23/33] Fix compiler warnings: In file included from sketch/ConfigurationStore.cpp:3:0: sketch/temperature.h:193:14: warning: 'temp_runaway_status' defined but not used [-Wunused-variable] static float temp_runaway_status[4]; ^ sketch/temperature.h:194:14: warning: 'temp_runaway_target' defined but not used [-Wunused-variable] static float temp_runaway_target[4]; ^ sketch/temperature.h:195:14: warning: 'temp_runaway_timer' defined but not used [-Wunused-variable] static float temp_runaway_timer[4]; ^ sketch/temperature.h:196:12: warning: 'temp_runaway_error_counter' defined but not used [-Wunused-variable] static int temp_runaway_error_counter[4]; --- Firmware/temperature.cpp | 10 ++++++++++ Firmware/temperature.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 0d7c6a3b..cf9cccfd 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -205,6 +205,16 @@ unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0); //============================= functions ============================ //=========================================================================== +#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) +static float temp_runaway_status[4]; +static float temp_runaway_target[4]; +static float temp_runaway_timer[4]; +static int temp_runaway_error_counter[4]; + +static void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); +static void temp_runaway_stop(bool isPreheat, bool isBed); +#endif + void PID_autotune(float temp, int extruder, int ncycles) { pid_number_of_cycles = ncycles; diff --git a/Firmware/temperature.h b/Firmware/temperature.h index b20a67cd..462412d3 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -189,16 +189,6 @@ FORCE_INLINE bool isCoolingBed() { #error Invalid number of extruders #endif -#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) -static float temp_runaway_status[4]; -static float temp_runaway_target[4]; -static float temp_runaway_timer[4]; -static int temp_runaway_error_counter[4]; - -void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); -void temp_runaway_stop(bool isPreheat, bool isBed); -#endif - int getHeaterPower(int heater); void disable_heater(); void setWatch(); From 6bd8e60176f8badd6a8070476f9322b580234092 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 19:27:25 +0200 Subject: [PATCH 24/33] Fix compiler warning: In file included from sketch/ConfigurationStore.cpp:4:0: sketch/ultralcd.h:12:14: warning: 'void lcd_language_menu()' declared 'static' but never defined [-Wunused-function] static void lcd_language_menu(); --- Firmware/ultralcd.cpp | 1 + Firmware/ultralcd.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e5b05d80..daf26014 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -209,6 +209,7 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, /* Different menus */ static void lcd_status_screen(); +static void lcd_language_menu(); #ifdef ULTIPANEL extern bool powersupply; static void lcd_main_menu(); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 1da244f6..39e26fda 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -9,8 +9,6 @@ extern int lcd_printf_P(const char* format, ...); #ifdef ULTRA_LCD - static void lcd_language_menu(); - void lcd_update(uint8_t lcdDrawUpdateOverride = 0, bool forceRedraw = false); // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. void lcd_update_enable(bool enable); From ea59d8a6e6566acb13c8ce38ab3ffbde31b083fc Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 19:50:51 +0200 Subject: [PATCH 25/33] Fix compiler warnings: In file included from sketch/ConfigurationStore.cpp:4:0: sketch/ultralcd.h:40:15: warning: 'void lcd_selftest_v()' declared 'static' but never defined [-Wunused-function] static void lcd_selftest_v(); ^ sketch/ultralcd.h:42:15: warning: 'bool lcd_selfcheck_endstops()' declared 'static' but never defined [-Wunused-function] static bool lcd_selfcheck_endstops(); ^ sketch/ultralcd.h:45:15: warning: 'void reset_crash_det(char)' declared 'static' but never defined [-Wunused-function] static void reset_crash_det(char axis); ^ sketch/ultralcd.h:46:15: warning: 'bool lcd_selfcheck_axis_sg(char)' declared 'static' but never defined [-Wunused-function] static bool lcd_selfcheck_axis_sg(char axis); ^ sketch/ultralcd.h:47:15: warning: 'bool lcd_selfcheck_axis(int, int)' declared 'static' but never defined [-Wunused-function] static bool lcd_selfcheck_axis(int _axis, int _travel); ^ sketch/ultralcd.h:54:15: warning: 'bool lcd_selfcheck_check_heater(bool)' declared 'static' but never defined [-Wunused-function] static bool lcd_selfcheck_check_heater(bool _isbed); ^ sketch/ultralcd.h:55:15: warning: 'int lcd_selftest_screen(int, int, int, bool, int)' declared 'static' but never defined [-Wunused-function] static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); ^ sketch/ultralcd.h:56:15: warning: 'void lcd_selftest_screen_step(int, int, int, const char*, const char*)' declared 'static' but never defined [-Wunused-function] static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); ^ sketch/ultralcd.h:57:15: warning: 'bool lcd_selftest_manual_fan_check(int, bool)' declared 'static' but never defined [-Wunused-function] static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); ^ sketch/ultralcd.h:58:15: warning: 'bool lcd_selftest_fan_dialog(int)' declared 'static' but never defined [-Wunused-function] static bool lcd_selftest_fan_dialog(int _fan); ^ sketch/ultralcd.h:59:15: warning: 'bool lcd_selftest_fsensor()' declared 'static' but never defined [-Wunused-function] static bool lcd_selftest_fsensor(); ^ sketch/ultralcd.h:60:15: warning: 'void lcd_selftest_error(int, const char*, const char*)' declared 'static' but never defined [-Wunused-function] static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); sketch/ultralcd.h:68:24: warning: 'blink' defined but not used [-Wunused-variable] static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD sketch/ultralcd.h:222:13: warning: 'void lcd_colorprint_change()' declared 'static' but never defined [-Wunused-function] static void lcd_colorprint_change(); ^ sketch/ultralcd.h:223:12: warning: 'int get_ext_nr()' declared 'static' but never defined [-Wunused-function] static int get_ext_nr(); ^ sketch/ultralcd.h:225:13: warning: 'void extr_adj_0()' declared 'static' but never defined [-Wunused-function] static void extr_adj_0(); ^ sketch/ultralcd.h:226:13: warning: 'void extr_adj_1()' declared 'static' but never defined [-Wunused-function] static void extr_adj_1(); ^ sketch/ultralcd.h:227:13: warning: 'void extr_adj_2()' declared 'static' but never defined [-Wunused-function] static void extr_adj_2(); ^ sketch/ultralcd.h:228:13: warning: 'void extr_adj_3()' declared 'static' but never defined [-Wunused-function] static void extr_adj_3(); ^ sketch/ultralcd.h:229:13: warning: 'void fil_load_menu()' declared 'static' but never defined [-Wunused-function] static void fil_load_menu(); ^ sketch/ultralcd.h:230:13: warning: 'void fil_unload_menu()' declared 'static' but never defined [-Wunused-function] static void fil_unload_menu(); ^ sketch/ultralcd.h:231:13: warning: 'void extr_unload_0()' declared 'static' but never defined [-Wunused-function] static void extr_unload_0(); ^ sketch/ultralcd.h:232:13: warning: 'void extr_unload_1()' declared 'static' but never defined [-Wunused-function] static void extr_unload_1(); ^ sketch/ultralcd.h:233:13: warning: 'void extr_unload_2()' declared 'static' but never defined [-Wunused-function] static void extr_unload_2(); ^ sketch/ultralcd.h:234:13: warning: 'void extr_unload_3()' declared 'static' but never defined [-Wunused-function] static void extr_unload_3(); ^ sketch/ultralcd.h:235:13: warning: 'void lcd_disable_farm_mode()' declared 'static' but never defined [-Wunused-function] static void lcd_disable_farm_mode(); ^ sketch/ultralcd.h:236:13: warning: 'void lcd_set_fan_check()' declared 'static' but never defined [-Wunused-function] static void lcd_set_fan_check(); ^ sketch/ultralcd.h:240:13: warning: 'char snmm_stop_print_menu()' declared 'static' but never defined [-Wunused-function] static char snmm_stop_print_menu(); ^ sketch/ultralcd.h:242:14: warning: 'void lcd_sort_type_set()' declared 'static' but never defined [-Wunused-function] static void lcd_sort_type_set(); ^ sketch/ultralcd.h:244:14: warning: 'float count_e(float, float, float)' declared 'static' but never defined [-Wunused-function] static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); ^ sketch/ultralcd.h:245:13: warning: 'void lcd_babystep_z()' declared 'static' but never defined [-Wunused-function] static void lcd_babystep_z(); ^ sketch/ultralcd.h:290:13: warning: 'void lcd_send_status()' declared 'static' but never defined [-Wunused-function] static void lcd_send_status(); ^ sketch/ultralcd.h:291:13: warning: 'void lcd_connect_printer()' declared 'static' but never defined [-Wunused-function] static void lcd_connect_printer(); sketch/ultralcd.h:227:13: warning: 'char snmm_stop_print_menu()' declared 'static' but never defined [-Wunused-function] static char snmm_stop_print_menu(); ^ sketch/ultralcd.h:229:14: warning: 'void lcd_sort_type_set()' declared 'static' but never defined [-Wunused-function] static void lcd_sort_type_set(); ^ sketch/ultralcd.h:231:14: warning: 'float count_e(float, float, float)' declared 'static' but never defined [-Wunused-function] static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); ^ sketch/ultralcd.h:232:13: warning: 'void lcd_babystep_z()' declared 'static' but never defined [-Wunused-function] static void lcd_babystep_z(); --- Firmware/ultralcd.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ Firmware/ultralcd.h | 44 +----------------------------------------- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index daf26014..040ea9b3 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -144,6 +144,8 @@ int8_t FSensorStateMenu = 1; int8_t CrashDetectMenu = 1; +static unsigned char blink = 0; //!< Variable for visualization of fan rotation in GLCD + extern void fsensor_block(); extern void fsensor_unblock(); @@ -238,6 +240,49 @@ static void lcd_menu_xyz_offset(); static void lcd_menu_fails_stats(); #endif //TMC2130 or PAT9125 +static void lcd_selftest_v(); +static bool lcd_selfcheck_endstops(); + +#ifdef TMC2130 +static void reset_crash_det(char axis); +static bool lcd_selfcheck_axis_sg(char axis); +static bool lcd_selfcheck_axis(int _axis, int _travel); +#else +static bool lcd_selfcheck_endstops(); +static bool lcd_selfcheck_axis(int _axis, int _travel); +static bool lcd_selfcheck_pulleys(int axis); +#endif //TMC2130 + +static bool lcd_selfcheck_check_heater(bool _isbed); +static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); +static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); +static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); +static bool lcd_selftest_fan_dialog(int _fan); +static bool lcd_selftest_fsensor(); +static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); +static void lcd_colorprint_change(); +static int get_ext_nr(); +static void extr_adj_0(); +static void extr_adj_1(); +static void extr_adj_2(); +static void extr_adj_3(); +static void fil_load_menu(); +static void fil_unload_menu(); +static void extr_unload_0(); +static void extr_unload_1(); +static void extr_unload_2(); +static void extr_unload_3(); +static void lcd_disable_farm_mode(); +static void lcd_set_fan_check(); +static char snmm_stop_print_menu(); +#ifdef SDCARD_SORT_ALPHA + static void lcd_sort_type_set(); +#endif +static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); +static void lcd_babystep_z(); +static void lcd_send_status(); +static void lcd_connect_printer(); + void lcd_finishstatus(); #ifdef DOGLCD diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 39e26fda..3250a4c1 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -37,27 +37,8 @@ extern int lcd_printf_P(const char* format, ...); //void lcd_mylang(); bool lcd_detected(void); - static void lcd_selftest_v(); extern bool lcd_selftest(); - static bool lcd_selfcheck_endstops(); -#ifdef TMC2130 - static void reset_crash_det(char axis); - static bool lcd_selfcheck_axis_sg(char axis); - static bool lcd_selfcheck_axis(int _axis, int _travel); -#else - static bool lcd_selfcheck_endstops(); - static bool lcd_selfcheck_axis(int _axis, int _travel); - static bool lcd_selfcheck_pulleys(int axis); -#endif //TMC2130 - - static bool lcd_selfcheck_check_heater(bool _isbed); - static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); - static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); - static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); - static bool lcd_selftest_fan_dialog(int _fan); - static bool lcd_selftest_fsensor(); - static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); void lcd_menu_statistics(); extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); @@ -84,7 +65,6 @@ extern int lcd_printf_P(const char* format, ...); void lcd_setcontrast(uint8_t value); #endif - static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) @@ -239,30 +219,11 @@ extern void lcd_implementation_print_at(uint8_t x, uint8_t y, const char *str); void change_extr(int extr); -static void lcd_colorprint_change(); -static int get_ext_nr(); void extr_adj(int extruder); -static void extr_adj_0(); -static void extr_adj_1(); -static void extr_adj_2(); -static void extr_adj_3(); -static void fil_load_menu(); -static void fil_unload_menu(); -static void extr_unload_0(); -static void extr_unload_1(); -static void extr_unload_2(); -static void extr_unload_3(); -static void lcd_disable_farm_mode(); -static void lcd_set_fan_check(); + void extr_unload_all(); void extr_unload_used(); void extr_unload(); -static char snmm_stop_print_menu(); -#ifdef SDCARD_SORT_ALPHA - static void lcd_sort_type_set(); -#endif -static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); -static void lcd_babystep_z(); void stack_error(); void lcd_printer_connected(); @@ -307,7 +268,4 @@ void lcd_language(); void lcd_wizard(); void lcd_wizard(int state); -static void lcd_send_status(); -static void lcd_connect_printer(); - #endif //ULTRALCD_H From 83081b0fbaef8cf8c154748b820ee3d4791f29ba Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 20:00:20 +0200 Subject: [PATCH 26/33] Fix compiler warning: sketch/LiquidCrystal_Prusa.cpp:502:1: warning: label 'end' defined but not used [-Wunused-label]. --- Firmware/LiquidCrystal_Prusa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/LiquidCrystal_Prusa.cpp b/Firmware/LiquidCrystal_Prusa.cpp index e06f8fa2..38dae5e4 100644 --- a/Firmware/LiquidCrystal_Prusa.cpp +++ b/Firmware/LiquidCrystal_Prusa.cpp @@ -499,7 +499,6 @@ inline size_t LiquidCrystal_Prusa::escape_write(uint8_t chr) break; } escape_cnt = 0; // reset escape -end: return 1; // assume sucess } From 42893b7a941a4d461377ca47981cc69ea878b7a9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Jul 2018 20:47:40 +0200 Subject: [PATCH 27/33] Fix compiler warnings: sketch/Marlin_main.cpp:806:6: warning: unused variable 'cursor_pos' [-Wunused-variable] sketch/Marlin_main.cpp:1922:7: warning: unused variable 'stack_integrity' [-Wunused-variable] sketch/Marlin_main.cpp:4254:8: warning: unused variable 'clamped' [-Wunused-variable] --- Firmware/Marlin_main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 11c1c6e3..951467d6 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -803,7 +803,6 @@ int er_progress = 0; void factory_reset(char level, bool quiet) { lcd_implementation_clear(); - int cursor_pos = 0; switch (level) { // Level 0: Language reset @@ -1920,7 +1919,6 @@ void host_keepalive() { void loop() { KEEPALIVE_STATE(NOT_BUSY); - bool stack_integrity = true; if ((usb_printing_counter > 0) && ((millis()-_usb_timer) > 1000)) { @@ -4254,10 +4252,11 @@ void process_commands() // The move to the first calibration point. current_position[X_AXIS] = pgm_read_float(bed_ref_points); current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); - bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 1) { + if (verbosity_level >= 1) + { + bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n"); } #endif //SUPPORT_VERBOSITY From 6824ab65dd41f974edeae3a7bd2f626d2c730862 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sun, 15 Jul 2018 20:00:29 +0200 Subject: [PATCH 28/33] G28 fix --- Firmware/Marlin.h | 4 +++- Firmware/Marlin_main.cpp | 52 ++++++++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index a839ef9a..4b14d251 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -451,7 +451,9 @@ void force_high_power_mode(bool start_high_power_section); #endif //TMC2130 // G-codes -void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib); +void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_y_value, bool home_z_axis, long home_z_value, bool calib, bool without_mbl); +void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis); + bool gcode_M45(bool onlyZ, int8_t verbosity_level); void gcode_M114(); void gcode_M701(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 97fa26f3..de269fcb 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -734,7 +734,7 @@ void crashdet_detected(uint8_t mask) lcd_update_enable(true); lcd_update(2); lcd_setstatuspgm(_T(MSG_CRASH_DETECTED)); - gcode_G28(true, true, false, false); //home X and Y + gcode_G28(true, true, false); //home X and Y st_synchronize(); if (automatic_recovery_after_crash) { @@ -2614,7 +2614,11 @@ void force_high_power_mode(bool start_high_power_section) { } #endif //TMC2130 -void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { +void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis) { + gcode_G28(home_x_axis, 0, home_y_axis, 0, home_z_axis, 0, false, true); +} + +void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_y_value, bool home_z_axis, long home_z_value, bool calib, bool without_mbl) { st_synchronize(); #if 0 @@ -2625,6 +2629,11 @@ void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { // Flag for the display update routine and to disable the print cancelation during homing. homing_flag = true; + // Which axes should be homed? + bool home_x = home_x_axis; + bool home_y = home_y_axis; + bool home_z = home_z_axis; + // Either all X,Y,Z codes are present, or none of them. bool home_all_axes = home_x == home_y && home_x == home_z; if (home_all_axes) @@ -2733,11 +2742,11 @@ void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { #endif //TMC2130 - if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) - current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; + if(home_x_axis && home_x_value != 0) + current_position[X_AXIS]=home_x_value+add_homing[X_AXIS]; - if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) - current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; + if(home_y_axis && home_y_value != 0) + current_position[Y_AXIS]=home_y_value+add_homing[Y_AXIS]; #if Z_HOME_DIR < 0 // If homing towards BED do Z last #ifndef Z_SAFE_HOMING @@ -2832,8 +2841,8 @@ void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { #endif // Z_SAFE_HOMING #endif // Z_HOME_DIR < 0 - if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) - current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; + if(home_z_axis && home_z_value != 0) + current_position[Z_AXIS]=home_z_value+add_homing[Z_AXIS]; #ifdef ENABLE_AUTO_BED_LEVELING if(home_z) current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) @@ -2865,7 +2874,7 @@ void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { world2machine_update_current(); #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) - if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) + if (home_x_axis || home_y_axis || without_mbl || home_z_axis) { if (! home_z && mbl_was_active) { // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. @@ -2878,10 +2887,6 @@ void gcode_G28(bool home_x, bool home_y, bool home_z, bool calib) { { st_synchronize(); homing_flag = false; - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - enquecommand_front_P((PSTR("G80"))); - //goto case_G80; } #endif @@ -3613,15 +3618,26 @@ void process_commands() #endif //FWRETRACT case 28: //G28 Home all Axis one at a time { - // Which axes should be homed? + long home_x_value = 0; + long home_y_value = 0; + long home_z_value = 0; + // Which axes should be homed? bool home_x = code_seen(axis_codes[X_AXIS]); + home_x_value = code_value_long(); bool home_y = code_seen(axis_codes[Y_AXIS]); - bool home_z = code_seen(axis_codes[Z_AXIS]); + home_y_value = code_value_long(); + bool home_z = code_seen(axis_codes[Z_AXIS]); + home_z_value = code_value_long(); + bool without_mbl = code_seen('W'); // calibrate? bool calib = code_seen('C'); - gcode_G28(home_x, home_y, home_z, calib); - + gcode_G28(home_x, home_x_value, home_y, home_y_value, home_z, home_z_value, calib, without_mbl); + if ((home_x || home_y || without_mbl || home_z) == false) { + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + goto case_G80; + } break; } #ifdef ENABLE_AUTO_BED_LEVELING @@ -3862,7 +3878,7 @@ void process_commands() current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); - gcode_G28(false, false, true, false); + gcode_G28(false, false, true); } if ((current_temperature_pinda > 35) && (farm_mode == false)) { From 0e15a4025b6281a8d15ae3f91684c85162df79b9 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sun, 15 Jul 2018 20:24:24 +0200 Subject: [PATCH 29/33] whitespace --- Firmware/Marlin_main.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index de269fcb..e78c8241 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2630,9 +2630,9 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_ homing_flag = true; // Which axes should be homed? - bool home_x = home_x_axis; - bool home_y = home_y_axis; - bool home_z = home_z_axis; + bool home_x = home_x_axis; + bool home_y = home_y_axis; + bool home_z = home_z_axis; // Either all X,Y,Z codes are present, or none of them. bool home_all_axes = home_x == home_y && home_x == home_z; @@ -2746,7 +2746,7 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_ current_position[X_AXIS]=home_x_value+add_homing[X_AXIS]; if(home_y_axis && home_y_value != 0) - current_position[Y_AXIS]=home_y_value+add_homing[Y_AXIS]; + current_position[Y_AXIS]=home_y_value+add_homing[Y_AXIS]; #if Z_HOME_DIR < 0 // If homing towards BED do Z last #ifndef Z_SAFE_HOMING @@ -3618,27 +3618,26 @@ void process_commands() #endif //FWRETRACT case 28: //G28 Home all Axis one at a time { - long home_x_value = 0; + long home_x_value = 0; long home_y_value = 0; - long home_z_value = 0; - // Which axes should be homed? + long home_z_value = 0; + // Which axes should be homed? bool home_x = code_seen(axis_codes[X_AXIS]); - home_x_value = code_value_long(); + home_x_value = code_value_long(); bool home_y = code_seen(axis_codes[Y_AXIS]); home_y_value = code_value_long(); - bool home_z = code_seen(axis_codes[Z_AXIS]); - home_z_value = code_value_long(); - bool without_mbl = code_seen('W'); + bool home_z = code_seen(axis_codes[Z_AXIS]); + home_z_value = code_value_long(); + bool without_mbl = code_seen('W'); // calibrate? bool calib = code_seen('C'); - - gcode_G28(home_x, home_x_value, home_y, home_y_value, home_z, home_z_value, calib, without_mbl); - if ((home_x || home_y || without_mbl || home_z) == false) { - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - goto case_G80; - } - break; + gcode_G28(home_x, home_x_value, home_y, home_y_value, home_z, home_z_value, calib, without_mbl); + if ((home_x || home_y || without_mbl || home_z) == false) { + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + goto case_G80; + } + break; } #ifdef ENABLE_AUTO_BED_LEVELING case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points. From a575c028bf0fcd37c23b982b18690b13bf0e23a5 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 16 Jul 2018 19:20:39 +0200 Subject: [PATCH 30/33] resend request sends OK --- Firmware/cmdqueue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 9ad24333..1b18acfe 100644 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -476,6 +476,7 @@ void get_command() SERIAL_ERROR_START; SERIAL_ERRORRPGM(_n("No Line Number with checksum, Last Line: "));////MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM c=0 r=0 SERIAL_ERRORLN(gcode_LastN); + FlushSerialRequestResend(); serial_count = 0; return; } From fddc02adfae6aec37da317331f9cca10a587b66a Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 16 Jul 2018 21:01:40 +0200 Subject: [PATCH 31/33] version changed --- Firmware/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 9a9304a2..d95a4e0d 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -7,8 +7,8 @@ #define STR(x) STR_HELPER(x) // Firmware version -#define FW_VERSION "3.3.0" -#define FW_COMMIT_NR 830 +#define FW_VERSION "3.3.1" +#define FW_COMMIT_NR 845 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN From 77426b563a06a821e5d0189a6ffbea42e71027f8 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 17 Jul 2018 11:28:44 +0200 Subject: [PATCH 32/33] Revert "Save 80B of flash and 8B of RAM and fix compiler warning:" --- Firmware/ConfigurationStore.h | 2 +- Firmware/LiquidCrystal_Prusa.cpp | 1 + Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 14 +- Firmware/adc.c | 5 +- Firmware/language.c | 6 +- Firmware/language.h | 69 ++--- Firmware/sm4.c | 5 +- Firmware/temperature.cpp | 12 +- Firmware/temperature.h | 10 + Firmware/tmc2130.cpp | 2 +- Firmware/uart2.c | 2 +- Firmware/uart2.h | 4 +- Firmware/ultralcd.cpp | 251 +++++++----------- Firmware/ultralcd.h | 48 +++- .../ultralcd_implementation_hitachi_HD44780.h | 5 +- Firmware/uni_avr_rpi.h | 2 +- .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 4 +- .../1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h | 4 +- 19 files changed, 203 insertions(+), 244 deletions(-) diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index 79055fdc..facdcca2 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -21,7 +21,7 @@ FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_Prin #endif inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } -inline void calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } +inline uint8_t calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); } #endif//CONFIG_STORE_H diff --git a/Firmware/LiquidCrystal_Prusa.cpp b/Firmware/LiquidCrystal_Prusa.cpp index 38dae5e4..e06f8fa2 100644 --- a/Firmware/LiquidCrystal_Prusa.cpp +++ b/Firmware/LiquidCrystal_Prusa.cpp @@ -499,6 +499,7 @@ inline size_t LiquidCrystal_Prusa::escape_write(uint8_t chr) break; } escape_cnt = 0; // reset escape +end: return 1; // assume sucess } diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 0faaf3cd..f59af1bf 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -419,6 +419,7 @@ extern void fsensor_init(); //estimated time to end of the print extern uint16_t print_time_remaining(); extern uint8_t print_percent_done(); +static void print_time_remaining_init(); #ifdef HOST_KEEPALIVE_FEATURE diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 57fa1658..4856750a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -535,9 +535,8 @@ static bool saved_extruder_relative_mode = false; //=============================Routines====================================== //=========================================================================== -static void get_arc_coordinates(); -static bool setTargetedHotend(int code); -static void print_time_remaining_init(); +void get_arc_coordinates(); +bool setTargetedHotend(int code); void serial_echopair_P(const char *s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } @@ -803,6 +802,7 @@ int er_progress = 0; void factory_reset(char level, bool quiet) { lcd_implementation_clear(); + int cursor_pos = 0; switch (level) { // Level 0: Language reset @@ -1920,6 +1920,7 @@ void host_keepalive() { void loop() { KEEPALIVE_STATE(NOT_BUSY); + bool stack_integrity = true; if ((usb_printing_counter > 0) && ((millis()-_usb_timer) > 1000)) { @@ -4277,11 +4278,10 @@ void process_commands() // The move to the first calibration point. current_position[X_AXIS] = pgm_read_float(bed_ref_points); current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); + bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 1) - { - bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); + if (verbosity_level >= 1) { clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n"); } #endif //SUPPORT_VERBOSITY @@ -9087,7 +9087,7 @@ void print_world_coordinates() void print_physical_coordinates() { - printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS)); + printf_P(_N("physical coordinates: (%.3f, %.3f, %.3f)\n"), st_get_position_mm[X_AXIS], st_get_position_mm[Y_AXIS], st_get_position_mm[Z_AXIS]); } void print_mesh_bed_leveling_table() diff --git a/Firmware/adc.c b/Firmware/adc.c index 1798b083..5cb88b79 100644 --- a/Firmware/adc.c +++ b/Firmware/adc.c @@ -1,9 +1,8 @@ //adc.c #include "adc.h" -#include #include -#include + uint8_t adc_state; uint8_t adc_count; @@ -18,7 +17,7 @@ uint16_t adc_sim_mask; void adc_init(void) { - printf_P(PSTR("adc_init\n")); + printf(("adc_init\n")); adc_sim_mask = 0x00; ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); ADMUX |= (1 << REFS0); diff --git a/Firmware/language.c b/Firmware/language.c index 79b6cb0a..ca3b9e88 100644 --- a/Firmware/language.c +++ b/Firmware/language.c @@ -63,7 +63,7 @@ uint8_t lang_select(uint8_t lang) if (lang_check(_SEC_LANG_TABLE)) if (pgm_read_dword(((uint32_t*)(_SEC_LANG_TABLE + 12))) == pgm_read_dword(((uint32_t*)(_PRI_LANG_SIGNATURE)))) //signature valid { - lang_table = (lang_table_t*)(_SEC_LANG_TABLE); // set table pointer + lang_table = _SEC_LANG_TABLE; // set table pointer lang_selected = lang; // set language id } } @@ -138,7 +138,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off if (lang == LANG_ID_SEC) { uint16_t ui = _SEC_LANG_TABLE; //table pointer - memcpy_P(header, (lang_table_t*)(_SEC_LANG_TABLE), sizeof(lang_table_header_t)); //read table header from progmem + memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem if (offset) *offset = ui; return (header->magic == LANG_MAGIC)?1:0; //return 1 if magic valid } @@ -147,7 +147,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off lang--; while (1) { - w25x20cl_rd_data(addr, (uint8_t*)(header), sizeof(lang_table_header_t)); //read table header from xflash + w25x20cl_rd_data(addr, header, sizeof(lang_table_header_t)); //read table header from xflash if (header->magic != LANG_MAGIC) break; //break if not valid if (offset) *offset = addr; if (--lang == 0) return 1; diff --git a/Firmware/language.h b/Firmware/language.h index f0cff9a1..569d9f9e 100644 --- a/Firmware/language.h +++ b/Firmware/language.h @@ -1,4 +1,3 @@ -/** @file */ //language.h #ifndef LANGUAGE_H #define LANGUAGE_H @@ -23,14 +22,11 @@ #define STRINGIFY_(n) #n #define STRINGIFY(n) STRINGIFY_(n) -/** @def PROGMEM_I2 - * @brief section progmem0 will be used for localized translated strings */ +//section progmem0 will be used for localized translated strings #define PROGMEM_I2 __attribute__((section(".progmem0"))) -/** @def PROGMEM_I1 - * @brief section progmem1 will be used for localized strings in english */ +//section progmem1 will be used for localized strings in english #define PROGMEM_I1 __attribute__((section(".progmem1"))) -/** @def PROGMEM_N1 - * @brief section progmem2 will be used for not localized strings in english */ +//section progmem2 will be used for not localized strings in english #define PROGMEM_N1 __attribute__((section(".progmem2"))) #if (LANG_MODE == 0) //primary language only @@ -47,7 +43,7 @@ #define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];})) #define _n(s) _N(s) -/** @brief lang_table_header_t structure - (size= 16byte) */ +//lang_table_header_t structure - (size= 16byte) typedef struct { uint32_t magic; //+0 @@ -58,76 +54,67 @@ typedef struct uint32_t signature; //+12 } lang_table_header_t; -/** @brief lang_table_t structure - (size= 16byte + 2*count) */ +//lang_table_t structure - (size= 16byte + 2*count) typedef struct { lang_table_header_t header; uint16_t table[]; } lang_table_t; -/** @name Language indices into their particular symbol tables.*/ -///@{ +// Language indices into their particular symbol tables. #define LANG_ID_PRI 0 #define LANG_ID_SEC 1 -///@} -/** @def LANG_ID_FORCE_SELECTION - * @brief Language is not defined and it shall be selected from the menu.*/ +// Language is not defined and it shall be selected from the menu. #define LANG_ID_FORCE_SELECTION 254 -/** @def LANG_ID_UNDEFINED - * @brief Language is not defined on a virgin RAMBo board. */ +// Language is not defined on a virgin RAMBo board. #define LANG_ID_UNDEFINED 255 -/** @def LANG_ID_DEFAULT - * @brief Default language ID, if no language is selected. */ +// Default language ID, if no language is selected. #define LANG_ID_DEFAULT LANG_ID_PRI -/** @def LANG_MAGIC - * @brief Magic number at begin of lang table. */ +// Magic number at begin of lang table. #define LANG_MAGIC 0x4bb45aa5 -/** @name Language codes (ISO639-1)*/ -///@{ -#define LANG_CODE_XX 0x3f3f //!<'??' -#define LANG_CODE_EN 0x656e //!<'en' -#define LANG_CODE_CZ 0x6373 //!<'cs' -#define LANG_CODE_DE 0x6465 //!<'de' -#define LANG_CODE_ES 0x6573 //!<'es' -#define LANG_CODE_IT 0x6974 //!<'it' -#define LANG_CODE_PL 0x706c //!<'pl' -///@} +// Language codes (ISO639-1) +#define LANG_CODE_XX 0x3f3f //'??' +#define LANG_CODE_EN 0x656e //'en' +#define LANG_CODE_CZ 0x6373 //'cs' +#define LANG_CODE_DE 0x6465 //'de' +#define LANG_CODE_ES 0x6573 //'es' +#define LANG_CODE_IT 0x6974 //'it' +#define LANG_CODE_PL 0x706c //'pl' #if defined(__cplusplus) extern "C" { #endif //defined(__cplusplus) -/** @brief Currectly active language selection.*/ +// Currectly active language selection. extern uint8_t lang_selected; #if (LANG_MODE != 0) extern const char _SEC_LANG[LANG_SIZE_RESERVED]; extern const char* lang_get_translation(const char* s); -/** @def _SEC_LANG_TABLE - * @brief Align table to start of 256 byte page */ #define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00) +//extern const uint32_t _PRI_LANG_SIGNATURE; #endif //(LANG_MODE != 0) -/** @brief selects language, eeprom is updated in case of success */ +//selects language, eeprom is updated in case of success extern uint8_t lang_select(uint8_t lang); -/** @brief performs checksum test of secondary language data */ +//performs checksum test of secondary language data extern uint8_t lang_check(uint16_t addr); -/** @return total number of languages (primary + all in xflash) */ +//returns total number of languages (primary + all in xflash) extern uint8_t lang_get_count(void); -/** @brief reads lang table header and offset in xflash or progmem */ +//reads lang table header and offset in xflash or progmem extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset); -/** @brief reads lang code from xflash or progmem */ +//reads lang code from xflash or progmem extern uint16_t lang_get_code(uint8_t lang); -/** @return localized language name (text for menu item) */ +//returns localized language name (text for menu item) extern const char* lang_get_name_by_code(uint16_t code); -/** @brief reset language to "LANG_ID_FORCE_SELECTION", epprom is updated */ +//reset language to "LANG_ID_FORCE_SELECTION", epprom is updated extern void lang_reset(void); -/** @retval 1 language is selected */ +//returns 1 if language is selected extern uint8_t lang_is_selected(void); #ifdef DEBUG_SEC_LANG diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 509ac23f..f50591c3 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -3,10 +3,9 @@ #include "sm4.h" #include #include -#include -#include "Arduino.h" #include "boards.h" +#define bool int8_t #define false 0 #define true 1 #include "Configuration_prusa.h" @@ -192,4 +191,4 @@ uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de) } -#endif //NEW_XYZCAL +#endif //NEW_XYZCAL \ No newline at end of file diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index cf9cccfd..83ead13b 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -205,16 +205,6 @@ unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0); //============================= functions ============================ //=========================================================================== -#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) -static float temp_runaway_status[4]; -static float temp_runaway_target[4]; -static float temp_runaway_timer[4]; -static int temp_runaway_error_counter[4]; - -static void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); -static void temp_runaway_stop(bool isPreheat, bool isBed); -#endif - void PID_autotune(float temp, int extruder, int ncycles) { pid_number_of_cycles = ncycles; @@ -1483,7 +1473,7 @@ void bed_min_temp_error(void) { } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); -#endif +#endif*/ } #ifdef HEATER_0_USES_MAX6675 diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 462412d3..b20a67cd 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -189,6 +189,16 @@ FORCE_INLINE bool isCoolingBed() { #error Invalid number of extruders #endif +#if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) +static float temp_runaway_status[4]; +static float temp_runaway_target[4]; +static float temp_runaway_timer[4]; +static int temp_runaway_error_counter[4]; + +void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); +void temp_runaway_stop(bool isPreheat, bool isBed); +#endif + int getHeaterPower(int heater); void disable_heater(); void setWatch(); diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 558ea5aa..bfc720c6 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -878,7 +878,7 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000) uint8_t x[3] = {255,255,255}; //X segment bounds (MSLUTSEL) uint8_t s = 0; //current segment int8_t b; //encoded bit value - int8_t dA; //delta value + uint8_t dA; //delta value int i; //microstep index uint32_t reg; //tmc2130 register tmc2130_wr_MSLUTSTART(axis, 0, amp); diff --git a/Firmware/uart2.c b/Firmware/uart2.c index e6d5c3f8..e12b254a 100644 --- a/Firmware/uart2.c +++ b/Firmware/uart2.c @@ -41,7 +41,7 @@ void uart2_init(void) fdev_setup_stream(uart2io, uart2_putchar, uart2_getchar, _FDEV_SETUP_WRITE | _FDEV_SETUP_READ); //setup uart2 i/o stream } -void uart2_rx_clr(void) +uint8_t uart2_rx_clr(void) { rbuf_w(uart2_ibuf) = 0; rbuf_r(uart2_ibuf) = 0; diff --git a/Firmware/uart2.h b/Firmware/uart2.h index 95a1bff9..e5455148 100644 --- a/Firmware/uart2.h +++ b/Firmware/uart2.h @@ -18,7 +18,7 @@ extern FILE _uart2io; extern void uart2_init(void); -extern void uart2_rx_clr(void); +extern uint8_t uart2_rx_clr(void); extern uint8_t uart2_rx_ok(void); @@ -26,4 +26,4 @@ extern uint8_t uart2_rx_ok(void); #if defined(__cplusplus) } #endif //defined(__cplusplus) -#endif //_UART2_H +#endif //_UART2_H \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index bd29909f..e58e2370 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -143,8 +143,6 @@ int8_t FSensorStateMenu = 1; int8_t CrashDetectMenu = 1; -static unsigned char blink = 0; //!< Variable for visualization of fan rotation in GLCD - extern void fsensor_block(); extern void fsensor_unblock(); @@ -211,7 +209,6 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, /* Different menus */ static void lcd_status_screen(); -static void lcd_language_menu(); #ifdef ULTIPANEL extern bool powersupply; static void lcd_main_menu(); @@ -240,49 +237,6 @@ static void lcd_menu_xyz_offset(); static void lcd_menu_fails_stats(); #endif //TMC2130 or PAT9125 -static void lcd_selftest_v(); -static bool lcd_selfcheck_endstops(); - -#ifdef TMC2130 -static void reset_crash_det(char axis); -static bool lcd_selfcheck_axis_sg(char axis); -static bool lcd_selfcheck_axis(int _axis, int _travel); -#else -static bool lcd_selfcheck_endstops(); -static bool lcd_selfcheck_axis(int _axis, int _travel); -static bool lcd_selfcheck_pulleys(int axis); -#endif //TMC2130 - -static bool lcd_selfcheck_check_heater(bool _isbed); -static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); -static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); -static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); -static bool lcd_selftest_fan_dialog(int _fan); -static bool lcd_selftest_fsensor(); -static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); -static void lcd_colorprint_change(); -static int get_ext_nr(); -static void extr_adj_0(); -static void extr_adj_1(); -static void extr_adj_2(); -static void extr_adj_3(); -static void fil_load_menu(); -static void fil_unload_menu(); -static void extr_unload_0(); -static void extr_unload_1(); -static void extr_unload_2(); -static void extr_unload_3(); -static void lcd_disable_farm_mode(); -static void lcd_set_fan_check(); -static char snmm_stop_print_menu(); -#ifdef SDCARD_SORT_ALPHA - static void lcd_sort_type_set(); -#endif -static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); -static void lcd_babystep_z(); -static void lcd_send_status(); -static void lcd_connect_printer(); - void lcd_finishstatus(); #ifdef DOGLCD @@ -390,7 +344,7 @@ bool lcd_oldcardstatus; #endif //ULTIPANEL menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ -ShortTimer lcd_next_update_millis; +uint32_t lcd_next_update_millis; uint8_t lcd_status_update_delay; bool ignore_click = false; bool wait_for_unclick; @@ -2528,8 +2482,8 @@ static void lcd_menu_xyz_skew() //|01234567890123456789| //|Measured skew: N/A | //|--------------------| -//|Slight skew: 0.12d| -//|Severe skew: 0.25d| +//|Slight skew: 0.12�| +//|Severe skew: 0.25�| //---------------------- float angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW)); lcd_printf_P(_N( @@ -6545,7 +6499,8 @@ bool lcd_selftest() } lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); - lcd_update_enable(true); + lcd_implementation_clear(); + lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; if (_result) { @@ -7254,7 +7209,7 @@ static bool lcd_selftest_fan_dialog(int _fan) static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) { - lcd_update_enable(false); + lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000); int _step_block = 0; const char *_indicator = (_progress > _progress_scale) ? "-" : "|"; @@ -7455,7 +7410,6 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, void lcd_init() { lcd_implementation_init(); - lcd_next_update_millis.start(); #ifdef NEWPANEL SET_INPUT(BTN_EN1); @@ -7537,8 +7491,7 @@ void lcd_update_enable(bool enabled) else lcd_set_custom_characters_arrows(); #endif - // Force the keypad update now. - lcd_update(2,true); + lcd_update(2); } else { // Clear the LCD always, or let it to the caller? } @@ -7563,121 +7516,96 @@ static inline bool forced_menu_expire() return retval; } -static inline void debugBlink() +void lcd_update(uint8_t lcdDrawUpdateOverride) { -#ifdef DEBUG_BLINK_ACTIVE - static bool active_led = false; - active_led = !active_led; - pinMode(LED_PIN, OUTPUT); - digitalWrite(LED_PIN, active_led?HIGH:LOW); -#endif //DEBUG_BLINK_ACTIVE -} -static inline void handleReprapKeyboard() -{ -#ifdef REPRAPWORLD_KEYPAD - if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) - { - reprapworld_keypad_move_z_up(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) - { - reprapworld_keypad_move_z_down(); - } - if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) - { - reprapworld_keypad_move_x_left(); - } - if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) - { - reprapworld_keypad_move_x_right(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) - { - reprapworld_keypad_move_y_down(); - } - if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) - { - reprapworld_keypad_move_y_up(); - } - if (REPRAPWORLD_KEYPAD_MOVE_HOME) - { - reprapworld_keypad_move_home(); - } -#endif -} + if (lcdDrawUpdate < lcdDrawUpdateOverride) + lcdDrawUpdate = lcdDrawUpdateOverride; + + if (!lcd_update_enabled) + return; -static inline void readSlowButtons() -{ #ifdef LCD_HAS_SLOW_BUTTONS - slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context + slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context #endif -} - -/** - * @brief Handle keyboard input and update display - * - * @param lcdDrawUpdateOverride - * @param forceRedraw if true, force redraw of display regardless of timer - */ -void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw) -{ - - if (lcdDrawUpdate < lcdDrawUpdateOverride) - { - lcdDrawUpdate = lcdDrawUpdateOverride; - } - - if (!lcd_update_enabled) return; - - readSlowButtons(); - lcd_buttons_update(); + + lcd_buttons_update(); #if (SDCARDDETECT > 0) - if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) - { - lcdDrawUpdate = 2; - lcd_oldcardstatus = IS_SD_INSERTED; - lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. + if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) + { + lcdDrawUpdate = 2; + lcd_oldcardstatus = IS_SD_INSERTED; + lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) - currentMenu == lcd_status_screen + currentMenu == lcd_status_screen #endif - ); + ); - if (lcd_oldcardstatus) - { - card.initsd(); - LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 - } - else - { - card.release(); - LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0 - } - } -#endif //(SDCARDDETECT > 0) + if (lcd_oldcardstatus) + { + card.initsd(); + LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 + //get_description(); + } + else + { + card.release(); + LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0 + } + } +#endif//CARDINSERTED - if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw) - { - lcd_next_update_millis.start(); - debugBlink(); + if (lcd_next_update_millis < millis()) + { +#ifdef DEBUG_BLINK_ACTIVE + static bool active_led = false; + active_led = !active_led; + pinMode(LED_PIN, OUTPUT); + digitalWrite(LED_PIN, active_led?HIGH:LOW); +#endif //DEBUG_BLINK_ACTIVE #ifdef ULTIPANEL - handleReprapKeyboard(); +#ifdef REPRAPWORLD_KEYPAD + if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) { + reprapworld_keypad_move_z_up(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) { + reprapworld_keypad_move_z_down(); + } + if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) { + reprapworld_keypad_move_x_left(); + } + if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) { + reprapworld_keypad_move_x_right(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) { + reprapworld_keypad_move_y_down(); + } + if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) { + reprapworld_keypad_move_y_up(); + } + if (REPRAPWORLD_KEYPAD_MOVE_HOME) { + reprapworld_keypad_move_home(); + } +#endif + if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) + { + if (lcdDrawUpdate == 0) + lcdDrawUpdate = 1; + encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; + encoderDiff = 0; + lcd_timeoutToStatus.start(); + } - if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) - { - if (lcdDrawUpdate == 0) lcdDrawUpdate = 1; - encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; - encoderDiff = 0; - lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; - lcd_timeoutToStatus.start(); - } - if (LCD_CLICKED) lcd_timeoutToStatus.start(); + if (LCD_CLICKED) lcd_timeoutToStatus.start(); #endif//ULTIPANEL - (*currentMenu)(); - lcd_implementation_update_indicators(); + (*currentMenu)(); + +#ifdef LCD_HAS_STATUS_INDICATORS + lcd_implementation_update_indicators(); +#endif #ifdef ULTIPANEL if (z_menu_expired() || other_menu_expired() || forced_menu_expire()) @@ -7695,16 +7623,17 @@ void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw) lcdDrawUpdate = 2; } #endif//ULTIPANEL - if (lcdDrawUpdate == 2) lcd_implementation_clear(); - if (lcdDrawUpdate) lcdDrawUpdate--; - } - if (!SdFatUtil::test_stack_integrity()) stack_error(); + if (lcdDrawUpdate == 2) lcd_implementation_clear(); + if (lcdDrawUpdate) lcdDrawUpdate--; + lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; + } + if (!SdFatUtil::test_stack_integrity()) stack_error(); #ifdef DEBUG_STEPPER_TIMER_MISSED - if (stepper_timer_overflow_state) stepper_timer_overflow(); + if (stepper_timer_overflow_state) stepper_timer_overflow(); #endif /* DEBUG_STEPPER_TIMER_MISSED */ - lcd_ping(); //check that we have received ping command if we are in farm mode - lcd_send_status(); - if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands(); + lcd_ping(); //check that we have received ping command if we are in farm mode + lcd_send_status(); + if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands(); } void lcd_printer_connected() { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 9fb2a7e3..254a94ae 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -10,7 +10,9 @@ extern int lcd_printf_P(const char* format, ...); #ifdef ULTRA_LCD - void lcd_update(uint8_t lcdDrawUpdateOverride = 0, bool forceRedraw = false); + static void lcd_language_menu(); + + void lcd_update(uint8_t lcdDrawUpdateOverride = 0); // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. void lcd_update_enable(bool enable); void lcd_init(); @@ -38,8 +40,27 @@ extern int lcd_printf_P(const char* format, ...); //void lcd_mylang(); bool lcd_detected(void); + static void lcd_selftest_v(); extern bool lcd_selftest(); + static bool lcd_selfcheck_endstops(); +#ifdef TMC2130 + static void reset_crash_det(char axis); + static bool lcd_selfcheck_axis_sg(char axis); + static bool lcd_selfcheck_axis(int _axis, int _travel); +#else + static bool lcd_selfcheck_endstops(); + static bool lcd_selfcheck_axis(int _axis, int _travel); + static bool lcd_selfcheck_pulleys(int axis); +#endif //TMC2130 + + static bool lcd_selfcheck_check_heater(bool _isbed); + static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); + static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); + static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); + static bool lcd_selftest_fan_dialog(int _fan); + static bool lcd_selftest_fsensor(); + static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); void lcd_menu_statistics(); extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); @@ -66,6 +87,7 @@ extern int lcd_printf_P(const char* format, ...); void lcd_setcontrast(uint8_t value); #endif + static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) @@ -221,11 +243,30 @@ extern void lcd_implementation_print_at(uint8_t x, uint8_t y, const char *str); void change_extr(int extr); +static void lcd_colorprint_change(); +static int get_ext_nr(); void extr_adj(int extruder); - +static void extr_adj_0(); +static void extr_adj_1(); +static void extr_adj_2(); +static void extr_adj_3(); +static void fil_load_menu(); +static void fil_unload_menu(); +static void extr_unload_0(); +static void extr_unload_1(); +static void extr_unload_2(); +static void extr_unload_3(); +static void lcd_disable_farm_mode(); +static void lcd_set_fan_check(); void extr_unload_all(); void extr_unload_used(); void extr_unload(); +static char snmm_stop_print_menu(); +#ifdef SDCARD_SORT_ALPHA + static void lcd_sort_type_set(); +#endif +static float count_e(float layer_heigth, float extrusion_width, float extrusion_length); +static void lcd_babystep_z(); void stack_error(); void lcd_printer_connected(); @@ -270,4 +311,7 @@ void lcd_language(); void lcd_wizard(); void lcd_wizard(int state); +static void lcd_send_status(); +static void lcd_connect_printer(); + #endif //ULTRALCD_H diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index e3a36313..1aa0f303 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -1390,10 +1390,9 @@ static void lcd_implementation_quick_feedback() #endif } - +#ifdef LCD_HAS_STATUS_INDICATORS static void lcd_implementation_update_indicators() { -#ifdef LCD_HAS_STATUS_INDICATORS #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; @@ -1409,8 +1408,8 @@ static void lcd_implementation_update_indicators() ledsprev = leds; } #endif -#endif } +#endif #ifdef LCD_HAS_SLOW_BUTTONS extern uint32_t blocking_enc; diff --git a/Firmware/uni_avr_rpi.h b/Firmware/uni_avr_rpi.h index 616a5662..6a7200c3 100644 --- a/Firmware/uni_avr_rpi.h +++ b/Firmware/uni_avr_rpi.h @@ -1,4 +1,5 @@ // unification for AVR and RPI +#define __AVR #ifdef __AVR //#include "Arduino.h" @@ -28,4 +29,3 @@ void print(int v) { printf("%d", v); } void print(float v) { printf("%f", v); } #endif //RC522_RPI - diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index b89b668c..2889c4e7 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -96,12 +96,12 @@ #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) //Silent mode limits -#define SILENT_MAX_ACCEL 960ul // max axxeleration in silent mode in mm/s^2 +#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2 #define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2 #define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) //Normal mode limits -#define NORMAL_MAX_ACCEL 2500ul // Y-axis max axxeleration in normal mode in mm/s^2 +#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2 #define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2 #define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) diff --git a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h index 88f0075c..f57c6da1 100644 --- a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h @@ -97,12 +97,12 @@ #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) //Silent mode limits -#define SILENT_MAX_ACCEL 960ul // max axxeleration in silent mode in mm/s^2 +#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2 #define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2 #define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) //Normal mode limits -#define NORMAL_MAX_ACCEL 2500ul // Y-axis max axxeleration in normal mode in mm/s^2 +#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2 #define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2 #define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) From 9e2985dfbad5bfedea3cf37613ce11faeb6c8abe Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 17 Jul 2018 11:38:38 +0200 Subject: [PATCH 33/33] Revert "Use timer" --- Firmware/cardreader.cpp | 2 +- Firmware/ultralcd.cpp | 88 ++++++++++++++++------------------------- Firmware/ultralcd.h | 6 +-- 3 files changed, 38 insertions(+), 58 deletions(-) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 85daef4a..23d84dab 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -972,7 +972,7 @@ void CardReader::presort() { #endif lcd_update(2); KEEPALIVE_STATE(NOT_BUSY); - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; } void CardReader::flush_presort() { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e58e2370..ea7a4105 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -10,6 +10,7 @@ #include "stepper.h" #include "ConfigurationStore.h" #include +#include "Timer.h" #include "util.h" #include "mesh_bed_leveling.h" @@ -177,10 +178,9 @@ float pid_temp = DEFAULT_PID_TEMP; bool long_press_active = false; static ShortTimer longPressTimer; -static ShortTimer buttonBlanking; +unsigned long button_blanking_time = millis(); bool button_pressed = false; -static bool forceMenuExpire = false; bool menuExiting = false; #ifdef FILAMENT_LCD_DISPLAY @@ -944,7 +944,7 @@ void lcd_commands() float extr = count_e(0.2, width, length); float extr_short_segment = count_e(0.2, width, width); - if (lcd_commands_step>1) lcd_timeoutToStatus.start(); //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + if (lcd_commands_step>1) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen if (lcd_commands_step == 0) { lcd_commands_step = 10; @@ -970,7 +970,7 @@ void lcd_commands() } if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; enquecommand_P(PSTR("G1 Z0.250 F7200.000")); enquecommand_P(PSTR("G1 X50.0 E80.0 F1000.0")); enquecommand_P(PSTR("G1 X160.0 E20.0 F1000.0")); @@ -994,7 +994,7 @@ void lcd_commands() } if (lcd_commands_step == 8 && !blocks_queued() && cmd_buffer_empty()) //draw meander { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; enquecommand_P(PSTR("G1 X50 Y155")); @@ -1019,7 +1019,7 @@ void lcd_commands() if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; strcpy(cmd1, "G1 X50 Y35 E"); strcat(cmd1, ftostr43(extr)); enquecommand(cmd1); @@ -1052,7 +1052,7 @@ void lcd_commands() if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 4; i < 8; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1081,7 +1081,7 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 8; i < 12; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1110,7 +1110,7 @@ void lcd_commands() if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 12; i < 16; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1139,7 +1139,7 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("G4 S0")); enquecommand_P(PSTR("G1 E-4 F2100.00000")); @@ -1208,7 +1208,7 @@ void lcd_commands() float length = 20 - width; float extr = count_e(0.2, width, length); float extr_short_segment = count_e(0.2, width, width); - if(lcd_commands_step>1) lcd_timeoutToStatus.start(); //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + if(lcd_commands_step>1) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen if (lcd_commands_step == 0) { lcd_commands_step = 9; @@ -1245,7 +1245,7 @@ void lcd_commands() } if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) //draw meander { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; //just opposite direction @@ -1293,7 +1293,7 @@ void lcd_commands() if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 0; i < 4; i++) { strcpy(cmd1, "G1 X70 Y"); @@ -1323,7 +1323,7 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 4; i < 8; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1352,7 +1352,7 @@ void lcd_commands() if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 8; i < 12; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1381,7 +1381,7 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; for (int i = 12; i < 16; i++) { strcpy(cmd1, "G1 X70 Y"); strcat(cmd1, ftostr32(35 - i*width * 2)); @@ -1410,7 +1410,7 @@ void lcd_commands() if (lcd_commands_step == 2 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("M107")); //turn off printer fan enquecommand_P(PSTR("M104 S0")); // turn off temperature @@ -1418,7 +1418,7 @@ void lcd_commands() enquecommand_P(PSTR("G1 Z10 F1300.000")); enquecommand_P(PSTR("G1 X10 Y180 F4000")); //home X axis enquecommand_P(PSTR("M84"));// disable motors - forceMenuExpire = true; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen + lcd_timeoutToStatus = millis() - 1; //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen lcd_commands_step = 1; } if (lcd_commands_step == 1 && !blocks_queued() && cmd_buffer_empty()) @@ -2482,8 +2482,8 @@ static void lcd_menu_xyz_skew() //|01234567890123456789| //|Measured skew: N/A | //|--------------------| -//|Slight skew: 0.12�| -//|Severe skew: 0.25�| +//|Slight skew: 0.12°| +//|Severe skew: 0.25°| //---------------------- float angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW)); lcd_printf_P(_N( @@ -2591,7 +2591,7 @@ static void _lcd_babystep(int axis, const char *msg) //SERIAL_ECHO("Z baby step: "); //SERIAL_ECHO(menuData.babyStep.babystepMem[2]); // Wait 90 seconds before closing the live adjust dialog. - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + 90000; } if (encoderPosition != 0) @@ -3898,7 +3898,7 @@ void menu_setlang(unsigned char lang) lcd_update_enable(true); lcd_implementation_clear(); lcd_goto_menu(lcd_language_menu); - lcd_timeoutToStatus.stop(); //infinite timeout + lcd_timeoutToStatus = -1; //infinite timeout lcdDrawUpdate = 2; } } @@ -4131,7 +4131,7 @@ void lcd_language() lcd_update_enable(true); lcd_implementation_clear(); lcd_goto_menu(lcd_language_menu); - lcd_timeoutToStatus.stop(); //infinite timeout + lcd_timeoutToStatus = -1; //infinite timeout lcdDrawUpdate = 2; while ((currentMenu != lcd_status_screen) && (!lang_is_selected())) { @@ -4527,7 +4527,7 @@ static void lcd_homing_accuracy_menu_advanced_back() static void lcd_homing_accuracy_menu_advanced() { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; MENU_BEGIN(); ///! MENU_ITEM_BACK_P(PSTR("Homing accuracy"), lcd_homing_accuracy_menu_advanced_back); MENU_ITEM_FUNCTION_P(PSTR("Reset def. steps"), lcd_homing_accuracy_menu_advanced_reset); @@ -4608,7 +4608,7 @@ static void lcd_ustep_resolution_reset_def_xyze() static void lcd_ustep_resolution_menu() { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; MENU_BEGIN(); ///! MENU_ITEM_BACK_P(PSTR("Experimental"), lcd_ustep_resolution_menu_back); MENU_ITEM_FUNCTION_P(PSTR("Reset defaults"), lcd_ustep_resolution_reset_def_xyze); @@ -4656,7 +4656,7 @@ static void lcd_ustep_linearity_menu_reset() static void lcd_ustep_linearity_menu() { - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; MENU_BEGIN(); ///! MENU_ITEM_BACK_P(PSTR("Experimental"), lcd_ustep_linearity_menu_back); MENU_ITEM_FUNCTION_P(PSTR("Reset correction"), lcd_ustep_linearity_menu_reset); @@ -7466,7 +7466,7 @@ void lcd_init() //#include static volatile bool lcd_update_enabled = true; -LongTimer lcd_timeoutToStatus; +unsigned long lcd_timeoutToStatus = 0; void lcd_update_enable(bool enabled) { @@ -7478,7 +7478,7 @@ void lcd_update_enable(bool enabled) encoderDiff = 0; // Enabling the normal LCD update procedure. // Reset the timeout interval. - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; // Force the keypad update now. lcd_next_update_millis = millis() - 1; // Full update. @@ -7497,24 +7497,6 @@ void lcd_update_enable(bool enabled) } } } -static inline bool z_menu_expired() -{ - return (currentMenu == lcd_babystep_z - && lcd_timeoutToStatus.expired(LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z)); -} -static inline bool other_menu_expired() -{ - return (currentMenu != lcd_status_screen - && currentMenu != lcd_babystep_z - && lcd_timeoutToStatus.expired(LCD_TIMEOUT_TO_STATUS)); -} -static inline bool forced_menu_expire() -{ - bool retval = (currentMenu != lcd_status_screen - && forceMenuExpire); - forceMenuExpire = false; - return retval; -} void lcd_update(uint8_t lcdDrawUpdateOverride) { @@ -7595,10 +7577,10 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) lcdDrawUpdate = 1; encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; encoderDiff = 0; - lcd_timeoutToStatus.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; } - if (LCD_CLICKED) lcd_timeoutToStatus.start(); + if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; #endif//ULTIPANEL (*currentMenu)(); @@ -7608,7 +7590,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride) #endif #ifdef ULTIPANEL - if (z_menu_expired() || other_menu_expired() || forced_menu_expire()) + if (lcd_timeoutToStatus < millis() && currentMenu != lcd_status_screen) { // Exiting a menu. Let's call the menu function the last time with menuExiting flag set to true // to give it a chance to save its state. @@ -7778,9 +7760,9 @@ void lcd_buttons_update() #if BTN_ENC > 0 if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release if (READ(BTN_ENC) == 0) { //button is pressed - lcd_timeoutToStatus.start(); - if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) { - buttonBlanking.start(); + lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; + if (millis() > button_blanking_time) { + button_blanking_time = millis() + BUTTON_BLANKING_TIME; if (button_pressed == false && long_press_active == false) { longPressTimer.start(); button_pressed = true; @@ -7796,7 +7778,7 @@ void lcd_buttons_update() } else { //button not pressed if (button_pressed) { //button was released - buttonBlanking.start(); + button_blanking_time = millis() + BUTTON_BLANKING_TIME; if (long_press_active == false) { //button released before long press gets activated newbutton |= EN_C; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 254a94ae..a03c5f1d 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -3,7 +3,6 @@ #include "Marlin.h" #include "mesh_bed_calibration.h" -#include "Timer.h" extern int lcd_puts_P(const char* str); extern int lcd_printf_P(const char* format, ...); @@ -95,8 +94,7 @@ extern int lcd_printf_P(const char* format, ...); #define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x)) #define LCD_UPDATE_INTERVAL 100 - #define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action. - #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms. + #define LCD_TIMEOUT_TO_STATUS 30000 #ifdef ULTIPANEL void lcd_buttons_update(); @@ -119,7 +117,7 @@ extern int lcd_printf_P(const char* format, ...); #define LCD_COMMAND_PID_EXTRUDER 7 #define LCD_COMMAND_V2_CAL 8 - extern LongTimer lcd_timeoutToStatus; + extern unsigned long lcd_timeoutToStatus; extern int lcd_commands_type; extern uint8_t farm_mode;