Skip to content

Commit

Permalink
- Fix the temperature symbol when using something other than celsius
Browse files Browse the repository at this point in the history
- Add defaults so we don't throw an exception if an invalid scale is
selected. Bad things happen if you spell fahrenheit wrong.
  • Loading branch information
andrewbeard committed Nov 16, 2019
1 parent de62424 commit 43c5ab7
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions pwnagotchi/plugins/default/memtemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,32 @@ def on_ui_setup(self, ui):
h_pos = (155, 76)
v_pos = (180, 61)

if self.options['orientation'] == "horizontal":
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='mem cpu temp\n - - -',
position=h_pos,
label_font=fonts.Small, text_font=fonts.Small))
elif self.options['orientation'] == "vertical":
if self.options['orientation'] == "vertical":
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value=' mem:-\n cpu:-\ntemp:-',
position=v_pos,
label_font=fonts.Small, text_font=fonts.Small))
else:
# default to horizontal
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='mem cpu temp\n - - -',
position=h_pos,
label_font=fonts.Small, text_font=fonts.Small))

def on_ui_update(self, ui):
if self.options['scale'] == "fahrenheit":
temp = (pwnagotchi.temperature() * 9 / 5) + 32
elif self.options['scale'] == "celsius":
temp = pwnagotchi.temperature()
symbol = "f"
elif self.options['scale'] == "kelvin":
temp = pwnagotchi.temperature() + 273.15
if self.options['orientation'] == "horizontal":
ui.set('memtemp',
" mem cpu temp\n %s%% %s%% %sc" % (self.mem_usage(), self.cpu_load(), temp))
symbol = "k"
else:
# default to celsius
temp = pwnagotchi.temperature()
symbol = "c"

elif self.options['orientation'] == "vertical":
if self.options['orientation'] == "vertical":
ui.set('memtemp',
" mem:%s%%\n cpu:%s%%\ntemp:%s%s" % (self.mem_usage(), self.cpu_load(), temp, symbol))
else:
# default to horizontal
ui.set('memtemp',
" mem:%s%%\n cpu:%s%%\ntemp:%sc" % (self.mem_usage(), self.cpu_load(), temp))
" mem cpu temp\n %s%% %s%% %s%s" % (self.mem_usage(), self.cpu_load(), temp, symbol))

0 comments on commit 43c5ab7

Please sign in to comment.