🐛 Finish and organize temp sensors (#23519)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
zerkix 2022-01-17 07:05:31 +01:00 committed by Scott Lahteine
parent ab40c99893
commit 70f03ad852
11 changed files with 144 additions and 229 deletions

View File

@ -211,7 +211,9 @@ void HAL_adc_init() {
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db));
TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db)); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.

View File

@ -54,20 +54,22 @@
#define GET_TEMP_5_ADC() TERN(HAS_TEMP_ADC_5, PIN_TO_ADC(TEMP_5_PIN), -1) #define GET_TEMP_5_ADC() TERN(HAS_TEMP_ADC_5, PIN_TO_ADC(TEMP_5_PIN), -1)
#define GET_TEMP_6_ADC() TERN(HAS_TEMP_ADC_6, PIN_TO_ADC(TEMP_6_PIN), -1) #define GET_TEMP_6_ADC() TERN(HAS_TEMP_ADC_6, PIN_TO_ADC(TEMP_6_PIN), -1)
#define GET_TEMP_7_ADC() TERN(HAS_TEMP_ADC_7, PIN_TO_ADC(TEMP_7_PIN), -1) #define GET_TEMP_7_ADC() TERN(HAS_TEMP_ADC_7, PIN_TO_ADC(TEMP_7_PIN), -1)
#define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
#define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1) #define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1)
#define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1) #define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
#define GET_PROBE_ADC() TERN(HAS_TEMP_ADC_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
#define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1) #define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1)
#define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1)
#define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
#define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1) #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
#define IS_ADC_REQUIRED(n) ( \ #define IS_ADC_REQUIRED(n) ( \
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \ GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
|| GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \ || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_BED_ADC() == n \ || GET_BED_ADC() == n \
|| GET_CHAMBER_ADC() == n \ || GET_CHAMBER_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_COOLER_ADC() == n \ || GET_COOLER_ADC() == n \
|| GET_BOARD_ADC() == n \
|| GET_FILAMENT_WIDTH_ADC() == n \ || GET_FILAMENT_WIDTH_ADC() == n \
|| GET_BUTTONS_ADC() == n \ || GET_BUTTONS_ADC() == n \
) )
@ -137,18 +139,21 @@ uint16_t HAL_adc_result;
#if GET_TEMP_7_ADC() == 0 #if GET_TEMP_7_ADC() == 0
TEMP_7_PIN, TEMP_7_PIN,
#endif #endif
#if GET_PROBE_ADC() == 0
TEMP_PROBE_PIN,
#endif
#if GET_BED_ADC() == 0 #if GET_BED_ADC() == 0
TEMP_BED_PIN, TEMP_BED_PIN,
#endif #endif
#if GET_CHAMBER_ADC() == 0 #if GET_CHAMBER_ADC() == 0
TEMP_CHAMBER_PIN, TEMP_CHAMBER_PIN,
#endif #endif
#if GET_PROBE_ADC() == 0
TEMP_PROBE_PIN,
#endif
#if GET_COOLER_ADC() == 0 #if GET_COOLER_ADC() == 0
TEMP_COOLER_PIN, TEMP_COOLER_PIN,
#endif #endif
#if GET_BOARD_ADC() == 0
TEMP_BOARD_PIN,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 0 #if GET_FILAMENT_WIDTH_ADC() == 0
FILWIDTH_PIN, FILWIDTH_PIN,
#endif #endif
@ -180,18 +185,21 @@ uint16_t HAL_adc_result;
#if GET_TEMP_7_ADC() == 1 #if GET_TEMP_7_ADC() == 1
TEMP_7_PIN, TEMP_7_PIN,
#endif #endif
#if GET_PROBE_ADC() == 1
TEMP_PROBE_PIN,
#endif
#if GET_BED_ADC() == 1 #if GET_BED_ADC() == 1
TEMP_BED_PIN, TEMP_BED_PIN,
#endif #endif
#if GET_CHAMBER_ADC() == 1 #if GET_CHAMBER_ADC() == 1
TEMP_CHAMBER_PIN, TEMP_CHAMBER_PIN,
#endif #endif
#if GET_PROBE_ADC() == 1
TEMP_PROBE_PIN,
#endif
#if GET_COOLER_ADC() == 1 #if GET_COOLER_ADC() == 1
TEMP_COOLER_PIN, TEMP_COOLER_PIN,
#endif #endif
#if GET_BOARD_ADC() == 1
TEMP_BOARD_PIN,
#endif
#if GET_FILAMENT_WIDTH_ADC() == 1 #if GET_FILAMENT_WIDTH_ADC() == 1
FILWIDTH_PIN, FILWIDTH_PIN,
#endif #endif
@ -231,18 +239,21 @@ uint16_t HAL_adc_result;
#if GET_TEMP_7_ADC() == 0 #if GET_TEMP_7_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) }, { PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif #endif
#if GET_PROBE_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_BED_ADC() == 0 #if GET_BED_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, { PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
#endif #endif
#if GET_CHAMBER_ADC() == 0 #if GET_CHAMBER_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
#endif #endif
#if GET_PROBE_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_COOLER_ADC() == 0 #if GET_COOLER_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
#endif #endif
#if GET_BOARD_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) },
#endif
#if GET_FILAMENT_WIDTH_ADC() == 0 #if GET_FILAMENT_WIDTH_ADC() == 0
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, { PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
#endif #endif
@ -283,18 +294,21 @@ uint16_t HAL_adc_result;
#if GET_TEMP_7_ADC() == 1 #if GET_TEMP_7_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) }, { PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif #endif
#if GET_PROBE_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_BED_ADC() == 1 #if GET_BED_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, { PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
#endif #endif
#if GET_CHAMBER_ADC() == 1 #if GET_CHAMBER_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
#endif #endif
#if GET_PROBE_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_COOLER_ADC() == 1 #if GET_COOLER_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
#endif #endif
#if GET_BOARD_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) },
#endif
#if GET_FILAMENT_WIDTH_ADC() == 1 #if GET_FILAMENT_WIDTH_ADC() == 1
{ PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, { PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
#endif #endif

View File

@ -120,123 +120,49 @@ uint16_t HAL_adc_result;
STM32ADC adc(ADC1); STM32ADC adc(ADC1);
const uint8_t adc_pins[] = { const uint8_t adc_pins[] = {
#if HAS_TEMP_ADC_0 OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN)
TEMP_0_PIN, OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN)
#endif OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN)
#if HAS_TEMP_ADC_PROBE OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN)
TEMP_PROBE_PIN, OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN)
#endif OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN)
#if HAS_HEATED_BED OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN)
TEMP_BED_PIN, OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN)
#endif OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN)
#if HAS_TEMP_CHAMBER OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN)
TEMP_CHAMBER_PIN, OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN)
#endif OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN)
#if HAS_TEMP_COOLER OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN)
TEMP_COOLER_PIN, OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN)
#endif OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN)
#if HAS_TEMP_ADC_1 OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN)
TEMP_1_PIN, OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN)
#endif OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN)
#if HAS_TEMP_ADC_2 OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN)
TEMP_2_PIN, OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN)
#endif
#if HAS_TEMP_ADC_3
TEMP_3_PIN,
#endif
#if HAS_TEMP_ADC_4
TEMP_4_PIN,
#endif
#if HAS_TEMP_ADC_5
TEMP_5_PIN,
#endif
#if HAS_TEMP_ADC_6
TEMP_6_PIN,
#endif
#if HAS_TEMP_ADC_7
TEMP_7_PIN,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH_PIN,
#endif
#if HAS_ADC_BUTTONS
ADC_KEYPAD_PIN,
#endif
#if HAS_JOY_ADC_X
JOY_X_PIN,
#endif
#if HAS_JOY_ADC_Y
JOY_Y_PIN,
#endif
#if HAS_JOY_ADC_Z
JOY_Z_PIN,
#endif
#if ENABLED(POWER_MONITOR_CURRENT)
POWER_MONITOR_CURRENT_PIN,
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
POWER_MONITOR_VOLTAGE_PIN,
#endif
}; };
enum TempPinIndex : char { enum TempPinIndex : char {
#if HAS_TEMP_ADC_0 OPTITEM(HAS_TEMP_ADC_0, TEMP_0)
TEMP_0, OPTITEM(HAS_TEMP_ADC_1, TEMP_1)
#endif OPTITEM(HAS_TEMP_ADC_2, TEMP_2)
#if HAS_TEMP_ADC_PROBE OPTITEM(HAS_TEMP_ADC_3, TEMP_3)
TEMP_PROBE, OPTITEM(HAS_TEMP_ADC_4, TEMP_4)
#endif OPTITEM(HAS_TEMP_ADC_5, TEMP_5)
#if HAS_HEATED_BED OPTITEM(HAS_TEMP_ADC_6, TEMP_6)
TEMP_BED, OPTITEM(HAS_TEMP_ADC_7, TEMP_7)
#endif OPTITEM(HAS_HEATED_BED, TEMP_BED)
#if HAS_TEMP_CHAMBER OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER)
TEMP_CHAMBER, OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE)
#endif OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER)
#if HAS_TEMP_COOLER OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD)
TEMP_COOLER_PIN, OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH)
#endif OPTITEM(HAS_ADC_BUTTONS, ADC_KEY)
#if HAS_TEMP_ADC_1 OPTITEM(HAS_JOY_ADC_X, JOY_X)
TEMP_1, OPTITEM(HAS_JOY_ADC_Y, JOY_Y)
#endif OPTITEM(HAS_JOY_ADC_Z, JOY_Z)
#if HAS_TEMP_ADC_2 OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT)
TEMP_2, OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS)
#endif
#if HAS_TEMP_ADC_3
TEMP_3,
#endif
#if HAS_TEMP_ADC_4
TEMP_4,
#endif
#if HAS_TEMP_ADC_5
TEMP_5,
#endif
#if HAS_TEMP_ADC_6
TEMP_6,
#endif
#if HAS_TEMP_ADC_7
TEMP_7,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH,
#endif
#if HAS_ADC_BUTTONS
ADC_KEY,
#endif
#if HAS_JOY_ADC_X
JOY_X,
#endif
#if HAS_JOY_ADC_Y
JOY_Y,
#endif
#if HAS_JOY_ADC_Z
JOY_Z,
#endif
#if ENABLED(POWER_MONITOR_CURRENT)
POWERMON_CURRENT,
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
POWERMON_VOLTS,
#endif
ADC_PIN_COUNT ADC_PIN_COUNT
}; };
@ -375,67 +301,32 @@ void HAL_adc_init() {
} }
void HAL_adc_start_conversion(const uint8_t adc_pin) { void HAL_adc_start_conversion(const uint8_t adc_pin) {
#define __TCASE(N,I) case N: pin_index = I; break;
#define _TCASE(C,N,I) TERN_(C, __TCASE(N, I))
//TEMP_PINS pin_index; //TEMP_PINS pin_index;
TempPinIndex pin_index; TempPinIndex pin_index;
switch (adc_pin) { switch (adc_pin) {
default: return; default: return;
#if HAS_TEMP_ADC_0 _TCASE(HAS_TEMP_ADC_0, TEMP_0_PIN, TEMP_0)
case TEMP_0_PIN: pin_index = TEMP_0; break; _TCASE(HAS_TEMP_ADC_1, TEMP_1_PIN, TEMP_1)
#endif _TCASE(HAS_TEMP_ADC_2, TEMP_2_PIN, TEMP_2)
#if HAS_TEMP_ADC_PROBE _TCASE(HAS_TEMP_ADC_3, TEMP_3_PIN, TEMP_3)
case TEMP_PROBE_PIN: pin_index = TEMP_PROBE; break; _TCASE(HAS_TEMP_ADC_4, TEMP_4_PIN, TEMP_4)
#endif _TCASE(HAS_TEMP_ADC_5, TEMP_5_PIN, TEMP_5)
#if HAS_HEATED_BED _TCASE(HAS_TEMP_ADC_6, TEMP_6_PIN, TEMP_6)
case TEMP_BED_PIN: pin_index = TEMP_BED; break; _TCASE(HAS_TEMP_ADC_7, TEMP_7_PIN, TEMP_7)
#endif _TCASE(HAS_HEATED_BED, TEMP_BED_PIN, TEMP_BED)
#if HAS_TEMP_CHAMBER _TCASE(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN, TEMP_CHAMBER)
case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break; _TCASE(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN, TEMP_PROBE)
#endif _TCASE(HAS_TEMP_COOLER, TEMP_COOLER_PIN, TEMP_COOLER)
#if HAS_TEMP_COOLER _TCASE(HAS_TEMP_BOARD, TEMP_BOARD_PIN, TEMP_BOARD)
case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break; _TCASE(HAS_JOY_ADC_X, JOY_X_PIN, JOY_X)
#endif _TCASE(HAS_JOY_ADC_Y, JOY_Y_PIN, JOY_Y)
#if HAS_TEMP_ADC_1 _TCASE(HAS_JOY_ADC_Z, JOY_Z_PIN, JOY_Z)
case TEMP_1_PIN: pin_index = TEMP_1; break; _TCASE(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN, FILWIDTH)
#endif _TCASE(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN, ADC_KEY)
#if HAS_TEMP_ADC_2 _TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT)
case TEMP_2_PIN: pin_index = TEMP_2; break; _TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS)
#endif
#if HAS_TEMP_ADC_3
case TEMP_3_PIN: pin_index = TEMP_3; break;
#endif
#if HAS_TEMP_ADC_4
case TEMP_4_PIN: pin_index = TEMP_4; break;
#endif
#if HAS_TEMP_ADC_5
case TEMP_5_PIN: pin_index = TEMP_5; break;
#endif
#if HAS_TEMP_ADC_6
case TEMP_6_PIN: pin_index = TEMP_6; break;
#endif
#if HAS_TEMP_ADC_7
case TEMP_7_PIN: pin_index = TEMP_7; break;
#endif
#if HAS_JOY_ADC_X
case JOY_X_PIN: pin_index = JOY_X; break;
#endif
#if HAS_JOY_ADC_Y
case JOY_Y_PIN: pin_index = JOY_Y; break;
#endif
#if HAS_JOY_ADC_Z
case JOY_Z_PIN: pin_index = JOY_Z; break;
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
case FILWIDTH_PIN: pin_index = FILWIDTH; break;
#endif
#if HAS_ADC_BUTTONS
case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break;
#endif
#if ENABLED(POWER_MONITOR_CURRENT)
case POWER_MONITOR_CURRENT_PIN: pin_index = POWERMON_CURRENT; break;
#endif
#if ENABLED(POWER_MONITOR_VOLTAGE)
case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break;
#endif
} }
HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
} }

