configfile: Add support for reporting runtime_warnings via the API server

Add a new runtime_warning() method that will add a 'runtime_warning'
type message to the printer.configfile.warnings object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2024-03-05 21:45:16 -05:00
parent d99d1a8463
commit 0291a1554c
2 changed files with 14 additions and 4 deletions

View file

@ -811,8 +811,10 @@ class MCU:
mcu_freq_mhz = int(mcu_freq / 1000000. + 0.5)
calc_freq_mhz = int(calc_freq / 1000000. + 0.5)
if mcu_freq_mhz != calc_freq_mhz:
logging.warn("MCU '%s' configured for %dMhz but running at %dMhz!",
self._name, mcu_freq_mhz, calc_freq_mhz)
pconfig = self._printer.lookup_object('configfile')
msg = ("MCU '%s' configured for %dMhz but running at %dMhz!"
% (self._name, mcu_freq_mhz, calc_freq_mhz))
pconfig.runtime_warning(msg)
# Config creation helpers
def setup_pin(self, pin_type, pin_params):
pcs = {'endstop': MCU_endstop,