Browse Source

Merge plus fixup zprobe_zoffset

- Make `zprobe_zoffset` conditional
- Fix ConfigurationStore for `zprobe_zoffset`
Scott Lahteine 9 years ago
parent
commit
fbf9b21e0c
5 changed files with 122 additions and 77 deletions
  1. 29
    14
      Marlin/ConfigurationStore.cpp
  2. 3
    1
      Marlin/Marlin.h
  3. 52
    31
      Marlin/Marlin_main.cpp
  4. 37
    30
      Marlin/temperature.cpp
  5. 1
    1
      Marlin/ultralcd.cpp

+ 29
- 14
Marlin/ConfigurationStore.cpp View File

25
  *  mesh_num_x
25
  *  mesh_num_x
26
  *  mesh_num_y
26
  *  mesh_num_y
27
  *  z_values[][]
27
  *  z_values[][]
28
+ *  zprobe_zoffset
28
  *
29
  *
29
  * DELTA:
30
  * DELTA:
30
  *  endstop_adj (x3)
31
  *  endstop_adj (x3)
39
  *  absPreheatHotendTemp
40
  *  absPreheatHotendTemp
40
  *  absPreheatHPBTemp
41
  *  absPreheatHPBTemp
41
  *  absPreheatFanSpeed
42
  *  absPreheatFanSpeed
42
- *  zprobe_zoffset
43
  *
43
  *
44
  * PIDTEMP:
44
  * PIDTEMP:
45
  *  Kp[0], Ki[0], Kd[0], Kc[0]
45
  *  Kp[0], Ki[0], Kd[0], Kc[0]
118
 // wrong data being written to the variables.
118
 // wrong data being written to the variables.
119
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
119
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
120
 
120
 
121
-#define EEPROM_VERSION "V17"
121
+#define EEPROM_VERSION "V18"
122
 
122
 
123
 #ifdef EEPROM_SETTINGS
123
 #ifdef EEPROM_SETTINGS
124
 
124
 
143
 
143
 
144
   uint8_t mesh_num_x = 3;
144
   uint8_t mesh_num_x = 3;
145
   uint8_t mesh_num_y = 3;
145
   uint8_t mesh_num_y = 3;
146
-  #if defined(MESH_BED_LEVELING)
146
+  #ifdef MESH_BED_LEVELING
147
     // Compile time test that sizeof(mbl.z_values) is as expected
147
     // Compile time test that sizeof(mbl.z_values) is as expected
148
     typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
148
     typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1];
149
     mesh_num_x = MESH_NUM_X_POINTS;
149
     mesh_num_x = MESH_NUM_X_POINTS;
161
     for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
161
     for (int q=0; q<mesh_num_x*mesh_num_y; q++) {
162
       EEPROM_WRITE_VAR(i, dummy);
162
       EEPROM_WRITE_VAR(i, dummy);
163
     }
163
     }
164
-  #endif  // MESH_BED_LEVELING
164
+  #endif // MESH_BED_LEVELING
165
+
166
+  #ifndef ENABLE_AUTO_BED_LEVELING
167
+    float zprobe_zoffset = 0;
168
+  #endif
169
+  EEPROM_WRITE_VAR(i, zprobe_zoffset);
165
 
170
 
166
   #ifdef DELTA
171
   #ifdef DELTA
167
     EEPROM_WRITE_VAR(i, endstop_adj);               // 3 floats
172
     EEPROM_WRITE_VAR(i, endstop_adj);               // 3 floats
188
   EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
193
   EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
189
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
194
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
190
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
195
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
191
-  EEPROM_WRITE_VAR(i, zprobe_zoffset);
196
+
192
 
197
 
193
   for (int e = 0; e < 4; e++) {
198
   for (int e = 0; e < 4; e++) {
194
 
199
 
328
       }
333
       }
329
     #endif  // MESH_BED_LEVELING
334
     #endif  // MESH_BED_LEVELING
330
 
335
 
336
+    #ifndef ENABLE_AUTO_BED_LEVELING
337
+      float zprobe_zoffset = 0;
338
+    #endif
339
+    EEPROM_READ_VAR(i, zprobe_zoffset);
340
+
331
     #ifdef DELTA
341
     #ifdef DELTA
