class BatteryMenuItem(object): TXT_LEVEL = "Battery" TXT_VOLTAGE = "Voltage" def __init__(self): self._battery = Battery() def textlabel(self): textlabel = (BatteryMenuItem.TXT_LEVEL+ ": %d%%" % self._battery.level(), \ BatteryMenuItem.TXT_VOLTAGE+ ": %.2f V" % self._battery.voltage()) return textlabel
def __init__(self): self._battery = Battery()
# LED pins (WiringPi numbering) LED_RED = 23 LED_GREEN = 26 LED_BLUE = 22 # SSD3106 reset pin (not used) RESET_PIN = 26 pipe = PipeWriter() if fork() != 0: pipe.close(PipeWriter.OUT) led = RGBLED(LED_RED, LED_GREEN, LED_BLUE) led.set(0, 0, 10) battery = Battery() battery.set_warn_function(low_battery_warning, led) battery.set_empty_function(empty_battery) battery.start_monitor() display = Display(RESET_PIN) display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm") display.set_modal_duration(3) menu_items = [] menu_items.append(BatteryMenuItem()) menu_items.append(IPMenuItem()) menu_items.append(HotspotMenuItem()) display.set_menu_items(menu_items) display.start_updates() while True: