@ -42,6 +42,8 @@
# define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n)
typedef struct { int16_t value , celsius ; } temp_entry_t ;
// Pt1000 and Pt100 handling
//
// Rt=R0*(1+a*T+b*T*T) [for T>0]
@ -185,12 +187,13 @@
# include "thermistor_999.h"
# endif
# if ANY_THERMISTOR_IS(1000) // Custom
const shor t temptable_1000 [ ] [ 2 ] PROGMEM = { { 0 , 0 } } ;
const temp_entry_ t temptable_1000 [ ] PROGMEM = { { 0 , 0 } } ;
# endif
# define _TT_NAME(_N) temptable_ ## _N
# define TT_NAME(_N) _TT_NAME(_N)
# if THERMISTOR_HEATER_0
# define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0)
# define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
@ -288,9 +291,12 @@
# else
# define CHAMBER_TEMPTABLE_LEN 0
# endif
# ifdef THERMISTORPROBE
# define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE)
# define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE)
# elif defined(HEATER_PROBE_USES_THERMISTOR)
# error "No probe thermistor table specified"
# else
# define PROBE_TEMPTABLE_LEN 0
# endif
@ -300,7 +306,7 @@ static_assert(
HEATER_0_TEMPTABLE_LEN < 256 & & HEATER_1_TEMPTABLE_LEN < 256
& & HEATER_2_TEMPTABLE_LEN < 256 & & HEATER_3_TEMPTABLE_LEN < 256
& & HEATER_4_TEMPTABLE_LEN < 256 & & HEATER_5_TEMPTABLE_LEN < 256
& & HEATER_6_TEMPTABLE_LEN < 258 & & HEATER_7_TEMPTABLE_LEN < 258
& & HEATER_6_TEMPTABLE_LEN < 256 & & HEATER_7_TEMPTABLE_LEN < 256
& & BED_TEMPTABLE_LEN < 256 & & CHAMBER_TEMPTABLE_LEN < 256
& & PROBE_TEMPTABLE_LEN < 256 ,
" Temperature conversion tables over 255 entries need special consideration. "
@ -309,8 +315,85 @@ static_assert(
// Set the high and low raw values for the heaters
// For thermistors the highest temperature results in the lowest ADC value
// For thermocouples the highest temperature results in the highest ADC value
# define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N
# define TT_REV(N) _TT_REV(N)
# ifdef HEATER_0_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_0)
# define HEATER_0_SENSOR_MINTEMP_IND 0
# define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1
# else
# define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1
# define HEATER_0_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_1_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_1)
# define HEATER_1_SENSOR_MINTEMP_IND 0
# define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1
# else
# define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1
# define HEATER_1_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_2_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_2)
# define HEATER_2_SENSOR_MINTEMP_IND 0
# define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1
# else
# define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1
# define HEATER_2_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_3_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_3)
# define HEATER_3_SENSOR_MINTEMP_IND 0
# define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1
# else
# define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1
# define HEATER_3_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_4_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_4)
# define HEATER_4_SENSOR_MINTEMP_IND 0
# define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1
# else
# define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1
# define HEATER_4_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_5_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_5)
# define HEATER_5_SENSOR_MINTEMP_IND 0
# define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1
# else
# define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1
# define HEATER_5_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_6_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_6)
# define HEATER_6_SENSOR_MINTEMP_IND 0
# define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1
# else
# define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1
# define HEATER_6_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifdef HEATER_7_TEMPTABLE
# if TT_REV(THERMISTOR_HEATER_7)
# define HEATER_7_SENSOR_MINTEMP_IND 0
# define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1
# else
# define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1
# define HEATER_7_SENSOR_MAXTEMP_IND 0
# endif
# endif
# ifndef HEATER_0_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_0 ) || !defined(HEATER_0_USES_THERMISTOR)
# define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_0_RAW_LO_TEMP 0
# else
@ -319,7 +402,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_1_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_1_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_1 ) || !defined(HEATER_1_USES_THERMISTOR)
# define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_1_RAW_LO_TEMP 0
# else
@ -328,7 +411,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_2_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_2_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_2 ) || !defined(HEATER_2_USES_THERMISTOR)
# define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_2_RAW_LO_TEMP 0
# else
@ -337,7 +420,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_3_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_3_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_3 ) || !defined(HEATER_3_USES_THERMISTOR)
# define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_3_RAW_LO_TEMP 0
# else
@ -346,7 +429,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_4_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_4_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_4 ) || !defined(HEATER_4_USES_THERMISTOR)
# define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_4_RAW_LO_TEMP 0
# else
@ -355,7 +438,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_5_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_5_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_5 ) || !defined(HEATER_5_USES_THERMISTOR)
# define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_5_RAW_LO_TEMP 0
# else
@ -364,7 +447,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_6_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_6_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_6 ) || !defined(HEATER_6_USES_THERMISTOR)
# define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_6_RAW_LO_TEMP 0
# else
@ -373,7 +456,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_7_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_7_USES_THERMISTOR)
# if TT_REV(THERMISTOR_HEATER_7 ) || !defined(HEATER_7_USES_THERMISTOR)
# define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_7_RAW_LO_TEMP 0
# else
@ -382,7 +465,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_BED_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_BED_USES_THERMISTOR)
# if TT_REV(THERMISTORBED ) || !defined(HEATER_BED_USES_THERMISTOR)
# define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_BED_RAW_LO_TEMP 0
# else
@ -391,7 +474,7 @@ static_assert(
# endif
# endif
# ifndef HEATER_CHAMBER_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE ) || !defined(HEATER_CHAMBER_USES_THERMISTOR)
# if TT_REV(THERMISTORCHAMBER ) || !defined(HEATER_CHAMBER_USES_THERMISTOR)
# define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_CHAMBER_RAW_LO_TEMP 0
# else
@ -399,5 +482,15 @@ static_assert(
# define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# ifndef HEATER_PROBE_RAW_HI_TEMP
# if TT_REV(THERMISTORPROBE) || !defined(HEATER_PROBE_USES_THERMISTOR)
# define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_PROBE_RAW_LO_TEMP 0
# else
# define HEATER_PROBE_RAW_HI_TEMP 0
# define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# undef REVERSE_TEMP_SENSOR_RANGE
# undef _TT_REV
# undef TT_REV