diff --git a/modules/app_components/menu.py b/modules/app_components/menu.py index 65f479f..05ccefa 100644 --- a/modules/app_components/menu.py +++ b/modules/app_components/menu.py @@ -117,7 +117,10 @@ def draw(self, ctx): # Current menu item ctx.font_size = self.item_font_size + animation_progress * ( - self.focused_item_font_size_arr[self.position % num_menu_items if num_menu_items > 0 else 1] - self.item_font_size + self.focused_item_font_size_arr[ + self.position % num_menu_items if num_menu_items > 0 else 1 + ] + - self.item_font_size ) label = "" diff --git a/modules/firmware_apps/patterninhibit.py b/modules/firmware_apps/patterninhibit.py index 07eb854..1fdefd9 100644 --- a/modules/firmware_apps/patterninhibit.py +++ b/modules/firmware_apps/patterninhibit.py @@ -3,7 +3,7 @@ from events.input import Buttons, BUTTON_TYPES from system.eventbus import eventbus -from system.patterndisplay.events import * +from system.patterndisplay.events import PatternEnable, PatternDisable from tildagonos import tildagonos @@ -18,7 +18,7 @@ def __init__(self): def _make_red(self): asyncio.sleep(0.5) for i in range(1, 13): - tildagonos.leds[i] = (int(i * (255/12)), 0, 0) + tildagonos.leds[i] = (int(i * (255 / 12)), 0, 0) tildagonos.leds.write() def update(self, delta): diff --git a/modules/fusb302b.py b/modules/fusb302b.py index 110cc6b..175463d 100644 --- a/modules/fusb302b.py +++ b/modules/fusb302b.py @@ -434,7 +434,7 @@ def get_status1a(self): ("RXSOP", 0), ("RXSOP1DB", 0), ("RXSOP2DB", 0), - ("TOGSS", 0 ), + ("TOGSS", 0), ] ) status["RXSOP"] = (read & self.rx_sop.mask) >> self.ocp.position @@ -444,8 +444,8 @@ def get_status1a(self): status["RXSOP2DB"] = ( read & self.rx_sop_double_debug.mask ) >> self.rx_sop_double_debug.position - status["TOGSS"] = ( - read & self.toggle_status.mask + status["TOGSS"] = ( + read & self.toggle_status.mask ) >> self.toggle_status.position return status @@ -462,9 +462,9 @@ def get_interrupts(self): Interruptb = self.i2c.readfrom_mem( self.ADDRESS, self.good_crc_sent_int.register, 1 )[0] - Interrupt = self.i2c.readfrom_mem( - self.ADDRESS, self.bc_level_int.register, 1 - )[0] + Interrupt = self.i2c.readfrom_mem(self.ADDRESS, self.bc_level_int.register, 1)[ + 0 + ] current_interrupts = dict( [ ("I_HARDRST", 0), @@ -473,7 +473,7 @@ def get_interrupts(self): ("I_HARDSENT", 0), ("I_RETRYFAIL", 0), ("I_SOFTFAIL", 0), - ("I_TOGDONE", 0 ), + ("I_TOGDONE", 0), ("I_OCP_TEMP", 0), ("I_GCRCSENT", 0), ("I_BC_LVL", 0), @@ -507,8 +507,8 @@ def get_interrupts(self): current_interrupts["I_OCP_TEMP"] = ( Interrupta & self.ocp_temp_int.mask ) >> self.ocp_temp_int.position - current_interrupts['I_TOGDONE '] = ( - Interrupta & self.toggle_done_int.mask + current_interrupts["I_TOGDONE "] = ( + Interrupta & self.toggle_done_int.mask ) >> self.toggle_done_int.position current_interrupts["I_GCRCSENT"] = ( Interruptb & self.good_crc_sent_int.mask @@ -798,7 +798,7 @@ def parse_pdo(self, pdo): limited, ) - def request_capability(self, msg_id = 0): + def request_capability(self, msg_id=0): """ ask for the power supply options """ @@ -809,7 +809,7 @@ def request_capability(self, msg_id = 0): self.TX_SOP2, self.TX_PACKSYM | 0x02, 0x47, - ( 0x00 | ( ( msg_id & 0x07 ) << 1 ) ), + (0x00 | ((msg_id & 0x07) << 1)), self.TX_JAM_CRC, self.TX_EOP, self.TX_OFF, @@ -822,7 +822,9 @@ def soft_reset(self): """ reset the protocol layer on other port """ - self.i2c.writeto_mem(self.ADDRESS, self.rxtx_fifo.register, bytes(self.TX_RESET1)) + self.i2c.writeto_mem( + self.ADDRESS, self.rxtx_fifo.register, bytes(self.TX_RESET1) + ) if __name__ == "__main__": diff --git a/modules/lib/flash_spi.py b/modules/lib/flash_spi.py index d746d59..0822c82 100644 --- a/modules/lib/flash_spi.py +++ b/modules/lib/flash_spi.py @@ -22,10 +22,18 @@ _SEC_SIZE = const(4096) # Flash sector size 0x1000 + # Logical Flash device comprising one or more physical chips sharing an SPI bus. class FLASH(FlashDevice): def __init__( - self, spi, cspins, size=None, verbose=True, sec_size=_SEC_SIZE, block_size=9, cmd5=None + self, + spi, + cspins, + size=None, + verbose=True, + sec_size=_SEC_SIZE, + block_size=9, + cmd5=None, ): self._spi = spi self._cspins = cspins @@ -44,7 +52,7 @@ def __init__( super().__init__(block_size, len(cspins), size * 1024, sec_size) # Select the correct command set - if (cmd5 is None and size <= 4096) or (cmd5 == False): + if (cmd5 is None and size <= 4096) or (not cmd5): self._cmds = _CMDS3BA self._cmdlen = 4 else: @@ -67,7 +75,9 @@ def scan(self, verbose, size): if size is None: size = scansize # Save size of 1st chip if size != scansize: # Mismatch passed size or 1st chip. - raise ValueError(f"Flash size mismatch: expected {size}KiB, found {scansize}KiB") + raise ValueError( + f"Flash size mismatch: expected {size}KiB, found {scansize}KiB" + ) if not 0x10 < mvp[3] < 0x22: raise ValueError(f"Invalid chip size {size}KiB. Specify size arg.") diff --git a/modules/lib/simple_tildagon.py b/modules/lib/simple_tildagon.py index 689433c..160225e 100644 --- a/modules/lib/simple_tildagon.py +++ b/modules/lib/simple_tildagon.py @@ -6,8 +6,7 @@ import time -class led(): - +class led: @staticmethod def _setup_leds(): tildagonos.set_led_power(True) @@ -24,8 +23,7 @@ def set(led_number, state): tildagonos.leds.write() -class button(): - +class button: @staticmethod def get(button_letter): button_letter = button_letter.lower() @@ -41,11 +39,13 @@ def get(button_letter): # Note the button must be flipped, as will return True when not pressed return not tildagonos.check_egpio_state(button_letters[button_letter]) else: - raise ValueError("button_letter must be a string of a single letter from a to f") + raise ValueError( + "button_letter must be a string of a single letter from a to f" + ) -class imu(): - class ImuData(): +class imu: + class ImuData: def __init__(self, x, y, z): self.x = x self.y = y @@ -66,7 +66,7 @@ def __str__(self): @staticmethod def _magnitude(acc_read): - return math.sqrt(sum(i ** 2 for i in acc_read)) + return math.sqrt(sum(i**2 for i in acc_read)) @staticmethod def is_tilted_forward(): diff --git a/modules/patterns/base.py b/modules/patterns/base.py index c44dc1c..ab078f3 100644 --- a/modules/patterns/base.py +++ b/modules/patterns/base.py @@ -1,14 +1,14 @@ -class BasePattern(): +class BasePattern: def __init__(self): self._current_frame_id = 0 self.fps = 1 - self.frames = [[(255,255,255)] * 12] + self.frames = [[(255, 255, 255)] * 12] def next(self): self._current_frame_id += 1 if self._current_frame_id == len(self.frames): self._current_frame_id = 0 - return(self.frames[self._current_frame_id]) + return self.frames[self._current_frame_id] def current(self): - return(self.frames[self._current_frame_id]) + return self.frames[self._current_frame_id] diff --git a/modules/patterns/cylon.py b/modules/patterns/cylon.py index 179b9ce..580b47f 100644 --- a/modules/patterns/cylon.py +++ b/modules/patterns/cylon.py @@ -1,66 +1,821 @@ from patterns.base import BasePattern + class CylonPattern(BasePattern): def __init__(self): super().__init__() self.fps = 11 self.frames = [ - [(255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0), (255, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0), (127, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0), (63, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0), (31, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0), (15, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0), (8, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0), (4, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (2, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0)], - [(0, 0, 0), (0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0)], - [(0, 0, 0), (255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0)], - [(255, 0, 0), (127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(127, 0, 0), (63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(63, 0, 0), (31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(31, 0, 0), (15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(15, 0, 0), (8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(8, 0, 0), (4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(4, 0, 0), (2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(2, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)] + [ + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + (255, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + (127, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + (63, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + (31, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + (15, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + (8, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + (4, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + (2, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (1, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (255, 0, 0), + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (127, 0, 0), + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (63, 0, 0), + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (31, 0, 0), + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (15, 0, 0), + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (8, 0, 0), + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (4, 0, 0), + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (2, 0, 0), + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (1, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], + [ + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + (0, 0, 0), + ], ] diff --git a/modules/patterns/flash.py b/modules/patterns/flash.py index 4899585..5bef058 100644 --- a/modules/patterns/flash.py +++ b/modules/patterns/flash.py @@ -1,10 +1,37 @@ from patterns.base import BasePattern + class FlashPattern(BasePattern): def __init__(self): super().__init__() self.fps = 1 self.frames = [ - [(0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255)], - [(255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0), (255,255,255), (0,0,0)] + [ + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + ], + [ + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + (255, 255, 255), + (0, 0, 0), + ], ] diff --git a/modules/patterns/rainbow.py b/modules/patterns/rainbow.py index b9bc5c2..bdd4d27 100644 --- a/modules/patterns/rainbow.py +++ b/modules/patterns/rainbow.py @@ -1,5 +1,6 @@ from patterns.base import BasePattern + class RainbowPattern(BasePattern): def __init__(self): super().__init__() @@ -11,7 +12,7 @@ def __init__(self): for j in range(num_frames): current_row = [] for i in range(num_pixels): - rc_index = ((i * 256 // num_pixels) + int(j*(255/num_frames))) & 255 + rc_index = ((i * 256 // num_pixels) + int(j * (255 / num_frames))) & 255 if rc_index < 0 or rc_index > 255: current_row.append((0, 0, 0)) elif rc_index < 85: diff --git a/modules/scratchpad.py b/modules/scratchpad.py index 1fa04a0..715067d 100644 --- a/modules/scratchpad.py +++ b/modules/scratchpad.py @@ -1,5 +1,4 @@ from system.notification.app import NotificationService -from tildagonos import tildagonos from system.scheduler import scheduler as sc from system.hexpansion.app import HexpansionManagerApp diff --git a/modules/scripts/mount_hexpansions.py b/modules/scripts/mount_hexpansions.py index 02788d8..d0c9a7d 100644 --- a/modules/scripts/mount_hexpansions.py +++ b/modules/scripts/mount_hexpansions.py @@ -1,5 +1,9 @@ from machine import I2C -from system.hexpansion.util import read_hexpansion_header, get_hexpansion_block_devices, detect_eeprom_addr +from system.hexpansion.util import ( + read_hexpansion_header, + get_hexpansion_block_devices, + detect_eeprom_addr, +) import vfs import os diff --git a/modules/scripts/prepare_eeprom.py b/modules/scripts/prepare_eeprom.py index 1f41c62..d81fc7f 100644 --- a/modules/scripts/prepare_eeprom.py +++ b/modules/scripts/prepare_eeprom.py @@ -27,7 +27,7 @@ vid=0xCA75, pid=0x1337, unique_id=0, - friendly_name="M24C16" + friendly_name="M24C16", ) # use this template for the ZD24C64A header_zd24c64 = HexpansionHeader( diff --git a/modules/system/hexpansion/app.py b/modules/system/hexpansion/app.py index d6c2848..1bcc383 100644 --- a/modules/system/hexpansion/app.py +++ b/modules/system/hexpansion/app.py @@ -196,7 +196,9 @@ async def handle_hexpansion_insertion(self, event): # Try creating block devices, one for the whole eeprom, # one for the partition with the filesystem on it try: - eep, partition = get_hexpansion_block_devices(i2c, header, addr, addr_len=addr_len) + eep, partition = get_hexpansion_block_devices( + i2c, header, addr, addr_len=addr_len + ) except RuntimeError as e: print(f"Could not initialize eeprom: {e}") eep = None diff --git a/modules/system/hexpansion/util.py b/modules/system/hexpansion/util.py index 6b16215..701c7ab 100644 --- a/modules/system/hexpansion/util.py +++ b/modules/system/hexpansion/util.py @@ -10,7 +10,16 @@ def detect_eeprom_addr(i2c): devices = i2c.scan() if 0x57 in devices and 0x50 not in devices: return (0x57, 2) - if 0x57 in devices and 0x56 in devices and 0x55 in devices and 0x54 in devices and 0x53 in devices and 0x52 in devices and 0x51 in devices and 0x50 in devices: + if ( + 0x57 in devices + and 0x56 in devices + and 0x55 in devices + and 0x54 in devices + and 0x53 in devices + and 0x52 in devices + and 0x51 in devices + and 0x50 in devices + ): return (0x50, 1) if 0x50 in devices: return (0x50, 2) @@ -40,7 +49,7 @@ def read_hexpansion_header( if set_read_addr: addr_bytes = [0] * addr_len i2c.writeto(eeprom_addr, bytes(addr_bytes)) - + header_bytes = i2c.readfrom(eeprom_addr, 32) try: @@ -58,14 +67,14 @@ def get_hexpansion_block_devices(i2c, header, addr=0x50, addr_len=2): else: chip_size = header.eeprom_total_size if header.eeprom_total_size >= 8192: - block_size = 9 # 512 byte blocks for big EEPROMs + block_size = 9 # 512 byte blocks for big EEPROMs else: - block_size = 6 # 64 byte blocks on small EEPROMs + block_size = 6 # 64 byte blocks on small EEPROMs eep = EEPROM( i2c=i2c, chip_size=chip_size, page_size=header.eeprom_page_size, - block_size=block_size + block_size=block_size, ) partition = EEPROMPartition( eep=eep, diff --git a/modules/system/patterndisplay/app.py b/modules/system/patterndisplay/app.py index c66131e..9699b56 100644 --- a/modules/system/patterndisplay/app.py +++ b/modules/system/patterndisplay/app.py @@ -2,7 +2,7 @@ from tildagonos import tildagonos import settings import asyncio -from system.patterndisplay.events import * +from system.patterndisplay.events import PatternEnable, PatternDisable, PatternReload from system.eventbus import eventbus @@ -23,7 +23,7 @@ def load_pattern(self): _pmodule = __import__(_patternpath, globals(), locals(), [_patternclass]) _pclass = getattr(_pmodule, _patternclass) self._p = _pclass() - except: + except ModuleNotFoundError: raise ImportError(f"Pattern {self.pattern} not found!") async def _enable(self, event: PatternEnable): @@ -40,13 +40,13 @@ async def background_task(self): brightness = settings.get("pattern_brightness", 0.1) next_frame = self._p.next() if self.enabled: - for l in range(12): + for led in range(12): if brightness < 1.0: - tildagonos.leds[l + 1] = tuple( - int(i * brightness) for i in next_frame[l] + tildagonos.leds[led + 1] = tuple( + int(i * brightness) for i in next_frame[led] ) else: - tildagonos.leds[l + 1] = next_frame[l] + tildagonos.leds[led + 1] = next_frame[led] tildagonos.leds.write() if not self._p.fps: break diff --git a/modules/system/power/events.py b/modules/system/power/events.py index 1ae54e8..b2a9596 100644 --- a/modules/system/power/events.py +++ b/modules/system/power/events.py @@ -1,29 +1,36 @@ - - - class PowerEvent: def __init__(self, EventName): self.__str__ = EventName + class RequestChargeEvent(PowerEvent): ... + class RequestBatFaultEvent(PowerEvent): ... + class RequestBoostFaultEvent(PowerEvent): ... + class RequestChargeFaultEvent(PowerEvent): ... + class RequestTimeoutFaultEvent(PowerEvent): ... + class RequestHostAttachEvent(PowerEvent): ... + class RequestHostDetachEvent(PowerEvent): ... + class RequestDeviceAttachEvent(PowerEvent): ... + class RequestDeviceDetachEvent(PowerEvent): ... + class RequestLanyardAttachEvent(PowerEvent): ... -class RequestLanyardDetachEvent(PowerEvent): ... +class RequestLanyardDetachEvent(PowerEvent): ...