332
       EEPROM_READ_VAR(i, endstop_adj);                // 3 floats
342
       EEPROM_READ_VAR(i, endstop_adj);                // 3 floats
333
       EEPROM_READ_VAR(i, delta_radius);               // 1 float
343
       EEPROM_READ_VAR(i, delta_radius);               // 1 float
353
     EEPROM_READ_VAR(i, absPreheatHotendTemp);
363
     EEPROM_READ_VAR(i, absPreheatHotendTemp);
354
     EEPROM_READ_VAR(i, absPreheatHPBTemp);
364
     EEPROM_READ_VAR(i, absPreheatHPBTemp);
355
     EEPROM_READ_VAR(i, absPreheatFanSpeed);
365
     EEPROM_READ_VAR(i, absPreheatFanSpeed);
356
-    EEPROM_READ_VAR(i, zprobe_zoffset);
357
 
366
 
358
     #ifdef PIDTEMP
367
     #ifdef PIDTEMP
359
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
368
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
738
     }
747
     }
739
   }
748
   }
740
 
749
 
741
-  #ifdef CUSTOM_M_CODES
750
+  #ifdef ENABLE_AUTO_BED_LEVELING
742
     SERIAL_ECHO_START;
751
     SERIAL_ECHO_START;
743
-    if (!forReplay) {
744
-      SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
745
-      SERIAL_ECHO_START;
746
-    }
747
-    SERIAL_ECHO("   M");
748
-    SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
749
-    SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
752
+    #ifdef CUSTOM_M_CODES
753
+      if (!forReplay) {
754
+        SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
755
+        SERIAL_ECHO_START;
756
+      }
757
+      SERIAL_ECHO("   M");
758
+      SERIAL_ECHO(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
759
+      SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
760
+    #else
761
+      if (!forReplay) {
762
+        SERIAL_ECHOPAIR("Z-Probe Offset (mm):", -zprobe_zoffset);
763
+      }
764
+    #endif
750
     SERIAL_EOL;
765
     SERIAL_EOL;
751
   #endif
766
   #endif
752
 }
767
 }

+ 3
- 1
Marlin/Marlin.h View File

251
 extern float min_pos[3];
251
 extern float min_pos[3];
252
 extern float max_pos[3];
252
 extern float max_pos[3];
253
 extern bool axis_known_position[3];
253
 extern bool axis_known_position[3];
254
-extern float zprobe_zoffset;
254
+#ifdef ENABLE_AUTO_BED_LEVELING
255
+  extern float zprobe_zoffset;
256
+#endif
255
 extern int fanSpeed;
257
 extern int fanSpeed;
256
 #ifdef BARICUDA
258
 #ifdef BARICUDA
257
   extern int ValvePressure;
259
   extern int ValvePressure;

+ 52
- 31
Marlin/Marlin_main.cpp View File

203
 
203
 
204
 float homing_feedrate[] = HOMING_FEEDRATE;
204
 float homing_feedrate[] = HOMING_FEEDRATE;
205
 #ifdef ENABLE_AUTO_BED_LEVELING
205
 #ifdef ENABLE_AUTO_BED_LEVELING
206
-int xy_travel_speed = XY_TRAVEL_SPEED;
206
+  int xy_travel_speed = XY_TRAVEL_SPEED;
207
+  float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
207
 #endif
208
 #endif
208
 int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
209
 int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
209
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
210
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
255
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
256
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
256
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
257
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
257
 bool axis_known_position[3] = { false, false, false };
258
 bool axis_known_position[3] = { false, false, false };
258
-float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
259
 
259
 
260
 // Extruder offset
260
 // Extruder offset
261
 #if EXTRUDERS > 1
261
 #if EXTRUDERS > 1
1162
     zPosition += home_retract_mm(Z_AXIS);
1162
     zPosition += home_retract_mm(Z_AXIS);
1163
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1163
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1164
     st_synchronize();
1164
     st_synchronize();
1165
+    endstops_hit_on_purpose();
1165
 
1166
 
1166
     // move back down slowly to find bed
1167
     // move back down slowly to find bed
1167
     
1168
     
1179
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1180
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1180
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1181
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1181
     st_synchronize();
1182
     st_synchronize();
1183
+    endstops_hit_on_purpose();
1182
 
1184
 
1183
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1185
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1184
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
1186
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
1383
   if (verbose_level > 2) {
1385
   if (verbose_level > 2) {
1384
     SERIAL_PROTOCOLPGM(MSG_BED);
1386
     SERIAL_PROTOCOLPGM(MSG_BED);
1385
     SERIAL_PROTOCOLPGM(" X: ");
1387
     SERIAL_PROTOCOLPGM(" X: ");
1386
-    SERIAL_PROTOCOL(x + 0.0001);
1388
+    SERIAL_PROTOCOL_F(x, 3);
1387
     SERIAL_PROTOCOLPGM(" Y: ");
1389
     SERIAL_PROTOCOLPGM(" Y: ");
1388
-    SERIAL_PROTOCOL(y + 0.0001);
1390
+    SERIAL_PROTOCOL_F(y, 3);
1389
     SERIAL_PROTOCOLPGM(" Z: ");
1391
     SERIAL_PROTOCOLPGM(" Z: ");
1390
-    SERIAL_PROTOCOL(measured_z + 0.0001);
1392
+    SERIAL_PROTOCOL_F(measured_z, 3);
1391
     SERIAL_EOL;
1393
     SERIAL_EOL;
1392
   }
1394
   }
1393
   return measured_z;
1395
   return measured_z;
2108
    *
2110
    *
2109
    *  S  Set the XY travel speed between probe points (in mm/min)
2111
    *  S  Set the XY travel speed between probe points (in mm/min)
2110
    *
2112
    *
2113
+   *  D  Dry-Run mode. Just evaluate the bed Topology - Don't apply
2114
+   *     or clean the rotation Matrix. Useful to check the topology
2115
+   *     after a first run of G29.
2116
+   *
2111
    *  V  Set the verbose level (0-4). Example: "G29 V3"
2117
    *  V  Set the verbose level (0-4). Example: "G29 V3"
2112
    *
2118
    *
2113
    *  T  Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
2119
    *  T  Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
2149
       }
2155
       }
2150
     }
2156
     }
2151
 
2157
 
2158
+    bool dryrun = code_seen('D') || code_seen('d');
2152
     bool enhanced_g29 = code_seen('E') || code_seen('e');
2159
     bool enhanced_g29 = code_seen('E') || code_seen('e');
2153
 
2160
 
2154
     #ifdef AUTO_BED_LEVELING_GRID
2161
     #ifdef AUTO_BED_LEVELING_GRID
2158
       #endif
2165
       #endif
2159
 
2166
 
2160
       if (verbose_level > 0)
2167
       if (verbose_level > 0)
2168
+      {
2161
         SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
2169
         SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
2170
+        if (dryrun) SERIAL_ECHOLN("Running in DRY-RUN mode");
2171
+      }
2162
 
2172
 
2163
       int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
2173
       int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
2164
       #ifndef DELTA
2174
       #ifndef DELTA
2215
 
2225
 
2216
     st_synchronize();
2226
     st_synchronize();
2217
 
2227
 
2218
-    #ifdef DELTA
2219
-      reset_bed_level();
2220
-    #else //!DELTA
2221
-      // make sure the bed_level_rotation_matrix is identity or the planner will get it wrong
2222
-      //vector_3 corrected_position = plan_get_position_mm();
2223
-      //corrected_position.debug("position before G29");
2224
-      plan_bed_level_matrix.set_to_identity();
2225
-      vector_3 uncorrected_position = plan_get_position();
2226
-      //uncorrected_position.debug("position during G29");
2227
-      current_position[X_AXIS] = uncorrected_position.x;
2228
-      current_position[Y_AXIS] = uncorrected_position.y;
2229
-      current_position[Z_AXIS] = uncorrected_position.z;
2230
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2231
-    #endif //!DELTA
2228
+    if (!dryrun)
2229
+    {
2230
+      #ifdef DELTA
2231
+        reset_bed_level();
2232
+      #else //!DELTA
2233
+
2234
+        // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
2235
+        //vector_3 corrected_position = plan_get_position_mm();
2236
+        //corrected_position.debug("position before G29");
2237
+        plan_bed_level_matrix.set_to_identity();
2238
+        vector_3 uncorrected_position = plan_get_position();
2239
+        //uncorrected_position.debug("position during G29");
2240
+        current_position[X_AXIS] = uncorrected_position.x;
2241
+        current_position[Y_AXIS] = uncorrected_position.y;
2242
+        current_position[Z_AXIS] = uncorrected_position.z;
2243
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2232
 
2244
 
2245
+      #endif
2246
+    }
2247
+    
2233
     setup_for_endstop_move();
