Procházet zdrojové kódy

Support temperature units in M503

Scott Lahteine před 8 roky
rodič
revize
ce507deb9f
2 změnil soubory, kde provedl 35 přidání a 10 odebrání
  1. 8
    7
      Marlin/Marlin_main.cpp
  2. 27
    3
      Marlin/configuration_store.cpp

+ 8
- 7
Marlin/Marlin_main.cpp Zobrazit soubor

@@ -1294,25 +1294,26 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
1294 1294
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1295 1295
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1296 1296
 
1297
-  int16_t code_value_temp_abs() {
1297
+  float temp_abs(const float &c) {
1298 1298
     switch (input_temp_units) {
1299 1299
       case TEMPUNIT_F:
1300
-        return (code_value_float() - 32) * 0.5555555556;
1300
+        return (c - 32.0) * 0.5555555556;
1301 1301
       case TEMPUNIT_K:
1302
-        return code_value_float() - 273.15;
1302
+        return c - 273.15;
1303 1303
       case TEMPUNIT_C:
1304 1304
       default:
1305
-        return code_value_int();
1305
+        return c;
1306 1306
     }
1307 1307
   }
1308 1308
 
1309
+  int16_t code_value_temp_abs() { return temp_abs(code_value_float()); }
1310
+
1309 1311
   int16_t code_value_temp_diff() {
1310 1312
     switch (input_temp_units) {
1311
-      case TEMPUNIT_C:
1312
-      case TEMPUNIT_K:
1313
-        return code_value_float();
1314 1313
       case TEMPUNIT_F:
1315 1314
         return code_value_float() * 0.5555555556;
1315
+      case TEMPUNIT_C:
1316
+      case TEMPUNIT_K:
1316 1317
       default:
1317 1318
         return code_value_float();
1318 1319
     }

+ 27
- 3
Marlin/configuration_store.cpp Zobrazit soubor

@@ -1239,7 +1239,10 @@ void MarlinSettings::reset() {
1239 1239
       extern float linear_unit_factor, volumetric_unit_factor;
1240 1240
       #define LINEAR_UNIT(N) ((N) / linear_unit_factor)
1241 1241
       #define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor))
1242
-      serialprintPGM(linear_unit_factor == 1.0 ? PSTR("  G21 ; Units in mm\n") : PSTR("  G20 ; Units in inches\n"));
1242
+      SERIAL_ECHOPGM("  G2");
1243
+      SERIAL_CHAR(linear_unit_factor == 1.0 ? '1' : '0');
1244
+      SERIAL_ECHOPGM(" ; Units in ");
1245
+      serialprintPGM(linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n"));
1243 1246
     #else
1244 1247
       #define LINEAR_UNIT(N) N
1245 1248
       #define VOLUMETRIC_UNIT(N) N
@@ -1247,6 +1250,27 @@ void MarlinSettings::reset() {
1247 1250
     #endif
1248 1251
     SERIAL_EOL;
1249 1252
 
1253
+    #if ENABLED(ULTIPANEL)
1254
+
1255
+      // Temperature units - for Ultipanel temperature options
1256
+
1257
+      CONFIG_ECHO_START;
1258
+      #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1259
+        extern TempUnit input_temp_units;
1260
+        extern float temp_abs(float &f);
1261
+        #define TEMP_UNIT(N) temp_abs(N)
1262
+        SERIAL_ECHOPGM("  M149 ");
1263
+        SERIAL_CHAR(input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C');
1264
+        SERIAL_ECHOPGM(" ; Units in ");
1265
+        serialprintPGM(input_temp_units == TEMPUNIT_K ? PSTR("Kelvin\n") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit\n") : PSTR("Celsius\n"));
1266
+      #else
1267
+        #define TEMP_UNIT(N) N
1268
+        SERIAL_ECHOLNPGM("  M149 C ; Units in Celsius\n");
1269
+      #endif
1270
+      SERIAL_EOL;
1271
+
1272
+    #endif
1273
+
1250 1274
     /**
1251 1275
      * Volumetric extrusion M200
1252 1276
      */
@@ -1519,8 +1543,8 @@ void MarlinSettings::reset() {
1519 1543
       CONFIG_ECHO_START;
1520 1544
       for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
1521 1545
         SERIAL_ECHOPAIR("  M145 S", (int)i);
1522
-        SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
1523
-        SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
1546
+        SERIAL_ECHOPAIR(" H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
1547
+        SERIAL_ECHOPAIR(" B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
1524 1548
         SERIAL_ECHOLNPAIR(" F", lcd_preheat_fan_speed[i]);
1525 1549
       }
1526 1550
     #endif // ULTIPANEL

Loading…
Zrušit
Uložit