Browse Source

Patch configuration temp units

Scott Lahteine 8 years ago
parent
commit
56ca47ab9d
2 changed files with 17 additions and 6 deletions
  1. 15
    4
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/configuration_store.cpp

+ 15
- 4
Marlin/Marlin_main.cpp View File

1298
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1298
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1299
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1299
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1300
 
1300
 
1301
-  float temp_abs(const float &c) {
1301
+  float to_temp_units(const float &c) {
1302
     switch (input_temp_units) {
1302
     switch (input_temp_units) {
1303
       case TEMPUNIT_F:
1303
       case TEMPUNIT_F:
1304
-        return (c - 32.0) * 0.5555555556;
1304
+        return c * 0.5555555556 + 32.0;
1305
       case TEMPUNIT_K:
1305
       case TEMPUNIT_K:
1306
-        return c - 273.15;
1306
+        return c + 273.15;
1307
       case TEMPUNIT_C:
1307
       case TEMPUNIT_C:
1308
       default:
1308
       default:
1309
         return c;
1309
         return c;
1310
     }
1310
     }
1311
   }
1311
   }
1312
 
1312
 
1313
-  int16_t code_value_temp_abs() { return temp_abs(code_value_float()); }
1313
+  int16_t code_value_temp_abs() {
1314
+    const float c = code_value_float();
1315
+    switch (input_temp_units) {
1316
+      case TEMPUNIT_F:
1317
+        return (int16_t)((c - 32.0) * 0.5555555556);
1318
+      case TEMPUNIT_K:
1319
+        return (int16_t)(c - 273.15);
1320
+      case TEMPUNIT_C:
1321
+      default:
1322
+        return (int16_t)(c);
1323
+    }
1324
+  }
1314
 
1325
 
1315
   int16_t code_value_temp_diff() {
1326
   int16_t code_value_temp_diff() {
1316
     switch (input_temp_units) {
1327
     switch (input_temp_units) {

+ 2
- 2
Marlin/configuration_store.cpp View File

1257
       CONFIG_ECHO_START;
1257
       CONFIG_ECHO_START;
1258
       #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1258
       #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1259
         extern TempUnit input_temp_units;
1259
         extern TempUnit input_temp_units;
1260
-        extern float temp_abs(const float &f);
1261
-        #define TEMP_UNIT(N) temp_abs(N)
1260
+        extern float to_temp_units(const float &f);
1261
+        #define TEMP_UNIT(N) to_temp_units(N)
1262
         SERIAL_ECHOPGM("  M149 ");
1262
         SERIAL_ECHOPGM("  M149 ");
1263
         SERIAL_CHAR(input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C');
1263
         SERIAL_CHAR(input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C');
1264
         SERIAL_ECHOPGM(" ; Units in ");
1264
         SERIAL_ECHOPGM(" ; Units in ");

Loading…
Cancel
Save