View File

@ -235,6 +235,8 @@
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
#define _OPTITEM(A...) A,
#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A))
#define _OPTARG(A...) , A #define _OPTARG(A...) , A
#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A)) #define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A))
#define _OPTCODE(A) A; #define _OPTCODE(A) A;

View File

@ -118,9 +118,9 @@
// Temperature sensor IDs // Temperature sensor IDs
#define HID_REDUNDANT -6 #define HID_REDUNDANT -6
#define HID_COOLER -5 #define HID_BOARD -5
#define HID_PROBE -4 #define HID_COOLER -4
#define HID_BOARD -3 #define HID_PROBE -3
#define HID_CHAMBER -2 #define HID_CHAMBER -2
#define HID_BED -1 #define HID_BED -1
#define HID_E0 0 #define HID_E0 0

View File

@ -507,7 +507,13 @@
#ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10
#endif #endif
#if REDUNDANT_TEMP_MATCH(SOURCE, COOLER) #if REDUNDANT_TEMP_MATCH(SOURCE, BOARD)
#if !PIN_EXISTS(TEMP_BOARD)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to BOARD requires TEMP_BOARD_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_BOARD_PIN
#endif
#elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER)
#if !PIN_EXISTS(TEMP_COOLER) #if !PIN_EXISTS(TEMP_COOLER)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN."
#else #else
@ -2446,12 +2452,12 @@
#if HAS_TEMP(BED) #if HAS_TEMP(BED)
#define HAS_TEMP_BED 1 #define HAS_TEMP_BED 1
#endif #endif
#if HAS_TEMP(PROBE)
#define HAS_TEMP_PROBE 1
#endif
#if HAS_TEMP(CHAMBER) #if HAS_TEMP(CHAMBER)
#define HAS_TEMP_CHAMBER 1 #define HAS_TEMP_CHAMBER 1
#endif #endif
#if HAS_TEMP(PROBE)
#define HAS_TEMP_PROBE 1
#endif
#if HAS_TEMP(COOLER) #if HAS_TEMP(COOLER)
#define HAS_TEMP_COOLER 1 #define HAS_TEMP_COOLER 1
#endif #endif

