def on_ui_update(self, ui): capacity = int(self.ps.get_battery_percentage().value) # new model use battery_power_plugged & battery_allow_charging to detect real charging status if self.is_new_model: if self.ps.get_battery_power_plugged( ).value and self.ps.get_battery_allow_charging().value: ui.set("chg", "CHG") if not self.is_charging: ui.update(force=True, new_data={"status": "Power!! I can feel it!"}) self.is_charging = True else: ui.set("chg", "") self.is_charging = False ui.set("bat", str(capacity) + "%") if capacity <= self.options["shutdown"]: logging.info( f"[pisugar2] Empty battery (<= {self.options['shutdown']}): shuting down" ) ui.update(force=True, new_data={"status": "Battery exhausted, bye ..."}) time.sleep(3) pwnagotchi.shutdown()
def do_GET(self): if self.path == '/': self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() try: self.wfile.write( bytes(self._index % (pwnagotchi.name(), 1000), "utf8")) except: pass elif self.path.startswith('/shutdown'): pwnagotchi.shutdown() elif self.path.startswith('/ui'): with self._lock: self.send_response(200) self.send_header('Content-type', 'image/png') self.end_headers() try: with open("/root/pwnagotchi.png", 'rb') as fp: shutil.copyfileobj(fp, self.wfile) except: pass else: self.send_response(404)
def on_ui_update(self, ui): capacity = self.ups.capacity() ui.set('ups', "%2i%%" % capacity) if capacity <= self.options['shutdown'] and (GPIO.input(4) == GPIO.LOW): # do not shutdown if charging logging.info('[ups_lite] Empty battery (<= %s%%): shuting down' % self.options['shutdown']) ui.update(force=True, new_data={'status': 'Battery exhausted, bye ...'}) pwnagotchi.shutdown()
def on_ui_update(self, ui): capacity = self.ups.capacity() charging = self.ups.charging() ui.set('ups', "%2i%s" % (capacity, charging)) if capacity <= self.options['shutdown']: logging.info('[ups_lite] Empty battery (<= %s%%): shuting down' % self.options['shutdown']) ui.update(force=True, new_data={'status': 'Battery exhausted, bye ...'}) pwnagotchi.shutdown()
def on_ui_update(self, ui): capacity = self.ups.capacity() ui.set('bat', "%2i%%" % capacity) if capacity <= self.options['shutdown']: logging.info('[pisugar2] Empty battery (<= %s%%): shuting down' % self.options['shutdown']) ui.update(force=True, new_data={'status': 'Battery exhausted, bye ...'}) pwnagotchi.shutdown()
def on_ui_update(self, ui): capacity = self.ups.capacity() ui.set('ups', f"{capacity:2.0f}%") if capacity <= self.options['shutdown']: logging.info( f"[ups_lite] Empty battery (<= {self.options['shutdown']}%): shutting down" ) ui.update(force=True, new_data={'status': 'Battery exhausted, bye...'}) pwnagotchi.shutdown()
def check_status(self): while True: status = self.get_status() if (not "pg" in status["stat"] and "low battery" in status["bat"]): logging.warn("Battery low! Shutting down") break elif ("button" in status["stat"]): logging.warn("Button pressed! Shutting down") run([self.path, "clear", "button"]) break sleep(self.refresh_time) run([self.path, "watchdog", "60"]) pwnagotchi.shutdown()
def on_ui_update(self, ui): charging = self.pisugar.charging() capacity = self.pisugar.capacity() if charging is True: ui.set('pisugar', f"⚡{capacity:2.0f}%") else: ui.set('pisugar', f"{capacity:2.0f}%") if capacity <= self.options['shutdown']: logging.info( f"[pisugar] Low battery ({capacity:2.0f}%), shutting down.") ui.update(force=True, new_data={'status', 'Battery exhausted, bye...'}) pwnagotchi.shutdown()
def check_status(self): # Cut off power after 60 seconds of inactivity run([self.path, "watchdog", "60"]) while True: status = self.get_status() # Details at https://www.microchip.com/wwwproducts/en/en536670 if (not "pg" in status["stat"] and not "stat1" in status["stat"] and "stat2" in status["stat"]): logging.warn("Battery low! Shutting down") break elif ("button" in status["stat"]): logging.warn("Button pressed! Shutting down") run([self.path, "clear", "button"]) break sleep(self.refresh_time) pwnagotchi.shutdown()
def _shutdown(self): self._html(SHUTDOWN % pwnagotchi.name()) pwnagotchi.shutdown()
def shutdown(self, channel): logging.warning('Received shutdown command from GPIO') pwnagotchi.shutdown()