*_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.
Remove most of the duplicated code inside temp_runaway_stop(),
making it identical to the other temperature handlers.
Move the lower-level functions required to stop the entirety of the
machine into UnconditionalStop(). Reuse this function inside
lcd_print_stop().
Set the LCD alert message before calling Stop(), as done in other safety
handlers, so that the error is visible while the printer is stopping.
This also avoids other temporary status messages to appear before
the real issue is shown and/or STEALING the first CRITICAL alert
level before we do.
When building with GCC 4.9.2 (bundled with PF-build-env-1.0.6.*), -Os
and LTO enabled, PID_autotune gets automatically inlined into
process_commands().
Sadly, due to the massive size of process_commands(), it results in
codegen bug doing a partial stack overwrite in process_commands()
itself, manifesting as random behavior depending on the timing of
interrupts and the codepath taken inside the merged function.
Mark the function as noinline and add a note about the affected compiler
version in order to be checked again in the future.
This avoids the "busy" output interleaving with regular output in very
rare scenarios.
We should focus in finding which calls are not using manage_inactivity()
properly instead of working it around.
Now that the stack_error function is truly minimal,
we can check for stack errors much more frequently.
Also move away stack_error from ultralcd to Marlin_main.