2248
     setup_for_endstop_move();
2234
 
2249
 
2235
     feedrate = homing_feedrate[Z_AXIS];
2250
     feedrate = homing_feedrate[Z_AXIS];
2330
       clean_up_after_endstop_move();
2345
       clean_up_after_endstop_move();
2331
 
2346
 
2332
       #ifdef DELTA
2347
       #ifdef DELTA
2333
-        extrapolate_unprobed_bed_level();
2348
+
2349
+        if (!dryrun) extrapolate_unprobed_bed_level();
2334
         print_bed_level();
2350
         print_bed_level();
2351
+
2335
       #else // !DELTA
2352
       #else // !DELTA
2353
+
2336
         // solve lsq problem
2354
         // solve lsq problem
2337
         double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
2355
         double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
2338
 
2356
 
2380
         } //do_topography_map
2398
         } //do_topography_map
2381
 
2399
 
2382
 
2400
 
2383
-        set_bed_level_equation_lsq(plane_equation_coefficients);
2401
+        if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
2384
         free(plane_equation_coefficients);
2402
         free(plane_equation_coefficients);
2385
 
2403
 
2386
-      #endif // !DELTA
2404
+      #endif //!DELTA
2387
 
2405
 
2388
     #else // !AUTO_BED_LEVELING_GRID
2406
     #else // !AUTO_BED_LEVELING_GRID
2389
 
2407
 
2402
         z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
2420
         z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
2403
       }
2421
       }
2404
       clean_up_after_endstop_move();
2422
       clean_up_after_endstop_move();
2405
-      set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2423
+      if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2406
 
2424
 
2407
     #endif // !AUTO_BED_LEVELING_GRID
2425
     #endif // !AUTO_BED_LEVELING_GRID
2408
 
2426
 
2413
       // Correct the Z height difference from z-probe position and hotend tip position.
2431
       // Correct the Z height difference from z-probe position and hotend tip position.
2414
       // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
2432
       // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
2415
       // When the bed is uneven, this height must be corrected.
2433
       // When the bed is uneven, this height must be corrected.
2416
-      real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2417
-      x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2418
-      y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2419
-      z_tmp = current_position[Z_AXIS];
2434
+      if (!dryrun)
2435
+      {
2436
+        real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
2437
+        x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
2438
+        y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
2439
+        z_tmp = current_position[Z_AXIS];
2420
 
2440
 
2421
-      apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2422
-      current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2423
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2424
-    #endif
2441
+        apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2442
+        current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2443
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2444
+      }
2445
+    #endif // !DELTA
2425
 
2446
 
2426
     #ifdef Z_PROBE_SLED
2447
     #ifdef Z_PROBE_SLED
2427
       dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
2448
       dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel

+ 37
- 30
Marlin/temperature.cpp View File

576
 
576
 
577
   updateTemperaturesFromRawValues();
577
   updateTemperaturesFromRawValues();
578
 
578
 
579
+  #ifdef HEATER_0_USES_MAX6675
580
+    float ct = current_temperature[0];
581
+    if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
582
+    if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
583
+  #endif //HEATER_0_USES_MAX6675
584
+
579
   unsigned long ms = millis();
585
   unsigned long ms = millis();
580
 
586
 
581
   // Loop through all extruders
587
   // Loop through all extruders
607
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
613
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
608
       if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
614
       if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
609
         disable_heater();
615
         disable_heater();
610
-        _temp_error(-1, MSG_EXTRUDER_SWITCHED_OFF, MSG_ERR_REDUNDANT_TEMP);
616
+        _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
611
       }
617
       }
612
     #endif //TEMP_SENSOR_1_AS_REDUNDANT
618
     #endif //TEMP_SENSOR_1_AS_REDUNDANT
613
 
619
 
1162
   StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1168
   StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1163
 };
1169
 };
1164
 
1170
 
