- Flag the error condition from the temp_mgr_isr
- Handle the error state from the user code
Currently only handles min/maxtemp and relays the error to the original
handler (which is a poor fit for the current design).
Split off setIsrTargetTemperatures and temp_mgr_pid() so that we can
propagate the target temperatures instantaneously down the pid/pwm chain
during emergencies.
This reduces the amount of code in disable_heater() itself, making it
a bit more maintenable.
The bed still isn't disabled on-the-spot yet, due to the heatbed_pwm
automaton. To be improved later.
*_temperature_raw: buffer for the ADC ISR (read by temp ISR)
*_temperature_isr: latest temperatures for PID regulation (copied from
_raw values)
*_temperature: latest temperature for user code
The flow:
- ADC ISR (async)
- perform oversampling
- call ADC callback: copy to _raw (async)
- temp ISR (timer)
- convert to C (_isr values)
- user code (async)
- check temp_meas_ready
- call updateTemperature()
- copy from _isr to current
- syncronize target temperatures
This removes PINDA value averaging (if needed, should be re-implemented
by averaging in user code where needed)
Use a new low-priority "temp_mgr_isr" running at constant rate for
temperature management.
This is done so that the temperatures are sampled at a constant
independent interval *and* with reduced jitter. Likewise for actual
PID management.
This will require further adjustment for the min/max/runaway display,
which cannot be done directly into this function anymore (the code will
need to disable heaters but flag for display to be handled in
manage_heaters).
Read from ADC as fast as possible using the ADC interrupt to get
more accurate instantaneous readings.
Decouple the temperature_isr from the adc reading interval, so that
the two can run independently for future use.
Setting pullups on the ADC should trigger the model-based check, making
this redundant and wasteful.
Keep the DEBUG_PULLUP_CRASH menu so that we can verify this behavior in
the future.
The max/min temperature check were incorrectly using
HEATER_AMBIENT_RAW_*_TEMP (non-existing) instead of the correct
AMBIENT_RAW_*_TEMP (this is not a heater afterall).
This doesn't change the current behavior, since the check defaulted to
the correct path for the MK3+ configuration anyway.
Partially revert previous change: cancelling a single loop would often
advance the gcode stream to the next wait-for loop if executed at the
beginning of an SD print, implicitly turning off the flag again.
Cancel the loop directly in UnconditionalStop() which stops the command
queue as well in an atomic way, handling this correctly.