diff --git a/pwnagotchi/plugins/default/pisugarx.py b/pwnagotchi/plugins/default/pisugarx.py index 65ea7bee..2f82b734 100644 --- a/pwnagotchi/plugins/default/pisugarx.py +++ b/pwnagotchi/plugins/default/pisugarx.py @@ -2,7 +2,6 @@ # wget https://cdn.pisugar.com/release/pisugar-power-manager.sh # bash pisugar-power-manager.sh -c release - # https://www.tindie.com/stores/pisugar/ import logging @@ -18,10 +17,13 @@ from flask import render_template_string class PiSugar(plugins.Plugin): __author__ = "jayofelony" - __version__ = "1.0" + __version__ = "1.2" __license__ = "GPL3" - __description__ = ("A plugin that will add a voltage indicator for the PiSugar batteries." - "This plugin will also have a web configuration in the future, just like the Power Manager.") + __description__ = ( + "A plugin that will add a voltage indicator for the PiSugar batteries. " + "Rotation of battery status can be enabled or disabled via configuration. " + "Additionally, when rotation is disabled, you can choose which metric to display." + ) def __init__(self): self._agent = None @@ -32,10 +34,25 @@ class PiSugar(plugins.Plugin): self.ready = False self.lasttemp = 69 self.drot = 0 # display rotation - self.nextDChg = 0 # last time display changed, rotate on updates after 5 seconds + self.nextDChg = 0 # last time display changed + self.rotation_enabled = True # default rotation enabled + self.default_display = "voltage" # default display option def on_loaded(self): logging.info("[PiSugarX] plugin loaded.") + # Read rotation option from configuration + cfg = pwnagotchi.config['main']['plugins']['pisugarx'] + self.rotation_enabled = cfg.get('rotation', True) + self.default_display = cfg.get('default_display', 'voltage').lower() + + # Validate default_display + valid_displays = ['voltage', 'percentage', 'temp'] + if self.default_display not in valid_displays: + logging.warning(f"[PiSugarX] Invalid default_display '{self.default_display}'. Using 'voltage'.") + self.default_display = 'voltage' + + logging.info(f"[PiSugarX] Rotation is {'enabled' if self.rotation_enabled else 'disabled'}.") + logging.info(f"[PiSugarX] Default display (when rotation disabled): {self.default_display}") def on_ready(self, agent): self.ready = True @@ -48,8 +65,7 @@ class PiSugar(plugins.Plugin): def on_internet_available(self, agent): self._agent = agent self.ps.rtc_web() - """ - WORK IN PROGRESS + def on_webhook(self, path, request): if not self.ready: ret = "