Example #1
0
class App:
    def __init__(self):
        print("[APP ] Initialized\n")
        self.d = Display()
        self.ds = DataStore()
        self.sett = AppSettings()
        self.keypad = Keypad()
        self.sensors = Sensors()
        self.lightc = LightController(self.ds, self.sett)
        self.condc = CondController(self.ds, self.sett)
        self.fanc = FanController(self.ds, self.sett)
        self.evc = EVController(self.ds, self.sett)
        self.screenMngr = ScreenManager(self.d, self.ds, self.sett,
                                        self.keypad)
        self.screenMngr.update()

        self.processStart = 0
        self.screensStart = 0

    def process(self):
        delta = time.time() - self.processStart
        if (delta > 1.0):
            self.ds.add_humidity(self.sensors.humidity())
            self.ds.add_temperature(self.sensors.temperature())
            self.ds.add_lux(self.sensors.lux())

            if (self.lightc != None):
                self.lightc.process()
            if (self.condc != None):
                self.condc.process()
            if (self.fanc != None):
                self.fanc.process()
            if (self.evc != None):
                self.evc.process()

            self.processStart = time.time()

    def handleScreens(self):
        delta = time.time() - self.screensStart
        if (delta > 1.0):
            self.screenMngr.update()
            self.screensStart = time.time()

        self.screenMngr.process()