Move temperature reporting to Temperature class
This commit is contained in:
parent
6e197d4a42
commit
5d01a2f467
5 changed files with 115 additions and 101 deletions
|
|
@ -2186,3 +2186,95 @@ void Temperature::isr() {
|
|||
in_temp_isr = false;
|
||||
SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
|
||||
}
|
||||
|
||||
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
||||
|
||||
void print_heater_state(const float &c, const float &t,
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
const float r,
|
||||
#endif
|
||||
const int8_t e=-2
|
||||
) {
|
||||
#if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
|
||||
SERIAL_PROTOCOLCHAR(' ');
|
||||
SERIAL_PROTOCOLCHAR(
|
||||
#if HAS_TEMP_BED && HAS_TEMP_HOTEND
|
||||
e == -1 ? 'B' : 'T'
|
||||
#elif HAS_TEMP_HOTEND
|
||||
'T'
|
||||
#else
|
||||
'B'
|
||||
#endif
|
||||
);
|
||||
#if HOTENDS > 1
|
||||
if (e >= 0) SERIAL_PROTOCOLCHAR('0' + e);
|
||||
#endif
|
||||
SERIAL_PROTOCOLCHAR(':');
|
||||
SERIAL_PROTOCOL(c);
|
||||
SERIAL_PROTOCOLPAIR(" /" , t);
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
SERIAL_PROTOCOLPAIR(" (", r / OVERSAMPLENR);
|
||||
SERIAL_PROTOCOLCHAR(')');
|
||||
#endif
|
||||
}
|
||||
|
||||
extern uint8_t target_extruder;
|
||||
|
||||
void Temperature::print_heaterstates() {
|
||||
#if HAS_TEMP_HOTEND
|
||||
print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
, rawHotendTemp(target_extruder)
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#if HAS_TEMP_BED
|
||||
print_heater_state(degBed(), degTargetBed()
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
, rawBedTemp()
|
||||
#endif
|
||||
, -1 // BED
|
||||
);
|
||||
#endif
|
||||
#if HOTENDS > 1
|
||||
HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
, rawHotendTemp(e)
|
||||
#endif
|
||||
, e
|
||||
);
|
||||
#endif
|
||||
SERIAL_PROTOCOLPGM(" @:");
|
||||
SERIAL_PROTOCOL(getHeaterPower(target_extruder));
|
||||
#if HAS_TEMP_BED
|
||||
SERIAL_PROTOCOLPGM(" B@:");
|
||||
SERIAL_PROTOCOL(getHeaterPower(-1));
|
||||
#endif
|
||||
#if HOTENDS > 1
|
||||
HOTEND_LOOP() {
|
||||
SERIAL_PROTOCOLPAIR(" @", e);
|
||||
SERIAL_PROTOCOLCHAR(':');
|
||||
SERIAL_PROTOCOL(getHeaterPower(e));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_REPORT_TEMPERATURES)
|
||||
|
||||
uint8_t Temperature::auto_report_temp_interval;
|
||||
millis_t Temperature::next_temp_report_ms;
|
||||
|
||||
void Temperature::auto_report_temperatures() {
|
||||
if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
|
||||
next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
|
||||
print_heaterstates();
|
||||
SERIAL_EOL();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // AUTO_REPORT_TEMPERATURES
|
||||
|
||||
#endif // HAS_TEMP_HOTEND || HAS_TEMP_BED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue