nebhead / PiFire

PiFire is a Smart WiFi enabled controller for your pellet smoker / grill.
https://nebhead.github.io/PiFire-Pages
MIT License
82 stars 31 forks source link

ST7789 display crashes if fewer than two food probes are defined #164

Closed ghandye closed 1 year ago

ghandye commented 1 year ago

Describe the bug ST7789 display crashes if fewer than two food probes are defined.

To Reproduce (Distilled from comments by @EricPalmquist and @nebhead on PiFire Discord) Steps to reproduce the behavior:

  1. Attach and define a ST7789 display in the configuration wizard
  2. Define only one food probe in the configuration wizard
  3. When control service restarts, use buttons/rotary knob to confirm that display is working
  4. Start Monitor mode from buttons/knob
  5. (BUG) Display goes black, traceback error spits out:

Exception in thread Thread-5: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/usr/local/bin/pifire/display/base_240x320.py", line 250, in _display_loop self._display_current(self.in_data, self.status_data) File "/usr/local/bin/pifire/display/base_240x320.py", line 790, in _display_current label = list(in_data['probe_history']['food'].keys())[1] IndexError: list index out of range

Expected behavior Display should not crash if fewer than two food probes are defined.

PiFire Version: Main (1.5.x)

Additional context Behavior reported by @EricPalmquist and probable bug identified by @nebhead on PiFire Discord. Documented here as an issue for posterity.

A similar bugfix exists in https://github.com/nebhead/PiFire/commit/da464dcfceb88ad4b8e6e308d904357983c5c491 but does not cover ST7789 displays (per @nebhead).

ghandye commented 1 year ago

After further review with @nebhead in the Discord, it sounds like https://github.com/nebhead/PiFire/commit/da464dcfceb88ad4b8e6e308d904357983c5c491 should have fixed this for the ST7789 after all. Closing based on that developer feedback.