1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 13:25:54 +00:00

Patch configuration temp units

This commit is contained in:
Scott Lahteine 2017-05-07 21:32:01 -05:00
parent c9bfe7004c
commit bb7e3f1d07
2 changed files with 17 additions and 6 deletions

View File

@ -1298,19 +1298,30 @@ 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; }
float temp_abs(const float &c) {
float to_temp_units(const float &c) {
switch (input_temp_units) {
case TEMPUNIT_F:
return (c - 32.0) * 0.5555555556;
return c * 0.5555555556 + 32.0;
case TEMPUNIT_K:
return c - 273.15;
return c + 273.15;
case TEMPUNIT_C:
default:
return c;
}
}
int16_t code_value_temp_abs() { return temp_abs(code_value_float()); }
int16_t code_value_temp_abs() {
const float c = code_value_float();
switch (input_temp_units) {
case TEMPUNIT_F:
return (int16_t)((c - 32.0) * 0.5555555556);
case TEMPUNIT_K:
return (int16_t)(c - 273.15);
case TEMPUNIT_C:
default:
return (int16_t)(c);
}
}
int16_t code_value_temp_diff() {
switch (input_temp_units) {

View File

@ -1257,8 +1257,8 @@ void MarlinSettings::reset() {
CONFIG_ECHO_START;
#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
extern TempUnit input_temp_units;
extern float temp_abs(const float &f);
#define TEMP_UNIT(N) temp_abs(N)
extern float to_temp_units(const float &f);
#define TEMP_UNIT(N) to_temp_units(N)
SERIAL_ECHOPGM(" M149 ");
SERIAL_CHAR(input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C');
SERIAL_ECHOPGM(" ; Units in ");