Make LCD preheat vars an array to reduce code size

This commit is contained in:
Scott Lahteine 2016-10-27 02:40:37 -05:00
parent 1226ae1912
commit 1a2310c494
4 changed files with 70 additions and 119 deletions

View File

@ -5519,46 +5519,26 @@ inline void gcode_M140() {
*/
inline void gcode_M145() {
int8_t material = code_seen('S') ? (int8_t)code_value_int() : 0;
if (material < 0 || material > 1) {
if (material < 0 || material >= COUNT(lcd_preheat_hotend_temp)) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
}
else {
int v;
switch (material) {
case 0:
if (code_seen('H')) {
v = code_value_int();
preheatHotendTemp1 = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
}
if (code_seen('F')) {
v = code_value_int();
preheatFanSpeed1 = constrain(v, 0, 255);
lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
}
#if TEMP_SENSOR_BED != 0
if (code_seen('B')) {
v = code_value_int();
preheatBedTemp1 = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
}
#endif
break;
case 1:
if (code_seen('H')) {
v = code_value_int();
preheatHotendTemp2 = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
}
if (code_seen('F')) {
v = code_value_int();
preheatFanSpeed2 = constrain(v, 0, 255);
}
#if TEMP_SENSOR_BED != 0
if (code_seen('B')) {
v = code_value_int();
preheatBedTemp2 = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
}
#endif
break;
}
}
}

View File

@ -86,12 +86,9 @@
* 301 M666 Z z_endstop_adj (float)
*
* ULTIPANEL:
* 305 M145 S0 H preheatHotendTemp1 (int)
* 307 M145 S0 B preheatBedTemp1 (int)
* 309 M145 S0 F preheatFanSpeed1 (int)
* 311 M145 S1 H preheatHotendTemp2 (int)
* 313 M145 S1 B preheatBedTemp2 (int)
* 315 M145 S1 F preheatFanSpeed2 (int)
* 305 M145 S0 H lcd_preheat_hotend_temp (int x2)
* 309 M145 S0 B lcd_preheat_bed_temp (int x2)
* 313 M145 S0 F lcd_preheat_fan_speed (int x2)
*
* PIDTEMP:
* 317 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
@ -277,16 +274,14 @@ void Config_Postprocess() {
#endif
#if DISABLED(ULTIPANEL)
int preheatHotendTemp1 = PREHEAT_1_TEMP_HOTEND, preheatBedTemp1 = PREHEAT_1_TEMP_BED, preheatFanSpeed1 = PREHEAT_1_FAN_SPEED,
preheatHotendTemp2 = PREHEAT_2_TEMP_HOTEND, preheatBedTemp2 = PREHEAT_2_TEMP_BED, preheatFanSpeed2 = PREHEAT_2_FAN_SPEED;
const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
#endif // !ULTIPANEL
EEPROM_WRITE(preheatHotendTemp1);
EEPROM_WRITE(preheatBedTemp1);
EEPROM_WRITE(preheatFanSpeed1);
EEPROM_WRITE(preheatHotendTemp2);
EEPROM_WRITE(preheatBedTemp2);
EEPROM_WRITE(preheatFanSpeed2);
EEPROM_WRITE(lcd_preheat_hotend_temp);
EEPROM_WRITE(lcd_preheat_bed_temp);
EEPROM_WRITE(lcd_preheat_fan_speed);
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
@ -465,16 +460,12 @@ void Config_Postprocess() {
#endif
#if DISABLED(ULTIPANEL)
int preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1,
preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2;
int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
#endif
EEPROM_READ(preheatHotendTemp1);
EEPROM_READ(preheatBedTemp1);
EEPROM_READ(preheatFanSpeed1);
EEPROM_READ(preheatHotendTemp2);
EEPROM_READ(preheatBedTemp2);
EEPROM_READ(preheatFanSpeed2);
EEPROM_READ(lcd_preheat_hotend_temp);
EEPROM_READ(lcd_preheat_bed_temp);
EEPROM_READ(lcd_preheat_fan_speed);
#if ENABLED(PIDTEMP)
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
@ -639,12 +630,12 @@ void Config_ResetDefault() {
#endif
#if ENABLED(ULTIPANEL)
preheatHotendTemp1 = PREHEAT_1_TEMP_HOTEND;
preheatBedTemp1 = PREHEAT_1_TEMP_BED;
preheatFanSpeed1 = PREHEAT_1_FAN_SPEED;
preheatHotendTemp2 = PREHEAT_2_TEMP_HOTEND;
preheatBedTemp2 = PREHEAT_2_TEMP_BED;
preheatFanSpeed2 = PREHEAT_2_FAN_SPEED;
lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
#endif
#if HAS_LCD_CONTRAST
@ -863,15 +854,13 @@ void Config_ResetDefault() {
SERIAL_ECHOLNPGM("Material heatup parameters:");
CONFIG_ECHO_START;
}
SERIAL_ECHOPAIR(" M145 S0 H", preheatHotendTemp1);
SERIAL_ECHOPAIR(" B", preheatBedTemp1);
SERIAL_ECHOPAIR(" F", preheatFanSpeed1);
SERIAL_EOL;
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M145 S1 H", preheatHotendTemp2);
SERIAL_ECHOPAIR(" B", preheatBedTemp2);
SERIAL_ECHOPAIR(" F", preheatFanSpeed2);
for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
SERIAL_ECHOPAIR(" M145 S", (int)i);
SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
SERIAL_ECHOPAIR(" F", lcd_preheat_fan_speed[i]);
SERIAL_EOL;
}
#endif // ULTIPANEL
#if HAS_PID_HEATING

View File

@ -43,8 +43,7 @@
#include "duration_t.h"
#endif
int preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1,
preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2;
int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
#if ENABLED(FILAMENT_LCD_DISPLAY)
millis_t previous_lcd_status_ms = 0;
@ -887,29 +886,29 @@ void kill_screen(const char* lcd_msg) {
}
#if TEMP_SENSOR_0 != 0
void lcd_preheat_pla0() { _lcd_preheat(0, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
void lcd_preheat_abs0() { _lcd_preheat(0, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
void lcd_preheat_pla0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_abs0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif
#if HOTENDS > 1
void lcd_preheat_pla1() { _lcd_preheat(1, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
void lcd_preheat_abs1() { _lcd_preheat(1, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
void lcd_preheat_pla1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_abs1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#if HOTENDS > 2
void lcd_preheat_pla2() { _lcd_preheat(2, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
void lcd_preheat_abs2() { _lcd_preheat(2, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
void lcd_preheat_pla2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_abs2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#if HOTENDS > 3
void lcd_preheat_pla3() { _lcd_preheat(3, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
void lcd_preheat_abs3() { _lcd_preheat(3, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
void lcd_preheat_pla3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_abs3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif
#endif
void lcd_preheat_pla0123() {
#if HOTENDS > 1
thermalManager.setTargetHotend(preheatHotendTemp1, 1);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(preheatHotendTemp1, 2);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(preheatHotendTemp1, 3);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
#endif
#endif
#endif
@ -917,11 +916,11 @@ void kill_screen(const char* lcd_msg) {
}
void lcd_preheat_abs0123() {
#if HOTENDS > 1
thermalManager.setTargetHotend(preheatHotendTemp2, 1);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(preheatHotendTemp2, 2);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(preheatHotendTemp2, 3);
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
#endif
#endif
#endif
@ -931,8 +930,8 @@ void kill_screen(const char* lcd_msg) {
#endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0
void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, preheatBedTemp1, preheatFanSpeed1); }
void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, preheatBedTemp2, preheatFanSpeed2); }
void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif
#if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
@ -1766,20 +1765,15 @@ void kill_screen(const char* lcd_msg) {
END_MENU();
}
/**
*
* "Temperature" > "Preheat PLA conf" submenu
*
*/
static void lcd_control_temperature_preheat_pla_settings_menu() {
static void _lcd_control_temperature_preheat_settings_menu(uint8_t material) {
START_MENU();
MENU_BACK(MSG_TEMPERATURE);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &preheatFanSpeed1, 0, 255);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &preheatHotendTemp1, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &preheatBedTemp1, BED_MINTEMP, BED_MAXTEMP - 15);
MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
@ -1787,26 +1781,19 @@ void kill_screen(const char* lcd_msg) {
END_MENU();
}
/**
*
* "Temperature" > "Preheat PLA conf" submenu
*
*/
static void lcd_control_temperature_preheat_pla_settings_menu() { _lcd_control_temperature_preheat_settings_menu(0); }
/**
*
* "Temperature" > "Preheat ABS conf" submenu
*
*/
static void lcd_control_temperature_preheat_abs_settings_menu() {
START_MENU();
MENU_BACK(MSG_TEMPERATURE);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &preheatFanSpeed2, 0, 255);
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &preheatHotendTemp2, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &preheatBedTemp2, BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
#endif
END_MENU();
}
static void lcd_control_temperature_preheat_abs_settings_menu() { _lcd_control_temperature_preheat_settings_menu(1); }
static void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
static void _planner_refresh_positioning() { planner.refresh_positioning(); }

View File

@ -30,12 +30,7 @@
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
extern int preheatHotendTemp1,
preheatBedTemp1,
preheatFanSpeed1,
preheatHotendTemp2,
preheatBedTemp2,
preheatFanSpeed2;
extern int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
int lcd_strlen(const char* s);
int lcd_strlen_P(const char* s);