From 1f131f66e096a73bb5718bd1cac006adcca8c20f Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Thu, 14 Mar 2019 00:36:56 +0100 Subject: [PATCH 01/36] print parameters checking nozzle diameter --- Firmware/Marlin_main.cpp | 39 +++++++++++++-- Firmware/eeprom.h | 4 ++ Firmware/ultralcd.cpp | 104 +++++++++++++++++++++++++++++++++++++++ Firmware/ultralcd.h | 4 +- Firmware/util.cpp | 43 ++++++++++++++++ Firmware/util.h | 25 ++++++++++ 6 files changed, 214 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2c083b0a..bf967812 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -214,8 +214,6 @@ static LongTimer crashDetTimer; bool mesh_bed_leveling_flag = false; bool mesh_bed_run_from_menu = false; -int8_t FarmMode = 0; - bool prusa_sd_card_upload = false; unsigned int status_number = 0; @@ -1617,6 +1615,7 @@ void setup() } #endif //UVLO_SUPPORT + fCheckModeInit(); KEEPALIVE_STATE(NOT_BUSY); #ifdef WATCHDOG wdt_enable(WDTO_4S); @@ -3578,7 +3577,39 @@ void process_commands() } else if(code_seen("FR")) { //! PRUSA FR // Factory full reset factory_reset(0); - } + +//-// +/* + } else if(code_seen("qqq")) { +MYSERIAL.println("=== checking ==="); +MYSERIAL.println(eeprom_read_byte((uint8_t*)EEPROM_CHECK_MODE),DEC); +MYSERIAL.println(eeprom_read_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER),DEC); +MYSERIAL.println(eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM),DEC); +MYSERIAL.println(farm_mode,DEC); +MYSERIAL.println(eCheckMode,DEC); + } else if(code_seen("www")) { +MYSERIAL.println("=== @ FF ==="); +eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODE,0xFF); +eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,0xFF); +eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); +*/ + } else if (code_seen("nozzle")) { //! PRUSA nozzle + uint16_t nDiameter; + if(code_seen('D')) + { + nDiameter=(uint16_t)(code_value()*1000.0+0.5); // [,um] + nozzle_diameter_check(nDiameter); + } + else if(code_seen("set") && farm_mode) + { + strchr_pointer++; // skip 2nd char (~ 'e') + strchr_pointer++; // skip 3rd char (~ 't') + nDiameter=(uint16_t)(code_value()*1000.0+0.5); // [,um] + eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)e_NOZZLE_DIAMETER_NULL); // for correct synchronization after farm-mode exiting + eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,nDiameter); + } + else SERIAL_PROTOCOLLN((float)eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM)/1000.0); + } //else if (code_seen('Cal')) { // lcd_calibration(); // } @@ -4854,6 +4885,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no); SilentModeMenu = SILENT_MODE_OFF; eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); + fCheckModeInit(); // alternatively invoke printer reset break; case 99: //! G99 (deactivate farm mode) @@ -4861,6 +4893,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) lcd_printer_connected(); eeprom_update_byte((unsigned char *)EEPROM_FARM_MODE, farm_mode); lcd_update(2); + fCheckModeInit(); // alternatively invoke printer reset break; default: printf_P(PSTR("Unknown G code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index a9274d4a..9927ea3b 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -156,6 +156,10 @@ #define EEPROM_MMU_CUTTER_ENABLED (EEPROM_MMU_LOAD_FAIL - 1) #define EEPROM_UVLO_MESH_BED_LEVELING_FULL (EEPROM_MMU_CUTTER_ENABLED - 12*12*2) //allow 12 calibration points for future expansion +#define EEPROM_CHECK_MODE (EEPROM_UVLO_MESH_BED_LEVELING_FULL-1) // uint8 +#define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8 +#define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16 + // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6bd94642..92370dbb 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5350,6 +5350,101 @@ do\ }\ while (0) +//-// +static void lcd_check_mode_set(void) +{ +switch(eCheckMode) + { + case e_CHECK_MODE_none: + eCheckMode=e_CHECK_MODE_warn; + break; + case e_CHECK_MODE_warn: + eCheckMode=e_CHECK_MODE_strict; + break; + case e_CHECK_MODE_strict: + eCheckMode=e_CHECK_MODE_none; + break; + default: + eCheckMode=e_CHECK_MODE_none; + } +eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODE,(uint8_t)eCheckMode); +} + +static void lcd_nozzle_diameter_set(void) +{ +uint16_t nDiameter; + +switch(eNozzleDiameter) + { + case e_NOZZLE_DIAMETER_250: + eNozzleDiameter=e_NOZZLE_DIAMETER_400; + nDiameter=400; + break; + case e_NOZZLE_DIAMETER_400: + eNozzleDiameter=e_NOZZLE_DIAMETER_600; + nDiameter=600; + break; + case e_NOZZLE_DIAMETER_600: + eNozzleDiameter=e_NOZZLE_DIAMETER_250; + nDiameter=250; + break; + default: + eNozzleDiameter=e_NOZZLE_DIAMETER_400; + nDiameter=400; + } +eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)eNozzleDiameter); +eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,nDiameter); +} + +#define SETTINGS_MODE \ +do\ +{\ + switch(eCheckMode)\ + {\ + case e_CHECK_MODE_none:\ + MENU_ITEM_FUNCTION_P(_i("Action [none]"),lcd_check_mode_set);\ + break;\ + case e_CHECK_MODE_warn:\ + MENU_ITEM_FUNCTION_P(_i("Action [warn]"),lcd_check_mode_set);\ + break;\ + case e_CHECK_MODE_strict:\ + MENU_ITEM_FUNCTION_P(_i("Action [strict]"),lcd_check_mode_set);\ + break;\ + default:\ + MENU_ITEM_FUNCTION_P(_i("Action [none]"),lcd_check_mode_set);\ + }\ +}\ +while (0) + +#define SETTINGS_NOZZLE \ +do\ +{\ + switch(eNozzleDiameter)\ + {\ + case e_NOZZLE_DIAMETER_250:\ + MENU_ITEM_FUNCTION_P(_i("Nozzle [0.25]"),lcd_nozzle_diameter_set);\ + break;\ + case e_NOZZLE_DIAMETER_400:\ + MENU_ITEM_FUNCTION_P(_i("Nozzle [0.40]"),lcd_nozzle_diameter_set);\ + break;\ + case e_NOZZLE_DIAMETER_600:\ + MENU_ITEM_FUNCTION_P(_i("Nozzle [0.60]"),lcd_nozzle_diameter_set);\ + break;\ + default:\ + MENU_ITEM_FUNCTION_P(_i("Nozzle [0.40]"),lcd_nozzle_diameter_set);\ + }\ +}\ +while (0) + +static void lcd_checking_menu() +{ +MENU_BEGIN(); +MENU_ITEM_BACK_P(_T(MSG_SETTINGS)); +SETTINGS_MODE; +SETTINGS_NOZZLE; +MENU_END(); +} + static void lcd_settings_menu() { EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu)); @@ -5398,6 +5493,9 @@ static void lcd_settings_menu() MENU_ITEM_SUBMENU_P(_i("Select language"), lcd_language_menu);////MSG_LANGUAGE_SELECT c=0 r=0 #endif //(LANG_MODE != 0) + if (!farm_mode) + MENU_ITEM_SUBMENU_P(_i("Print checking"), lcd_checking_menu); + SETTINGS_SD; SETTINGS_SOUND; @@ -6660,6 +6758,12 @@ static void lcd_sd_updir() void lcd_print_stop() { +//-// + if(!card.sdprinting) + { + SERIAL_ECHOLNPGM("// action:cancel"); // for Octoprint + return; + } saved_printing = false; cancel_heatup = true; #ifdef MESH_BED_LEVELING diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index b7f65d9a..668c9103 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -138,14 +138,14 @@ void extr_unload(); typedef enum { - e_FILAMENT_ACTION_none, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) + e_FILAMENT_ACTION_none, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) e_FILAMENT_ACTION_Load, e_FILAMENT_ACTION_autoLoad, e_FILAMENT_ACTION_unLoad, e_FILAMENT_ACTION_mmuLoad, e_FILAMENT_ACTION_mmuUnLoad, e_FILAMENT_ACTION_mmuEject, - e_FILAMENT_ACTION_mmuCut, + e_FILAMENT_ACTION_mmuCut } eFILAMENT_ACTION; extern eFILAMENT_ACTION eFilamentAction; extern bool bFilamentFirstRun; diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 2499b513..a493ba91 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -327,3 +327,46 @@ void update_current_firmware_version_to_eeprom() eeprom_update_word((uint16_t*)EEPROM_FIRMWARE_VERSION_FLAVOR, ver_current[3]); } } + + +//-// +eNOZZLE_DIAMETER eNozzleDiameter=e_NOZZLE_DIAMETER_400; +eCHECK_MODE eCheckMode=e_CHECK_MODE_none; + +void fCheckModeInit() +{ +eCheckMode=(eCHECK_MODE)eeprom_read_byte((uint8_t*)EEPROM_CHECK_MODE); +if(eCheckMode==e_CHECK_MODE_NULL) + { + eCheckMode=e_CHECK_MODE_warn; + eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODE,(uint8_t)eCheckMode); + } +if(farm_mode) + eCheckMode=e_CHECK_MODE_strict; +eNozzleDiameter=(eNOZZLE_DIAMETER)eeprom_read_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER); +if((eNozzleDiameter==e_NOZZLE_DIAMETER_NULL)&& !farm_mode) + { + eNozzleDiameter=e_NOZZLE_DIAMETER_400; + eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)eNozzleDiameter); + eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,400); + } +} + +void nozzle_diameter_check(uint16_t nDiameter) +{ +uint16_t nDiameter_um; + +nDiameter_um=eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM); +if(nDiameter==nDiameter_um) + return; +switch(eCheckMode) + { + case e_CHECK_MODE_warn: + lcd_show_fullscreen_message_and_wait_P(_i("Nozzle diameter doesn't match! Press the knob to continue.")); + break; + case e_CHECK_MODE_strict: + lcd_show_fullscreen_message_and_wait_P(_i("Nozzle diameter doesn't match! Print is aborted, press the knob.")); + lcd_print_stop(); + break; + } +} diff --git a/Firmware/util.h b/Firmware/util.h index 7cbcb027..d3b7e7d1 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -33,4 +33,29 @@ inline void eeprom_update_int8(unsigned char* addr, int8_t v) { eeprom_update_byte(addr, *reinterpret_cast(&v)); } + +//-// +#define e_CHECK_MODE_NULL 0xFF +#define e_NOZZLE_DIAMETER_NULL 0xFF + +typedef enum +{ + e_NOZZLE_DIAMETER_250, + e_NOZZLE_DIAMETER_400, + e_NOZZLE_DIAMETER_600 +} eNOZZLE_DIAMETER; + +typedef enum +{ + e_CHECK_MODE_none, + e_CHECK_MODE_warn, + e_CHECK_MODE_strict +} eCHECK_MODE; + +extern eNOZZLE_DIAMETER eNozzleDiameter; +extern eCHECK_MODE eCheckMode; + +void fCheckModeInit(); +void nozzle_diameter_check(uint16_t nDiameter); + #endif /* UTIL_H */ From 7d98177716287e8b75acad1e6c370dae1caf95c7 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Tue, 19 Mar 2019 19:48:40 +0100 Subject: [PATCH 02/36] farmMode updates --- Firmware/Marlin.h | 3 +++ Firmware/Marlin_main.cpp | 5 ++++- Firmware/ultralcd.cpp | 14 +++++++++++--- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 3 ++- .../variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h | 3 ++- .../variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 3 ++- 11 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 83e587d9..d45c6870 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -213,6 +213,9 @@ void manage_inactivity(bool ignore_stepper_queue=false); #endif +#define FARM_FILAMENT_COLOR_NONE 99; + + enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5}; #define X_AXIS_MASK 1 #define Y_AXIS_MASK 2 diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bf967812..e5c48cd5 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1039,6 +1039,9 @@ void setup() //disabled filament autoload (PFW360) fsensor_autoload_set(false); #endif //FILAMENT_SENSOR + // ~ FanCheck -> on + if(!(eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED))) + eeprom_update_byte((unsigned char *)EEPROM_FAN_CHECK_ENABLED,true); } MYSERIAL.begin(BAUDRATE); fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream @@ -7537,7 +7540,7 @@ static void handleSafetyTimer() { safetyTimer.start(); } - else if (safetyTimer.expired(safetytimer_inactive_time)) + else if (safetyTimer.expired(farm_mode?FARM_DEFAULT_SAFETYTIMER_TIME_ms:safetytimer_inactive_time)) { setTargetBed(0); setAllTargetHotends(0); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 92370dbb..22e68aa2 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2167,7 +2167,6 @@ static void lcd_preheat_menu() MENU_ITEM_FUNCTION_P(PSTR("farm - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FARM_PREHEAT_HPB_TEMP)), lcd_preheat_farm); MENU_ITEM_FUNCTION_P(PSTR("nozzle - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/0"), lcd_preheat_farm_nozzle); MENU_ITEM_FUNCTION_P(_T(MSG_COOLDOWN), lcd_cooldown); - MENU_ITEM_FUNCTION_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs); } else { MENU_ITEM_FUNCTION_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)), lcd_preheat_pla); MENU_ITEM_FUNCTION_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)), lcd_preheat_pet); @@ -6317,10 +6316,11 @@ void lcd_confirm_print() } if (lcd_clicked()) { + filament_type = FARM_FILAMENT_COLOR_NONE; if (cursor_pos == 1) { _ret = 1; - filament_type = lcd_choose_color(); +// filament_type = lcd_choose_color(); prusa_statistics(4, filament_type); no_response = true; //we need confirmation by recieving PRUSA thx important_status = 4; @@ -6330,7 +6330,7 @@ void lcd_confirm_print() if (cursor_pos == 2) { _ret = 2; - filament_type = lcd_choose_color(); +// filament_type = lcd_choose_color(); prusa_statistics(5, filament_type); no_response = true; //we need confirmation by recieving PRUSA thx important_status = 5; @@ -6663,6 +6663,14 @@ static void lcd_tune_menu() SETTINGS_CUTTER; + if(farm_mode) + { + if (fans_check_enabled == true) + MENU_ITEM_FUNCTION_P(_i("Fans check [on]"), lcd_set_fan_check);////MSG_FANS_CHECK_ON c=17 r=1 + else + MENU_ITEM_FUNCTION_P(_i("Fans check [off]"), lcd_set_fan_check);////MSG_FANS_CHECK_OFF c=17 r=1 + } + #ifdef TMC2130 if(!farm_mode) { diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index 3b9f7698..e9449a6f 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -312,7 +312,7 @@ PREHEAT SETTINGS *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 @@ -435,6 +435,7 @@ THERMISTORS SETTINGS // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) #define M600_TIMEOUT 600 //seconds diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index 2d00929f..fda7126e 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -312,7 +312,7 @@ PREHEAT SETTINGS *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 @@ -435,6 +435,7 @@ THERMISTORS SETTINGS // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) #define M600_TIMEOUT 600 //seconds diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index 40a3a229..47cd81df 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -109,6 +109,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -368,7 +369,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index e316c4f0..fef1dfae 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -110,6 +110,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -369,7 +370,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h index d3badf6a..0f8f89ba 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h @@ -109,6 +109,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -368,7 +369,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h index 2563f848..46ad5aa0 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h @@ -110,6 +110,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -369,7 +370,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index c400b016..aca735e8 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -131,6 +131,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -480,7 +481,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 60 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 37512071..5ca0c0b8 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -131,6 +131,7 @@ // Safety timer #define SAFETYTIMER #define DEFAULT_SAFETYTIMER_TIME_MINS 30 +#define FARM_DEFAULT_SAFETYTIMER_TIME_ms (45*60*1000ul) // Filament sensor #define FILAMENT_SENSOR @@ -480,7 +481,7 @@ *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 60 +#define FARM_PREHEAT_HPB_TEMP 80 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 From 32f34718624fc2bbed4412aa4f2b3d343a2a7ac6 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Tue, 9 Apr 2019 15:22:08 +0200 Subject: [PATCH 03/36] print parameters checking prusa_stat_diameter() --- Firmware/ultralcd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 22e68aa2..8e8c246e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -128,6 +128,7 @@ static void lcd_control_volumetric_menu(); static void lcd_settings_linearity_correction_menu_save(); static void prusa_stat_printerstatus(int _status); static void prusa_stat_farm_number(); +static void prusa_stat_diameter(); static void prusa_stat_temperatures(); static void prusa_stat_printinfo(); static void lcd_farm_no(); @@ -4107,6 +4108,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { SERIAL_ECHO("{"); prusa_stat_printerstatus(1); prusa_stat_farm_number(); + prusa_stat_diameter(); SERIAL_ECHOLN("}"); status_number = 1; } @@ -4261,6 +4263,12 @@ static void prusa_stat_farm_number() { SERIAL_ECHO("]"); } +static void prusa_stat_diameter() { + SERIAL_ECHO("[DIA:"); + SERIAL_ECHO(eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM)); + SERIAL_ECHO("]"); +} + static void prusa_stat_temperatures() { SERIAL_ECHO("[ST0:"); @@ -4296,6 +4304,7 @@ static void prusa_stat_printinfo() SERIAL_ECHO("][FWR:"); SERIAL_ECHO(FW_VERSION); SERIAL_ECHO("]"); + prusa_stat_diameter(); } /* From 3b2cbc68d825053e8fed1b81cc42ea1d084f58d6 Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Tue, 28 May 2019 18:22:34 +0200 Subject: [PATCH 04/36] PFW-571 send PRN:4 instead PRN:1 while changing filament --- Firmware/Marlin_main.cpp | 4 ++++ Firmware/ultralcd.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 982e2130..b61897c7 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3146,6 +3146,10 @@ void gcode_M701() { printf_P(PSTR("gcode_M701 begin\n")); + if (farm_mode){ + prusa_statistics(22); + } + if (mmu_enabled) { extr_adj(tmp_extruder);//loads current extruder diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 97304adb..ee8522bd 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -986,6 +986,8 @@ static void lcd_status_screen() { case 8: prusa_statistics(21); + if(loading_flag) + prusa_statistics(22); break; case 5: if (IS_SD_PRINTING) @@ -4145,7 +4147,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { SERIAL_ECHOLN("}"); status_number = 14; } - else if (IS_SD_PRINTING) + else if (IS_SD_PRINTING || loading_flag) { SERIAL_ECHO("{"); prusa_stat_printerstatus(4); @@ -4183,7 +4185,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { status_number = 3; farm_timer = 1; - if (IS_SD_PRINTING) + if (IS_SD_PRINTING || loading_flag) { farm_status = 4; SERIAL_ECHO("{"); From 0cab2284eaf78ad6841467cc4efacb0a9462a464 Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Wed, 5 Jun 2019 15:48:10 +0200 Subject: [PATCH 05/36] PFW-874 new firmware alert timeout --- Firmware/Marlin_main.cpp | 2 +- Firmware/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b61897c7..cb262e12 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5903,7 +5903,7 @@ Sigma_Exit: SERIAL_PROTOCOLLNRPGM(FW_VERSION_STR_P()); } else if (code_seen('U')) { // Check the firmware version provided. If the firmware version provided by the U code is higher than the currently running firmware, - // pause the print and ask the user to upgrade the firmware. + // pause the print for 30s and ask the user to upgrade the firmware. show_upgrade_dialog_if_version_newer(++ strchr_pointer); } else { SERIAL_ECHOPGM("FIRMWARE_NAME:Prusa-Firmware "); diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 18df92f6..e6a6963e 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -304,7 +304,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) _tone(BEEPER, 1000); delay_keep_alive(50); _noTone(BEEPER); - lcd_wait_for_click(); + lcd_wait_for_click_delay(30); lcd_update_enable(true); lcd_clear(); lcd_update(0); From 4be8fa701ed60240025d2414452917a4496e44ca Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 10 Jun 2019 20:41:18 +0200 Subject: [PATCH 06/36] Use loop to enquecommand_P() in first layer calibration. --- Firmware/first_lay_cal.cpp | 30 ++++++++++++++++++++++++++++++ Firmware/first_lay_cal.h | 16 ++++++++++++++++ Firmware/ultralcd.cpp | 14 +++++--------- 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 Firmware/first_lay_cal.cpp create mode 100644 Firmware/first_lay_cal.h diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp new file mode 100644 index 00000000..fb0e7989 --- /dev/null +++ b/Firmware/first_lay_cal.cpp @@ -0,0 +1,30 @@ +/* + * first_lay_cal.cpp + * + * Created on: Jun 10, 2019 + * Author: marek + */ +#include "first_lay_cal.h" +#include "Configuration_prusa.h" +#include "language.h" + +static const char cmd_0[] PROGMEM = "M107"; +static const char cmd_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); +static const char cmd_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); +static const char cmd_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); +static const char cmd_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); +static const char cmd_6[] PROGMEM = "G28"; +static const char cmd_7[] PROGMEM = "G92 E0.0"; + + +const char * const layer1_cal[8] PROGMEM = +{ + cmd_0, + cmd_1, + cmd_2, + cmd_3, + cmd_4, + MSG_M117_V2_CALIBRATION, //TODO missing internationalization + cmd_6, + cmd_7, +}; diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h new file mode 100644 index 00000000..e22a742b --- /dev/null +++ b/Firmware/first_lay_cal.h @@ -0,0 +1,16 @@ +/* + * first_lay_cal.h + * + * Created on: Jun 10, 2019 + * Author: marek + */ + +#ifndef FIRMWARE_FIRST_LAY_CAL_H_ +#define FIRMWARE_FIRST_LAY_CAL_H_ +#include + + +extern const char * const layer1_cal[8] PROGMEM; + + +#endif /* FIRMWARE_FIRST_LAY_CAL_H_ */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f69efbbc..a1be6eab 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -40,6 +40,7 @@ #include "static_assert.h" #include "io_atmega2560.h" +#include "first_lay_cal.h" int scrollstuff = 0; @@ -1386,15 +1387,10 @@ void lcd_commands() if (lcd_commands_step == 10) { - enquecommand_P(PSTR("M107")); - enquecommand_P(PSTR("M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP))); - enquecommand_P(PSTR("M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP))); - enquecommand_P(PSTR("M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP))); - enquecommand_P(PSTR("M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP))); - enquecommand_P(_T(MSG_M117_V2_CALIBRATION)); - enquecommand_P(PSTR("G28")); - enquecommand_P(PSTR("G92 E0.0")); - + for (uint8_t i = 0; i < (sizeof(layer1_cal)/sizeof(layer1_cal[0])); ++i) + { + enquecommand_P(static_cast(pgm_read_ptr(&layer1_cal[i]))); + } lcd_commands_step = 9; } if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) From 27145204ed9c4e8c47ebaf938ac844d7b75cd128 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 10 Jun 2019 21:40:12 +0200 Subject: [PATCH 07/36] Use internationalized M117, but anyway the text is not shown. --- Firmware/first_lay_cal.cpp | 22 +++++++++++++++++----- Firmware/first_lay_cal.h | 3 +-- Firmware/ultralcd.cpp | 5 +---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index fb0e7989..8f12bb96 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -7,24 +7,36 @@ #include "first_lay_cal.h" #include "Configuration_prusa.h" #include "language.h" +#include "Marlin.h" +#include + static const char cmd_0[] PROGMEM = "M107"; static const char cmd_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); static const char cmd_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); static const char cmd_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); static const char cmd_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); -static const char cmd_6[] PROGMEM = "G28"; -static const char cmd_7[] PROGMEM = "G92 E0.0"; +static const char cmd_5[] PROGMEM = "G28"; +static const char cmd_6[] PROGMEM = "G92 E0.0"; -const char * const layer1_cal[8] PROGMEM = +static const char * const preheat_cmd[] PROGMEM = { cmd_0, cmd_1, cmd_2, cmd_3, cmd_4, - MSG_M117_V2_CALIBRATION, //TODO missing internationalization + cmd_5, //call MSG_M117_V2_CALIBRATION before cmd_6, - cmd_7, }; + +void lay1cal_preheat() +{ + for (uint8_t i = 0; i < (sizeof(preheat_cmd)/sizeof(preheat_cmd[0])); ++i) + { + if (5 == i) enquecommand_P(_T(MSG_M117_V2_CALIBRATION)); + enquecommand_P(static_cast(pgm_read_ptr(&preheat_cmd[i]))); + } + +} diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index e22a742b..5068e337 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -7,10 +7,9 @@ #ifndef FIRMWARE_FIRST_LAY_CAL_H_ #define FIRMWARE_FIRST_LAY_CAL_H_ -#include +void lay1cal_preheat(); -extern const char * const layer1_cal[8] PROGMEM; #endif /* FIRMWARE_FIRST_LAY_CAL_H_ */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a1be6eab..66bc453a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1387,10 +1387,7 @@ void lcd_commands() if (lcd_commands_step == 10) { - for (uint8_t i = 0; i < (sizeof(layer1_cal)/sizeof(layer1_cal[0])); ++i) - { - enquecommand_P(static_cast(pgm_read_ptr(&layer1_cal[i]))); - } + lay1cal_preheat(); lcd_commands_step = 9; } if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) From 0c9121e99e1cc5bc94df8e585a879b6da4b67df0 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 17:08:56 +0200 Subject: [PATCH 08/36] Use loop to enquecommand_P() in first layer calibration. --- Firmware/first_lay_cal.cpp | 81 +++++++++++++++++++++++++++++++------- Firmware/first_lay_cal.h | 2 + Firmware/ultralcd.cpp | 25 +----------- 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 8f12bb96..60bb5440 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -8,27 +8,28 @@ #include "Configuration_prusa.h" #include "language.h" #include "Marlin.h" +#include "mmu.h" #include -static const char cmd_0[] PROGMEM = "M107"; -static const char cmd_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); -static const char cmd_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); -static const char cmd_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); -static const char cmd_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); -static const char cmd_5[] PROGMEM = "G28"; -static const char cmd_6[] PROGMEM = "G92 E0.0"; +static const char cmd_preheat_0[] PROGMEM = "M107"; +static const char cmd_preheat_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); +static const char cmd_preheat_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); +static const char cmd_preheat_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); +static const char cmd_preheat_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); +static const char cmd_preheat_5[] PROGMEM = "G28"; +static const char cmd_preheat_6[] PROGMEM = "G92 E0.0"; static const char * const preheat_cmd[] PROGMEM = { - cmd_0, - cmd_1, - cmd_2, - cmd_3, - cmd_4, - cmd_5, //call MSG_M117_V2_CALIBRATION before - cmd_6, + cmd_preheat_0, + cmd_preheat_1, + cmd_preheat_2, + cmd_preheat_3, + cmd_preheat_4, + cmd_preheat_5, //call MSG_M117_V2_CALIBRATION before + cmd_preheat_6, }; void lay1cal_preheat() @@ -40,3 +41,55 @@ void lay1cal_preheat() } } + +static const char cmd_intro_mmu_0[] PROGMEM = "M83"; +static const char cmd_intro_mmu_1[] PROGMEM = "G1 Y-3.0 F1000.0"; +static const char cmd_intro_mmu_2[] PROGMEM = "G1 Z0.4 F1000.0"; +static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0"; // call T code before +static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E32.0 F1800.0"; +static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55.0 E8.0 F2000.0"; +static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000.0"; +static const char cmd_intro_mmu_7[] PROGMEM = "G92 E0.0"; +static const char cmd_intro_mmu_8[] PROGMEM = "G1 X240.0 E25.0 F2200.0"; +static const char cmd_intro_mmu_9[] PROGMEM = "G1 Y-2.0 F1000.0"; +static const char cmd_intro_mmu_10[] PROGMEM = "G1 X55.0 E25 F1400.0"; +static const char cmd_intro_mmu_11[] PROGMEM = "G1 Z0.20 F1000.0"; +static const char cmd_intro_mmu_12[] PROGMEM = "G1 X5.0 E4.0 F1000.0"; + +static const char * const intro_mmu_cmd[] PROGMEM = +{ + cmd_intro_mmu_0, + cmd_intro_mmu_1, + cmd_intro_mmu_2, + cmd_intro_mmu_3, // call T code before + cmd_intro_mmu_4, + cmd_intro_mmu_5, + cmd_intro_mmu_6, + cmd_intro_mmu_7, + cmd_intro_mmu_8, + cmd_intro_mmu_9, + cmd_intro_mmu_10, + cmd_intro_mmu_11, + cmd_intro_mmu_12, +}; + +void lay1cal_intro_line(char *cmd_buffer, uint8_t filament) +{ + if (mmu_enabled) + { + for (uint8_t i = 0; i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i) + { + if (3 == i) + { + sprintf_P(cmd_buffer, PSTR("T%d"), filament); + enquecommand(cmd_buffer); + } + enquecommand_P(static_cast(pgm_read_ptr(&intro_mmu_cmd[i]))); + } + } + else + { + enquecommand_P(PSTR("G1 X60.0 E9.0 F1000.0")); + enquecommand_P(PSTR("G1 X100.0 E12.5 F1000.0")); + } +} diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 5068e337..12f1a3d9 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -7,8 +7,10 @@ #ifndef FIRMWARE_FIRST_LAY_CAL_H_ #define FIRMWARE_FIRST_LAY_CAL_H_ +#include void lay1cal_preheat(); +void lay1cal_intro_line(char *cmd_buffer, uint8_t filament); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 66bc453a..4ce79dc3 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1396,30 +1396,7 @@ void lcd_commands() menu_depth = 0; menu_submenu(lcd_babystep_z); - if (mmu_enabled) - { - enquecommand_P(PSTR("M83")); //intro line - enquecommand_P(PSTR("G1 Y-3.0 F1000.0")); //intro line - enquecommand_P(PSTR("G1 Z0.4 F1000.0")); //intro line - strcpy(cmd1, "T"); - strcat(cmd1, itostr3left(filament)); - enquecommand(cmd1); - enquecommand_P(PSTR("G1 X55.0 E32.0 F1073.0")); //intro line - enquecommand_P(PSTR("G1 X5.0 E32.0 F1800.0")); //intro line - enquecommand_P(PSTR("G1 X55.0 E8.0 F2000.0")); //intro line - enquecommand_P(PSTR("G1 Z0.3 F1000.0")); //intro line - enquecommand_P(PSTR("G92 E0.0")); //intro line - enquecommand_P(PSTR("G1 X240.0 E25.0 F2200.0")); //intro line - enquecommand_P(PSTR("G1 Y-2.0 F1000.0")); //intro line - enquecommand_P(PSTR("G1 X55.0 E25 F1400.0")); //intro line - enquecommand_P(PSTR("G1 Z0.20 F1000.0")); //intro line - enquecommand_P(PSTR("G1 X5.0 E4.0 F1000.0")); //intro line - - } else - { - enquecommand_P(PSTR("G1 X60.0 E9.0 F1000.0")); //intro line - enquecommand_P(PSTR("G1 X100.0 E12.5 F1000.0")); //intro line - } + lay1cal_intro_line(cmd1, filament); lcd_commands_step = 8; } From 58948cffcd6d2e5ccaea6e5508f0144e34619eec Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 11 Jun 2019 16:24:40 +0200 Subject: [PATCH 09/36] Code size reduction - saved almost 2KB --- Firmware/ultralcd.cpp | 114 ++++++++++-------------------------------- Firmware/ultralcd.h | 2 +- 2 files changed, 27 insertions(+), 89 deletions(-) mode change 100644 => 100755 Firmware/ultralcd.h diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4ce79dc3..8a226b4b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -74,8 +74,8 @@ extern void crashdet_disable(); bool presort_flag = false; #endif -int lcd_commands_type = LCD_COMMAND_IDLE; -int lcd_commands_step = 0; +uint8_t lcd_commands_type = LCD_COMMAND_IDLE; +uint8_t lcd_commands_step = 0; unsigned int custom_message_type = CUSTOM_MSG_TYPE_STATUS; unsigned int custom_message_state = 0; @@ -1061,6 +1061,20 @@ static void lcd_status_screen() feedmultiply = 999; } +//! extracted common code from lcd_commands into a separate function +//! along with the sprintf_P optimization this change gained more than 1.6KB +static void lcd_commands_func1(char *cmd1, uint8_t i, float width, float extr, float extr_short_segment){ + static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; + static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; + sprintf_P(cmd1, fmt1, 70, (35 - i*width * 2), extr); + enquecommand(cmd1); + sprintf_P(cmd1, fmt2, (35 - (2 * i + 1)*width), extr_short_segment); + enquecommand(cmd1); + sprintf_P(cmd1, fmt1, 50, (35 - (2 * i + 1)*width), extr); + enquecommand(cmd1); + sprintf_P(cmd1, fmt2, (35 - (i + 1)*width * 2), extr_short_segment); + enquecommand(cmd1); +} void lcd_commands() { @@ -1466,27 +1480,8 @@ void lcd_commands() lcd_timeoutToStatus.start(); - for (int i = 0; i < 4; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 0; i < 4; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 5; @@ -1495,56 +1490,18 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { lcd_timeoutToStatus.start(); - for (int i = 4; i < 8; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 4; i < 8; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 4; } - + if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); - for (int i = 8; i < 12; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + lcd_timeoutToStatus.start(); + for (uint8_t i = 8; i < 12; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 3; @@ -1553,27 +1510,8 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { lcd_timeoutToStatus.start(); - for (int i = 12; i < 16; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 12; i < 16; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 2; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h old mode 100644 new mode 100755 index 665c1233..f8cf8365 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -97,7 +97,7 @@ extern void lcd_diag_show_end_stops(); #define LCD_COMMAND_PID_EXTRUDER 7 #define LCD_COMMAND_V2_CAL 8 -extern int lcd_commands_type; +extern uint8_t lcd_commands_type; extern int8_t FSensorStateMenu; #define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable From 9b1e3213ae35e2c66d41020e04c9c391f82902c1 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 17:25:52 +0200 Subject: [PATCH 10/36] Variable lcd_commands_step doesn't need to be global. --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8a226b4b..6edca9bf 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -75,7 +75,7 @@ bool presort_flag = false; #endif uint8_t lcd_commands_type = LCD_COMMAND_IDLE; -uint8_t lcd_commands_step = 0; +static uint8_t lcd_commands_step = 0; unsigned int custom_message_type = CUSTOM_MSG_TYPE_STATUS; unsigned int custom_message_state = 0; From 97a5d6b5f4037b863ffe6e31cd0160bf5760ac0a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 17:30:37 +0200 Subject: [PATCH 11/36] Make constants const. --- Firmware/ultralcd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6edca9bf..a6d31450 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1363,10 +1363,10 @@ void lcd_commands() { char cmd1[30]; static uint8_t filament = 0; - float width = 0.4; - float length = 20 - width; - float extr = count_e(0.2, width, length); - float extr_short_segment = count_e(0.2, width, width); + const float width = 0.4; + const float length = 20 - width; + const float extr = count_e(0.2, width, length); + const 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 == 0 && !blocks_queued() && cmd_buffer_empty()) From d21f256cd06699a774306ea6f94026a09ff6adec Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 18:26:59 +0200 Subject: [PATCH 12/36] Remove duplicate calls of lcd_timeoutToStatus.start(), move !blocks_queued() && cmd_buffer_empty() condition to outer if, rewrite using switch statement. Save 487B of FLASH memory. --- Firmware/ultralcd.cpp | 293 ++++++++++++++++++------------------------ 1 file changed, 123 insertions(+), 170 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a6d31450..b57196ae 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1367,180 +1367,133 @@ void lcd_commands() const float length = 20 - width; const float extr = count_e(0.2, width, length); const 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 == 0 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_commands_step = 10; - } - if (lcd_commands_step == 20 && !blocks_queued() && cmd_buffer_empty()) - { - filament = 0; - lcd_commands_step = 10; - } - if (lcd_commands_step == 21 && !blocks_queued() && cmd_buffer_empty()) + if (!blocks_queued() && cmd_buffer_empty()) { - filament = 1; - lcd_commands_step = 10; + switch(lcd_commands_step) + { + case 0: + lcd_commands_step = 10; + break; + case 20: + filament = 0; + lcd_commands_step = 10; + break; + case 21: + filament = 1; + lcd_commands_step = 10; + break; + case 22: + filament = 2; + lcd_commands_step = 10; + break; + case 23: + filament = 3; + lcd_commands_step = 10; + break; + case 24: + filament = 4; + lcd_commands_step = 10; + break; + case 10: + lay1cal_preheat(); + lcd_commands_step = 9; + break; + case 9: + lcd_clear(); + menu_depth = 0; + menu_submenu(lcd_babystep_z); + lay1cal_intro_line(cmd1, filament); + lcd_commands_step = 8; + break; + case 8: + enquecommand_P(PSTR("G92 E0.0")); + enquecommand_P(PSTR("G21")); //set units to millimeters + enquecommand_P(PSTR("G90")); //use absolute coordinates + enquecommand_P(PSTR("M83")); //use relative distances for extrusion + enquecommand_P(PSTR("G1 E-1.50000 F2100.00000")); + enquecommand_P(PSTR("G1 Z5 F7200.000")); + enquecommand_P(PSTR("M204 S1000")); //set acceleration + enquecommand_P(PSTR("G1 F4000")); + lcd_commands_step = 7; + break; + case 7: + enquecommand_P(PSTR("G1 X50 Y155")); + enquecommand_P(PSTR("G1 Z0.150 F7200.000")); + enquecommand_P(PSTR("G1 F1080")); + enquecommand_P(PSTR("G1 X75 Y155 E2.5")); + enquecommand_P(PSTR("G1 X100 Y155 E2")); + enquecommand_P(PSTR("G1 X200 Y155 E2.62773")); + enquecommand_P(PSTR("G1 X200 Y135 E0.66174")); + enquecommand_P(PSTR("G1 X50 Y135 E3.62773")); + enquecommand_P(PSTR("G1 X50 Y115 E0.49386")); + enquecommand_P(PSTR("G1 X200 Y115 E3.62773")); + enquecommand_P(PSTR("G1 X200 Y95 E0.49386")); + enquecommand_P(PSTR("G1 X50 Y95 E3.62773")); + enquecommand_P(PSTR("G1 X50 Y75 E0.49386")); + enquecommand_P(PSTR("G1 X200 Y75 E3.62773")); + enquecommand_P(PSTR("G1 X200 Y55 E0.49386")); + enquecommand_P(PSTR("G1 X50 Y55 E3.62773")); + + strcpy(cmd1, "G1 X50 Y35 E"); + strcat(cmd1, ftostr43(extr)); + enquecommand(cmd1); + + lcd_commands_step = 6; + break; + case 6: + for (uint8_t i = 0; i < 4; i++) + { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + } + lcd_commands_step = 5; + break; + case 5: + for (uint8_t i = 4; i < 8; i++) + { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + } + lcd_commands_step = 4; + break; + case 4: + for (uint8_t i = 8; i < 12; i++) + { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + } + lcd_commands_step = 3; + break; + case 3: + for (uint8_t i = 12; i < 16; i++) + { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + } + lcd_commands_step = 2; + break; + case 2: + enquecommand_P(PSTR("M107")); //turn off printer fan + enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); //retract + enquecommand_P(PSTR("M104 S0")); // turn off temperature + enquecommand_P(PSTR("M140 S0")); // turn off heatbed + enquecommand_P(PSTR("G1 Z10 F1300.000")); //lift Z + enquecommand_P(PSTR("G1 X10 Y180 F4000")); //Go to parking position + if (mmu_enabled) enquecommand_P(PSTR("M702 C")); //unload from nozzle + 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_commands_step = 1; + break; + case 1: + lcd_setstatuspgm(_T(WELCOME_MSG)); + lcd_commands_step = 0; + lcd_commands_type = 0; + if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) + { + lcd_wizard(WizState::RepeatLay1Cal); + } + break; + } } - if (lcd_commands_step == 22 && !blocks_queued() && cmd_buffer_empty()) - { - filament = 2; - lcd_commands_step = 10; - } - if (lcd_commands_step == 23 && !blocks_queued() && cmd_buffer_empty()) - { - filament = 3; - lcd_commands_step = 10; - } - if (lcd_commands_step == 24 && !blocks_queued() && cmd_buffer_empty()) - { - filament = 4; - lcd_commands_step = 10; - } - - if (lcd_commands_step == 10) - { - lay1cal_preheat(); - lcd_commands_step = 9; - } - if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_clear(); - menu_depth = 0; - menu_submenu(lcd_babystep_z); - - lay1cal_intro_line(cmd1, filament); - - lcd_commands_step = 8; - } - if (lcd_commands_step == 8 && !blocks_queued() && cmd_buffer_empty()) - { - - enquecommand_P(PSTR("G92 E0.0")); - enquecommand_P(PSTR("G21")); //set units to millimeters - enquecommand_P(PSTR("G90")); //use absolute coordinates - enquecommand_P(PSTR("M83")); //use relative distances for extrusion - enquecommand_P(PSTR("G1 E-1.50000 F2100.00000")); - enquecommand_P(PSTR("G1 Z5 F7200.000")); - enquecommand_P(PSTR("M204 S1000")); //set acceleration - enquecommand_P(PSTR("G1 F4000")); - lcd_commands_step = 7; - } - if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) //draw meander - { - lcd_timeoutToStatus.start(); - - - //just opposite direction - /*enquecommand_P(PSTR("G1 X50 Y55")); - enquecommand_P(PSTR("G1 F1080")); - enquecommand_P(PSTR("G1 X200 Y55 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y75 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y75 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y95 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y95 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y115 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y115 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y135 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y135 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y155 E0.66174")); - enquecommand_P(PSTR("G1 X100 Y155 E2.62773")); - enquecommand_P(PSTR("G1 X75 Y155 E2")); - enquecommand_P(PSTR("G1 X50 Y155 E2.5")); - enquecommand_P(PSTR("G1 E - 0.07500 F2100.00000"));*/ - - - enquecommand_P(PSTR("G1 X50 Y155")); - enquecommand_P(PSTR("G1 Z0.150 F7200.000")); - enquecommand_P(PSTR("G1 F1080")); - enquecommand_P(PSTR("G1 X75 Y155 E2.5")); - enquecommand_P(PSTR("G1 X100 Y155 E2")); - enquecommand_P(PSTR("G1 X200 Y155 E2.62773")); - enquecommand_P(PSTR("G1 X200 Y135 E0.66174")); - enquecommand_P(PSTR("G1 X50 Y135 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y115 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y115 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y95 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y95 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y75 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y75 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y55 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y55 E3.62773")); - - strcpy(cmd1, "G1 X50 Y35 E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - - lcd_commands_step = 6; - } - - if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) - { - - lcd_timeoutToStatus.start(); - - for (uint8_t i = 0; i < 4; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); - } - - lcd_commands_step = 5; - } - - if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_timeoutToStatus.start(); - for (uint8_t i = 4; i < 8; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); - } - - lcd_commands_step = 4; - } - - if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_timeoutToStatus.start(); - for (uint8_t i = 8; i < 12; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); - } - - lcd_commands_step = 3; - } - - if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_timeoutToStatus.start(); - for (uint8_t i = 12; i < 16; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); - } - - lcd_commands_step = 2; - } - - if (lcd_commands_step == 2 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_timeoutToStatus.start(); - enquecommand_P(PSTR("M107")); //turn off printer fan - enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); //retract - enquecommand_P(PSTR("M104 S0")); // turn off temperature - enquecommand_P(PSTR("M140 S0")); // turn off heatbed - enquecommand_P(PSTR("G1 Z10 F1300.000")); //lift Z - enquecommand_P(PSTR("G1 X10 Y180 F4000")); //Go to parking position - if (mmu_enabled) enquecommand_P(PSTR("M702 C")); //unload from nozzle - 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_commands_step = 1; - } - if (lcd_commands_step == 1 && !blocks_queued() && cmd_buffer_empty()) - { - lcd_setstatuspgm(_T(WELCOME_MSG)); - lcd_commands_step = 0; - lcd_commands_type = 0; - if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { - lcd_wizard(WizState::RepeatLay1Cal); - } - } - } #endif // not SNMM From 4effff9e9991a56a14fb246ba5d503faa231b18a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 18:56:29 +0200 Subject: [PATCH 13/36] Use loop to enquecommand_P() in first layer calibration. Save 10B FLASH memory. --- Firmware/first_lay_cal.cpp | 29 +++++++++++++++++++++++++++++ Firmware/first_lay_cal.h | 1 + Firmware/ultralcd.cpp | 9 +-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 60bb5440..0958faaa 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -93,3 +93,32 @@ void lay1cal_intro_line(char *cmd_buffer, uint8_t filament) enquecommand_P(PSTR("G1 X100.0 E12.5 F1000.0")); } } + +static const char cmd_pre_meander_0[] PROGMEM = "G92 E0.0"; +static const char cmd_pre_meander_1[] PROGMEM = "G21"; //set units to millimeters TODO unsupported command +static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates +static const char cmd_pre_meander_3[] PROGMEM = "M83"; //use relative distances for extrusion TODO: duplicate +static const char cmd_pre_meander_4[] PROGMEM = "G1 E-1.50000 F2100.00000"; +static const char cmd_pre_meander_5[] PROGMEM = "G1 Z5 F7200.000"; +static const char cmd_pre_meander_6[] PROGMEM = "M204 S1000"; //set acceleration +static const char cmd_pre_meander_7[] PROGMEM = "G1 F4000"; + +static const char * const cmd_pre_meander[] PROGMEM = +{ + cmd_pre_meander_0, + cmd_pre_meander_1, + cmd_pre_meander_2, + cmd_pre_meander_3, + cmd_pre_meander_4, + cmd_pre_meander_5, + cmd_pre_meander_6, + cmd_pre_meander_7, +}; + +void lay1cal_before_meander() +{ + for (uint8_t i = 0; i < (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0])); ++i) + { + enquecommand_P(static_cast(pgm_read_ptr(&cmd_pre_meander[i]))); + } +} diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 12f1a3d9..b99d691b 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -11,6 +11,7 @@ void lay1cal_preheat(); void lay1cal_intro_line(char *cmd_buffer, uint8_t filament); +void lay1cal_before_meander(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b57196ae..efb58b86 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1409,14 +1409,7 @@ void lcd_commands() lcd_commands_step = 8; break; case 8: - enquecommand_P(PSTR("G92 E0.0")); - enquecommand_P(PSTR("G21")); //set units to millimeters - enquecommand_P(PSTR("G90")); //use absolute coordinates - enquecommand_P(PSTR("M83")); //use relative distances for extrusion - enquecommand_P(PSTR("G1 E-1.50000 F2100.00000")); - enquecommand_P(PSTR("G1 Z5 F7200.000")); - enquecommand_P(PSTR("M204 S1000")); //set acceleration - enquecommand_P(PSTR("G1 F4000")); + lay1cal_before_meander(); lcd_commands_step = 7; break; case 7: From 21f466960043aace1f2a1ac1476f612151f4d225 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 19:22:08 +0200 Subject: [PATCH 14/36] Make count_e() constexpr. --- Firmware/ultralcd.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index efb58b86..23ab61cd 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -246,7 +246,7 @@ 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 constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length); static void lcd_babystep_z(); static void lcd_send_status(); #ifdef FARM_CONNECT_MESSAGE @@ -1680,10 +1680,9 @@ void lcd_commands() } -static float count_e(float layer_heigth, float extrusion_width, float extrusion_length) { +static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length) { //returns filament length in mm which needs to be extrude to form line with extrusion_length * extrusion_width * layer heigth dimensions - float extr = extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4); - return extr; + return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4)); } void lcd_return_to_status() From 47a183e96e5bc6ecb2e049520a4fa805f52ed090 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 19:49:56 +0200 Subject: [PATCH 15/36] Use loop to enquecommand_P() in first layer calibration. Save 126B of FLASH memory. --- Firmware/first_lay_cal.cpp | 45 ++++++++++++++++++++++++++++++++++++++ Firmware/first_lay_cal.h | 1 + Firmware/ultralcd.cpp | 17 +------------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 0958faaa..446b8201 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -122,3 +122,48 @@ void lay1cal_before_meander() enquecommand_P(static_cast(pgm_read_ptr(&cmd_pre_meander[i]))); } } + +static const char cmd_meander_0[] PROGMEM = "G1 X50 Y155"; +static const char cmd_meander_1[] PROGMEM = "G1 Z0.150 F7200.000"; +static const char cmd_meander_2[] PROGMEM = "G1 F1080"; +static const char cmd_meander_3[] PROGMEM = "G1 X75 Y155 E2.5"; +static const char cmd_meander_4[] PROGMEM = "G1 X100 Y155 E2"; +static const char cmd_meander_5[] PROGMEM = "G1 X200 Y155 E2.62773"; +static const char cmd_meander_6[] PROGMEM = "G1 X200 Y135 E0.66174"; +static const char cmd_meander_7[] PROGMEM = "G1 X50 Y135 E3.62773"; +static const char cmd_meander_8[] PROGMEM = "G1 X50 Y115 E0.49386"; +static const char cmd_meander_9[] PROGMEM = "G1 X200 Y115 E3.62773"; +static const char cmd_meander_10[] PROGMEM = "G1 X200 Y95 E0.49386"; +static const char cmd_meander_11[] PROGMEM = "G1 X50 Y95 E3.62773"; +static const char cmd_meander_12[] PROGMEM = "G1 X50 Y75 E0.49386"; +static const char cmd_meander_13[] PROGMEM = "G1 X200 Y75 E3.62773"; +static const char cmd_meander_14[] PROGMEM = "G1 X200 Y55 E0.49386"; +static const char cmd_meander_15[] PROGMEM = "G1 X50 Y55 E3.62773"; + +static const char * const cmd_meander[] PROGMEM = +{ + cmd_meander_0, + cmd_meander_1, + cmd_meander_2, + cmd_meander_3, + cmd_meander_4, + cmd_meander_5, + cmd_meander_6, + cmd_meander_7, + cmd_meander_8, + cmd_meander_9, + cmd_meander_10, + cmd_meander_11, + cmd_meander_12, + cmd_meander_13, + cmd_meander_14, + cmd_meander_15, +}; + +void lay1cal_meander() +{ + for (uint8_t i = 0; i < (sizeof(cmd_meander)/sizeof(cmd_meander[0])); ++i) + { + enquecommand_P(static_cast(pgm_read_ptr(&cmd_meander[i]))); + } +} diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index b99d691b..7ebed5e8 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -12,6 +12,7 @@ void lay1cal_preheat(); void lay1cal_intro_line(char *cmd_buffer, uint8_t filament); void lay1cal_before_meander(); +void lay1cal_meander(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 23ab61cd..1cac19a9 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1413,22 +1413,7 @@ void lcd_commands() lcd_commands_step = 7; break; case 7: - enquecommand_P(PSTR("G1 X50 Y155")); - enquecommand_P(PSTR("G1 Z0.150 F7200.000")); - enquecommand_P(PSTR("G1 F1080")); - enquecommand_P(PSTR("G1 X75 Y155 E2.5")); - enquecommand_P(PSTR("G1 X100 Y155 E2")); - enquecommand_P(PSTR("G1 X200 Y155 E2.62773")); - enquecommand_P(PSTR("G1 X200 Y135 E0.66174")); - enquecommand_P(PSTR("G1 X50 Y135 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y115 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y115 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y95 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y95 E3.62773")); - enquecommand_P(PSTR("G1 X50 Y75 E0.49386")); - enquecommand_P(PSTR("G1 X200 Y75 E3.62773")); - enquecommand_P(PSTR("G1 X200 Y55 E0.49386")); - enquecommand_P(PSTR("G1 X50 Y55 E3.62773")); + lay1cal_meander(); strcpy(cmd1, "G1 X50 Y35 E"); strcat(cmd1, ftostr43(extr)); From 60cc3d58ece82fd52f886e819bde1a33146a137a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 20:00:49 +0200 Subject: [PATCH 16/36] Use sprintf_P in first layer calibration. Save 30B of FLASH memory. --- Firmware/ultralcd.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1cac19a9..c1295f4d 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1414,9 +1414,7 @@ void lcd_commands() break; case 7: lay1cal_meander(); - - strcpy(cmd1, "G1 X50 Y35 E"); - strcat(cmd1, ftostr43(extr)); + sprintf_P(cmd1, PSTR("G1 X50 Y35 E%-.3f"), extr); enquecommand(cmd1); lcd_commands_step = 6; From d528a53526b7d4e241d9943c295fbef035193bb8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 01:36:48 +0200 Subject: [PATCH 17/36] Refactor. Move lcd_commands_func1() to first_lay_cal.cpp and rename it to lay1cal_square(). Remove its constant parameters. Move remaining G1 code to lay1cal_meander(). Saves 6B of FLASH memory. --- Firmware/first_lay_cal.cpp | 41 +++++++++++++++++++++++++++++++++++++- Firmware/first_lay_cal.h | 5 ++--- Firmware/ultralcd.cpp | 38 +++++------------------------------ 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 446b8201..c539ebda 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -160,10 +160,49 @@ static const char * const cmd_meander[] PROGMEM = cmd_meander_15, }; -void lay1cal_meander() +//! @brief Count extrude length +//! +//! @param layer_heigth layer heigth in mm +//! @param extrusion_width extrusion width in mm +//! @param extrusion_length extrusion length in mm +//! @return filament length in mm which needs to be extruded to form line +static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length) +{ + return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4)); +} + +static const float width = 0.4; +static const float length = 20 - width; +static const float extr = count_e(0.2, width, length); + +void lay1cal_meander(char *cmd_buffer) { for (uint8_t i = 0; i < (sizeof(cmd_meander)/sizeof(cmd_meander[0])); ++i) { enquecommand_P(static_cast(pgm_read_ptr(&cmd_meander[i]))); } + sprintf_P(cmd_buffer, PSTR("G1 X50 Y35 E%-.3f"), extr); + enquecommand(cmd_buffer); +} + +//! @brief Print square +//! +//! This function needs to be called 16 times for i from 0 to 15. +//! +//! @par cmd_buffer character buffer needed to format gcodes +//! @par i iteration +void lay1cal_square(char *cmd_buffer, uint8_t i) +{ + const float extr_short_segment = count_e(0.2, width, width); + + static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; + static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; + sprintf_P(cmd_buffer, fmt1, 70, (35 - i*width * 2), extr); + enquecommand(cmd_buffer); + sprintf_P(cmd_buffer, fmt2, (35 - (2 * i + 1)*width), extr_short_segment); + enquecommand(cmd_buffer); + sprintf_P(cmd_buffer, fmt1, 50, (35 - (2 * i + 1)*width), extr); + enquecommand(cmd_buffer); + sprintf_P(cmd_buffer, fmt2, (35 - (i + 1)*width * 2), extr_short_segment); + enquecommand(cmd_buffer); } diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 7ebed5e8..4da415fd 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -12,8 +12,7 @@ void lay1cal_preheat(); void lay1cal_intro_line(char *cmd_buffer, uint8_t filament); void lay1cal_before_meander(); -void lay1cal_meander(); - - +void lay1cal_meander(char *cmd_buffer); +void lay1cal_square(char *cmd_buffer, uint8_t i); #endif /* FIRMWARE_FIRST_LAY_CAL_H_ */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index c1295f4d..be4b1537 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -246,7 +246,6 @@ static char snmm_stop_print_menu(); #ifdef SDCARD_SORT_ALPHA static void lcd_sort_type_set(); #endif -static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length); static void lcd_babystep_z(); static void lcd_send_status(); #ifdef FARM_CONNECT_MESSAGE @@ -1061,21 +1060,6 @@ static void lcd_status_screen() feedmultiply = 999; } -//! extracted common code from lcd_commands into a separate function -//! along with the sprintf_P optimization this change gained more than 1.6KB -static void lcd_commands_func1(char *cmd1, uint8_t i, float width, float extr, float extr_short_segment){ - static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; - static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; - sprintf_P(cmd1, fmt1, 70, (35 - i*width * 2), extr); - enquecommand(cmd1); - sprintf_P(cmd1, fmt2, (35 - (2 * i + 1)*width), extr_short_segment); - enquecommand(cmd1); - sprintf_P(cmd1, fmt1, 50, (35 - (2 * i + 1)*width), extr); - enquecommand(cmd1); - sprintf_P(cmd1, fmt2, (35 - (i + 1)*width * 2), extr_short_segment); - enquecommand(cmd1); -} - void lcd_commands() { if (lcd_commands_type == LCD_COMMAND_LONG_PAUSE) @@ -1363,10 +1347,6 @@ void lcd_commands() { char cmd1[30]; static uint8_t filament = 0; - const float width = 0.4; - const float length = 20 - width; - const float extr = count_e(0.2, width, length); - const 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 @@ -1413,37 +1393,34 @@ void lcd_commands() lcd_commands_step = 7; break; case 7: - lay1cal_meander(); - sprintf_P(cmd1, PSTR("G1 X50 Y35 E%-.3f"), extr); - enquecommand(cmd1); - + lay1cal_meander(cmd1); lcd_commands_step = 6; break; case 6: for (uint8_t i = 0; i < 4; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + lay1cal_square(cmd1, i); } lcd_commands_step = 5; break; case 5: for (uint8_t i = 4; i < 8; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + lay1cal_square(cmd1, i); } lcd_commands_step = 4; break; case 4: for (uint8_t i = 8; i < 12; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + lay1cal_square(cmd1, i); } lcd_commands_step = 3; break; case 3: for (uint8_t i = 12; i < 16; i++) { - lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); + lay1cal_square(cmd1, i); } lcd_commands_step = 2; break; @@ -1663,11 +1640,6 @@ void lcd_commands() } -static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length) { - //returns filament length in mm which needs to be extrude to form line with extrusion_length * extrusion_width * layer heigth dimensions - return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4)); -} - void lcd_return_to_status() { lcd_refresh(); // to maybe revive the LCD if static electricity killed it. From 342954b88ce5f95f1a04d1b9a720ffecf71cbfb0 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 13:31:17 +0200 Subject: [PATCH 18/36] Refactor. Make constants producing first layer calibration square more clear. Note layer height discrepancy. --- Firmware/first_lay_cal.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index c539ebda..32eb4370 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -173,7 +173,8 @@ static constexpr float count_e(float layer_heigth, float extrusion_width, float static const float width = 0.4; static const float length = 20 - width; -static const float extr = count_e(0.2, width, length); +static const float heigth = 0.2; //!< TODO This is wrong, as current Z height is 0.15 mm +static const float extr = count_e(heigth, width, length); void lay1cal_meander(char *cmd_buffer) { @@ -193,7 +194,7 @@ void lay1cal_meander(char *cmd_buffer) //! @par i iteration void lay1cal_square(char *cmd_buffer, uint8_t i) { - const float extr_short_segment = count_e(0.2, width, width); + const float extr_short_segment = count_e(heigth, width, width); static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; From 2755a3733d70401523ce30e9466d60586e09179c Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 14:15:58 +0200 Subject: [PATCH 19/36] Document. --- Firmware/first_lay_cal.cpp | 30 ++++++++++++++++++------------ Firmware/first_lay_cal.h | 9 +++------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 32eb4370..5910873e 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -1,9 +1,8 @@ -/* - * first_lay_cal.cpp - * - * Created on: Jun 10, 2019 - * Author: marek - */ +//! @file +//! @date Jun 10, 2019 +//! @author Marek Bel +//! @brief First layer (Z offset) calibration + #include "first_lay_cal.h" #include "Configuration_prusa.h" #include "language.h" @@ -32,6 +31,7 @@ static const char * const preheat_cmd[] PROGMEM = cmd_preheat_6, }; +//! @brief Preheat void lay1cal_preheat() { for (uint8_t i = 0; i < (sizeof(preheat_cmd)/sizeof(preheat_cmd[0])); ++i) @@ -73,6 +73,9 @@ static const char * const intro_mmu_cmd[] PROGMEM = cmd_intro_mmu_12, }; +//! @brief Print intro line +//! @param cmd_buffer character buffer needed to format gcodes +//! @param filament filament to use (applies for MMU only) void lay1cal_intro_line(char *cmd_buffer, uint8_t filament) { if (mmu_enabled) @@ -115,6 +118,7 @@ static const char * const cmd_pre_meander[] PROGMEM = cmd_pre_meander_7, }; +//! @brief Setup for printing meander void lay1cal_before_meander() { for (uint8_t i = 0; i < (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0])); ++i) @@ -171,11 +175,13 @@ static constexpr float count_e(float layer_heigth, float extrusion_width, float return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4)); } -static const float width = 0.4; -static const float length = 20 - width; -static const float heigth = 0.2; //!< TODO This is wrong, as current Z height is 0.15 mm -static const float extr = count_e(heigth, width, length); +static const float width = 0.4; //!< line width +static const float length = 20 - width; //!< line length +static const float heigth = 0.2; //!< layer height TODO This is wrong, as current Z height is 0.15 mm +static const float extr = count_e(heigth, width, length); //!< E axis movement needed to print line +//! @brief Print meander +//! @param cmd_buffer character buffer needed to format gcodes void lay1cal_meander(char *cmd_buffer) { for (uint8_t i = 0; i < (sizeof(cmd_meander)/sizeof(cmd_meander[0])); ++i) @@ -190,8 +196,8 @@ void lay1cal_meander(char *cmd_buffer) //! //! This function needs to be called 16 times for i from 0 to 15. //! -//! @par cmd_buffer character buffer needed to format gcodes -//! @par i iteration +//! @param cmd_buffer character buffer needed to format gcodes +//! @param i iteration void lay1cal_square(char *cmd_buffer, uint8_t i) { const float extr_short_segment = count_e(heigth, width, width); diff --git a/Firmware/first_lay_cal.h b/Firmware/first_lay_cal.h index 4da415fd..1f338cc5 100644 --- a/Firmware/first_lay_cal.h +++ b/Firmware/first_lay_cal.h @@ -1,9 +1,6 @@ -/* - * first_lay_cal.h - * - * Created on: Jun 10, 2019 - * Author: marek - */ +//! @file +//! @date Jun 10, 2019 +//! @author Marek Bel #ifndef FIRMWARE_FIRST_LAY_CAL_H_ #define FIRMWARE_FIRST_LAY_CAL_H_ From 7ac098a135463334cbf4d08440ecc30e5d33c1e6 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 14:20:20 +0200 Subject: [PATCH 20/36] Refactor. Put constants needed in functions inside fuctions to limit its scope. --- Firmware/first_lay_cal.cpp | 217 ++++++++++++++++++------------------- 1 file changed, 108 insertions(+), 109 deletions(-) diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 5910873e..50f08c5e 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -10,30 +10,28 @@ #include "mmu.h" #include - -static const char cmd_preheat_0[] PROGMEM = "M107"; -static const char cmd_preheat_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); -static const char cmd_preheat_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); -static const char cmd_preheat_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); -static const char cmd_preheat_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); -static const char cmd_preheat_5[] PROGMEM = "G28"; -static const char cmd_preheat_6[] PROGMEM = "G92 E0.0"; - - -static const char * const preheat_cmd[] PROGMEM = -{ - cmd_preheat_0, - cmd_preheat_1, - cmd_preheat_2, - cmd_preheat_3, - cmd_preheat_4, - cmd_preheat_5, //call MSG_M117_V2_CALIBRATION before - cmd_preheat_6, -}; - //! @brief Preheat void lay1cal_preheat() { + static const char cmd_preheat_0[] PROGMEM = "M107"; + static const char cmd_preheat_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); + static const char cmd_preheat_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); + static const char cmd_preheat_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP); + static const char cmd_preheat_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP); + static const char cmd_preheat_5[] PROGMEM = "G28"; + static const char cmd_preheat_6[] PROGMEM = "G92 E0.0"; + + static const char * const preheat_cmd[] PROGMEM = + { + cmd_preheat_0, + cmd_preheat_1, + cmd_preheat_2, + cmd_preheat_3, + cmd_preheat_4, + cmd_preheat_5, //call MSG_M117_V2_CALIBRATION before + cmd_preheat_6, + }; + for (uint8_t i = 0; i < (sizeof(preheat_cmd)/sizeof(preheat_cmd[0])); ++i) { if (5 == i) enquecommand_P(_T(MSG_M117_V2_CALIBRATION)); @@ -42,42 +40,42 @@ void lay1cal_preheat() } -static const char cmd_intro_mmu_0[] PROGMEM = "M83"; -static const char cmd_intro_mmu_1[] PROGMEM = "G1 Y-3.0 F1000.0"; -static const char cmd_intro_mmu_2[] PROGMEM = "G1 Z0.4 F1000.0"; -static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0"; // call T code before -static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E32.0 F1800.0"; -static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55.0 E8.0 F2000.0"; -static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000.0"; -static const char cmd_intro_mmu_7[] PROGMEM = "G92 E0.0"; -static const char cmd_intro_mmu_8[] PROGMEM = "G1 X240.0 E25.0 F2200.0"; -static const char cmd_intro_mmu_9[] PROGMEM = "G1 Y-2.0 F1000.0"; -static const char cmd_intro_mmu_10[] PROGMEM = "G1 X55.0 E25 F1400.0"; -static const char cmd_intro_mmu_11[] PROGMEM = "G1 Z0.20 F1000.0"; -static const char cmd_intro_mmu_12[] PROGMEM = "G1 X5.0 E4.0 F1000.0"; - -static const char * const intro_mmu_cmd[] PROGMEM = -{ - cmd_intro_mmu_0, - cmd_intro_mmu_1, - cmd_intro_mmu_2, - cmd_intro_mmu_3, // call T code before - cmd_intro_mmu_4, - cmd_intro_mmu_5, - cmd_intro_mmu_6, - cmd_intro_mmu_7, - cmd_intro_mmu_8, - cmd_intro_mmu_9, - cmd_intro_mmu_10, - cmd_intro_mmu_11, - cmd_intro_mmu_12, -}; - //! @brief Print intro line //! @param cmd_buffer character buffer needed to format gcodes //! @param filament filament to use (applies for MMU only) void lay1cal_intro_line(char *cmd_buffer, uint8_t filament) { + static const char cmd_intro_mmu_0[] PROGMEM = "M83"; + static const char cmd_intro_mmu_1[] PROGMEM = "G1 Y-3.0 F1000.0"; + static const char cmd_intro_mmu_2[] PROGMEM = "G1 Z0.4 F1000.0"; + static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0"; // call T code before + static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E32.0 F1800.0"; + static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55.0 E8.0 F2000.0"; + static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000.0"; + static const char cmd_intro_mmu_7[] PROGMEM = "G92 E0.0"; + static const char cmd_intro_mmu_8[] PROGMEM = "G1 X240.0 E25.0 F2200.0"; + static const char cmd_intro_mmu_9[] PROGMEM = "G1 Y-2.0 F1000.0"; + static const char cmd_intro_mmu_10[] PROGMEM = "G1 X55.0 E25 F1400.0"; + static const char cmd_intro_mmu_11[] PROGMEM = "G1 Z0.20 F1000.0"; + static const char cmd_intro_mmu_12[] PROGMEM = "G1 X5.0 E4.0 F1000.0"; + + static const char * const intro_mmu_cmd[] PROGMEM = + { + cmd_intro_mmu_0, + cmd_intro_mmu_1, + cmd_intro_mmu_2, + cmd_intro_mmu_3, // call T code before + cmd_intro_mmu_4, + cmd_intro_mmu_5, + cmd_intro_mmu_6, + cmd_intro_mmu_7, + cmd_intro_mmu_8, + cmd_intro_mmu_9, + cmd_intro_mmu_10, + cmd_intro_mmu_11, + cmd_intro_mmu_12, + }; + if (mmu_enabled) { for (uint8_t i = 0; i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i) @@ -97,72 +95,36 @@ void lay1cal_intro_line(char *cmd_buffer, uint8_t filament) } } -static const char cmd_pre_meander_0[] PROGMEM = "G92 E0.0"; -static const char cmd_pre_meander_1[] PROGMEM = "G21"; //set units to millimeters TODO unsupported command -static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates -static const char cmd_pre_meander_3[] PROGMEM = "M83"; //use relative distances for extrusion TODO: duplicate -static const char cmd_pre_meander_4[] PROGMEM = "G1 E-1.50000 F2100.00000"; -static const char cmd_pre_meander_5[] PROGMEM = "G1 Z5 F7200.000"; -static const char cmd_pre_meander_6[] PROGMEM = "M204 S1000"; //set acceleration -static const char cmd_pre_meander_7[] PROGMEM = "G1 F4000"; - -static const char * const cmd_pre_meander[] PROGMEM = -{ - cmd_pre_meander_0, - cmd_pre_meander_1, - cmd_pre_meander_2, - cmd_pre_meander_3, - cmd_pre_meander_4, - cmd_pre_meander_5, - cmd_pre_meander_6, - cmd_pre_meander_7, -}; - //! @brief Setup for printing meander void lay1cal_before_meander() { + static const char cmd_pre_meander_0[] PROGMEM = "G92 E0.0"; + static const char cmd_pre_meander_1[] PROGMEM = "G21"; //set units to millimeters TODO unsupported command + static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates + static const char cmd_pre_meander_3[] PROGMEM = "M83"; //use relative distances for extrusion TODO: duplicate + static const char cmd_pre_meander_4[] PROGMEM = "G1 E-1.50000 F2100.00000"; + static const char cmd_pre_meander_5[] PROGMEM = "G1 Z5 F7200.000"; + static const char cmd_pre_meander_6[] PROGMEM = "M204 S1000"; //set acceleration + static const char cmd_pre_meander_7[] PROGMEM = "G1 F4000"; + + static const char * const cmd_pre_meander[] PROGMEM = + { + cmd_pre_meander_0, + cmd_pre_meander_1, + cmd_pre_meander_2, + cmd_pre_meander_3, + cmd_pre_meander_4, + cmd_pre_meander_5, + cmd_pre_meander_6, + cmd_pre_meander_7, + }; + for (uint8_t i = 0; i < (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0])); ++i) { enquecommand_P(static_cast(pgm_read_ptr(&cmd_pre_meander[i]))); } } -static const char cmd_meander_0[] PROGMEM = "G1 X50 Y155"; -static const char cmd_meander_1[] PROGMEM = "G1 Z0.150 F7200.000"; -static const char cmd_meander_2[] PROGMEM = "G1 F1080"; -static const char cmd_meander_3[] PROGMEM = "G1 X75 Y155 E2.5"; -static const char cmd_meander_4[] PROGMEM = "G1 X100 Y155 E2"; -static const char cmd_meander_5[] PROGMEM = "G1 X200 Y155 E2.62773"; -static const char cmd_meander_6[] PROGMEM = "G1 X200 Y135 E0.66174"; -static const char cmd_meander_7[] PROGMEM = "G1 X50 Y135 E3.62773"; -static const char cmd_meander_8[] PROGMEM = "G1 X50 Y115 E0.49386"; -static const char cmd_meander_9[] PROGMEM = "G1 X200 Y115 E3.62773"; -static const char cmd_meander_10[] PROGMEM = "G1 X200 Y95 E0.49386"; -static const char cmd_meander_11[] PROGMEM = "G1 X50 Y95 E3.62773"; -static const char cmd_meander_12[] PROGMEM = "G1 X50 Y75 E0.49386"; -static const char cmd_meander_13[] PROGMEM = "G1 X200 Y75 E3.62773"; -static const char cmd_meander_14[] PROGMEM = "G1 X200 Y55 E0.49386"; -static const char cmd_meander_15[] PROGMEM = "G1 X50 Y55 E3.62773"; - -static const char * const cmd_meander[] PROGMEM = -{ - cmd_meander_0, - cmd_meander_1, - cmd_meander_2, - cmd_meander_3, - cmd_meander_4, - cmd_meander_5, - cmd_meander_6, - cmd_meander_7, - cmd_meander_8, - cmd_meander_9, - cmd_meander_10, - cmd_meander_11, - cmd_meander_12, - cmd_meander_13, - cmd_meander_14, - cmd_meander_15, -}; //! @brief Count extrude length //! @@ -184,6 +146,43 @@ static const float extr = count_e(heigth, width, length); //!< E axis movement n //! @param cmd_buffer character buffer needed to format gcodes void lay1cal_meander(char *cmd_buffer) { + static const char cmd_meander_0[] PROGMEM = "G1 X50 Y155"; + static const char cmd_meander_1[] PROGMEM = "G1 Z0.150 F7200.000"; + static const char cmd_meander_2[] PROGMEM = "G1 F1080"; + static const char cmd_meander_3[] PROGMEM = "G1 X75 Y155 E2.5"; + static const char cmd_meander_4[] PROGMEM = "G1 X100 Y155 E2"; + static const char cmd_meander_5[] PROGMEM = "G1 X200 Y155 E2.62773"; + static const char cmd_meander_6[] PROGMEM = "G1 X200 Y135 E0.66174"; + static const char cmd_meander_7[] PROGMEM = "G1 X50 Y135 E3.62773"; + static const char cmd_meander_8[] PROGMEM = "G1 X50 Y115 E0.49386"; + static const char cmd_meander_9[] PROGMEM = "G1 X200 Y115 E3.62773"; + static const char cmd_meander_10[] PROGMEM = "G1 X200 Y95 E0.49386"; + static const char cmd_meander_11[] PROGMEM = "G1 X50 Y95 E3.62773"; + static const char cmd_meander_12[] PROGMEM = "G1 X50 Y75 E0.49386"; + static const char cmd_meander_13[] PROGMEM = "G1 X200 Y75 E3.62773"; + static const char cmd_meander_14[] PROGMEM = "G1 X200 Y55 E0.49386"; + static const char cmd_meander_15[] PROGMEM = "G1 X50 Y55 E3.62773"; + + static const char * const cmd_meander[] PROGMEM = + { + cmd_meander_0, + cmd_meander_1, + cmd_meander_2, + cmd_meander_3, + cmd_meander_4, + cmd_meander_5, + cmd_meander_6, + cmd_meander_7, + cmd_meander_8, + cmd_meander_9, + cmd_meander_10, + cmd_meander_11, + cmd_meander_12, + cmd_meander_13, + cmd_meander_14, + cmd_meander_15, + }; + for (uint8_t i = 0; i < (sizeof(cmd_meander)/sizeof(cmd_meander[0])); ++i) { enquecommand_P(static_cast(pgm_read_ptr(&cmd_meander[i]))); From b15bbaf1779acdea717c34274e957f5f9b21b9bf Mon Sep 17 00:00:00 2001 From: DRracer Date: Wed, 12 Jun 2019 10:31:09 +0200 Subject: [PATCH 21/36] for cycles' variables: int -> uint8_t where appropriate, part1 --- Firmware/temperature.cpp | 2 +- Firmware/tmc2130.cpp | 10 +++++----- Firmware/ultralcd.cpp | 32 ++++++++++++++++---------------- 3 files changed, 22 insertions(+), 22 deletions(-) mode change 100644 => 100755 Firmware/tmc2130.cpp diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 9c49cf79..03845b12 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -434,7 +434,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { + for(uint8_t e = 0; e < EXTRUDERS; e++) { iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; } #endif diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp old mode 100644 new mode 100755 index 05ea2ab6..fe04e8da --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -158,7 +158,7 @@ void tmc2130_init() SET_INPUT(Y_TMC2130_DIAG); SET_INPUT(Z_TMC2130_DIAG); SET_INPUT(E0_TMC2130_DIAG); - for (int axis = 0; axis < 2; axis++) // X Y axes + for (uint8_t axis = 0; axis < 2; axis++) // X Y axes { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -169,7 +169,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); //tmc2130_wr_THIGH(axis, TMC2130_THIGH); } - for (int axis = 2; axis < 3; axis++) // Z axis + for (uint8_t axis = 2; axis < 3; axis++) // Z axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -183,7 +183,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); #endif //TMC2130_STEALTH_Z } - for (int axis = 3; axis < 4; axis++) // E axis + for (uint8_t axis = 3; axis < 4; axis++) // E axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -383,7 +383,7 @@ void tmc2130_check_overtemp() static uint32_t checktime = 0; if (_millis() - checktime > 1000 ) { - for (int i = 0; i < 4; i++) + for (uint8_t i = 0; i < 4; i++) { uint32_t drv_status = 0; skip_debug_msg = true; @@ -392,7 +392,7 @@ void tmc2130_check_overtemp() { // BIT 26 - over temp prewarning ~120C (+-20C) SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP); SERIAL_ECHOLN(i); - for (int j = 0; j < 4; j++) + for (uint8_t j = 0; j < 4; j++) tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000); kill(MSG_TMC_OVERTEMP); } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index be4b1537..c19555d5 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -317,7 +317,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, char* longF char c; int enc_dif = lcd_encoder_diff; uint8_t n = LCD_WIDTH - 1; - for(int g = 0; g<4;g++){ + for(uint8_t g = 0; g<4;g++){ lcd_set_cursor(0, g); lcd_print(' '); } @@ -2578,11 +2578,11 @@ void lcd_change_success() { static void lcd_loading_progress_bar(uint16_t loading_time_ms) { - for (int i = 0; i < 20; i++) { + for (uint8_t i = 0; i < 20; i++) { lcd_set_cursor(i, 3); lcd_print("."); //loading_time_ms/20 delay - for (int j = 0; j < 5; j++) { + for (uint8_t j = 0; j < 5; j++) { delay_keep_alive(loading_time_ms / 100); } } @@ -3024,7 +3024,7 @@ static void lcd_menu_xyz_offset() float cntr[2]; world2machine_read_valid(vec_x, vec_y, cntr); - for (int i = 0; i < 2; i++) + for (uint8_t i = 0; i < 2; i++) { lcd_puts_at_P(11, i + 2, PSTR("")); lcd_print(cntr[i]); @@ -4692,7 +4692,7 @@ void lcd_v2_calibration() else { lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 lcd_consume_click(); - for (int i = 0; i < 20; i++) { //wait max. 2s + for (uint8_t i = 0; i < 20; i++) { //wait max. 2s delay_keep_alive(100); if (lcd_clicked()) { break; @@ -5419,7 +5419,7 @@ void bowden_menu() { lcd_clear(); lcd_set_cursor(0, 0); lcd_print(">"); - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5507,7 +5507,7 @@ void bowden_menu() { enc_dif = lcd_encoder_diff; lcd_set_cursor(0, cursor_pos); lcd_print(">"); - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5634,14 +5634,14 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite if (header) lcd_puts_at_P(0,0,header); const bool last_visible = (first == items_no - 3); - const int8_t ordinary_items = (last_item&&last_visible)?2:3; + const uint8_t ordinary_items = (last_item&&last_visible)?2:3; - for (int i = 0; i < ordinary_items; i++) + for (uint8_t i = 0; i < ordinary_items; i++) { if (item) lcd_puts_at_P(1, i + 1, item); } - for (int i = 0; i < ordinary_items; i++) + for (uint8_t i = 0; i < ordinary_items; i++) { lcd_set_cursor(2 + item_len, i+1); lcd_print(first + i + 1); @@ -5695,7 +5695,7 @@ char reset_menu() { lcd_consume_click(); while (1) { - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print(item[first + i]); } @@ -6021,7 +6021,7 @@ unsigned char lcd_choose_color() { item[0] = "Orange"; item[1] = "Black"; //----------------------------------------------------- - unsigned char active_rows; + uint8_t active_rows; static int first = 0; int enc_dif = 0; unsigned char cursor_pos = 1; @@ -6034,7 +6034,7 @@ unsigned char lcd_choose_color() { lcd_consume_click(); while (1) { lcd_puts_at_P(0, 0, PSTR("Choose color:")); - for (int i = 0; i < active_rows; i++) { + for (uint8_t i = 0; i < active_rows; i++) { lcd_set_cursor(1, i+1); lcd_print(item[first + i]); } @@ -7071,7 +7071,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { //end of second measurement, now check for possible errors: - for(int i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length + for(uint8_t i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length printf_P(_N("Measured axis length:%.3f\n"), measured_axis_length[i]); if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { enable_endstops(false); @@ -7935,7 +7935,7 @@ static void menu_action_sdfile(const char* filename) const char end[5] = ".gco"; //we are storing just first 8 characters of 8.3 filename assuming that extension is always ".gco" - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (strcmp((cmd + i + 4), end) == 0) { //filename is shorter then 8.3, store '\0' character on position where ".gco" string was found to terminate stored string properly eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, '\0'); @@ -7950,7 +7950,7 @@ static void menu_action_sdfile(const char* filename) eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth); for (uint8_t i = 0; i < depth; i++) { - for (int j = 0; j < 8; j++) { + for (uint8_t j = 0; j < 8; j++) { eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]); } } From 49f172a7b9fd2ea71425122b5acf2df4679e1ec9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 15:01:57 +0200 Subject: [PATCH 22/36] Convert uint8_t cycle control varibles changed in previous commit to uint_least8_t to be potentially more portable. --- Firmware/temperature.cpp | 2 +- Firmware/tmc2130.cpp | 10 +++++----- Firmware/ultralcd.cpp | 34 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 03845b12..08d1a55b 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -434,7 +434,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); void updatePID() { #ifdef PIDTEMP - for(uint8_t e = 0; e < EXTRUDERS; e++) { + for(uint_least8_t e = 0; e < EXTRUDERS; e++) { iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; } #endif diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index fe04e8da..7bfd9708 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -158,7 +158,7 @@ void tmc2130_init() SET_INPUT(Y_TMC2130_DIAG); SET_INPUT(Z_TMC2130_DIAG); SET_INPUT(E0_TMC2130_DIAG); - for (uint8_t axis = 0; axis < 2; axis++) // X Y axes + for (uint_least8_t axis = 0; axis < 2; axis++) // X Y axes { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -169,7 +169,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); //tmc2130_wr_THIGH(axis, TMC2130_THIGH); } - for (uint8_t axis = 2; axis < 3; axis++) // Z axis + for (uint_least8_t axis = 2; axis < 3; axis++) // Z axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -183,7 +183,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); #endif //TMC2130_STEALTH_Z } - for (uint8_t axis = 3; axis < 4; axis++) // E axis + for (uint_least8_t axis = 3; axis < 4; axis++) // E axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -383,7 +383,7 @@ void tmc2130_check_overtemp() static uint32_t checktime = 0; if (_millis() - checktime > 1000 ) { - for (uint8_t i = 0; i < 4; i++) + for (uint_least8_t i = 0; i < 4; i++) { uint32_t drv_status = 0; skip_debug_msg = true; @@ -392,7 +392,7 @@ void tmc2130_check_overtemp() { // BIT 26 - over temp prewarning ~120C (+-20C) SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP); SERIAL_ECHOLN(i); - for (uint8_t j = 0; j < 4; j++) + for (uint_least8_t j = 0; j < 4; j++) tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000); kill(MSG_TMC_OVERTEMP); } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index c19555d5..c22b9581 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -317,7 +317,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, char* longF char c; int enc_dif = lcd_encoder_diff; uint8_t n = LCD_WIDTH - 1; - for(uint8_t g = 0; g<4;g++){ + for(uint_least8_t g = 0; g<4;g++){ lcd_set_cursor(0, g); lcd_print(' '); } @@ -2578,11 +2578,11 @@ void lcd_change_success() { static void lcd_loading_progress_bar(uint16_t loading_time_ms) { - for (uint8_t i = 0; i < 20; i++) { + for (uint_least8_t i = 0; i < 20; i++) { lcd_set_cursor(i, 3); lcd_print("."); //loading_time_ms/20 delay - for (uint8_t j = 0; j < 5; j++) { + for (uint_least8_t j = 0; j < 5; j++) { delay_keep_alive(loading_time_ms / 100); } } @@ -3024,7 +3024,7 @@ static void lcd_menu_xyz_offset() float cntr[2]; world2machine_read_valid(vec_x, vec_y, cntr); - for (uint8_t i = 0; i < 2; i++) + for (uint_least8_t i = 0; i < 2; i++) { lcd_puts_at_P(11, i + 2, PSTR("")); lcd_print(cntr[i]); @@ -4692,7 +4692,7 @@ void lcd_v2_calibration() else { lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 lcd_consume_click(); - for (uint8_t i = 0; i < 20; i++) { //wait max. 2s + for (uint_least8_t i = 0; i < 20; i++) { //wait max. 2s delay_keep_alive(100); if (lcd_clicked()) { break; @@ -5419,7 +5419,7 @@ void bowden_menu() { lcd_clear(); lcd_set_cursor(0, 0); lcd_print(">"); - for (uint8_t i = 0; i < 4; i++) { + for (uint_least8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5507,7 +5507,7 @@ void bowden_menu() { enc_dif = lcd_encoder_diff; lcd_set_cursor(0, cursor_pos); lcd_print(">"); - for (uint8_t i = 0; i < 4; i++) { + for (uint_least8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5634,14 +5634,14 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite if (header) lcd_puts_at_P(0,0,header); const bool last_visible = (first == items_no - 3); - const uint8_t ordinary_items = (last_item&&last_visible)?2:3; + const uint_least8_t ordinary_items = (last_item&&last_visible)?2:3; - for (uint8_t i = 0; i < ordinary_items; i++) + for (uint_least8_t i = 0; i < ordinary_items; i++) { if (item) lcd_puts_at_P(1, i + 1, item); } - for (uint8_t i = 0; i < ordinary_items; i++) + for (uint_least8_t i = 0; i < ordinary_items; i++) { lcd_set_cursor(2 + item_len, i+1); lcd_print(first + i + 1); @@ -5695,7 +5695,7 @@ char reset_menu() { lcd_consume_click(); while (1) { - for (uint8_t i = 0; i < 4; i++) { + for (uint_least8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print(item[first + i]); } @@ -6021,7 +6021,7 @@ unsigned char lcd_choose_color() { item[0] = "Orange"; item[1] = "Black"; //----------------------------------------------------- - uint8_t active_rows; + uint_least8_t active_rows; static int first = 0; int enc_dif = 0; unsigned char cursor_pos = 1; @@ -6034,7 +6034,7 @@ unsigned char lcd_choose_color() { lcd_consume_click(); while (1) { lcd_puts_at_P(0, 0, PSTR("Choose color:")); - for (uint8_t i = 0; i < active_rows; i++) { + for (uint_least8_t i = 0; i < active_rows; i++) { lcd_set_cursor(1, i+1); lcd_print(item[first + i]); } @@ -7071,7 +7071,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { //end of second measurement, now check for possible errors: - for(uint8_t i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length + for(uint_least8_t i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length printf_P(_N("Measured axis length:%.3f\n"), measured_axis_length[i]); if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { enable_endstops(false); @@ -7935,7 +7935,7 @@ static void menu_action_sdfile(const char* filename) const char end[5] = ".gco"; //we are storing just first 8 characters of 8.3 filename assuming that extension is always ".gco" - for (uint8_t i = 0; i < 8; i++) { + for (uint_least8_t i = 0; i < 8; i++) { if (strcmp((cmd + i + 4), end) == 0) { //filename is shorter then 8.3, store '\0' character on position where ".gco" string was found to terminate stored string properly eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, '\0'); @@ -7949,8 +7949,8 @@ static void menu_action_sdfile(const char* filename) uint8_t depth = (uint8_t)card.getWorkDirDepth(); eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth); - for (uint8_t i = 0; i < depth; i++) { - for (uint8_t j = 0; j < 8; j++) { + for (uint_least8_t i = 0; i < depth; i++) { + for (uint_least8_t j = 0; j < 8; j++) { eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]); } } From 94a51759802837b73cb1220dd90433a6b1c094d7 Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 11 Jun 2019 16:24:40 +0200 Subject: [PATCH 23/36] Code size reduction - saved almost 2KB --- Firmware/ultralcd.cpp | 114 ++++++++++-------------------------------- Firmware/ultralcd.h | 2 +- 2 files changed, 27 insertions(+), 89 deletions(-) mode change 100644 => 100755 Firmware/ultralcd.h diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f69efbbc..b7f7e68d 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -73,8 +73,8 @@ extern void crashdet_disable(); bool presort_flag = false; #endif -int lcd_commands_type = LCD_COMMAND_IDLE; -int lcd_commands_step = 0; +uint8_t lcd_commands_type = LCD_COMMAND_IDLE; +uint8_t lcd_commands_step = 0; unsigned int custom_message_type = CUSTOM_MSG_TYPE_STATUS; unsigned int custom_message_state = 0; @@ -1060,6 +1060,20 @@ static void lcd_status_screen() feedmultiply = 999; } +//! extracted common code from lcd_commands into a separate function +//! along with the sprintf_P optimization this change gained more than 1.6KB +static void lcd_commands_func1(char *cmd1, uint8_t i, float width, float extr, float extr_short_segment){ + static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; + static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; + sprintf_P(cmd1, fmt1, 70, (35 - i*width * 2), extr); + enquecommand(cmd1); + sprintf_P(cmd1, fmt2, (35 - (2 * i + 1)*width), extr_short_segment); + enquecommand(cmd1); + sprintf_P(cmd1, fmt1, 50, (35 - (2 * i + 1)*width), extr); + enquecommand(cmd1); + sprintf_P(cmd1, fmt2, (35 - (i + 1)*width * 2), extr_short_segment); + enquecommand(cmd1); +} void lcd_commands() { @@ -1496,27 +1510,8 @@ void lcd_commands() lcd_timeoutToStatus.start(); - for (int i = 0; i < 4; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 0; i < 4; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 5; @@ -1525,56 +1520,18 @@ void lcd_commands() if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) { lcd_timeoutToStatus.start(); - for (int i = 4; i < 8; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 4; i < 8; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 4; } - + if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) { - lcd_timeoutToStatus.start(); - for (int i = 8; i < 12; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + lcd_timeoutToStatus.start(); + for (uint8_t i = 8; i < 12; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 3; @@ -1583,27 +1540,8 @@ void lcd_commands() if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) { lcd_timeoutToStatus.start(); - for (int i = 12; i < 16; i++) { - strcpy(cmd1, "G1 X70 Y"); - strcat(cmd1, ftostr32(35 - i*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); - strcpy(cmd1, "G1 X50 Y"); - strcat(cmd1, ftostr32(35 - (2 * i + 1)*width)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr)); - enquecommand(cmd1); - strcpy(cmd1, "G1 Y"); - strcat(cmd1, ftostr32(35 - (i + 1)*width * 2)); - strcat(cmd1, " E"); - strcat(cmd1, ftostr43(extr_short_segment)); - enquecommand(cmd1); + for (uint8_t i = 12; i < 16; i++) { + lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); } lcd_commands_step = 2; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h old mode 100644 new mode 100755 index 665c1233..f8cf8365 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -97,7 +97,7 @@ extern void lcd_diag_show_end_stops(); #define LCD_COMMAND_PID_EXTRUDER 7 #define LCD_COMMAND_V2_CAL 8 -extern int lcd_commands_type; +extern uint8_t lcd_commands_type; extern int8_t FSensorStateMenu; #define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable From c7e1e738808d82d533d43e9bea09a228245262ad Mon Sep 17 00:00:00 2001 From: DRracer Date: Wed, 12 Jun 2019 09:58:42 +0200 Subject: [PATCH 24/36] another almost 200B down by proper usage of smaller data types and enum classes --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 38 +++---- Firmware/cmdqueue.cpp | 2 +- Firmware/mmu.cpp | 6 +- Firmware/ultralcd.cpp | 236 +++++++++++++++++++-------------------- Firmware/ultralcd.h | 59 +++++----- 6 files changed, 174 insertions(+), 169 deletions(-) mode change 100644 => 100755 Firmware/Marlin.h mode change 100644 => 100755 Firmware/cmdqueue.cpp mode change 100644 => 100755 Firmware/mmu.cpp diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h old mode 100644 new mode 100755 index 2e60597d..f53e55cc --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -389,7 +389,7 @@ extern bool wizard_active; //autoload temporarily disabled during wizard extern LongTimer safetyTimer; #define PRINT_PERCENT_DONE_INIT 0xff -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsgTypes::TEMCAL) || saved_printing || (lcd_commands_type == LcdCommands::V2_CAL) || card.paused || mmu_print_saved) //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 711c428b..e0846228 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3157,7 +3157,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float #endif //IR_SENSOR lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; } //! @brief Rise Z if too low to avoid blob/jam before filament loading @@ -3181,7 +3181,7 @@ void gcode_M701() else { enable_z(); - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; + custom_message_type = CustomMsgTypes::F_LOAD; #ifdef FSENSOR_QUALITY fsensor_oq_meassure_start(40); @@ -3211,7 +3211,7 @@ void gcode_M701() lcd_setstatuspgm(_T(WELCOME_MSG)); disable_z(); loading_flag = false; - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; #ifdef FSENSOR_QUALITY fsensor_oq_meassure_stop(); @@ -4194,7 +4194,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // setTargetHotend(200, 0); setTargetBed(70 + (start_temp - 30)); - custom_message_type = CUSTOM_MSG_TYPE_TEMCAL; + custom_message_type = CustomMsgTypes::TEMCAL; custom_message_state = 1; lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; @@ -4296,7 +4296,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } puts_P(_N("PINDA probe calibration start")); - custom_message_type = CUSTOM_MSG_TYPE_TEMCAL; + custom_message_type = CustomMsgTypes::TEMCAL; custom_message_state = 1; lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[X_AXIS] = PINDA_PREHEAT_X; @@ -4364,7 +4364,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); puts_P(_N("Temperature calibration done.")); @@ -4424,7 +4424,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // We don't know where we are! HOME! // Push the commands to the front of the message queue in the reverse order! // There shall be always enough space reserved for these commands. - if (lcd_commands_type != LCD_COMMAND_STOP_PRINT) { + if (lcd_commands_type != LcdCommands::STOP_PRINT) { repeatcommand_front(); // repeat G80 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); } @@ -4464,7 +4464,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (temp_comp_start) if (run == false && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { - if (lcd_commands_type != LCD_COMMAND_STOP_PRINT) { + if (lcd_commands_type != LcdCommands::STOP_PRINT) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters @@ -4476,14 +4476,14 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } run = false; - if (lcd_commands_type == LCD_COMMAND_STOP_PRINT) { + if (lcd_commands_type == LcdCommands::STOP_PRINT) { mesh_bed_leveling_flag = false; break; } // Save custom message state, set a new custom message state to display: Calibrating point 9. - unsigned int custom_message_type_old = custom_message_type; + CustomMsgTypes custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CUSTOM_MSG_TYPE_MESHBL; + custom_message_type = CustomMsgTypes::MESHBL; custom_message_state = (nMeasPoints * nMeasPoints) + 10; lcd_update(1); @@ -4683,7 +4683,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) enable_z_endstop(bState); } while (st_get_position_mm(Z_AXIS) > MESH_HOME_Z_SEARCH); // i.e. Z-leveling not o.k. // plan_set_z_position(MESH_HOME_Z_SEARCH); // is not necessary ('do-while' loop always ends at the expected Z-position) - custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery + custom_message_type=CustomMsgTypes::STATUS; // display / status-line recovery lcd_update_enable(true); // display / status-line recovery gcode_G28(true, true, true); // X & Y & Z-homing (must be after individual Z-homing (problem with spool-holder)!) repeatcommand_front(); // re-run (i.e. of "G80") @@ -7693,9 +7693,9 @@ bool bInhibitFlag; #ifdef IR_SENSOR bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active #endif // IR_SENSOR - if ((mcode_in_progress != 600) && (eFilamentAction != e_FILAMENT_ACTION_autoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active + if ((mcode_in_progress != 600) && (eFilamentAction != eFILAMENT_ACTION::autoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { - if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL) && !wizard_active) + if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL) && !wizard_active) { if (fsensor_check_autoload()) { @@ -7719,7 +7719,7 @@ if(0) show_preheat_nozzle_warning(); lcd_update_enable(true); */ - eFilamentAction=e_FILAMENT_ACTION_autoLoad; + eFilamentAction=eFILAMENT_ACTION::autoLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -8210,7 +8210,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CUSTOM_MSG_TYPE_MESHBL; + custom_message_type = CustomMsgTypes::MESHBL; custom_message_state = (x_points_num * y_points_num) + 10; lcd_update(1); @@ -8408,7 +8408,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ } unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CUSTOM_MSG_TYPE_MESHBL; + custom_message_type = CustomMsgTypes::MESHBL; custom_message_state = (x_points_num * y_points_num) + 10; lcd_update(1); @@ -8558,7 +8558,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ void temp_compensation_start() { - custom_message_type = CUSTOM_MSG_TYPE_TEMPRE; + custom_message_type = CustomMsgTypes::TEMPRE; custom_message_state = PINDA_HEAT_T + 1; lcd_update(2); if (degHotend(active_extruder) > EXTRUDE_MINTEMP) { @@ -8579,7 +8579,7 @@ void temp_compensation_start() { if (custom_message_state == 99 || custom_message_state == 9) lcd_update(2); //force whole display redraw if number of digits changed else lcd_update(1); } - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; custom_message_state = 0; } diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp old mode 100644 new mode 100755 index 2e29ad5f..1e1167c4 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -598,7 +598,7 @@ void get_command() if (farm_mode) { prusa_statistics(6); - lcd_commands_type = LCD_COMMAND_FARM_MODE_CONFIRM; + lcd_commands_type = LcdCommands::FARM_MODE_CONFIRM; } } diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp old mode 100644 new mode 100755 index 916b3d0f..c289f31d --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1076,7 +1076,7 @@ if(0) extr_unload(); } else { - eFilamentAction=e_FILAMENT_ACTION_mmuUnLoad; + eFilamentAction=eFILAMENT_ACTION::mmuUnLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -1372,13 +1372,13 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) mmu_load_to_nozzle(); load_filament_final_feed(); st_synchronize(); - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; + custom_message_type = CustomMsgTypes::F_LOAD; lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); lcd_return_to_status(); lcd_update_enable(true); lcd_load_filament_color_check(); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; } else { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b7f7e68d..19601df3 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -73,10 +73,10 @@ extern void crashdet_disable(); bool presort_flag = false; #endif -uint8_t lcd_commands_type = LCD_COMMAND_IDLE; +LcdCommands lcd_commands_type = LcdCommands::IDLE; uint8_t lcd_commands_step = 0; -unsigned int custom_message_type = CUSTOM_MSG_TYPE_STATUS; +CustomMsgTypes custom_message_type = CustomMsgTypes::STATUS; unsigned int custom_message_state = 0; @@ -84,7 +84,7 @@ bool isPrintPaused = false; uint8_t farm_mode = 0; int farm_no = 0; int farm_timer = 8; -int farm_status = 0; +uint8_t farm_status = 0; bool printer_connected = true; unsigned long display_time; //just timer for showing pid finished message on lcd; @@ -565,7 +565,7 @@ void lcdui_print_temp(char type, int val_current, int val_target) // Print Z-coordinate (8 chars total) void lcdui_print_Z_coord(void) { - if (custom_message_type == CUSTOM_MSG_TYPE_MESHBL) + if (custom_message_type == CustomMsgTypes::MESHBL) lcd_puts_P(_N("Z --- ")); else lcd_printf_P(_N("Z%6.2f "), current_position[Z_AXIS]); @@ -760,7 +760,7 @@ void lcdui_print_status_line(void) break; } } - else if ((IS_SD_PRINTING) && (custom_message_type == CUSTOM_MSG_TYPE_STATUS)) + else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsgTypes::STATUS)) { // If printing from SD, show what we are printing if(strlen(card.longFilename) > LCD_WIDTH) { @@ -794,10 +794,10 @@ void lcdui_print_status_line(void) { // Otherwise check for other special events switch (custom_message_type) { - case CUSTOM_MSG_TYPE_STATUS: // Nothing special, print status message normally + case CustomMsgTypes::STATUS: // Nothing special, print status message normally lcd_print(lcd_status_message); break; - case CUSTOM_MSG_TYPE_MESHBL: // If mesh bed leveling in progress, show the status + case CustomMsgTypes::MESHBL: // If mesh bed leveling in progress, show the status if (custom_message_state > 10) { lcd_set_cursor(0, 3); @@ -813,7 +813,7 @@ void lcdui_print_status_line(void) { lcd_puts_P(_T(WELCOME_MSG)); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; } if (custom_message_state > 3 && custom_message_state <= 10 ) { @@ -825,10 +825,10 @@ void lcdui_print_status_line(void) } } break; - case CUSTOM_MSG_TYPE_F_LOAD: // If loading filament, print status + case CustomMsgTypes::F_LOAD: // If loading filament, print status lcd_print(lcd_status_message); break; - case CUSTOM_MSG_TYPE_PIDCAL: // PID tuning in progress + case CustomMsgTypes::PIDCAL: // PID tuning in progress lcd_print(lcd_status_message); if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) { @@ -838,7 +838,7 @@ void lcdui_print_status_line(void) lcd_print(itostr3left(pid_number_of_cycles)); } break; - case CUSTOM_MSG_TYPE_TEMCAL: // PINDA temp calibration in progress + case CustomMsgTypes::TEMCAL: // PINDA temp calibration in progress { char progress[4]; lcd_set_cursor(0, 3); @@ -848,7 +848,7 @@ void lcdui_print_status_line(void) lcd_print(progress); } break; - case CUSTOM_MSG_TYPE_TEMPRE: // temp compensation preheat + case CustomMsgTypes::TEMPRE: // temp compensation preheat lcd_set_cursor(0, 3); lcd_puts_P(_i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 if (custom_message_state <= PINDA_HEAT_T) @@ -996,7 +996,7 @@ static void lcd_status_screen() } // end of farm_mode lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ - if (lcd_commands_type != LCD_COMMAND_IDLE) + if (lcd_commands_type != LcdCommands::IDLE) lcd_commands(); } // end of lcd_draw_update @@ -1020,7 +1020,7 @@ static void lcd_status_screen() } if (current_click - && (lcd_commands_type != LCD_COMMAND_STOP_PRINT) //click is aborted unless stop print finishes + && (lcd_commands_type != LcdCommands::STOP_PRINT) //click is aborted unless stop print finishes && ( menu_block_entering_on_serious_errors == SERIOUS_ERR_NONE ) // or a serious error blocks entering the menu ) { @@ -1077,15 +1077,15 @@ static void lcd_commands_func1(char *cmd1, uint8_t i, float width, float extr, f void lcd_commands() { - if (lcd_commands_type == LCD_COMMAND_LONG_PAUSE) + if (lcd_commands_type == LcdCommands::LONG_PAUSE) { if (!blocks_queued() && !homing_flag) { lcd_setstatuspgm(_i("Print paused"));////MSG_PRINT_PAUSED c=20 r=1 long_pause(); - if (lcd_commands_type == LCD_COMMAND_LONG_PAUSE) // !!! because "lcd_commands_type" can be changed during/inside "long_pause()" + if (lcd_commands_type == LcdCommands::LONG_PAUSE) // !!! because "lcd_commands_type" can be changed during/inside "long_pause()" { - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; lcd_commands_step = 0; } } @@ -1093,7 +1093,7 @@ void lcd_commands() #ifdef SNMM - if (lcd_commands_type == LCD_COMMAND_V2_CAL) + if (lcd_commands_type == LcdCommands::V2_CAL) { char cmd1[30]; float width = 0.4; @@ -1358,7 +1358,7 @@ void lcd_commands() #else //if not SNMM - if (lcd_commands_type == LCD_COMMAND_V2_CAL) + if (lcd_commands_type == LcdCommands::V2_CAL) { char cmd1[30]; static uint8_t filament = 0; @@ -1565,7 +1565,7 @@ void lcd_commands() { lcd_setstatuspgm(_T(WELCOME_MSG)); lcd_commands_step = 0; - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { lcd_wizard(WizState::RepeatLay1Cal); } @@ -1575,7 +1575,7 @@ void lcd_commands() #endif // not SNMM - if (lcd_commands_type == LCD_COMMAND_STOP_PRINT) /// stop print + if (lcd_commands_type == LcdCommands::STOP_PRINT) /// stop print { @@ -1587,9 +1587,9 @@ void lcd_commands() if (lcd_commands_step == 1 && !blocks_queued()) { lcd_commands_step = 0; - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; isPrintPaused = false; } if (lcd_commands_step == 2 && !blocks_queued()) @@ -1645,7 +1645,7 @@ void lcd_commands() if (mmu_enabled) setAllTargetHotends(0); manage_heater(); - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; + custom_message_type = CustomMsgTypes::F_LOAD; lcd_commands_step = 5; } if (lcd_commands_step == 7 && !blocks_queued()) @@ -1667,12 +1667,12 @@ void lcd_commands() } } - if (lcd_commands_type == 3) + if (lcd_commands_type == LcdCommands::UNKNOWN3) { - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; } - if (lcd_commands_type == LCD_COMMAND_FARM_MODE_CONFIRM) /// farm mode confirm + if (lcd_commands_type == LcdCommands::FARM_MODE_CONFIRM) /// farm mode confirm { if (lcd_commands_step == 0) { lcd_commands_step = 6; } @@ -1681,7 +1681,7 @@ void lcd_commands() { lcd_confirm_print(); lcd_commands_step = 0; - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; } if (lcd_commands_step == 2 && !blocks_queued()) { @@ -1714,11 +1714,11 @@ void lcd_commands() } } - if (lcd_commands_type == LCD_COMMAND_PID_EXTRUDER) { + if (lcd_commands_type == LcdCommands::PID_EXTRUDER) { char cmd1[30]; if (lcd_commands_step == 0) { - custom_message_type = CUSTOM_MSG_TYPE_PIDCAL; + custom_message_type = CustomMsgTypes::PIDCAL; custom_message_state = 1; lcd_draw_update = 3; lcd_commands_step = 3; @@ -1754,10 +1754,10 @@ void lcd_commands() } if ((lcd_commands_step == 1) && ((_millis()- display_time)>2000)) { //calibration finished message lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; pid_temp = DEFAULT_PID_TEMP; lcd_commands_step = 0; - lcd_commands_type = 0; + lcd_commands_type = LcdCommands::IDLE; } } @@ -1775,7 +1775,7 @@ void lcd_return_to_status() lcd_refresh(); // to maybe revive the LCD if static electricity killed it. menu_goto(lcd_status_screen, 0, false, true); menu_depth = 0; - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad } //! @brief Pause print, disable nozzle heater, move to park position @@ -1785,9 +1785,9 @@ void lcd_pause_print() stop_and_save_print_to_ram(0.0,0.0); setAllTargetHotends(0); isPrintPaused = true; - if (LCD_COMMAND_IDLE == lcd_commands_type) + if (LcdCommands::IDLE == lcd_commands_type) { - lcd_commands_type = LCD_COMMAND_LONG_PAUSE; + lcd_commands_type = LcdCommands::LONG_PAUSE; } } @@ -1928,7 +1928,7 @@ void lcd_menu_extruder_info() // NOT static due to using ins lcd_puts_P(_N("Filament sensor\n" "is disabled.")); else { - if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) + if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) pat9125_update(); lcd_printf_P(_N( "Fil. Xd:%3d Yd:%3d\n" @@ -2314,7 +2314,7 @@ void lcd_set_filament_oq_meass() } -eFILAMENT_ACTION eFilamentAction=e_FILAMENT_ACTION_none; // must be initialized as 'non-autoLoad' +eFILAMENT_ACTION eFilamentAction=eFILAMENT_ACTION::none; // must be initialized as 'non-autoLoad' bool bFilamentFirstRun; bool bFilamentPreheatState; bool bFilamentAction=false; @@ -2331,18 +2331,18 @@ lcd_puts_P(_i("Press the knob")); ////MSG_ c=20 r=1 lcd_set_cursor(0,3); switch(eFilamentAction) { - case e_FILAMENT_ACTION_Load: - case e_FILAMENT_ACTION_autoLoad: - case e_FILAMENT_ACTION_mmuLoad: + case eFILAMENT_ACTION::load: + case eFILAMENT_ACTION::autoLoad: + case eFILAMENT_ACTION::mmuLoad: lcd_puts_P(_i("to load filament")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_unLoad: - case e_FILAMENT_ACTION_mmuUnLoad: + case eFILAMENT_ACTION::unLoad: + case eFILAMENT_ACTION::mmuUnLoad: lcd_puts_P(_i("to unload filament")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_mmuEject: - case e_FILAMENT_ACTION_mmuCut: - case e_FILAMENT_ACTION_none: + case eFILAMENT_ACTION::mmuEject: + case eFILAMENT_ACTION::mmuCut: + case eFILAMENT_ACTION::none: break; } if(lcd_clicked()) @@ -2356,21 +2356,21 @@ if(lcd_clicked()) menu_back(nLevel); switch(eFilamentAction) { - case e_FILAMENT_ACTION_autoLoad: - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad + case eFILAMENT_ACTION::autoLoad: + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad // no break - case e_FILAMENT_ACTION_Load: + case eFILAMENT_ACTION::load: loading_flag=true; enquecommand_P(PSTR("M701")); // load filament break; - case e_FILAMENT_ACTION_unLoad: + case eFILAMENT_ACTION::unLoad: enquecommand_P(PSTR("M702")); // unload filament break; - case e_FILAMENT_ACTION_mmuLoad: - case e_FILAMENT_ACTION_mmuUnLoad: - case e_FILAMENT_ACTION_mmuEject: - case e_FILAMENT_ACTION_mmuCut: - case e_FILAMENT_ACTION_none: + case eFILAMENT_ACTION::mmuLoad: + case eFILAMENT_ACTION::mmuUnLoad: + case eFILAMENT_ACTION::mmuEject: + case eFILAMENT_ACTION::mmuCut: + case eFILAMENT_ACTION::none: break; } } @@ -2394,19 +2394,19 @@ lcdui_print_temp(LCD_STR_THERMOMETER[0],(int)degHotend(0),(int)degTargetHotend(0 lcd_set_cursor(0,1); switch(eFilamentAction) { - case e_FILAMENT_ACTION_Load: - case e_FILAMENT_ACTION_autoLoad: - case e_FILAMENT_ACTION_mmuLoad: + case eFILAMENT_ACTION::load: + case eFILAMENT_ACTION::autoLoad: + case eFILAMENT_ACTION::mmuLoad: lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_unLoad: - case e_FILAMENT_ACTION_mmuUnLoad: + case eFILAMENT_ACTION::unLoad: + case eFILAMENT_ACTION::mmuUnLoad: lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_mmuEject: + case eFILAMENT_ACTION::mmuEject: lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_mmuCut: + case eFILAMENT_ACTION::mmuCut: lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 r=1 break; } @@ -2425,20 +2425,20 @@ if(lcd_clicked()) setTargetBed((float)nTargetBedOld); } menu_back(); - if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad + if(eFilamentAction==eFILAMENT_ACTION::autoLoad) + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad } else { if(current_temperature[0]>(target_temperature[0]*0.95)) { switch(eFilamentAction) { - case e_FILAMENT_ACTION_Load: - case e_FILAMENT_ACTION_autoLoad: - case e_FILAMENT_ACTION_unLoad: + case eFILAMENT_ACTION::load: + case eFILAMENT_ACTION::autoLoad: + case eFILAMENT_ACTION::unLoad: menu_submenu(mFilamentPrompt); break; - case e_FILAMENT_ACTION_mmuLoad: + case eFILAMENT_ACTION::mmuLoad: nLevel=1; if(!bFilamentPreheatState) nLevel++; @@ -2446,7 +2446,7 @@ else { menu_back(nLevel); menu_submenu(mmu_load_to_nozzle_menu); break; - case e_FILAMENT_ACTION_mmuUnLoad: + case eFILAMENT_ACTION::mmuUnLoad: nLevel=1; if(!bFilamentPreheatState) nLevel++; @@ -2454,7 +2454,7 @@ else { menu_back(nLevel); extr_unload(); break; - case e_FILAMENT_ACTION_mmuEject: + case eFILAMENT_ACTION::mmuEject: nLevel=1; if(!bFilamentPreheatState) nLevel++; @@ -2462,7 +2462,7 @@ else { menu_back(nLevel); menu_submenu(mmu_fil_eject_menu); break; - case e_FILAMENT_ACTION_mmuCut: + case eFILAMENT_ACTION::mmuCut: nLevel=1; if(!bFilamentPreheatState) nLevel++; @@ -2495,44 +2495,44 @@ if(current_temperature[0]>(target_temperature[0]*0.95)) { switch(eFilamentAction) { - case e_FILAMENT_ACTION_Load: - case e_FILAMENT_ACTION_autoLoad: - case e_FILAMENT_ACTION_unLoad: + case eFILAMENT_ACTION::load: + case eFILAMENT_ACTION::autoLoad: + case eFILAMENT_ACTION::unLoad: if(bFilamentWaitingFlag) menu_submenu(mFilamentPrompt); else { nLevel=bFilamentPreheatState?1:2; menu_back(nLevel); - if((eFilamentAction==e_FILAMENT_ACTION_Load)||(eFilamentAction==e_FILAMENT_ACTION_autoLoad)) + if((eFilamentAction==eFILAMENT_ACTION::load)||(eFilamentAction==eFILAMENT_ACTION::autoLoad)) { loading_flag=true; enquecommand_P(PSTR("M701")); // load filament - if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad + if(eFilamentAction==eFILAMENT_ACTION::autoLoad) + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad } - if(eFilamentAction==e_FILAMENT_ACTION_unLoad) + if(eFilamentAction==eFILAMENT_ACTION::unLoad) enquecommand_P(PSTR("M702")); // unload filament } break; - case e_FILAMENT_ACTION_mmuLoad: + case eFILAMENT_ACTION::mmuLoad: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); menu_submenu(mmu_load_to_nozzle_menu); break; - case e_FILAMENT_ACTION_mmuUnLoad: + case eFILAMENT_ACTION::mmuUnLoad: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); extr_unload(); break; - case e_FILAMENT_ACTION_mmuEject: + case eFILAMENT_ACTION::mmuEject: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); menu_submenu(mmu_fil_eject_menu); break; - case e_FILAMENT_ACTION_mmuCut: + case eFILAMENT_ACTION::mmuCut: #ifdef MMU_HAS_CUTTER nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; @@ -2540,7 +2540,7 @@ if(current_temperature[0]>(target_temperature[0]*0.95)) menu_submenu(mmu_cut_filament_menu); #endif //MMU_HAS_CUTTER break; - case e_FILAMENT_ACTION_none: + case eFILAMENT_ACTION::none: break; } if(bFilamentWaitingFlag) @@ -2554,22 +2554,22 @@ else { lcd_set_cursor(0,1); switch(eFilamentAction) { - case e_FILAMENT_ACTION_Load: - case e_FILAMENT_ACTION_autoLoad: - case e_FILAMENT_ACTION_mmuLoad: + case eFILAMENT_ACTION::load: + case eFILAMENT_ACTION::autoLoad: + case eFILAMENT_ACTION::mmuLoad: lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_unLoad: - case e_FILAMENT_ACTION_mmuUnLoad: + case eFILAMENT_ACTION::unLoad: + case eFILAMENT_ACTION::mmuUnLoad: lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_mmuEject: + case eFILAMENT_ACTION::mmuEject: lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_mmuCut: + case eFILAMENT_ACTION::mmuCut: lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 r=1 break; - case e_FILAMENT_ACTION_none: + case eFILAMENT_ACTION::none: break; } lcd_set_cursor(0,3); @@ -2588,8 +2588,8 @@ else { setTargetBed((float)nTargetBedOld); } menu_back(); - if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad + if(eFilamentAction==eFILAMENT_ACTION::autoLoad) + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad } } } @@ -2634,8 +2634,8 @@ mFilamentItem(FLEX_PREHEAT_HOTEND_TEMP,FLEX_PREHEAT_HPB_TEMP); void mFilamentBack() { menu_back(); -if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) - eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad +if(eFilamentAction==eFILAMENT_ACTION::autoLoad) + eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad } void mFilamentMenu() @@ -2666,7 +2666,7 @@ if(0) enquecommand_P(PSTR("M702")); // unload filament } else { - eFilamentAction=e_FILAMENT_ACTION_unLoad; + eFilamentAction=eFILAMENT_ACTION::unLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -2893,7 +2893,7 @@ static void lcd_LoadFilament() if(0) { // menu_back(); // not necessary (see "lcd_return_to_status()" below) - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; + custom_message_type = CustomMsgTypes::F_LOAD; loading_flag = true; enquecommand_P(PSTR("M701")); //load filament SERIAL_ECHOLN("Loading filament"); @@ -2901,7 +2901,7 @@ if(0) } else { - eFilamentAction=e_FILAMENT_ACTION_Load; + eFilamentAction=eFILAMENT_ACTION::load; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -3350,7 +3350,7 @@ void pid_extruder() lcd_set_cursor(1, 2); lcd_print(ftostr3(pid_temp)); if (lcd_clicked()) { - lcd_commands_type = LCD_COMMAND_PID_EXTRUDER; + lcd_commands_type = LcdCommands::PID_EXTRUDER; lcd_return_to_status(); lcd_update(2); } @@ -3952,7 +3952,7 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui void lcd_temp_cal_show_result(bool result) { - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; disable_x(); disable_y(); disable_z(); @@ -4573,7 +4573,7 @@ static void lcd_crash_mode_set() }else{ crashdet_enable(); } - if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) menu_goto(lcd_tune_menu, 9, true, true); + if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) menu_goto(lcd_tune_menu, 9, true, true); else menu_goto(lcd_settings_menu, 9, true, true); } @@ -4810,14 +4810,14 @@ void lcd_v2_calibration() if (filament < 5) { lcd_commands_step = 20 + filament; - lcd_commands_type = LCD_COMMAND_V2_CAL; + lcd_commands_type = LcdCommands::V2_CAL; } } else { bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2 if (loaded) { - lcd_commands_type = LCD_COMMAND_V2_CAL; + lcd_commands_type = LcdCommands::V2_CAL; } else { lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 @@ -5077,7 +5077,7 @@ void lcd_wizard(WizState state) case S::Lay1Cal: lcd_show_fullscreen_message_and_wait_P(_i("Now I will calibrate distance between tip of the nozzle and heatbed surface."));////MSG_WIZARD_V2_CAL c=20 r=8 lcd_show_fullscreen_message_and_wait_P(_i("I will start to print line and you will gradually lower the nozzle by rotating the knob, until you reach optimal height. Check the pictures in our handbook in chapter Calibration."));////MSG_WIZARD_V2_CAL_2 c=20 r=12 - lcd_commands_type = LCD_COMMAND_V2_CAL; + lcd_commands_type = LcdCommands::V2_CAL; lcd_return_to_status(); end = true; break; @@ -5930,7 +5930,7 @@ static void mmu_load_to_nozzle_menu() } else { - eFilamentAction = e_FILAMENT_ACTION_mmuLoad; + eFilamentAction = eFILAMENT_ACTION::mmuLoad; bFilamentFirstRun = false; if (target_temperature[0] >= EXTRUDE_MINTEMP) { @@ -5962,7 +5962,7 @@ static void mmu_fil_eject_menu() } else { - eFilamentAction = e_FILAMENT_ACTION_mmuEject; + eFilamentAction = eFILAMENT_ACTION::mmuEject; bFilamentFirstRun = false; if (target_temperature[0] >= EXTRUDE_MINTEMP) { @@ -5990,7 +5990,7 @@ static void mmu_cut_filament_menu() } else { - eFilamentAction=e_FILAMENT_ACTION_mmuCut; + eFilamentAction=eFILAMENT_ACTION::mmuCut; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -6035,7 +6035,7 @@ static void change_extr_menu(){ //unload filament for single material printer (used in M702 gcode) void unload_filament() { - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; + custom_message_type = CustomMsgTypes::F_LOAD; lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT)); // extr_unload2(); @@ -6070,7 +6070,7 @@ void unload_filament() lcd_update_enable(true); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CUSTOM_MSG_TYPE_STATUS; + custom_message_type = CustomMsgTypes::STATUS; } @@ -6397,13 +6397,13 @@ static void lcd_main_menu() }*/ - if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) + if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) { MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 } - if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) + if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) { MENU_ITEM_SUBMENU_P(_i("Tune"), lcd_tune_menu);////MSG_TUNE } else @@ -6412,7 +6412,7 @@ static void lcd_main_menu() } #ifdef SDSUPPORT - if (card.cardOK || lcd_commands_type == LCD_COMMAND_V2_CAL) + if (card.cardOK || lcd_commands_type == LcdCommands::V2_CAL) { if (card.isFileOpen()) { @@ -6428,12 +6428,12 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } } - else if (lcd_commands_type == LCD_COMMAND_V2_CAL && mesh_bed_leveling_flag == false && homing_flag == false) { + else if (lcd_commands_type == LcdCommands::V2_CAL && mesh_bed_leveling_flag == false && homing_flag == false) { //MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } else { - if (!is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) + if (!is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) { //if (farm_mode) MENU_ITEM_SUBMENU_P(MSG_FARM_CARD_MENU, lcd_farm_sdcard_menu); /*else*/ { @@ -6457,7 +6457,7 @@ static void lcd_main_menu() #endif - if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) + if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) { if (farm_mode) { @@ -6501,7 +6501,7 @@ static void lcd_main_menu() } - if (!is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) + if (!is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) { MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS } @@ -6557,7 +6557,7 @@ static void lcd_colorprint_change() { enquecommand_P(PSTR("M600")); - custom_message_type = CUSTOM_MSG_TYPE_F_LOAD; //just print status message + custom_message_type = CustomMsgTypes::F_LOAD; //just print status message lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); lcd_return_to_status(); lcd_draw_update = 3; @@ -6786,7 +6786,7 @@ void lcd_print_stop() lcd_return_to_status(); lcd_ignore_click(true); lcd_commands_step = 0; - lcd_commands_type = LCD_COMMAND_STOP_PRINT; + lcd_commands_type = LcdCommands::STOP_PRINT; // Turn off the print fan SET_OUTPUT(FAN_PIN); WRITE(FAN_PIN, 0); @@ -8359,5 +8359,5 @@ void menu_lcd_lcdupdate_func(void) if (!SdFatUtil::test_stack_integrity()) stack_error(); 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(); + if (lcd_commands_type == LcdCommands::V2_CAL) lcd_commands(); } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index f8cf8365..26e282a0 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -89,31 +89,36 @@ extern void lcd_diag_show_end_stops(); // To be used in lcd_commands_type. -#define LCD_COMMAND_IDLE 0 -#define LCD_COMMAND_LOAD_FILAMENT 1 -#define LCD_COMMAND_STOP_PRINT 2 -#define LCD_COMMAND_FARM_MODE_CONFIRM 4 -#define LCD_COMMAND_LONG_PAUSE 5 -#define LCD_COMMAND_PID_EXTRUDER 7 -#define LCD_COMMAND_V2_CAL 8 +enum class LcdCommands : uint8_t { + IDLE = 0, + LOAD_FILAMENT = 1, + STOP_PRINT = 2, + UNKNOWN3 = 3, + FARM_MODE_CONFIRM = 4, + LONG_PAUSE = 5, + PID_EXTRUDER = 7, + V2_CAL = 8, +}; -extern uint8_t lcd_commands_type; +extern LcdCommands lcd_commands_type; extern int8_t FSensorStateMenu; -#define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable -#define CUSTOM_MSG_TYPE_MESHBL 1 // Mesh bed leveling in progress -#define CUSTOM_MSG_TYPE_F_LOAD 2 // Loading filament in progress -#define CUSTOM_MSG_TYPE_PIDCAL 3 // PID tuning in progress -#define CUSTOM_MSG_TYPE_TEMCAL 4 // PINDA temp calibration -#define CUSTOM_MSG_TYPE_TEMPRE 5 // Temp compensation preheat +enum class CustomMsgTypes : uint8_t { + STATUS = 0, //!< status message from lcd_status_message variable + MESHBL = 1, //!< Mesh bed leveling in progress + F_LOAD = 2, //!< Loading filament in progress + PIDCAL = 3, //!< PID tuning in progress + TEMCAL = 4, //!< PINDA temp calibration + TEMPRE = 5, //!< Temp compensation preheat +}; -extern unsigned int custom_message_type; +extern CustomMsgTypes custom_message_type; extern unsigned int custom_message_state; extern uint8_t farm_mode; extern int farm_no; extern int farm_timer; -extern int farm_status; +extern uint8_t farm_status; #ifdef TMC2130 #define SILENT_MODE_NORMAL 0 @@ -145,17 +150,17 @@ void extr_unload_used(); #endif //SNMM void extr_unload(); -typedef enum -{ - e_FILAMENT_ACTION_none, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) - e_FILAMENT_ACTION_Load, - e_FILAMENT_ACTION_autoLoad, - e_FILAMENT_ACTION_unLoad, - e_FILAMENT_ACTION_mmuLoad, - e_FILAMENT_ACTION_mmuUnLoad, - e_FILAMENT_ACTION_mmuEject, - e_FILAMENT_ACTION_mmuCut, -} eFILAMENT_ACTION; +enum class eFILAMENT_ACTION : uint8_t { + none, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) + load, + autoLoad, + unLoad, + mmuLoad, + mmuUnLoad, + mmuEject, + mmuCut, +}; + extern eFILAMENT_ACTION eFilamentAction; extern bool bFilamentFirstRun; extern bool bFilamentPreheatState; From e393d91b1241894ae8f55e2b2816f799a62c34e9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 16:20:21 +0200 Subject: [PATCH 25/36] Use first letter capital camel case for enum class members. --- Firmware/mmu.cpp | 18 +++++++++--------- Firmware/temperature.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index c289f31d..912305d2 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1511,20 +1511,20 @@ void mmu_continue_loading(bool blocking) enum class Ls : uint_least8_t { - enter, - retry, - unload, + Enter, + Retry, + Unload, }; - Ls state = Ls::enter; + Ls state = Ls::Enter; while (PIN_GET(IR_SENSOR_PIN) != 0) { switch (state) { - case Ls::enter: + case Ls::Enter: increment_load_fail(); // no break - case Ls::retry: + case Ls::Retry: #ifdef MMU_HAS_CUTTER if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED)) { @@ -1535,9 +1535,9 @@ void mmu_continue_loading(bool blocking) mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(true, true, MMU_TCODE_MOVE); load_more(); - state = Ls::unload; + state = Ls::Unload; break; - case Ls::unload: + case Ls::Unload: stop_and_save_print_to_ram(0, 0); //lift z @@ -1562,7 +1562,7 @@ void mmu_continue_loading(bool blocking) { marlin_wait_for_click(); restore_print_from_ram_and_continue(0); - state = Ls::retry; + state = Ls::Retry; } else { diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 08d1a55b..db0b8628 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2053,8 +2053,8 @@ void check_max_temp() struct alert_automaton_mintemp { private: enum { ALERT_AUTOMATON_SPEED_DIV = 5 }; - enum class States : uint8_t { INIT = 0, TEMP_ABOVE_MINTEMP, SHOW_PLEASE_RESTART, SHOW_MINTEMP }; - States state = States::INIT; + enum class States : uint8_t { Init = 0, TempAboveMintemp, ShowPleaseRestart, ShowMintemp }; + States state = States::Init; uint8_t repeat = ALERT_AUTOMATON_SPEED_DIV; void substep(States next_state){ @@ -2073,26 +2073,26 @@ public: static const char m2[] PROGMEM = "MINTEMP fixed"; static const char m1[] PROGMEM = "Please restart"; switch(state){ - case States::INIT: // initial state - check hysteresis + case States::Init: // initial state - check hysteresis if( current_temp > mintemp ){ - state = States::TEMP_ABOVE_MINTEMP; + state = States::TempAboveMintemp; } // otherwise keep the Err MINTEMP alert message on the display, // i.e. do not transfer to state 1 break; - case States::TEMP_ABOVE_MINTEMP: // the temperature has risen above the hysteresis check + case States::TempAboveMintemp: // the temperature has risen above the hysteresis check lcd_setalertstatuspgm(m2); - substep(States::SHOW_MINTEMP); + substep(States::ShowMintemp); last_alert_sent_to_lcd = LCDALERT_MINTEMPFIXED; break; - case States::SHOW_PLEASE_RESTART: // displaying "Please restart" + case States::ShowPleaseRestart: // displaying "Please restart" lcd_updatestatuspgm(m1); - substep(States::SHOW_MINTEMP); + substep(States::ShowMintemp); last_alert_sent_to_lcd = LCDALERT_PLEASERESTART; break; - case States::SHOW_MINTEMP: // displaying "MINTEMP fixed" + case States::ShowMintemp: // displaying "MINTEMP fixed" lcd_updatestatuspgm(m2); - substep(States::SHOW_PLEASE_RESTART); + substep(States::ShowPleaseRestart); last_alert_sent_to_lcd = LCDALERT_MINTEMPFIXED; break; } From 6dd085bcc5e4639d26ac5283852c99ceb0e5c214 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 16:44:07 +0200 Subject: [PATCH 26/36] Use first letter capital camel case for enum class members. --- Firmware/ultralcd.cpp | 138 +++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d60fd67f..3ce74e12 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -166,23 +166,23 @@ static bool lcd_selfcheck_pulleys(int axis); #endif //TMC2130 static bool lcd_selfcheck_check_heater(bool _isbed); -enum class testScreen : uint_least8_t +enum class TestScreen : uint_least8_t { - extruderFan, - printFan, - fansOk, - endStops, - axisX, - axisY, - axisZ, - bed, - hotend, - hotendOk, - fsensor, - fsensorOk, - allCorrect, - failed, - home, + ExtruderFan, + PrintFan, + FansOk, + EndStops, + AxisX, + AxisY, + AxisZ, + Bed, + Hotend, + HotendOk, + Fsensor, + FsensorOk, + AllCorrect, + Failed, + Home, }; enum class TestError : uint_least8_t @@ -201,7 +201,7 @@ enum class TestError : uint_least8_t triggeringFsensor, }; -static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); +static int lcd_selftest_screen(TestScreen screen, 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, bool _default=false); @@ -6769,7 +6769,7 @@ bool lcd_selftest() _delay(2000); KEEPALIVE_STATE(IN_HANDLER); - _progress = lcd_selftest_screen(testScreen::extruderFan, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(TestScreen::ExtruderFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_0)) switch (lcd_selftest_fan_auto(0)){ // check extruder Fan case FanCheck::extruderFan: @@ -6792,7 +6792,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::printFan, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(TestScreen::PrintFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_1)) switch (lcd_selftest_fan_auto(1)){ // check print fan case FanCheck::printFan: @@ -6832,7 +6832,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::fansOk, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(TestScreen::FansOk, _progress, 3, true, 2000); #ifndef TMC2130 _result = lcd_selfcheck_endstops(); #else @@ -6843,7 +6843,7 @@ bool lcd_selftest() if (_result) { //current_position[Z_AXIS] += 15; //move Z axis higher to avoid false triggering of Z end stop in case that we are very low - just above heatbed - _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(TestScreen::AxisX, _progress, 3, true, 2000); #ifdef TMC2130 _result = lcd_selfcheck_axis_sg(X_AXIS); #else @@ -6856,7 +6856,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 0); + _progress = lcd_selftest_screen(TestScreen::AxisX, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(X_AXIS); @@ -6866,7 +6866,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::axisY, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(TestScreen::AxisY, _progress, 3, true, 1500); #ifdef TMC2130 _result = lcd_selfcheck_axis_sg(Y_AXIS); #else @@ -6876,7 +6876,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 0); + _progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(Y_AXIS); #endif // TMC2130 @@ -6897,7 +6897,7 @@ bool lcd_selftest() current_position[Z_AXIS] = current_position[Z_AXIS] + 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); - _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500); _result = lcd_selfcheck_axis(2, Z_MAX_POS); if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) != 1) { enquecommand_P(PSTR("G28 W")); @@ -6911,11 +6911,11 @@ bool lcd_selftest() current_position[Z_AXIS] = current_position[Z_AXIS] + 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); - _progress = lcd_selftest_screen(testScreen::home, 0, 2, true, 0); + _progress = lcd_selftest_screen(TestScreen::Home, 0, 2, true, 0); bool bres = tmc2130_home_calibrate(X_AXIS); - _progress = lcd_selftest_screen(testScreen::home, 1, 2, true, 0); + _progress = lcd_selftest_screen(TestScreen::Home, 1, 2, true, 0); bres &= tmc2130_home_calibrate(Y_AXIS); - _progress = lcd_selftest_screen(testScreen::home, 2, 2, true, 0); + _progress = lcd_selftest_screen(TestScreen::Home, 2, 2, true, 0); if (bres) eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 1); _result = bres; @@ -6924,18 +6924,18 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(testScreen::bed, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(TestScreen::Bed, _progress, 3, true, 2000); _result = lcd_selfcheck_check_heater(true); } if (_result) { - _progress = lcd_selftest_screen(testScreen::hotend, _progress, 3, true, 1000); + _progress = lcd_selftest_screen(TestScreen::Hotend, _progress, 3, true, 1000); _result = lcd_selfcheck_check_heater(false); } if (_result) { - _progress = lcd_selftest_screen(testScreen::hotendOk, _progress, 3, true, 2000); //nozzle ok + _progress = lcd_selftest_screen(TestScreen::HotendOk, _progress, 3, true, 2000); //nozzle ok } #ifdef FILAMENT_SENSOR if (_result) @@ -6943,20 +6943,20 @@ bool lcd_selftest() if (mmu_enabled) { - _progress = lcd_selftest_screen(testScreen::fsensor, _progress, 3, true, 2000); //check filaments sensor + _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filaments sensor _result = selftest_irsensor(); if (_result) { - _progress = lcd_selftest_screen(testScreen::fsensorOk, _progress, 3, true, 2000); //fil sensor OK + _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK } } else { #ifdef PAT9125 - _progress = lcd_selftest_screen(testScreen::fsensor, _progress, 3, true, 2000); //check filaments sensor + _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filaments sensor _result = lcd_selftest_fsensor(); if (_result) { - _progress = lcd_selftest_screen(testScreen::fsensorOk, _progress, 3, true, 2000); //fil sensor OK + _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK } #endif //PAT9125 } @@ -6964,11 +6964,11 @@ bool lcd_selftest() #endif //FILAMENT_SENSOR if (_result) { - _progress = lcd_selftest_screen(testScreen::allCorrect, _progress, 3, true, 5000); //all correct + _progress = lcd_selftest_screen(TestScreen::AllCorrect, _progress, 3, true, 5000); //all correct } else { - _progress = lcd_selftest_screen(testScreen::failed, _progress, 3, true, 5000); + _progress = lcd_selftest_screen(TestScreen::Failed, _progress, 3, true, 5000); } lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); @@ -7175,7 +7175,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel) } else { - _progress = lcd_selftest_screen(static_cast(static_cast(testScreen::axisX) + _axis), _progress, 3, false, 0); + _progress = lcd_selftest_screen(static_cast(static_cast(TestScreen::AxisX) + _axis), _progress, 3, false, 0); _lcd_refresh = 0; } @@ -7342,7 +7342,7 @@ static bool lcd_selfcheck_check_heater(bool _isbed) manage_heater(); manage_inactivity(true); - _progress = (_isbed) ? lcd_selftest_screen(testScreen::bed, _progress, 2, false, 400) : lcd_selftest_screen(testScreen::hotend, _progress, 2, false, 400); + _progress = (_isbed) ? lcd_selftest_screen(TestScreen::Bed, _progress, 2, false, 400) : lcd_selftest_screen(TestScreen::Hotend, _progress, 2, false, 400); /*if (_isbed) { MYSERIAL.print("Bed temp:"); MYSERIAL.println(degBed()); @@ -7560,16 +7560,16 @@ static bool selftest_irsensor() TempBackup tempBackup; setTargetHotend(ABS_PREHEAT_HOTEND_TEMP,active_extruder); mmu_wait_for_heater_blocking(); - progress = lcd_selftest_screen(testScreen::fsensor, 0, 1, true, 0); + progress = lcd_selftest_screen(TestScreen::Fsensor, 0, 1, true, 0); mmu_filament_ramming(); } - progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0); + progress = lcd_selftest_screen(TestScreen::Fsensor, progress, 1, true, 0); mmu_command(MmuCmd::U0); manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) { - if (0 == (i % 32)) progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0); + if (0 == (i % 32)) progress = lcd_selftest_screen(TestScreen::Fsensor, progress, 1, true, 0); mmu_load_step(false); while (blocks_queued()) @@ -7795,7 +7795,7 @@ static FanCheck lcd_selftest_fan_auto(int _fan) #endif //FANCHECK -static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay) +static int lcd_selftest_screen(TestScreen screen, int _progress, int _progress_scale, bool _clear, int _delay) { lcd_update_enable(false); @@ -7807,58 +7807,58 @@ static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_s lcd_set_cursor(0, 0); - if (screen == testScreen::extruderFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (screen == testScreen::printFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (screen == testScreen::fansOk) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (screen == testScreen::endStops) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 - if (screen == testScreen::axisX) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 - if (screen == testScreen::axisY) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 - if (screen == testScreen::axisZ) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 - if (screen == testScreen::bed) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); - if (screen == testScreen::hotend - || screen == testScreen::hotendOk) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 - if (screen == testScreen::fsensor) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); - if (screen == testScreen::fsensorOk) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); - if (screen == testScreen::allCorrect) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 - if (screen == testScreen::failed) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); - if (screen == testScreen::home) lcd_puts_P(_i("Calibrating home"));////c=20 r=1 + if (screen == TestScreen::ExtruderFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == TestScreen::PrintFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == TestScreen::FansOk) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == TestScreen::EndStops) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 + if (screen == TestScreen::AxisX) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 + if (screen == TestScreen::AxisY) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 + if (screen == TestScreen::AxisZ) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 + if (screen == TestScreen::Bed) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); + if (screen == TestScreen::Hotend + || screen == TestScreen::HotendOk) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 + if (screen == TestScreen::Fsensor) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); + if (screen == TestScreen::FsensorOk) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); + if (screen == TestScreen::AllCorrect) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 + if (screen == TestScreen::Failed) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); + if (screen == TestScreen::Home) lcd_puts_P(_i("Calibrating home"));////c=20 r=1 lcd_set_cursor(0, 1); lcd_puts_P(separator); - if ((screen >= testScreen::extruderFan) && (screen <= testScreen::fansOk)) + if ((screen >= TestScreen::ExtruderFan) && (screen <= TestScreen::FansOk)) { //SERIAL_ECHOLNPGM("Fan test"); lcd_puts_at_P(0, 2, _i("Extruder fan:"));////MSG_SELFTEST_EXTRUDER_FAN_SPEED c=18 lcd_set_cursor(18, 2); - (screen < testScreen::printFan) ? lcd_print(_indicator) : lcd_print("OK"); + (screen < TestScreen::PrintFan) ? lcd_print(_indicator) : lcd_print("OK"); lcd_puts_at_P(0, 3, _i("Print fan:"));////MSG_SELFTEST_PRINT_FAN_SPEED c=18 lcd_set_cursor(18, 3); - (screen < testScreen::fansOk) ? lcd_print(_indicator) : lcd_print("OK"); + (screen < TestScreen::FansOk) ? lcd_print(_indicator) : lcd_print("OK"); } - else if (screen >= testScreen::fsensor && screen <= testScreen::fsensorOk) + else if (screen >= TestScreen::Fsensor && screen <= TestScreen::FsensorOk) { lcd_puts_at_P(0, 2, _T(MSG_SELFTEST_FILAMENT_SENSOR)); lcd_putc(':'); lcd_set_cursor(18, 2); - (screen == testScreen::fsensor) ? lcd_print(_indicator) : lcd_print("OK"); + (screen == TestScreen::Fsensor) ? lcd_print(_indicator) : lcd_print("OK"); } - else if (screen < testScreen::fsensor) + else if (screen < TestScreen::Fsensor) { //SERIAL_ECHOLNPGM("Other tests"); - testScreen _step_block = testScreen::axisX; + TestScreen _step_block = TestScreen::AxisX; lcd_selftest_screen_step(2, 2, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "X", _indicator); - _step_block = testScreen::axisY; + _step_block = TestScreen::AxisY; lcd_selftest_screen_step(2, 8, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Y", _indicator); - _step_block = testScreen::axisZ; + _step_block = TestScreen::AxisZ; lcd_selftest_screen_step(2, 14, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Z", _indicator); - _step_block = testScreen::bed; + _step_block = TestScreen::Bed; lcd_selftest_screen_step(3, 0, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Bed", _indicator); - _step_block = testScreen::hotend; + _step_block = TestScreen::Hotend; lcd_selftest_screen_step(3, 9, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Hotend", _indicator); } From 9ceba004267df35b3c2c12a91fd28ee57f0face9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 18:53:09 +0200 Subject: [PATCH 27/36] Use first letter capital camel case for enum class members. Remove dependency of FanCheck values on TestError values as it is not used. --- Firmware/ultralcd.cpp | 86 +++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 3ce74e12..01bcb85b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -187,18 +187,18 @@ enum class TestScreen : uint_least8_t enum class TestError : uint_least8_t { - heater, - bed, - endstops, - motor, - endstop, - printFan, - extruderFan, - pulley, - axis, - swappedFan, - wiringFsensor, - triggeringFsensor, + Heater, + Bed, + Endstops, + Motor, + Endstop, + PrintFan, + ExtruderFan, + Pulley, + Axis, + SwappedFan, + WiringFsensor, + TriggeringFsensor, }; static int lcd_selftest_screen(TestScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); @@ -211,9 +211,9 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite, */ enum class FanCheck : uint_least8_t { success, - printFan = TestError::printFan, - extruderFan = TestError::extruderFan, - swappedFan = TestError::swappedFan, + printFan, + extruderFan, + swappedFan, }; /** @@ -6787,7 +6787,7 @@ bool lcd_selftest() #endif //defined(TACH_0) if (!_result) { - lcd_selftest_error(TestError::extruderFan, "", ""); + lcd_selftest_error(TestError::ExtruderFan, "", ""); } if (_result) @@ -6810,7 +6810,7 @@ bool lcd_selftest() #endif //defined(TACH_1) if (!_result) { - lcd_selftest_error(TestError::printFan, "", ""); //print fan not spinning + lcd_selftest_error(TestError::PrintFan, "", ""); //print fan not spinning } } @@ -6821,12 +6821,12 @@ bool lcd_selftest() //print fan is stil turned on; check that it is spinning _result = lcd_selftest_manual_fan_check(1, false, true); if (!_result){ - lcd_selftest_error(TestError::printFan, "", ""); + lcd_selftest_error(TestError::PrintFan, "", ""); } } else { // fans are swapped - lcd_selftest_error(TestError::swappedFan, "", ""); + lcd_selftest_error(TestError::SwappedFan, "", ""); } } @@ -7082,7 +7082,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { if (axis == Y_AXIS) _error_1 = "Y"; if (axis == Z_AXIS) _error_1 = "Z"; - lcd_selftest_error(TestError::axis, _error_1, ""); + lcd_selftest_error(TestError::Axis, _error_1, ""); current_position[axis] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); reset_crash_det(axis); @@ -7100,7 +7100,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { if (axis == Y_AXIS) _error_1 = "Y"; if (axis == Z_AXIS) _error_1 = "Z"; - lcd_selftest_error(TestError::pulley, _error_1, ""); + lcd_selftest_error(TestError::Pulley, _error_1, ""); current_position[axis] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); reset_crash_det(axis); @@ -7207,11 +7207,11 @@ static bool lcd_selfcheck_axis(int _axis, int _travel) if (_travel_done >= _travel) { - lcd_selftest_error(TestError::endstop, _error_1, _error_2); + lcd_selftest_error(TestError::Endstop, _error_1, _error_2); } else { - lcd_selftest_error(TestError::motor, _error_1, _error_2); + lcd_selftest_error(TestError::Motor, _error_1, _error_2); } } @@ -7251,7 +7251,7 @@ static bool lcd_selfcheck_pulleys(int axis) st_synchronize(); if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) || ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1)) { - lcd_selftest_error(TestError::pulley, (axis == 0) ? "X" : "Y", ""); + lcd_selftest_error(TestError::Pulley, (axis == 0) ? "X" : "Y", ""); return(false); } } @@ -7269,7 +7269,7 @@ static bool lcd_selfcheck_pulleys(int axis) return(true); } else { - lcd_selftest_error(TestError::pulley, (axis == 0) ? "X" : "Y", ""); + lcd_selftest_error(TestError::Pulley, (axis == 0) ? "X" : "Y", ""); return(false); } } @@ -7278,7 +7278,7 @@ static bool lcd_selfcheck_pulleys(int axis) plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); if (_millis() > timeout_counter) { - lcd_selftest_error(TestError::pulley, (axis == 0) ? "X" : "Y", ""); + lcd_selftest_error(TestError::Pulley, (axis == 0) ? "X" : "Y", ""); return(false); } } @@ -7311,7 +7311,7 @@ static bool lcd_selfcheck_endstops() if ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "X"); if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Y"); if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Z"); - lcd_selftest_error(TestError::endstops, _error, ""); + lcd_selftest_error(TestError::Endstops, _error, ""); } manage_heater(); manage_inactivity(true); @@ -7377,12 +7377,12 @@ static bool lcd_selfcheck_check_heater(bool _isbed) } else { - lcd_selftest_error(TestError::heater, "", ""); + lcd_selftest_error(TestError::Heater, "", ""); } } else { - lcd_selftest_error(TestError::bed, "", ""); + lcd_selftest_error(TestError::Bed, "", ""); } manage_heater(); @@ -7409,19 +7409,19 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const switch (testError) { - case TestError::heater: + case TestError::Heater: lcd_set_cursor(0, 2); lcd_puts_P(_i("Heater/Thermistor"));////MSG_SELFTEST_HEATERTHERMISTOR lcd_set_cursor(0, 3); lcd_puts_P(_i("Not connected"));////MSG_SELFTEST_NOTCONNECTED break; - case TestError::bed: + case TestError::Bed: lcd_set_cursor(0, 2); lcd_puts_P(_i("Bed / Heater"));////MSG_SELFTEST_BEDHEATER lcd_set_cursor(0, 3); lcd_puts_P(_T(MSG_SELFTEST_WIRINGERROR)); break; - case TestError::endstops: + case TestError::Endstops: lcd_set_cursor(0, 2); lcd_puts_P(_i("Endstops"));////MSG_SELFTEST_ENDSTOPS lcd_set_cursor(0, 3); @@ -7429,7 +7429,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(17, 3); lcd_print(_error_1); break; - case TestError::motor: + case TestError::Motor: lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_SELFTEST_MOTOR)); lcd_set_cursor(18, 2); @@ -7439,7 +7439,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_2); break; - case TestError::endstop: + case TestError::Endstop: lcd_set_cursor(0, 2); lcd_puts_P(_i("Endstop not hit"));////MSG_SELFTEST_ENDSTOP_NOTHIT c=20 r=1 lcd_set_cursor(0, 3); @@ -7447,7 +7447,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::printFan: + case TestError::PrintFan: lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_SELFTEST_COOLING_FAN)); lcd_set_cursor(0, 3); @@ -7455,7 +7455,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::extruderFan: + case TestError::ExtruderFan: lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_SELFTEST_EXTRUDER_FAN)); lcd_set_cursor(0, 3); @@ -7463,7 +7463,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::pulley: + case TestError::Pulley: lcd_set_cursor(0, 2); lcd_puts_P(_i("Loose pulley"));////MSG_LOOSE_PULLEY c=20 r=1 lcd_set_cursor(0, 3); @@ -7471,7 +7471,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::axis: + case TestError::Axis: lcd_set_cursor(0, 2); lcd_puts_P(_i("Axis length"));////MSG_SELFTEST_AXIS_LENGTH lcd_set_cursor(0, 3); @@ -7479,7 +7479,7 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::swappedFan: + case TestError::SwappedFan: lcd_set_cursor(0, 2); lcd_puts_P(_i("Front/left fans"));////MSG_SELFTEST_FANS lcd_set_cursor(0, 3); @@ -7487,13 +7487,13 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_set_cursor(18, 3); lcd_print(_error_1); break; - case TestError::wiringFsensor: + case TestError::WiringFsensor: lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_SELFTEST_FILAMENT_SENSOR)); lcd_set_cursor(0, 3); lcd_puts_P(_T(MSG_SELFTEST_WIRINGERROR)); break; - case TestError::triggeringFsensor: + case TestError::TriggeringFsensor: lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_SELFTEST_FILAMENT_SENSOR)); lcd_set_cursor(0, 3); @@ -7522,7 +7522,7 @@ static bool lcd_selftest_fsensor(void) fsensor_init(); if (fsensor_not_responding) { - lcd_selftest_error(TestError::wiringFsensor, "", ""); + lcd_selftest_error(TestError::WiringFsensor, "", ""); } return (!fsensor_not_responding); } @@ -7576,7 +7576,7 @@ static bool selftest_irsensor() { if (PIN_GET(IR_SENSOR_PIN) == 0) { - lcd_selftest_error(TestError::triggeringFsensor, "", ""); + lcd_selftest_error(TestError::TriggeringFsensor, "", ""); return false; } #ifdef TMC2130 From 0401490cc16826895e94ec712f969c3360344ba3 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 17:19:19 +0200 Subject: [PATCH 28/36] Use first letter capital camel case for enum class members. --- Firmware/ultralcd.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 01bcb85b..169e5ed8 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -210,10 +210,10 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite, /** Enumerate for lcd_selftest_fan_auto function. */ enum class FanCheck : uint_least8_t { - success, - printFan, - extruderFan, - swappedFan, + Success, + PrintFan, + ExtruderFan, + SwappedFan, }; /** @@ -6772,10 +6772,10 @@ bool lcd_selftest() _progress = lcd_selftest_screen(TestScreen::ExtruderFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_0)) switch (lcd_selftest_fan_auto(0)){ // check extruder Fan - case FanCheck::extruderFan: + case FanCheck::ExtruderFan: _result = false; break; - case FanCheck::swappedFan: + case FanCheck::SwappedFan: _swapped_fan = true; // no break default: @@ -6795,10 +6795,10 @@ bool lcd_selftest() _progress = lcd_selftest_screen(TestScreen::PrintFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_1)) switch (lcd_selftest_fan_auto(1)){ // check print fan - case FanCheck::printFan: + case FanCheck::PrintFan: _result = false; break; - case FanCheck::swappedFan: + case FanCheck::SwappedFan: _swapped_fan = true; // no break default: @@ -7721,11 +7721,11 @@ static FanCheck lcd_selftest_fan_auto(int _fan) printf_P(PSTR("Extr fan speed: %d \n"), fan_speed[0]); if (!fan_speed[0]) { - return FanCheck::extruderFan; + return FanCheck::ExtruderFan; } #ifdef FAN_SOFT_PWM else if (fan_speed[0] > 50 ) { // printerFan is faster - return FanCheck::swappedFan; + return FanCheck::SwappedFan; } break; #endif @@ -7760,7 +7760,7 @@ static FanCheck lcd_selftest_fan_auto(int _fan) printf_P(PSTR("Print fan speed: %d \n"), fan_speed[1]); printf_P(PSTR("Extr fan speed: %d \n"), fan_speed[0]); if (!fan_speed[1]) { - return FanCheck::printFan; + return FanCheck::PrintFan; } #ifdef FAN_SOFT_PWM @@ -7779,18 +7779,18 @@ static FanCheck lcd_selftest_fan_auto(int _fan) // noctua speed is between 17 and 24, turbine more then 30 if (fan_speed[1] < 30) { - return FanCheck::swappedFan; + return FanCheck::SwappedFan; } #else // fan is spinning, but measured RPM are too low for print fan, it must // be left extruder fan else if (fan_speed[1] < 34) { - return FanCheck::swappedFan; + return FanCheck::SwappedFan; } #endif //FAN_SOFT_PWM break; } - return FanCheck::success; + return FanCheck::Success; } #endif //FANCHECK From cbb92860d06ea19eafaf3e65a135a36b2ae7ead5 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 18:19:41 +0200 Subject: [PATCH 29/36] Use first letter capital camel case for enum class members. --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 8 ++--- Firmware/cmdqueue.cpp | 2 +- Firmware/ultralcd.cpp | 68 ++++++++++++++++++++-------------------- Firmware/ultralcd.h | 16 +++++----- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index f53e55cc..e896b838 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -389,7 +389,7 @@ extern bool wizard_active; //autoload temporarily disabled during wizard extern LongTimer safetyTimer; #define PRINT_PERCENT_DONE_INIT 0xff -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsgTypes::TEMCAL) || saved_printing || (lcd_commands_type == LcdCommands::V2_CAL) || card.paused || mmu_print_saved) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsgTypes::TEMCAL) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved) //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e0846228..374d0b68 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4424,7 +4424,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // We don't know where we are! HOME! // Push the commands to the front of the message queue in the reverse order! // There shall be always enough space reserved for these commands. - if (lcd_commands_type != LcdCommands::STOP_PRINT) { + if (lcd_commands_type != LcdCommands::StopPrint) { repeatcommand_front(); // repeat G80 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); } @@ -4464,7 +4464,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if (temp_comp_start) if (run == false && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { - if (lcd_commands_type != LcdCommands::STOP_PRINT) { + if (lcd_commands_type != LcdCommands::StopPrint) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters @@ -4476,7 +4476,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } run = false; - if (lcd_commands_type == LcdCommands::STOP_PRINT) { + if (lcd_commands_type == LcdCommands::StopPrint) { mesh_bed_leveling_flag = false; break; } @@ -7695,7 +7695,7 @@ bool bInhibitFlag; #endif // IR_SENSOR if ((mcode_in_progress != 600) && (eFilamentAction != eFILAMENT_ACTION::autoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { - if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL) && !wizard_active) + if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && !wizard_active) { if (fsensor_check_autoload()) { diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 1e1167c4..37b6388d 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -598,7 +598,7 @@ void get_command() if (farm_mode) { prusa_statistics(6); - lcd_commands_type = LcdCommands::FARM_MODE_CONFIRM; + lcd_commands_type = LcdCommands::FarmModeConfirm; } } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 169e5ed8..808cbfea 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -74,7 +74,7 @@ extern void crashdet_disable(); bool presort_flag = false; #endif -LcdCommands lcd_commands_type = LcdCommands::IDLE; +LcdCommands lcd_commands_type = LcdCommands::Idle; static uint8_t lcd_commands_step = 0; CustomMsgTypes custom_message_type = CustomMsgTypes::STATUS; @@ -996,7 +996,7 @@ static void lcd_status_screen() } // end of farm_mode lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ - if (lcd_commands_type != LcdCommands::IDLE) + if (lcd_commands_type != LcdCommands::Idle) lcd_commands(); } // end of lcd_draw_update @@ -1020,7 +1020,7 @@ static void lcd_status_screen() } if (current_click - && (lcd_commands_type != LcdCommands::STOP_PRINT) //click is aborted unless stop print finishes + && (lcd_commands_type != LcdCommands::StopPrint) //click is aborted unless stop print finishes && ( menu_block_entering_on_serious_errors == SERIOUS_ERR_NONE ) // or a serious error blocks entering the menu ) { @@ -1062,15 +1062,15 @@ static void lcd_status_screen() void lcd_commands() { - if (lcd_commands_type == LcdCommands::LONG_PAUSE) + if (lcd_commands_type == LcdCommands::LongPause) { if (!blocks_queued() && !homing_flag) { lcd_setstatuspgm(_i("Print paused"));////MSG_PRINT_PAUSED c=20 r=1 long_pause(); - if (lcd_commands_type == LcdCommands::LONG_PAUSE) // !!! because "lcd_commands_type" can be changed during/inside "long_pause()" + if (lcd_commands_type == LcdCommands::LongPause) // !!! because "lcd_commands_type" can be changed during/inside "long_pause()" { - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; lcd_commands_step = 0; } } @@ -1078,7 +1078,7 @@ void lcd_commands() #ifdef SNMM - if (lcd_commands_type == LcdCommands::V2_CAL) + if (lcd_commands_type == LcdCommands::Layer1Cal) { char cmd1[30]; float width = 0.4; @@ -1343,7 +1343,7 @@ void lcd_commands() #else //if not SNMM - if (lcd_commands_type == LcdCommands::V2_CAL) + if (lcd_commands_type == LcdCommands::Layer1Cal) { char cmd1[30]; static uint8_t filament = 0; @@ -1439,7 +1439,7 @@ void lcd_commands() case 1: lcd_setstatuspgm(_T(WELCOME_MSG)); lcd_commands_step = 0; - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { lcd_wizard(WizState::RepeatLay1Cal); @@ -1451,7 +1451,7 @@ void lcd_commands() #endif // not SNMM - if (lcd_commands_type == LcdCommands::STOP_PRINT) /// stop print + if (lcd_commands_type == LcdCommands::StopPrint) /// stop print { @@ -1463,7 +1463,7 @@ void lcd_commands() if (lcd_commands_step == 1 && !blocks_queued()) { lcd_commands_step = 0; - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; lcd_setstatuspgm(_T(WELCOME_MSG)); custom_message_type = CustomMsgTypes::STATUS; isPrintPaused = false; @@ -1543,12 +1543,12 @@ void lcd_commands() } } - if (lcd_commands_type == LcdCommands::UNKNOWN3) + if (lcd_commands_type == LcdCommands::Unknown3) { - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; } - if (lcd_commands_type == LcdCommands::FARM_MODE_CONFIRM) /// farm mode confirm + if (lcd_commands_type == LcdCommands::FarmModeConfirm) /// farm mode confirm { if (lcd_commands_step == 0) { lcd_commands_step = 6; } @@ -1557,7 +1557,7 @@ void lcd_commands() { lcd_confirm_print(); lcd_commands_step = 0; - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; } if (lcd_commands_step == 2 && !blocks_queued()) { @@ -1590,7 +1590,7 @@ void lcd_commands() } } - if (lcd_commands_type == LcdCommands::PID_EXTRUDER) { + if (lcd_commands_type == LcdCommands::PidExtruder) { char cmd1[30]; if (lcd_commands_step == 0) { @@ -1633,7 +1633,7 @@ void lcd_commands() custom_message_type = CustomMsgTypes::STATUS; pid_temp = DEFAULT_PID_TEMP; lcd_commands_step = 0; - lcd_commands_type = LcdCommands::IDLE; + lcd_commands_type = LcdCommands::Idle; } } @@ -1655,9 +1655,9 @@ void lcd_pause_print() stop_and_save_print_to_ram(0.0,0.0); setAllTargetHotends(0); isPrintPaused = true; - if (LcdCommands::IDLE == lcd_commands_type) + if (LcdCommands::Idle == lcd_commands_type) { - lcd_commands_type = LcdCommands::LONG_PAUSE; + lcd_commands_type = LcdCommands::LongPause; } } @@ -1798,7 +1798,7 @@ void lcd_menu_extruder_info() // NOT static due to using ins lcd_puts_P(_N("Filament sensor\n" "is disabled.")); else { - if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) + if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) pat9125_update(); lcd_printf_P(_N( "Fil. Xd:%3d Yd:%3d\n" @@ -3220,7 +3220,7 @@ void pid_extruder() lcd_set_cursor(1, 2); lcd_print(ftostr3(pid_temp)); if (lcd_clicked()) { - lcd_commands_type = LcdCommands::PID_EXTRUDER; + lcd_commands_type = LcdCommands::PidExtruder; lcd_return_to_status(); lcd_update(2); } @@ -4443,7 +4443,7 @@ static void lcd_crash_mode_set() }else{ crashdet_enable(); } - if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) menu_goto(lcd_tune_menu, 9, true, true); + if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true); else menu_goto(lcd_settings_menu, 9, true, true); } @@ -4680,14 +4680,14 @@ void lcd_v2_calibration() if (filament < 5) { lcd_commands_step = 20 + filament; - lcd_commands_type = LcdCommands::V2_CAL; + lcd_commands_type = LcdCommands::Layer1Cal; } } else { bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2 if (loaded) { - lcd_commands_type = LcdCommands::V2_CAL; + lcd_commands_type = LcdCommands::Layer1Cal; } else { lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 @@ -4947,7 +4947,7 @@ void lcd_wizard(WizState state) case S::Lay1Cal: lcd_show_fullscreen_message_and_wait_P(_i("Now I will calibrate distance between tip of the nozzle and heatbed surface."));////MSG_WIZARD_V2_CAL c=20 r=8 lcd_show_fullscreen_message_and_wait_P(_i("I will start to print line and you will gradually lower the nozzle by rotating the knob, until you reach optimal height. Check the pictures in our handbook in chapter Calibration."));////MSG_WIZARD_V2_CAL_2 c=20 r=12 - lcd_commands_type = LcdCommands::V2_CAL; + lcd_commands_type = LcdCommands::Layer1Cal; lcd_return_to_status(); end = true; break; @@ -6267,13 +6267,13 @@ static void lcd_main_menu() }*/ - if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) + if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) { MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 } - if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) + if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) { MENU_ITEM_SUBMENU_P(_i("Tune"), lcd_tune_menu);////MSG_TUNE } else @@ -6282,7 +6282,7 @@ static void lcd_main_menu() } #ifdef SDSUPPORT - if (card.cardOK || lcd_commands_type == LcdCommands::V2_CAL) + if (card.cardOK || lcd_commands_type == LcdCommands::Layer1Cal) { if (card.isFileOpen()) { @@ -6298,12 +6298,12 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } } - else if (lcd_commands_type == LcdCommands::V2_CAL && mesh_bed_leveling_flag == false && homing_flag == false) { + else if (lcd_commands_type == LcdCommands::Layer1Cal && mesh_bed_leveling_flag == false && homing_flag == false) { //MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } else { - if (!is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) + if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { //if (farm_mode) MENU_ITEM_SUBMENU_P(MSG_FARM_CARD_MENU, lcd_farm_sdcard_menu); /*else*/ { @@ -6327,7 +6327,7 @@ static void lcd_main_menu() #endif - if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::V2_CAL)) + if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) { if (farm_mode) { @@ -6371,7 +6371,7 @@ static void lcd_main_menu() } - if (!is_usb_printing && (lcd_commands_type != LcdCommands::V2_CAL)) + if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS } @@ -6656,7 +6656,7 @@ void lcd_print_stop() lcd_return_to_status(); lcd_ignore_click(true); lcd_commands_step = 0; - lcd_commands_type = LcdCommands::STOP_PRINT; + lcd_commands_type = LcdCommands::StopPrint; // Turn off the print fan SET_OUTPUT(FAN_PIN); WRITE(FAN_PIN, 0); @@ -8229,5 +8229,5 @@ void menu_lcd_lcdupdate_func(void) if (!SdFatUtil::test_stack_integrity()) stack_error(); lcd_ping(); //check that we have received ping command if we are in farm mode lcd_send_status(); - if (lcd_commands_type == LcdCommands::V2_CAL) lcd_commands(); + if (lcd_commands_type == LcdCommands::Layer1Cal) lcd_commands(); } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 26e282a0..f980b7fb 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -90,14 +90,14 @@ extern void lcd_diag_show_end_stops(); // To be used in lcd_commands_type. enum class LcdCommands : uint8_t { - IDLE = 0, - LOAD_FILAMENT = 1, - STOP_PRINT = 2, - UNKNOWN3 = 3, - FARM_MODE_CONFIRM = 4, - LONG_PAUSE = 5, - PID_EXTRUDER = 7, - V2_CAL = 8, + Idle = 0, + LoadFilament = 1, + StopPrint = 2, + Unknown3 = 3, + FarmModeConfirm = 4, + LongPause = 5, + PidExtruder = 7, + Layer1Cal = 8, }; extern LcdCommands lcd_commands_type; From 51df6cdfdc75c69cd6b167f9d4ed4b7e27b89972 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 18:22:57 +0200 Subject: [PATCH 30/36] Remove LcdCommands::Unknown3. Remove LcdCommands mapping to numbers, as it is not needed. --- Firmware/ultralcd.cpp | 5 ----- Firmware/ultralcd.h | 18 +++++++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 808cbfea..890475c2 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1543,11 +1543,6 @@ void lcd_commands() } } - if (lcd_commands_type == LcdCommands::Unknown3) - { - lcd_commands_type = LcdCommands::Idle; - } - if (lcd_commands_type == LcdCommands::FarmModeConfirm) /// farm mode confirm { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index f980b7fb..1a88679f 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -89,15 +89,15 @@ extern void lcd_diag_show_end_stops(); // To be used in lcd_commands_type. -enum class LcdCommands : uint8_t { - Idle = 0, - LoadFilament = 1, - StopPrint = 2, - Unknown3 = 3, - FarmModeConfirm = 4, - LongPause = 5, - PidExtruder = 7, - Layer1Cal = 8, +enum class LcdCommands : uint8_t +{ + Idle, + LoadFilament, + StopPrint, + FarmModeConfirm, + LongPause, + PidExtruder, + Layer1Cal, }; extern LcdCommands lcd_commands_type; From 5fcf76095468e9a8eb65ed573264d281d71c252e Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 18:42:55 +0200 Subject: [PATCH 31/36] Use first letter capital camel case for enum class members. Rename CustomMsgTypes to CustomMsg. Remove unnecessary maping to numbers. Change underlying type to uint_least8_t. --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 26 +++++++++++++------------- Firmware/mmu.cpp | 4 ++-- Firmware/ultralcd.cpp | 38 +++++++++++++++++++------------------- Firmware/ultralcd.h | 19 ++++++++++--------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index e896b838..cef1aa25 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -389,7 +389,7 @@ extern bool wizard_active; //autoload temporarily disabled during wizard extern LongTimer safetyTimer; #define PRINT_PERCENT_DONE_INIT 0xff -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsgTypes::TEMCAL) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved) //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 374d0b68..17d9e087 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3157,7 +3157,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float #endif //IR_SENSOR lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; } //! @brief Rise Z if too low to avoid blob/jam before filament loading @@ -3181,7 +3181,7 @@ void gcode_M701() else { enable_z(); - custom_message_type = CustomMsgTypes::F_LOAD; + custom_message_type = CustomMsg::FilamentLoading; #ifdef FSENSOR_QUALITY fsensor_oq_meassure_start(40); @@ -3211,7 +3211,7 @@ void gcode_M701() lcd_setstatuspgm(_T(WELCOME_MSG)); disable_z(); loading_flag = false; - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; #ifdef FSENSOR_QUALITY fsensor_oq_meassure_stop(); @@ -4194,7 +4194,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // setTargetHotend(200, 0); setTargetBed(70 + (start_temp - 30)); - custom_message_type = CustomMsgTypes::TEMCAL; + custom_message_type = CustomMsg::TempCal; custom_message_state = 1; lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; @@ -4296,7 +4296,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } puts_P(_N("PINDA probe calibration start")); - custom_message_type = CustomMsgTypes::TEMCAL; + custom_message_type = CustomMsg::TempCal; custom_message_state = 1; lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); current_position[X_AXIS] = PINDA_PREHEAT_X; @@ -4364,7 +4364,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); puts_P(_N("Temperature calibration done.")); @@ -4481,9 +4481,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; } // Save custom message state, set a new custom message state to display: Calibrating point 9. - CustomMsgTypes custom_message_type_old = custom_message_type; + CustomMsg custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CustomMsgTypes::MESHBL; + custom_message_type = CustomMsg::MeshBedLeveling; custom_message_state = (nMeasPoints * nMeasPoints) + 10; lcd_update(1); @@ -4683,7 +4683,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) enable_z_endstop(bState); } while (st_get_position_mm(Z_AXIS) > MESH_HOME_Z_SEARCH); // i.e. Z-leveling not o.k. // plan_set_z_position(MESH_HOME_Z_SEARCH); // is not necessary ('do-while' loop always ends at the expected Z-position) - custom_message_type=CustomMsgTypes::STATUS; // display / status-line recovery + custom_message_type=CustomMsg::Status; // display / status-line recovery lcd_update_enable(true); // display / status-line recovery gcode_G28(true, true, true); // X & Y & Z-homing (must be after individual Z-homing (problem with spool-holder)!) repeatcommand_front(); // re-run (i.e. of "G80") @@ -8210,7 +8210,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CustomMsgTypes::MESHBL; + custom_message_type = CustomMsg::MeshBedLeveling; custom_message_state = (x_points_num * y_points_num) + 10; lcd_update(1); @@ -8408,7 +8408,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ } unsigned int custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; - custom_message_type = CustomMsgTypes::MESHBL; + custom_message_type = CustomMsg::MeshBedLeveling; custom_message_state = (x_points_num * y_points_num) + 10; lcd_update(1); @@ -8558,7 +8558,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ void temp_compensation_start() { - custom_message_type = CustomMsgTypes::TEMPRE; + custom_message_type = CustomMsg::TempCompPreheat; custom_message_state = PINDA_HEAT_T + 1; lcd_update(2); if (degHotend(active_extruder) > EXTRUDE_MINTEMP) { @@ -8579,7 +8579,7 @@ void temp_compensation_start() { if (custom_message_state == 99 || custom_message_state == 9) lcd_update(2); //force whole display redraw if number of digits changed else lcd_update(1); } - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; custom_message_state = 0; } diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 912305d2..d13cee6f 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1372,13 +1372,13 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) mmu_load_to_nozzle(); load_filament_final_feed(); st_synchronize(); - custom_message_type = CustomMsgTypes::F_LOAD; + custom_message_type = CustomMsg::FilamentLoading; lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); lcd_return_to_status(); lcd_update_enable(true); lcd_load_filament_color_check(); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; } else { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 890475c2..f07efa32 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -77,7 +77,7 @@ bool presort_flag = false; LcdCommands lcd_commands_type = LcdCommands::Idle; static uint8_t lcd_commands_step = 0; -CustomMsgTypes custom_message_type = CustomMsgTypes::STATUS; +CustomMsg custom_message_type = CustomMsg::Status; unsigned int custom_message_state = 0; @@ -565,7 +565,7 @@ void lcdui_print_temp(char type, int val_current, int val_target) // Print Z-coordinate (8 chars total) void lcdui_print_Z_coord(void) { - if (custom_message_type == CustomMsgTypes::MESHBL) + if (custom_message_type == CustomMsg::MeshBedLeveling) lcd_puts_P(_N("Z --- ")); else lcd_printf_P(_N("Z%6.2f "), current_position[Z_AXIS]); @@ -760,7 +760,7 @@ void lcdui_print_status_line(void) break; } } - else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsgTypes::STATUS)) + else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsg::Status)) { // If printing from SD, show what we are printing if(strlen(card.longFilename) > LCD_WIDTH) { @@ -794,10 +794,10 @@ void lcdui_print_status_line(void) { // Otherwise check for other special events switch (custom_message_type) { - case CustomMsgTypes::STATUS: // Nothing special, print status message normally + case CustomMsg::Status: // Nothing special, print status message normally lcd_print(lcd_status_message); break; - case CustomMsgTypes::MESHBL: // If mesh bed leveling in progress, show the status + case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status if (custom_message_state > 10) { lcd_set_cursor(0, 3); @@ -813,7 +813,7 @@ void lcdui_print_status_line(void) { lcd_puts_P(_T(WELCOME_MSG)); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; } if (custom_message_state > 3 && custom_message_state <= 10 ) { @@ -825,10 +825,10 @@ void lcdui_print_status_line(void) } } break; - case CustomMsgTypes::F_LOAD: // If loading filament, print status + case CustomMsg::FilamentLoading: // If loading filament, print status lcd_print(lcd_status_message); break; - case CustomMsgTypes::PIDCAL: // PID tuning in progress + case CustomMsg::PidCal: // PID tuning in progress lcd_print(lcd_status_message); if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) { @@ -838,7 +838,7 @@ void lcdui_print_status_line(void) lcd_print(itostr3left(pid_number_of_cycles)); } break; - case CustomMsgTypes::TEMCAL: // PINDA temp calibration in progress + case CustomMsg::TempCal: // PINDA temp calibration in progress { char progress[4]; lcd_set_cursor(0, 3); @@ -848,7 +848,7 @@ void lcdui_print_status_line(void) lcd_print(progress); } break; - case CustomMsgTypes::TEMPRE: // temp compensation preheat + case CustomMsg::TempCompPreheat: // temp compensation preheat lcd_set_cursor(0, 3); lcd_puts_P(_i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 if (custom_message_state <= PINDA_HEAT_T) @@ -1465,7 +1465,7 @@ void lcd_commands() lcd_commands_step = 0; lcd_commands_type = LcdCommands::Idle; lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; isPrintPaused = false; } if (lcd_commands_step == 2 && !blocks_queued()) @@ -1521,7 +1521,7 @@ void lcd_commands() if (mmu_enabled) setAllTargetHotends(0); manage_heater(); - custom_message_type = CustomMsgTypes::F_LOAD; + custom_message_type = CustomMsg::FilamentLoading; lcd_commands_step = 5; } if (lcd_commands_step == 7 && !blocks_queued()) @@ -1589,7 +1589,7 @@ void lcd_commands() char cmd1[30]; if (lcd_commands_step == 0) { - custom_message_type = CustomMsgTypes::PIDCAL; + custom_message_type = CustomMsg::PidCal; custom_message_state = 1; lcd_draw_update = 3; lcd_commands_step = 3; @@ -1625,7 +1625,7 @@ void lcd_commands() } if ((lcd_commands_step == 1) && ((_millis()- display_time)>2000)) { //calibration finished message lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; pid_temp = DEFAULT_PID_TEMP; lcd_commands_step = 0; lcd_commands_type = LcdCommands::Idle; @@ -2758,7 +2758,7 @@ static void lcd_LoadFilament() if(0) { // menu_back(); // not necessary (see "lcd_return_to_status()" below) - custom_message_type = CustomMsgTypes::F_LOAD; + custom_message_type = CustomMsg::FilamentLoading; loading_flag = true; enquecommand_P(PSTR("M701")); //load filament SERIAL_ECHOLN("Loading filament"); @@ -3817,7 +3817,7 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui void lcd_temp_cal_show_result(bool result) { - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; disable_x(); disable_y(); disable_z(); @@ -5900,7 +5900,7 @@ static void change_extr_menu(){ //unload filament for single material printer (used in M702 gcode) void unload_filament() { - custom_message_type = CustomMsgTypes::F_LOAD; + custom_message_type = CustomMsg::FilamentLoading; lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT)); // extr_unload2(); @@ -5935,7 +5935,7 @@ void unload_filament() lcd_update_enable(true); lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsgTypes::STATUS; + custom_message_type = CustomMsg::Status; } @@ -6422,7 +6422,7 @@ static void lcd_colorprint_change() { enquecommand_P(PSTR("M600")); - custom_message_type = CustomMsgTypes::F_LOAD; //just print status message + custom_message_type = CustomMsg::FilamentLoading; //just print status message lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); lcd_return_to_status(); lcd_draw_update = 3; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 1a88679f..f802edd8 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -89,7 +89,7 @@ extern void lcd_diag_show_end_stops(); // To be used in lcd_commands_type. -enum class LcdCommands : uint8_t +enum class LcdCommands : uint_least8_t { Idle, LoadFilament, @@ -103,16 +103,17 @@ enum class LcdCommands : uint8_t extern LcdCommands lcd_commands_type; extern int8_t FSensorStateMenu; -enum class CustomMsgTypes : uint8_t { - STATUS = 0, //!< status message from lcd_status_message variable - MESHBL = 1, //!< Mesh bed leveling in progress - F_LOAD = 2, //!< Loading filament in progress - PIDCAL = 3, //!< PID tuning in progress - TEMCAL = 4, //!< PINDA temp calibration - TEMPRE = 5, //!< Temp compensation preheat +enum class CustomMsg : uint_least8_t +{ + Status, //!< status message from lcd_status_message variable + MeshBedLeveling, //!< Mesh bed leveling in progress + FilamentLoading, //!< Loading filament in progress + PidCal, //!< PID tuning in progress + TempCal, //!< PINDA temperature calibration + TempCompPreheat, //!< Temperature compensation preheat }; -extern CustomMsgTypes custom_message_type; +extern CustomMsg custom_message_type; extern unsigned int custom_message_state; extern uint8_t farm_mode; From 1390d4e5b9cf74b20b721be7cffee32a35f1473a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 12 Jun 2019 19:11:41 +0200 Subject: [PATCH 32/36] Use first letter capital camel case for enum class members. Change underlying type to uint_least8_t. --- Firmware/Marlin_main.cpp | 4 +- Firmware/mmu.cpp | 2 +- Firmware/ultralcd.cpp | 96 ++++++++++++++++++++-------------------- Firmware/ultralcd.h | 21 ++++----- 4 files changed, 62 insertions(+), 61 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 17d9e087..e6b0f947 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7693,7 +7693,7 @@ bool bInhibitFlag; #ifdef IR_SENSOR bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active #endif // IR_SENSOR - if ((mcode_in_progress != 600) && (eFilamentAction != eFILAMENT_ACTION::autoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active + if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && !wizard_active) { @@ -7719,7 +7719,7 @@ if(0) show_preheat_nozzle_warning(); lcd_update_enable(true); */ - eFilamentAction=eFILAMENT_ACTION::autoLoad; + eFilamentAction=FilamentAction::AutoLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index d13cee6f..fa4a5517 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1076,7 +1076,7 @@ if(0) extr_unload(); } else { - eFilamentAction=eFILAMENT_ACTION::mmuUnLoad; + eFilamentAction=FilamentAction::MmuUnLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f07efa32..890b7475 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1640,7 +1640,7 @@ void lcd_return_to_status() lcd_refresh(); // to maybe revive the LCD if static electricity killed it. menu_goto(lcd_status_screen, 0, false, true); menu_depth = 0; - eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad + eFilamentAction=FilamentAction::None; // i.e. non-autoLoad } //! @brief Pause print, disable nozzle heater, move to park position @@ -2179,7 +2179,7 @@ void lcd_set_filament_oq_meass() } -eFILAMENT_ACTION eFilamentAction=eFILAMENT_ACTION::none; // must be initialized as 'non-autoLoad' +FilamentAction eFilamentAction=FilamentAction::None; // must be initialized as 'non-autoLoad' bool bFilamentFirstRun; bool bFilamentPreheatState; bool bFilamentAction=false; @@ -2196,18 +2196,18 @@ lcd_puts_P(_i("Press the knob")); ////MSG_ c=20 r=1 lcd_set_cursor(0,3); switch(eFilamentAction) { - case eFILAMENT_ACTION::load: - case eFILAMENT_ACTION::autoLoad: - case eFILAMENT_ACTION::mmuLoad: + case FilamentAction::Load: + case FilamentAction::AutoLoad: + case FilamentAction::MmuLoad: lcd_puts_P(_i("to load filament")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::unLoad: - case eFILAMENT_ACTION::mmuUnLoad: + case FilamentAction::UnLoad: + case FilamentAction::MmuUnLoad: lcd_puts_P(_i("to unload filament")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::mmuEject: - case eFILAMENT_ACTION::mmuCut: - case eFILAMENT_ACTION::none: + case FilamentAction::MmuEject: + case FilamentAction::MmuCut: + case FilamentAction::None: break; } if(lcd_clicked()) @@ -2221,21 +2221,21 @@ if(lcd_clicked()) menu_back(nLevel); switch(eFilamentAction) { - case eFILAMENT_ACTION::autoLoad: - eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad + case FilamentAction::AutoLoad: + eFilamentAction=FilamentAction::None; // i.e. non-autoLoad // no break - case eFILAMENT_ACTION::load: + case FilamentAction::Load: loading_flag=true; enquecommand_P(PSTR("M701")); // load filament break; - case eFILAMENT_ACTION::unLoad: + case FilamentAction::UnLoad: enquecommand_P(PSTR("M702")); // unload filament break; - case eFILAMENT_ACTION::mmuLoad: - case eFILAMENT_ACTION::mmuUnLoad: - case eFILAMENT_ACTION::mmuEject: - case eFILAMENT_ACTION::mmuCut: - case eFILAMENT_ACTION::none: + case FilamentAction::MmuLoad: + case FilamentAction::MmuUnLoad: + case FilamentAction::MmuEject: + case FilamentAction::MmuCut: + case FilamentAction::None: break; } } @@ -2360,44 +2360,44 @@ if(current_temperature[0]>(target_temperature[0]*0.95)) { switch(eFilamentAction) { - case eFILAMENT_ACTION::load: - case eFILAMENT_ACTION::autoLoad: - case eFILAMENT_ACTION::unLoad: + case FilamentAction::Load: + case FilamentAction::AutoLoad: + case FilamentAction::UnLoad: if(bFilamentWaitingFlag) menu_submenu(mFilamentPrompt); else { nLevel=bFilamentPreheatState?1:2; menu_back(nLevel); - if((eFilamentAction==eFILAMENT_ACTION::load)||(eFilamentAction==eFILAMENT_ACTION::autoLoad)) + if((eFilamentAction==FilamentAction::Load)||(eFilamentAction==FilamentAction::AutoLoad)) { loading_flag=true; enquecommand_P(PSTR("M701")); // load filament - if(eFilamentAction==eFILAMENT_ACTION::autoLoad) - eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad + if(eFilamentAction==FilamentAction::AutoLoad) + eFilamentAction=FilamentAction::None; // i.e. non-autoLoad } - if(eFilamentAction==eFILAMENT_ACTION::unLoad) + if(eFilamentAction==FilamentAction::UnLoad) enquecommand_P(PSTR("M702")); // unload filament } break; - case eFILAMENT_ACTION::mmuLoad: + case FilamentAction::MmuLoad: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); menu_submenu(mmu_load_to_nozzle_menu); break; - case eFILAMENT_ACTION::mmuUnLoad: + case FilamentAction::MmuUnLoad: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); extr_unload(); break; - case eFILAMENT_ACTION::mmuEject: + case FilamentAction::MmuEject: nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; menu_back(nLevel); menu_submenu(mmu_fil_eject_menu); break; - case eFILAMENT_ACTION::mmuCut: + case FilamentAction::MmuCut: #ifdef MMU_HAS_CUTTER nLevel=bFilamentPreheatState?1:2; bFilamentAction=true; @@ -2405,7 +2405,7 @@ if(current_temperature[0]>(target_temperature[0]*0.95)) menu_submenu(mmu_cut_filament_menu); #endif //MMU_HAS_CUTTER break; - case eFILAMENT_ACTION::none: + case FilamentAction::None: break; } if(bFilamentWaitingFlag) @@ -2419,22 +2419,22 @@ else { lcd_set_cursor(0,1); switch(eFilamentAction) { - case eFILAMENT_ACTION::load: - case eFILAMENT_ACTION::autoLoad: - case eFILAMENT_ACTION::mmuLoad: + case FilamentAction::Load: + case FilamentAction::AutoLoad: + case FilamentAction::MmuLoad: lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::unLoad: - case eFILAMENT_ACTION::mmuUnLoad: + case FilamentAction::UnLoad: + case FilamentAction::MmuUnLoad: lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::mmuEject: + case FilamentAction::MmuEject: lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::mmuCut: + case FilamentAction::MmuCut: lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 r=1 break; - case eFILAMENT_ACTION::none: + case FilamentAction::None: break; } lcd_set_cursor(0,3); @@ -2453,8 +2453,8 @@ else { setTargetBed((float)nTargetBedOld); } menu_back(); - if(eFilamentAction==eFILAMENT_ACTION::autoLoad) - eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad + if(eFilamentAction==FilamentAction::AutoLoad) + eFilamentAction=FilamentAction::None; // i.e. non-autoLoad } } } @@ -2499,8 +2499,8 @@ mFilamentItem(FLEX_PREHEAT_HOTEND_TEMP,FLEX_PREHEAT_HPB_TEMP); void mFilamentBack() { menu_back(); -if(eFilamentAction==eFILAMENT_ACTION::autoLoad) - eFilamentAction=eFILAMENT_ACTION::none; // i.e. non-autoLoad +if(eFilamentAction==FilamentAction::AutoLoad) + eFilamentAction=FilamentAction::None; // i.e. non-autoLoad } void mFilamentMenu() @@ -2531,7 +2531,7 @@ if(0) enquecommand_P(PSTR("M702")); // unload filament } else { - eFilamentAction=eFILAMENT_ACTION::unLoad; + eFilamentAction=FilamentAction::UnLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -2766,7 +2766,7 @@ if(0) } else { - eFilamentAction=eFILAMENT_ACTION::load; + eFilamentAction=FilamentAction::Load; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -5795,7 +5795,7 @@ static void mmu_load_to_nozzle_menu() } else { - eFilamentAction = eFILAMENT_ACTION::mmuLoad; + eFilamentAction = FilamentAction::MmuLoad; bFilamentFirstRun = false; if (target_temperature[0] >= EXTRUDE_MINTEMP) { @@ -5827,7 +5827,7 @@ static void mmu_fil_eject_menu() } else { - eFilamentAction = eFILAMENT_ACTION::mmuEject; + eFilamentAction = FilamentAction::MmuEject; bFilamentFirstRun = false; if (target_temperature[0] >= EXTRUDE_MINTEMP) { @@ -5855,7 +5855,7 @@ static void mmu_cut_filament_menu() } else { - eFilamentAction=eFILAMENT_ACTION::mmuCut; + eFilamentAction=FilamentAction::MmuCut; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index f802edd8..99c4c0cf 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -151,18 +151,19 @@ void extr_unload_used(); #endif //SNMM void extr_unload(); -enum class eFILAMENT_ACTION : uint8_t { - none, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) - load, - autoLoad, - unLoad, - mmuLoad, - mmuUnLoad, - mmuEject, - mmuCut, +enum class FilamentAction : uint_least8_t +{ + None, //!< 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) + Load, + AutoLoad, + UnLoad, + MmuLoad, + MmuUnLoad, + MmuEject, + MmuCut, }; -extern eFILAMENT_ACTION eFilamentAction; +extern FilamentAction eFilamentAction; extern bool bFilamentFirstRun; extern bool bFilamentPreheatState; extern bool bFilamentAction; From 25f0eb9a3983782d63d2de517e44db174f25ca0f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 13 Jun 2019 15:01:54 +0200 Subject: [PATCH 33/36] Fix spelling. --- Firmware/Marlin_main.cpp | 4 ++-- Firmware/first_lay_cal.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 230fda94..660f5095 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8229,7 +8229,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi float bed_zero_ref_y = (-0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER); float mesh_home_z_search = 4; - float measure_z_heigth = 0.2f; + float measure_z_height = 0.2f; float row[x_points_num]; int ix = 0; int iy = 0; @@ -8264,7 +8264,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi } st_synchronize(); */ - destination[Z_AXIS] = measure_z_heigth; + destination[Z_AXIS] = measure_z_height; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 50f08c5e..bfec021f 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -128,19 +128,19 @@ void lay1cal_before_meander() //! @brief Count extrude length //! -//! @param layer_heigth layer heigth in mm +//! @param layer_height layer height in mm //! @param extrusion_width extrusion width in mm //! @param extrusion_length extrusion length in mm //! @return filament length in mm which needs to be extruded to form line -static constexpr float count_e(float layer_heigth, float extrusion_width, float extrusion_length) +static constexpr float count_e(float layer_height, float extrusion_width, float extrusion_length) { - return (extrusion_length * layer_heigth * extrusion_width / (M_PI * pow(1.75, 2) / 4)); + return (extrusion_length * layer_height * extrusion_width / (M_PI * pow(1.75, 2) / 4)); } static const float width = 0.4; //!< line width static const float length = 20 - width; //!< line length -static const float heigth = 0.2; //!< layer height TODO This is wrong, as current Z height is 0.15 mm -static const float extr = count_e(heigth, width, length); //!< E axis movement needed to print line +static const float height = 0.2; //!< layer height TODO This is wrong, as current Z height is 0.15 mm +static const float extr = count_e(height, width, length); //!< E axis movement needed to print line //! @brief Print meander //! @param cmd_buffer character buffer needed to format gcodes @@ -199,7 +199,7 @@ void lay1cal_meander(char *cmd_buffer) //! @param i iteration void lay1cal_square(char *cmd_buffer, uint8_t i) { - const float extr_short_segment = count_e(heigth, width, width); + const float extr_short_segment = count_e(height, width, width); static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f"; static const char fmt2[] PROGMEM = "G1 Y%-.2f E%-.3f"; From fee67d9451a68c203617bdfd5c87652401a3cc94 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 13 Jun 2019 16:37:51 +0200 Subject: [PATCH 34/36] Increase version. --- Firmware/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index bfa44a73..eee1b167 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.7.1" -#define FW_COMMIT_NR 2266 +#define FW_VERSION "3.7.2-RC1" +#define FW_COMMIT_NR 2359 // 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 e46cc30c61aa624811dfcdc8a425a44f44bdb2de Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 13 Jun 2019 18:00:31 +0200 Subject: [PATCH 35/36] Fix length false positives... - Just reading the length of the translation line gives false positives as the " are included in the length BUT not displayed on the LCD. - added missing argument 'pl' --- lang/lang-check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/lang-check.py b/lang/lang-check.py index 6b918df8..f592798e 100644 --- a/lang/lang-check.py +++ b/lang/lang-check.py @@ -38,7 +38,7 @@ def parse_txt(lang, no_warning): if rows is None: rows = 1 - if len(translation) > cols*rows: + if len(translation)-2 > cols*rows: stderr.write( "[E]: Text %s is longer then definiton on line %d\n" % (translation, lines)) @@ -56,7 +56,7 @@ def main(): usage="$(prog)s lang") parser.add_argument( "lang", nargs='?', default="en", type=str, - help="Check lang file (en|cs|de|es|fr|it)") + help="Check lang file (en|cs|de|es|fr|it|pl)") parser.add_argument( "--no-warning", action="store_true", help="Disable warnings") From b1df1fb1f120114c032ae475e4e663944b1d8a4e Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 14 Jun 2019 18:18:27 +0200 Subject: [PATCH 36/36] Fix formatting. We are never using 2 space indentation. 4 spaces are preferred, tabulator is acceptable if surrounding code uses tabs. --- Firmware/Marlin_main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index cb262e12..575dec97 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3146,9 +3146,10 @@ void gcode_M701() { printf_P(PSTR("gcode_M701 begin\n")); - if (farm_mode){ - prusa_statistics(22); - } + if (farm_mode) + { + prusa_statistics(22); + } if (mmu_enabled) {