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.

This commit is contained in:
Marek Bel 2019-06-11 18:26:59 +02:00
parent 97a5d6b5f4
commit d21f256cd0
1 changed files with 123 additions and 170 deletions

View File

@ -1367,56 +1367,48 @@ void lcd_commands()
const float length = 20 - width; const float length = 20 - width;
const float extr = count_e(0.2, width, length); const float extr = count_e(0.2, width, length);
const float extr_short_segment = count_e(0.2, width, width); 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>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()) if (!blocks_queued() && cmd_buffer_empty())
{ {
switch(lcd_commands_step)
{
case 0:
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
if (lcd_commands_step == 20 && !blocks_queued() && cmd_buffer_empty()) case 20:
{
filament = 0; filament = 0;
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
if (lcd_commands_step == 21 && !blocks_queued() && cmd_buffer_empty()) case 21:
{
filament = 1; filament = 1;
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
if (lcd_commands_step == 22 && !blocks_queued() && cmd_buffer_empty()) case 22:
{
filament = 2; filament = 2;
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
if (lcd_commands_step == 23 && !blocks_queued() && cmd_buffer_empty()) case 23:
{
filament = 3; filament = 3;
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
if (lcd_commands_step == 24 && !blocks_queued() && cmd_buffer_empty()) case 24:
{
filament = 4; filament = 4;
lcd_commands_step = 10; lcd_commands_step = 10;
} break;
case 10:
if (lcd_commands_step == 10)
{
lay1cal_preheat(); lay1cal_preheat();
lcd_commands_step = 9; lcd_commands_step = 9;
} break;
if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty()) case 9:
{
lcd_clear(); lcd_clear();
menu_depth = 0; menu_depth = 0;
menu_submenu(lcd_babystep_z); menu_submenu(lcd_babystep_z);
lay1cal_intro_line(cmd1, filament); lay1cal_intro_line(cmd1, filament);
lcd_commands_step = 8; lcd_commands_step = 8;
} break;
if (lcd_commands_step == 8 && !blocks_queued() && cmd_buffer_empty()) case 8:
{
enquecommand_P(PSTR("G92 E0.0")); enquecommand_P(PSTR("G92 E0.0"));
enquecommand_P(PSTR("G21")); //set units to millimeters enquecommand_P(PSTR("G21")); //set units to millimeters
enquecommand_P(PSTR("G90")); //use absolute coordinates enquecommand_P(PSTR("G90")); //use absolute coordinates
@ -1426,31 +1418,8 @@ void lcd_commands()
enquecommand_P(PSTR("M204 S1000")); //set acceleration enquecommand_P(PSTR("M204 S1000")); //set acceleration
enquecommand_P(PSTR("G1 F4000")); enquecommand_P(PSTR("G1 F4000"));
lcd_commands_step = 7; lcd_commands_step = 7;
} break;
if (lcd_commands_step == 7 && !blocks_queued() && cmd_buffer_empty()) //draw meander case 7:
{
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 X50 Y155"));
enquecommand_P(PSTR("G1 Z0.150 F7200.000")); enquecommand_P(PSTR("G1 Z0.150 F7200.000"));
enquecommand_P(PSTR("G1 F1080")); enquecommand_P(PSTR("G1 F1080"));
@ -1473,53 +1442,36 @@ void lcd_commands()
enquecommand(cmd1); enquecommand(cmd1);
lcd_commands_step = 6; lcd_commands_step = 6;
} break;
case 6:
if (lcd_commands_step == 6 && !blocks_queued() && cmd_buffer_empty()) for (uint8_t i = 0; i < 4; i++)
{ {
lcd_timeoutToStatus.start();
for (uint8_t i = 0; i < 4; i++) {
lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); lcd_commands_func1(cmd1, i, width, extr, extr_short_segment );
} }
lcd_commands_step = 5; lcd_commands_step = 5;
} break;
case 5:
if (lcd_commands_step == 5 && !blocks_queued() && cmd_buffer_empty()) for (uint8_t i = 4; i < 8; i++)
{ {
lcd_timeoutToStatus.start();
for (uint8_t i = 4; i < 8; i++) {
lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); lcd_commands_func1(cmd1, i, width, extr, extr_short_segment );
} }
lcd_commands_step = 4; lcd_commands_step = 4;
} break;
case 4:
if (lcd_commands_step == 4 && !blocks_queued() && cmd_buffer_empty()) for (uint8_t i = 8; i < 12; i++)
{ {
lcd_timeoutToStatus.start();
for (uint8_t i = 8; i < 12; i++) {
lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); lcd_commands_func1(cmd1, i, width, extr, extr_short_segment );
} }
lcd_commands_step = 3; lcd_commands_step = 3;
} break;
case 3:
if (lcd_commands_step == 3 && !blocks_queued() && cmd_buffer_empty()) for (uint8_t i = 12; i < 16; i++)
{ {
lcd_timeoutToStatus.start();
for (uint8_t i = 12; i < 16; i++) {
lcd_commands_func1(cmd1, i, width, extr, extr_short_segment ); lcd_commands_func1(cmd1, i, width, extr, extr_short_segment );
} }
lcd_commands_step = 2; lcd_commands_step = 2;
} break;
case 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("M107")); //turn off printer fan
enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); //retract enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); //retract
enquecommand_P(PSTR("M104 S0")); // turn off temperature enquecommand_P(PSTR("M104 S0")); // turn off temperature
@ -1530,17 +1482,18 @@ void lcd_commands()
enquecommand_P(PSTR("M84"));// disable motors 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 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; lcd_commands_step = 1;
} break;
if (lcd_commands_step == 1 && !blocks_queued() && cmd_buffer_empty()) case 1:
{
lcd_setstatuspgm(_T(WELCOME_MSG)); lcd_setstatuspgm(_T(WELCOME_MSG));
lcd_commands_step = 0; lcd_commands_step = 0;
lcd_commands_type = 0; lcd_commands_type = 0;
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1)
{
lcd_wizard(WizState::RepeatLay1Cal); lcd_wizard(WizState::RepeatLay1Cal);
} }
break;
}
} }
} }
#endif // not SNMM #endif // not SNMM