1171
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1172
+  #define TEMP_SENSOR_COUNT 2
1173
+#else
1174
+  #define TEMP_SENSOR_COUNT EXTRUDERS
1175
+#endif
1176
+
1177
+static unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
1178
+static unsigned long raw_temp_bed_value = 0;
1179
+
1180
+static void set_current_temp_raw() {
1181
+  #ifndef HEATER_0_USES_MAX6675
1182
+    current_temperature_raw[0] = raw_temp_value[0];
1183
+  #endif
1184
+  #if EXTRUDERS > 1
1185
+    current_temperature_raw[1] = raw_temp_value[1];
1186
+    #if EXTRUDERS > 2
1187
+      current_temperature_raw[2] = raw_temp_value[2];
1188
+      #if EXTRUDERS > 3
1189
+        current_temperature_raw[3] = raw_temp_value[3];
1190
+      #endif
1191
+    #endif
1192
+  #endif
1193
+  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1194
+    redundant_temperature_raw = raw_temp_value[1];
1195
+  #endif
1196
+  current_temperature_bed_raw = raw_temp_bed_value;
1197
+}
1198
+
1165
 //
1199
 //
1166
 // Timer 0 is shared with millies
1200
 // Timer 0 is shared with millies
1167
 //
1201
 //
1168
 ISR(TIMER0_COMPB_vect) {
1202
 ISR(TIMER0_COMPB_vect) {
1169
-  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1170
-    #define TEMP_SENSOR_COUNT 2
1171
-  #else 
1172
-    #define TEMP_SENSOR_COUNT EXTRUDERS
1173
-  #endif
1174
-
1175
   //these variables are only accesible from the ISR, but static, so they don't lose their value
1203
   //these variables are only accesible from the ISR, but static, so they don't lose their value
1176
   static unsigned char temp_count = 0;
1204
   static unsigned char temp_count = 0;
1177
-  static unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
1178
-  static unsigned long raw_temp_bed_value = 0;
1179
   static TempState temp_state = StartupDelay;
1205
   static TempState temp_state = StartupDelay;
1180
   static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1206
   static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1181
 
1207
 
1478
 
1504
 
1479
   if (temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256)  = 164ms.
1505
   if (temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256)  = 164ms.
1480
     if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
1506
     if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
1481
-      #ifndef HEATER_0_USES_MAX6675
1482
-        current_temperature_raw[0] = raw_temp_value[0];
1483
-      #endif
1484
-      #if EXTRUDERS > 1
1485
-        current_temperature_raw[1] = raw_temp_value[1];
1486
-        #if EXTRUDERS > 2
1487
-          current_temperature_raw[2] = raw_temp_value[2];
1488
-          #if EXTRUDERS > 3
1489
-            current_temperature_raw[3] = raw_temp_value[3];
1490
-          #endif
1491
-        #endif
1492
-      #endif
1493
-      #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1494
-        redundant_temperature_raw = raw_temp_value[1];
1495
-      #endif
1496
-      current_temperature_bed_raw = raw_temp_bed_value;
1507
+      set_current_temp_raw();
1497
     } //!temp_meas_ready
1508
     } //!temp_meas_ready
1498
 
1509
 
1499
     // Filament Sensor - can be read any time since IIR filtering is used
1510
     // Filament Sensor - can be read any time since IIR filtering is used
1506
     for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
1517
     for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
1507
     raw_temp_bed_value = 0;
1518
     raw_temp_bed_value = 0;
1508
 
1519
 
1509
-    #ifdef HEATER_0_USES_MAX6675
1510
-      float ct = current_temperature[0];
1511
-      if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
1512
-      if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
1513
-    #else
1520
+    #ifndef HEATER_0_USES_MAX6675
1514
       #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
1521
       #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
1515
         #define GE0 <=
1522
         #define GE0 <=
1516
       #else
1523
       #else

+ 1
- 1
Marlin/ultralcd.cpp View File

204
   #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
204
   #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
205
 #endif //!ENCODER_RATE_MULTIPLIER
205
 #endif //!ENCODER_RATE_MULTIPLIER
206
 #define END_MENU() \
206
 #define END_MENU() \
207
-    if (encoderLine >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
207
+    if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; }\
208
     if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
208
     if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
209
     } } while(0)
209
     } } while(0)
210
 
210
 

Loading…
Cancel
Save