2019-10-19 21:32:55 +02:00
|
|
|
# memtemp shows memory infos and cpu temperature
|
2019-10-03 18:11:42 +02:00
|
|
|
#
|
2019-10-19 21:32:55 +02:00
|
|
|
# mem usage, cpu load, cpu temp
|
2019-10-03 18:11:42 +02:00
|
|
|
#
|
2019-10-17 23:55:11 +02:00
|
|
|
###############################################################
|
|
|
|
#
|
|
|
|
# Updated 18-10-2019 by spees <speeskonijn@gmail.com>
|
|
|
|
# - Changed the place where the data was displayed on screen
|
|
|
|
# - Made the data a bit more compact and easier to read
|
|
|
|
# - removed the label so we wont waste screen space
|
|
|
|
# - Updated version to 1.0.1
|
|
|
|
#
|
2019-10-19 21:32:55 +02:00
|
|
|
# 20-10-2019 by spees <speeskonijn@gmail.com>
|
|
|
|
# - Refactored to use the already existing functions
|
|
|
|
# - Now only shows memory usage in percentage
|
|
|
|
# - Added CPU load
|
|
|
|
# - Added horizontal and vertical orientation
|
|
|
|
#
|
2019-10-17 23:55:11 +02:00
|
|
|
###############################################################
|
|
|
|
|
2019-10-03 18:11:42 +02:00
|
|
|
__author__ = 'https://github.com/xenDE'
|
2019-10-17 23:55:11 +02:00
|
|
|
__version__ = '1.0.1'
|
2019-10-03 18:11:42 +02:00
|
|
|
__name__ = 'memtemp'
|
|
|
|
__license__ = 'GPL3'
|
2019-10-19 21:32:55 +02:00
|
|
|
__description__ = 'A plugin that will display memory/cpu usage and temperature'
|
2019-10-03 18:11:42 +02:00
|
|
|
|
|
|
|
from pwnagotchi.ui.components import LabeledValue
|
|
|
|
from pwnagotchi.ui.view import BLACK
|
|
|
|
import pwnagotchi.ui.fonts as fonts
|
2019-10-19 22:25:12 +02:00
|
|
|
import pwnagotchi
|
2019-10-19 21:32:55 +02:00
|
|
|
import logging
|
2019-10-03 18:11:42 +02:00
|
|
|
|
2019-10-19 21:32:55 +02:00
|
|
|
OPTIONS = dict()
|
2019-10-03 18:11:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
def on_loaded():
|
2019-10-19 21:32:55 +02:00
|
|
|
logging.info("memtemp plugin loaded.")
|
|
|
|
|
|
|
|
|
|
|
|
def mem_usage():
|
2019-10-19 22:25:12 +02:00
|
|
|
return int(pwnagotchi.mem_usage() * 100)
|
2019-10-19 21:32:55 +02:00
|
|
|
|
2019-10-20 14:28:34 +02:00
|
|
|
|
2019-10-19 21:32:55 +02:00
|
|
|
def cpu_load():
|
2019-10-19 22:25:12 +02:00
|
|
|
return int(pwnagotchi.cpu_load() * 100)
|
2019-10-19 21:32:55 +02:00
|
|
|
|
|
|
|
|
2019-10-03 18:11:42 +02:00
|
|
|
def on_ui_setup(ui):
|
2019-10-19 21:32:55 +02:00
|
|
|
if OPTIONS['orientation'] == "horizontal":
|
2019-10-20 14:28:34 +02:00
|
|
|
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='mem cpu temp\n - - -',
|
|
|
|
position=(ui.width() / 2 + 30, ui.height() / 2 + 15),
|
|
|
|
label_font=fonts.Small, text_font=fonts.Small))
|
2019-10-19 21:32:55 +02:00
|
|
|
elif OPTIONS['orientation'] == "vertical":
|
2019-10-20 14:28:34 +02:00
|
|
|
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value=' mem:-\n cpu:-\ntemp:-',
|
|
|
|
position=(ui.width() / 2 + 55, ui.height() / 2),
|
|
|
|
label_font=fonts.Small, text_font=fonts.Small))
|
|
|
|
|
2019-10-03 18:11:42 +02:00
|
|
|
|
|
|
|
def on_ui_update(ui):
|
2019-10-19 21:32:55 +02:00
|
|
|
if OPTIONS['orientation'] == "horizontal":
|
2019-10-19 22:25:12 +02:00
|
|
|
ui.set('memtemp', " mem cpu temp\n %s%% %s%% %sc" % (mem_usage(), cpu_load(), pwnagotchi.temperature()))
|
2019-10-20 14:28:34 +02:00
|
|
|
|
2019-10-19 21:32:55 +02:00
|
|
|
elif OPTIONS['orientation'] == "vertical":
|
2019-10-19 22:25:12 +02:00
|
|
|
ui.set('memtemp', " mem:%s%%\n cpu:%s%%\ntemp:%sc" % (mem_usage(), cpu_load(), pwnagotchi.temperature()))
|