Skip to content

Commit

Permalink
🐛 Followup to TEMP_SENSOR_BOARD (#22344)
Browse files Browse the repository at this point in the history
Followup to #22279
  • Loading branch information
slowbro authored Jul 13, 2021
1 parent 315a722 commit cd98d0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@

// Usurp a sensor to do redundant readings
#if TEMP_SENSOR_REDUNDANT
#define REDUNDANT_TEMP_MATCH(M,N) (TEMP_SENSOR_REDUNDANT_##M == HID_##N)
#define _HEATER_ID(M) HID_##M
#define HEATER_ID(M) _HEATER_ID(M)
#define REDUNDANT_TEMP_MATCH(M,N) (HEATER_ID(TEMP_SENSOR_REDUNDANT_##M) == _HEATER_ID(N))
#else
#define REDUNDANT_TEMP_MATCH(...) 0
#endif
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms
#if HAS_TEMP_REDUNDANT
if (heater_id == H_REDUNDANT) {
SERIAL_ECHOPGM(STR_REDUNDANT); // print redundant and cascade to print target, too.
real_heater_id = (heater_id_t)TEMP_SENSOR_REDUNDANT_TARGET;
real_heater_id = (heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET);
}
#endif

Expand Down Expand Up @@ -1323,7 +1323,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_REDUNDANT
// Make sure measured temperatures are close together
if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF)
_temp_error((heater_id_t)TEMP_SENSOR_REDUNDANT_TARGET, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
_temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
#endif

#if HAS_AUTO_FAN
Expand Down Expand Up @@ -2015,7 +2015,7 @@ void Temperature::updateTemperaturesFromRawValues() {

TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0));
TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1));
TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(TEMP_SENSOR_REDUNDANT_SOURCE));
TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)));

#if HAS_HOTEND
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
Expand Down Expand Up @@ -2473,7 +2473,7 @@ void Temperature::init() {
#elif REDUNDANT_TEMP_MATCH(TARGET, BED) && HAS_TEMP_BED
temp_bed
#else
temp_hotend[TEMP_SENSOR_REDUNDANT_TARGET]
temp_hotend[HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET)]
#endif
);
#endif
Expand Down
11 changes: 11 additions & 0 deletions buildroot/tests/mega2560
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOO

exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3"

#
# Test redundant temperature sensors + MAX TC
#
restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \
TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \
TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \
TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12

exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675" "$3"

#
# Language files test with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
#
Expand Down

0 comments on commit cd98d0c

Please sign in to comment.