Support temperature units in M503

This commit is contained in:
Scott Lahteine 2017-05-06 19:41:50 -05:00
parent d99794f11d
commit fbd021a756
2 changed files with 35 additions and 10 deletions

View File

@ -1294,25 +1294,26 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
int16_t code_value_temp_abs() {
float temp_abs(const float &c) {
switch (input_temp_units) {
case TEMPUNIT_F:
return (code_value_float() - 32) * 0.5555555556;
return (c - 32.0) * 0.5555555556;
case TEMPUNIT_K:
return code_value_float() - 273.15;
return c - 273.15;
case TEMPUNIT_C:
default:
return code_value_int();
return c;
}
}
int16_t code_value_temp_abs() { return temp_abs(code_value_float()); }
int16_t code_value_temp_diff() {
switch (input_temp_units) {
case TEMPUNIT_C:
case TEMPUNIT_K:
return code_value_float();
case TEMPUNIT_F:
return code_value_float() * 0.5555555556;
case TEMPUNIT_C:
case TEMPUNIT_K:
default:
return code_value_float();
}

View File

@ -1239,7 +1239,10 @@ void MarlinSettings::reset() {
extern float linear_unit_factor, volumetric_unit_factor;
#define LINEAR_UNIT(N) ((N) / linear_unit_factor)
#define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor))
serialprintPGM(linear_unit_factor == 1.0 ? PSTR(" G21 ; Units in mm\n") : PSTR(" G20 ; Units in inches\n"));
SERIAL_ECHOPGM(" G2");
SERIAL_CHAR(linear_unit_factor == 1.0 ? '1' : '0');
SERIAL_ECHOPGM(" ; Units in ");
serialprintPGM(linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n"));
#else
#define LINEAR_UNIT(N) N
#define VOLUMETRIC_UNIT(N) N
@ -1247,6 +1250,27 @@ void MarlinSettings::reset() {
#endif
SERIAL_EOL;
#if ENABLED(ULTIPANEL)
// Temperature units - for Ultipanel temperature options
CONFIG_ECHO_START;
#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
extern TempUnit input_temp_units;
extern float temp_abs(float &f);
#define TEMP_UNIT(N) temp_abs(N)
SERIAL_ECHOPGM(" M149 ");
SERIAL_CHAR(input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C');
SERIAL_ECHOPGM(" ; Units in ");
serialprintPGM(input_temp_units == TEMPUNIT_K ? PSTR("Kelvin\n") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit\n") : PSTR("Celsius\n"));
#else
#define TEMP_UNIT(N) N
SERIAL_ECHOLNPGM(" M149 C ; Units in Celsius\n");
#endif
SERIAL_EOL;
#endif
/**
* Volumetric extrusion M200
*/
@ -1519,8 +1543,8 @@ void MarlinSettings::reset() {
CONFIG_ECHO_START;
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(" H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
SERIAL_ECHOPAIR(" B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
SERIAL_ECHOLNPAIR(" F", lcd_preheat_fan_speed[i]);
}
#endif // ULTIPANEL