|
@@ -203,6 +203,7 @@ void manage_heater()
|
203
|
203
|
#endif
|
204
|
204
|
}
|
205
|
205
|
|
|
206
|
+#define PGM_RD_W(x) (short)pgm_read_word(&x)
|
206
|
207
|
// Takes hot end temperature value as input and returns corresponding raw value.
|
207
|
208
|
// For a thermistor, it uses the RepRap thermistor temp table.
|
208
|
209
|
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
|
|
@@ -214,18 +215,18 @@ int temp2analog(int celsius) {
|
214
|
215
|
|
215
|
216
|
for (i=1; i<NUMTEMPS_HEATER_0; i++)
|
216
|
217
|
{
|
217
|
|
- if (pgm_read_word(&(heater_0_temptable[i][1])) < celsius)
|
|
218
|
+ if (PGM_RD_W(heater_0_temptable[i][1]) < celsius)
|
218
|
219
|
{
|
219
|
|
- raw = pgm_read_word(&(heater_0_temptable[i-1][0])) +
|
220
|
|
- (celsius - pgm_read_word(&(heater_0_temptable[i-1][1]))) *
|
221
|
|
- (pgm_read_word(&(heater_0_temptable[i][0])) - pgm_read_word(&(heater_0_temptable[i-1][0]))) /
|
222
|
|
- (pgm_read_word(&(heater_0_temptable[i][1])) - pgm_read_word(&(heater_0_temptable[i-1][1])));
|
|
220
|
+ raw = PGM_RD_W(heater_0_temptable[i-1][0]) +
|
|
221
|
+ (celsius - PGM_RD_W(heater_0_temptable[i-1][1])) *
|
|
222
|
+ (PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0])) /
|
|
223
|
+ (PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1]));
|
223
|
224
|
break;
|
224
|
225
|
}
|
225
|
226
|
}
|
226
|
227
|
|
227
|
228
|
// Overflow: Set to last value in the table
|
228
|
|
- if (i == NUMTEMPS_HEATER_0) raw = pgm_read_word(&(heater_0_temptable[i-1][0]));
|
|
229
|
+ if (i == NUMTEMPS_HEATER_0) raw = PGM_RD_W(heater_0_temptable[i-1][0]);
|
229
|
230
|
|
230
|
231
|
return (1023 * OVERSAMPLENR) - raw;
|
231
|
232
|
#elif defined HEATER_0_USES_AD595
|
|
@@ -245,19 +246,19 @@ int temp2analogBed(int celsius) {
|
245
|
246
|
|
246
|
247
|
for (i=1; i<BNUMTEMPS; i++)
|
247
|
248
|
{
|
248
|
|
- if (pgm_read_word(&)bedtemptable[i][1])) < celsius)
|
|
249
|
+ if (PGM_RD_W(bedtemptable[i][1]) < celsius)
|
249
|
250
|
{
|
250
|
|
- raw = pgm_read_word(&(bedtemptable[i-1][0])) +
|
251
|
|
- (celsius - pgm_read_word(&(bedtemptable[i-1][1]))) *
|
252
|
|
- (pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0]))) /
|
253
|
|
- (pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1])));
|
|
251
|
+ raw = PGM_RD_W(bedtemptable[i-1][0]) +
|
|
252
|
+ (celsius - PGM_RD_W(bedtemptable[i-1][1])) *
|
|
253
|
+ (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0])) /
|
|
254
|
+ (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1]));
|
254
|
255
|
|
255
|
256
|
break;
|
256
|
257
|
}
|
257
|
258
|
}
|
258
|
259
|
|
259
|
260
|
// Overflow: Set to last value in the table
|
260
|
|
- if (i == BNUMTEMPS) raw = pgm_read_word(&(bedtemptable[i-1][0]));
|
|
261
|
+ if (i == BNUMTEMPS) raw = PGM_RD_W(bedtemptable[i-1][0]);
|
261
|
262
|
|
262
|
263
|
return (1023 * OVERSAMPLENR) - raw;
|
263
|
264
|
#elif defined BED_USES_AD595
|
|
@@ -274,18 +275,18 @@ float analog2temp(int raw) {
|
274
|
275
|
raw = (1023 * OVERSAMPLENR) - raw;
|
275
|
276
|
for (i=1; i<NUMTEMPS_HEATER_0; i++)
|
276
|
277
|
{
|
277
|
|
- if ((short)pgm_read_word(&heater_0_temptable[i][0]) > raw)
|
|
278
|
+ if (PGM_RD_W(heater_0_temptable[i][0]) > raw)
|
278
|
279
|
{
|
279
|
|
- celsius = (short)pgm_read_word(&heater_0_temptable[i-1][1]) +
|
280
|
|
- (raw - (short)pgm_read_word(&heater_0_temptable[i-1][0])) *
|
281
|
|
- (float)((short)pgm_read_word(&heater_0_temptable[i][1]) - (short)pgm_read_word(&heater_0_temptable[i-1][1])) /
|
282
|
|
- (float)((short)pgm_read_word(&heater_0_temptable[i][0]) - (short)pgm_read_word(&heater_0_temptable[i-1][0]));
|
|
280
|
+ celsius = PGM_RD_W(heater_0_temptable[i-1][1]) +
|
|
281
|
+ (raw - PGM_RD_W(heater_0_temptable[i-1][0])) *
|
|
282
|
+ (float)(PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1])) /
|
|
283
|
+ (float)(PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0]));
|
283
|
284
|
break;
|
284
|
285
|
}
|
285
|
286
|
}
|
286
|
287
|
|
287
|
288
|
// Overflow: Set to last value in the table
|
288
|
|
- if (i == NUMTEMPS_HEATER_0) celsius = (short)pgm_read_word(&(heater_0_temptable[i-1][1]));
|
|
289
|
+ if (i == NUMTEMPS_HEATER_0) celsius = PGM_RD_W(heater_0_temptable[i-1][1]);
|
289
|
290
|
|
290
|
291
|
return celsius;
|
291
|
292
|
#elif defined HEATER_0_USES_AD595
|
|
@@ -304,19 +305,19 @@ float analog2tempBed(int raw) {
|
304
|
305
|
|
305
|
306
|
for (i=1; i<BNUMTEMPS; i++)
|
306
|
307
|
{
|
307
|
|
- if (pgm_read_word(&(bedtemptable[i][0])) > raw)
|
|
308
|
+ if (PGM_RD_W(bedtemptable[i][0]) > raw)
|
308
|
309
|
{
|
309
|
|
- celsius = pgm_read_word(&(bedtemptable[i-1][1])) +
|
310
|
|
- (raw - pgm_read_word(&(bedtemptable[i-1][0]))) *
|
311
|
|
- (pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1]))) /
|
312
|
|
- (pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0])));
|
|
310
|
+ celsius = PGM_RD_W(bedtemptable[i-1][1]) +
|
|
311
|
+ (raw - PGM_RD_W(bedtemptable[i-1][0])) *
|
|
312
|
+ (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
|
|
313
|
+ (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
|
313
|
314
|
|
314
|
315
|
break;
|
315
|
316
|
}
|
316
|
317
|
}
|
317
|
318
|
|
318
|
319
|
// Overflow: Set to last value in the table
|
319
|
|
- if (i == BNUMTEMPS) celsius = pgm_read_word(&(bedtemptable[i-1][1]));
|
|
320
|
+ if (i == BNUMTEMPS) celsius = PGM_RD_W(bedtemptable[i-1][1]);
|
320
|
321
|
|
321
|
322
|
return celsius;
|
322
|
323
|
|