22 lines
816 B
Python
22 lines
816 B
Python
class ScreenManager:
|
|
VALID_SCREENS = ("dashboard", "battery", "temps", "power", "system")
|
|
|
|
def __init__(self):
|
|
self.current_screen = "dashboard"
|
|
|
|
def go_to(self, screen_name):
|
|
if screen_name not in self.VALID_SCREENS:
|
|
raise ValueError(f"Invalid screen: {screen_name}")
|
|
|
|
self.current_screen = screen_name
|
|
|
|
def next_screen(self):
|
|
current_index = self.VALID_SCREENS.index(self.current_screen)
|
|
next_index = (current_index + 1) % len(self.VALID_SCREENS)
|
|
self.current_screen = self.VALID_SCREENS[next_index]
|
|
|
|
def previous_screen(self):
|
|
current_index = self.VALID_SCREENS.index(self.current_screen)
|
|
previous_index = (current_index - 1) % len(self.VALID_SCREENS)
|
|
self.current_screen = self.VALID_SCREENS[previous_index]
|