View File

@ -222,12 +222,12 @@ const uint16_t VPList_SDPrintTune[] PROGMEM = {
}; };
const uint16_t VPList_StepPerMM[] PROGMEM = { const uint16_t VPList_StepPerMM[] PROGMEM = {
VP_X_STEP_PER_MM VP_X_STEP_PER_MM,
, VP_Y_STEP_PER_MM VP_Y_STEP_PER_MM,
, VP_Z_STEP_PER_MM VP_Z_STEP_PER_MM,
OPTARG(HAS_HOTEND, VP_E0_STEP_PER_MM) OPTITEM(HAS_HOTEND, VP_E0_STEP_PER_MM)
OPTARG(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) OPTITEM(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM)
, 0x0000 0x0000
}; };
const uint16_t VPList_PIDE0[] PROGMEM = { const uint16_t VPList_PIDE0[] PROGMEM = {

View File

@ -2361,12 +2361,12 @@ void Temperature::init() {
#if HAS_TEMP_ADC_CHAMBER #if HAS_TEMP_ADC_CHAMBER
HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN); HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN);
#endif #endif
#if HAS_TEMP_ADC_COOLER
HAL_ANALOG_SELECT(TEMP_COOLER_PIN);
#endif
#if HAS_TEMP_ADC_PROBE #if HAS_TEMP_ADC_PROBE
HAL_ANALOG_SELECT(TEMP_PROBE_PIN); HAL_ANALOG_SELECT(TEMP_PROBE_PIN);
#endif #endif
#if HAS_TEMP_ADC_COOLER
HAL_ANALOG_SELECT(TEMP_COOLER_PIN);
#endif
#if HAS_TEMP_ADC_BOARD #if HAS_TEMP_ADC_BOARD
HAL_ANALOG_SELECT(TEMP_BOARD_PIN); HAL_ANALOG_SELECT(TEMP_BOARD_PIN);
#endif #endif
@ -2948,8 +2948,8 @@ void Temperature::update_raw_temperatures() {
TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_BED, temp_bed.update());
TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update());
TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update());
TERN_(HAS_TEMP_ADC_BOARD, temp_board.update());
TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update());
TERN_(HAS_TEMP_ADC_BOARD, temp_board.update());
TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update());
TERN_(HAS_JOY_ADC_Y, joystick.y.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update());

View File

@ -231,9 +231,6 @@ struct PIDHeaterInfo : public HeaterInfo {
typedef heater_info_t bed_info_t; typedef heater_info_t bed_info_t;
#endif #endif
#endif #endif
#if HAS_TEMP_PROBE
typedef temp_info_t probe_info_t;
#endif
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
#if ENABLED(PIDTEMPCHAMBER) #if ENABLED(PIDTEMPCHAMBER)
typedef struct PIDHeaterInfo<PID_t> chamber_info_t; typedef struct PIDHeaterInfo<PID_t> chamber_info_t;
@ -243,12 +240,15 @@ struct PIDHeaterInfo : public HeaterInfo {
#elif HAS_TEMP_CHAMBER #elif HAS_TEMP_CHAMBER
typedef temp_info_t chamber_info_t; typedef temp_info_t chamber_info_t;
#endif #endif
#if HAS_TEMP_BOARD #if HAS_TEMP_PROBE
typedef temp_info_t board_info_t; typedef temp_info_t probe_info_t;
#endif #endif
#if EITHER(HAS_COOLER, HAS_TEMP_COOLER) #if EITHER(HAS_COOLER, HAS_TEMP_COOLER)
typedef heater_info_t cooler_info_t; typedef heater_info_t cooler_info_t;
#endif #endif
#if HAS_TEMP_BOARD
typedef temp_info_t board_info_t;
#endif
// Heater watch handling // Heater watch handling
template <int INCREASE, int HYSTERESIS, millis_t PERIOD> template <int INCREASE, int HYSTERESIS, millis_t PERIOD>
@ -318,12 +318,12 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra
#if TEMP_SENSOR_BED_IS_CUSTOM #if TEMP_SENSOR_BED_IS_CUSTOM
CTI_BED, CTI_BED,
#endif #endif
#if TEMP_SENSOR_PROBE_IS_CUSTOM
CTI_PROBE,
#endif
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
CTI_CHAMBER, CTI_CHAMBER,
#endif #endif
#if TEMP_SENSOR_PROBE_IS_CUSTOM
CTI_PROBE,
#endif
#if TEMP_SENSOR_COOLER_IS_CUSTOM #if TEMP_SENSOR_COOLER_IS_CUSTOM
CTI_COOLER, CTI_COOLER,
#endif #endif
@ -599,12 +599,12 @@ class Temperature {
#if HAS_HEATED_BED #if HAS_HEATED_BED
static celsius_float_t analog_to_celsius_bed(const int16_t raw); static celsius_float_t analog_to_celsius_bed(const int16_t raw);
#endif #endif
#if HAS_TEMP_PROBE
static celsius_float_t analog_to_celsius_probe(const int16_t raw);
#endif
#if HAS_TEMP_CHAMBER #if HAS_TEMP_CHAMBER
static celsius_float_t analog_to_celsius_chamber(const int16_t raw); static celsius_float_t analog_to_celsius_chamber(const int16_t raw);
#endif #endif
#if HAS_TEMP_PROBE
static celsius_float_t analog_to_celsius_probe(const int16_t raw);
#endif
#if HAS_TEMP_COOLER #if HAS_TEMP_COOLER
static celsius_float_t analog_to_celsius_cooler(const int16_t raw); static celsius_float_t analog_to_celsius_cooler(const int16_t raw);
#endif #endif

View File

@ -283,13 +283,6 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
#define TEMPTABLE_CHAMBER_LEN 0 #define TEMPTABLE_CHAMBER_LEN 0
#endif #endif
#if TEMP_SENSOR_COOLER > 0
#define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER)
#define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER)
#else
#define TEMPTABLE_COOLER_LEN 0
#endif
#if TEMP_SENSOR_PROBE > 0 #if TEMP_SENSOR_PROBE > 0
#define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE) #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE)
#define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE)
@ -297,6 +290,13 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
#define TEMPTABLE_PROBE_LEN 0 #define TEMPTABLE_PROBE_LEN 0
#endif #endif
#if TEMP_SENSOR_COOLER > 0
#define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER)
#define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER)
#else
#define TEMPTABLE_COOLER_LEN 0
#endif
#if TEMP_SENSOR_BOARD > 0 #if TEMP_SENSOR_BOARD > 0
#define TEMPTABLE_BOARD TT_NAME(TEMP_SENSOR_BOARD) #define TEMPTABLE_BOARD TT_NAME(TEMP_SENSOR_BOARD)
#define TEMPTABLE_BOARD_LEN COUNT(TEMPTABLE_BOARD) #define TEMPTABLE_BOARD_LEN COUNT(TEMPTABLE_BOARD)
@ -316,8 +316,8 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_
|| 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN || 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN
|| 255 > TEMPTABLE_BED_LEN || 255 > TEMPTABLE_BED_LEN
|| 255 > TEMPTABLE_CHAMBER_LEN || 255 > TEMPTABLE_CHAMBER_LEN
|| 255 > TEMPTABLE_COOLER_LEN
|| 255 > TEMPTABLE_PROBE_LEN || 255 > TEMPTABLE_PROBE_LEN
|| 255 > TEMPTABLE_COOLER_LEN
|| 255 > TEMPTABLE_BOARD_LEN || 255 > TEMPTABLE_BOARD_LEN
|| 255 > TEMPTABLE_REDUNDANT_LEN || 255 > TEMPTABLE_REDUNDANT_LEN
, "Temperature conversion tables over 255 entries need special consideration." , "Temperature conversion tables over 255 entries need special consideration."

View File

@ -141,24 +141,24 @@
REPORT_NAME_ANALOG(__LINE__, TEMP_BED_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_BED_PIN)
#endif #endif
#endif #endif
#if PIN_EXISTS(TEMP_BOARD)
#if ANALOG_OK(TEMP_BOARD_PIN)
REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN)
#endif
#endif
#if PIN_EXISTS(TEMP_CHAMBER) #if PIN_EXISTS(TEMP_CHAMBER)
#if ANALOG_OK(TEMP_CHAMBER_PIN) #if ANALOG_OK(TEMP_CHAMBER_PIN)
REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN)
#endif #endif
#endif #endif
#if PIN_EXISTS(TEMP_PROBE)
#if ANALOG_OK(TEMP_PROBE_PIN)
REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN)
#endif
#endif
#if PIN_EXISTS(TEMP_COOLER) #if PIN_EXISTS(TEMP_COOLER)
#if ANALOG_OK(TEMP_COOLER_PIN) #if ANALOG_OK(TEMP_COOLER_PIN)
REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN)
#endif #endif
#endif #endif
#if PIN_EXISTS(TEMP_PROBE) #if PIN_EXISTS(TEMP_BOARD)
#if ANALOG_OK(TEMP_PROBE_PIN) #if ANALOG_OK(TEMP_BOARD_PIN)
REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN)
#endif #endif
#endif #endif
#if PIN_EXISTS(ADC_KEYPAD) #if PIN_EXISTS(ADC_KEYPAD)