Add Fahrenheit and Kelvin temperature scales to memtemp.py

This commit is contained in:
bensmith83 2019-11-08 19:50:33 -05:00 committed by GitHub
parent 94521f2174
commit 1da59b50b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,10 +58,16 @@ class MemTemp(plugins.Plugin):
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()
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(), pwnagotchi.temperature()))
" mem cpu temp\n %s%% %s%% %sc" % (self.mem_usage(), self.cpu_load(), temp))
elif self.options['orientation'] == "vertical":
ui.set('memtemp',
" mem:%s%%\n cpu:%s%%\ntemp:%sc" % (self.mem_usage(), self.cpu_load(), pwnagotchi.temperature()))
" mem:%s%%\n cpu:%s%%\ntemp:%sc" % (self.mem_usage(), self.cpu_load(), temp))