From 4effff9e9991a56a14fb246ba5d503faa231b18a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 11 Jun 2019 18:56:29 +0200 Subject: [PATCH] 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: