Exemplo n.º 1
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik",
                            "home25.png")
     self.offIcon = pygame.image.load(os.path.join('icons', "tube70.png"))
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
Exemplo n.º 2
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "GRZALKA",
                            "settings25.png")
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
     self.temp_set = Register.WATER_TEMP_SET
     self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
     self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA
Exemplo n.º 3
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik",
                            "settings25.png")
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
     self.switch_on_icon = pygame.image.load(
         os.path.join("icons", "switchon50.png"))
     self.switch_off_icon = pygame.image.load(
         os.path.join("icons", "switchoff50.png"))
     self.reset()
Exemplo n.º 4
0
    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Ustawienia",
                               "settings25.png")

        self.tiles.append(
            MenuTile(Coordinate(15, 40, 180, 90), 'light32.png', "Lampa 1"))
        self.tiles.append(
            MenuTile(Coordinate(205, 40, 180, 90), 'pump32.png', "Dozownik"))
        self.tiles.append(
            MenuTile(Coordinate(15, 140, 180, 90), 'light32.png', "Lampa 2"))
        self.tiles.append(
            MenuTile(Coordinate(205, 140, 180, 90), 'heater32.png', "Grzalka"))

        self.tiles[self.selectedIndex].select()
Exemplo n.º 5
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik", "settings25.png")
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
     self.switch_on_icon = pygame.image.load(os.path.join("icons", "switchon50.png"))
     self.switch_off_icon = pygame.image.load(os.path.join("icons", "switchoff50.png"))
     self.reset()
Exemplo n.º 6
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "GRZALKA", "settings25.png")
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
     self.temp_set = Register.WATER_TEMP_SET
     self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
     self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA
Exemplo n.º 7
0
    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25),"Ustawienia","settings25.png")

        self.tiles.append(MenuTile(Coordinate(15, 40, 180, 90),'light32.png',"Lampa 1"))
        self.tiles.append(MenuTile(Coordinate(205, 40, 180, 90),'pump32.png',"Dozownik"))
        self.tiles.append(MenuTile(Coordinate(15, 140, 180, 90),'light32.png',"Lampa 2"))
        self.tiles.append(MenuTile(Coordinate(205, 140, 180, 90),'heater32.png',"Grzalka"))

        self.tiles[self.selectedIndex].select()
Exemplo n.º 8
0
class SettingsWindow():

    lcd = None

    barTile =None
    selectedIndex = 0
    tiles = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25),"Ustawienia","settings25.png")

        self.tiles.append(MenuTile(Coordinate(15, 40, 180, 90),'light32.png',"Lampa 1"))
        self.tiles.append(MenuTile(Coordinate(205, 40, 180, 90),'pump32.png',"Dozownik"))
        self.tiles.append(MenuTile(Coordinate(15, 140, 180, 90),'light32.png',"Lampa 2"))
        self.tiles.append(MenuTile(Coordinate(205, 140, 180, 90),'heater32.png',"Grzalka"))

        self.tiles[self.selectedIndex].select()

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            self.tiles[self.selectedIndex].select()
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex + 1) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_LEFT:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex - 1) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_UP:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex - 2) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_DOWN:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex + 2) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                DisplayRegister.set_light1_settings_window()
            if self.selectedIndex == 1:
                DisplayRegister.set_bottle_settings_window()
            if self.selectedIndex == 2:
                DisplayRegister.set_light2_settings_window()
            if self.selectedIndex == 3:
                DisplayRegister .set_heater_settings_window()

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        for tile in self.tiles:
            tile.draw()
Exemplo n.º 9
0
class SettingsWindow():

    lcd = None

    barTile = None
    selectedIndex = 0
    tiles = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Ustawienia",
                               "settings25.png")

        self.tiles.append(
            MenuTile(Coordinate(15, 40, 180, 90), 'light32.png', "Lampa 1"))
        self.tiles.append(
            MenuTile(Coordinate(205, 40, 180, 90), 'pump32.png', "Dozownik"))
        self.tiles.append(
            MenuTile(Coordinate(15, 140, 180, 90), 'light32.png', "Lampa 2"))
        self.tiles.append(
            MenuTile(Coordinate(205, 140, 180, 90), 'heater32.png', "Grzalka"))

        self.tiles[self.selectedIndex].select()

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            self.tiles[self.selectedIndex].select()
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex + 1) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_LEFT:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex - 1) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_UP:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex - 2) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_DOWN:
            self.tiles[self.selectedIndex].unselect()
            self.selectedIndex = (self.selectedIndex + 2) % 4
            self.tiles[self.selectedIndex].select()

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                DisplayRegister.set_light1_settings_window()
            if self.selectedIndex == 1:
                DisplayRegister.set_bottle_settings_window()
            if self.selectedIndex == 2:
                DisplayRegister.set_light2_settings_window()
            if self.selectedIndex == 3:
                DisplayRegister.set_heater_settings_window()

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        for tile in self.tiles:
            tile.draw()
Exemplo n.º 10
0
class BottleSettingWindow:

    lcd = None

    barTile =None
    selectedIndex = 0
    tiles = []
    bottles = None
    bottles_names = ['bottle1', 'bottle2', 'bottle3', 'bottle4']

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik", "settings25.png")
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
        self.switch_on_icon = pygame.image.load(os.path.join("icons", "switchon50.png"))
        self.switch_off_icon = pygame.image.load(os.path.join("icons", "switchoff50.png"))
        self.reset()

    def reset(self):
        self.bottles = dict(bottle1={
            'ON': Register.BOTTLE_MOD['bottle1']['ON'],
            'HOUR': Register.BOTTLE_MOD['bottle1']['HOUR'],
            'MIN': Register.BOTTLE_MOD['bottle1']['MIN'],
            'DOSE': Register.BOTTLE_MOD['bottle1']['DOSE'],
            'SEC_PER_ML': Register.BOTTLE_MOD['bottle1']['SEC_PER_ML']
        }, bottle2={
            'ON': Register.BOTTLE_MOD['bottle2']['ON'],
            'HOUR': Register.BOTTLE_MOD['bottle2']['HOUR'],
            'MIN': Register.BOTTLE_MOD['bottle2']['MIN'],
            'DOSE': Register.BOTTLE_MOD['bottle2']['DOSE'],
            'SEC_PER_ML': Register.BOTTLE_MOD['bottle2']['SEC_PER_ML']
        }, bottle3={
            'ON': Register.BOTTLE_MOD['bottle3']['ON'],
            'HOUR': Register.BOTTLE_MOD['bottle3']['HOUR'],
            'MIN': Register.BOTTLE_MOD['bottle3']['MIN'],
            'DOSE': Register.BOTTLE_MOD['bottle3']['DOSE'],
            'SEC_PER_ML': Register.BOTTLE_MOD['bottle3']['SEC_PER_ML']
        }, bottle4={
            'ON': Register.BOTTLE_MOD['bottle4']['ON'],
            'HOUR': Register.BOTTLE_MOD['bottle4']['HOUR'],
            'MIN': Register.BOTTLE_MOD['bottle4']['MIN'],
            'DOSE': Register.BOTTLE_MOD['bottle4']['DOSE'],
            'SEC_PER_ML': Register.BOTTLE_MOD['bottle4']['SEC_PER_ML']
        })

    def save(self):
        for bottle in self.bottles_names:
            Register.BOTTLE_MOD[bottle]['ON'] = self.bottles[bottle]['ON']
            Register.BOTTLE_MOD[bottle]['HOUR'] = self.bottles[bottle]['HOUR']
            Register.BOTTLE_MOD[bottle]['MIN'] = self.bottles[bottle]['MIN']
            Register.BOTTLE_MOD[bottle]['DOSE'] = self.bottles[bottle]['DOSE']
            Register.BOTTLE_MOD[bottle]['SEC_PER_ML'] = self.bottles[bottle]['SEC_PER_ML']
        settings.save_settings()

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_settingsWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 38

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 1) % 38

        if lirc_event == LircEvents.KEY_UP:
            self.selectedIndex = (self.selectedIndex - 9) % 38

        if lirc_event == LircEvents.KEY_DOWN:
            self.selectedIndex = (self.selectedIndex + 9) % 38

        if lirc_event == LircEvents.KEY_OK:

            if self.selectedIndex == 36:  #reset
                self.reset()
                return
            if self.selectedIndex == 37:  #zapisz
                self.save()
                self.reset()
                return

            i = 0
            if self.selectedIndex in range(0, 9):
                i = 0
            elif self.selectedIndex in range(9, 18):
                i = 1
            elif self.selectedIndex in range(18, 27):
                i = 2
            else:
                i = 3

            method = self.selectedIndex - (i * 9)

            if method == 0:
                self.bottles[self.bottles_names[i]]['ON'] = not self.bottles[self.bottles_names[i]]['ON']
            elif method == 1:
                self.bottles[self.bottles_names[i]]['DOSE'] += 1
            elif method == 2:
                self.bottles[self.bottles_names[i]]['DOSE'] -= 1
                if self.bottles[self.bottles_names[i]]['DOSE'] < 0:
                    self.bottles[self.bottles_names[i]]['DOSE'] = 0
            elif method == 3:
                self.bottles[self.bottles_names[i]]['SEC_PER_ML'] += 0.1
            elif method == 4:
                self.bottles[self.bottles_names[i]]['SEC_PER_ML'] -= 0.1
                if self.bottles[self.bottles_names[i]]['SEC_PER_ML'] < 0:
                    self.bottles[self.bottles_names[i]]['SEC_PER_ML'] = 0
            elif method == 5:
                self.bottles[self.bottles_names[i]]['HOUR'] = (self.bottles[self.bottles_names[i]]['HOUR'] + 1) % 24
            elif method == 6:
                self.bottles[self.bottles_names[i]]['HOUR'] = (self.bottles[self.bottles_names[i]]['HOUR'] - 1) % 24
            elif method == 7:
                self.bottles[self.bottles_names[i]]['MIN'] = (self.bottles[self.bottles_names[i]]['MIN'] + 1) % 60
            elif method == 8:
                self.bottles[self.bottles_names[i]]['MIN'] = (self.bottles[self.bottles_names[i]]['MIN'] - 1) % 60

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        i = 0

        for x in range(0, self.bottles_names.__len__()):
            bottle = self.bottles_names[x]

            main_cord = Coordinate(0, 35 + (35 * x), 400, 30)
            cord = Coordinate(*main_cord.get_slice(50))
            if self.bottles[bottle]['ON'] != Register.BOTTLE_MOD[bottle]['ON']:
                pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.size_full()))
            if self.bottles[bottle]['ON']:
                self.lcd.blit(self.switch_on_icon, cord.get_center(self.switch_on_icon.get_width(), self.switch_on_icon.get_height()))
            else:
                self.lcd.blit(self.switch_off_icon, cord.get_center(self.switch_off_icon.get_width(), self.switch_off_icon.get_height()))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(55))
            text_surface = Fonts.font_40.render(Register.BOTTLE_MOD[bottle]['NAME'],
                                                True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))


            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("D", True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['DOSE'] != Register.BOTTLE_MOD[bottle]['DOSE']:
                pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(str(self.bottles[bottle]['DOSE']), True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))


            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)
            i += 1
            self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(35))
            text_surface = Fonts.font_20.render("m/s", True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(30))
            if self.bottles[bottle]['SEC_PER_ML'] != Register.BOTTLE_MOD[bottle]['SEC_PER_ML']:
                pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(str(self.bottles[bottle]['SEC_PER_ML']), True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)
            i += 1
            self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)
            i += 1


            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("H", True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['HOUR'] != Register.BOTTLE_MOD[bottle]['HOUR']:
                pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(str(self.bottles[bottle]['HOUR']), True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)
            i += 1
            self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)
            i += 1


            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("M", True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['MIN'] != Register.BOTTLE_MOD[bottle]['MIN']:
                pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(str(self.bottles[bottle]['MIN']), True, Colors.WHITE)
            self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)
            i += 1
            self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)
            i += 1

        main_cord = Coordinate(0, 190, 400, 40)
        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("RESET", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 36:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("ZAPISZ", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 37:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
Exemplo n.º 11
0
class BottleWindow():
    lcd = None

    barTile = None
    selectedIndex = 0
    selected_bottle = 0
    bottles_on = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik",
                               "home25.png")
        self.offIcon = pygame.image.load(os.path.join('icons', "tube70.png"))
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 1) % 6
        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 6

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                self.selected_bottle = (self.selected_bottle - 1) % len(
                    self.bottles_on)
            if self.selectedIndex == 1:
                self.selected_bottle = (self.selected_bottle + 1) % len(
                    self.bottles_on)
            if self.selectedIndex == 2:
                BottleLogic.up_dose(1)
            if self.selectedIndex == 3:
                BottleLogic.down_dose(1)
            if self.selectedIndex == 4:
                BottleLogic.set_bottle(self.bottles_on[self.selected_bottle])
            if self.selectedIndex == 5:
                BottleLogic.refill_bottle(
                    self.bottles_on[self.selected_bottle])

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        self.bottles_on = []

        start = 0
        for x in ('bottle1', 'bottle2', 'bottle3', 'bottle4', 'bottle5',
                  'bottle6', 'bottle7', 'bottle8'):

            if Register.BOTTLE_MOD[x]['ON']:
                self.bottles_on.append(x)

                cord = Coordinate(10 + start, 40, 70, 120)

                height = int(Register.BOTTLE_MOD[x]['PERCENT'] / 1.85)
                height += 8

                pygame.draw.rect(
                    self.lcd, Colors.BLUE,
                    pygame.Rect(cord.locate(28, 65), (15, -height)))

                self.lcd.blit(self.offIcon, cord.locate(0, 0))
                text_surface = Fonts.font_30.render(
                    Register.BOTTLE_MOD[x]['NAME'], True, Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(27, 75))
                text_surface = Fonts.font_20.render(
                    str(Register.BOTTLE_MOD[x]['STATE']), True, Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(25, 95))

                text_surface = Fonts.font_20.render(
                    "(" + str(Register.BOTTLE_MOD[x]["PERCENT"]) + "%)", True,
                    Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(15, 110))
            start += 45

        # przyciski

        main_cord = Coordinate(0, 160, 400, 80)

        cord = Coordinate(*main_cord.get_slice(50))
        text_surface = Fonts.font_40.render(
            Register.BOTTLE_MOD[self.bottles_on[self.selected_bottle]]['NAME'],
            True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(20))
        self.lcd.blit(
            self.upIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() + 20))
        if self.selectedIndex == 0:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)

        self.lcd.blit(
            self.downIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() - 20))
        if self.selectedIndex == 1:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)

        cord = Coordinate(*main_cord.get_slice(40))
        text_surface = Fonts.font_40.render(str(Register.BOTTLE_MANUAL_DOSE),
                                            True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        text_surface = Fonts.font_30.render("ml", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(20))
        self.lcd.blit(
            self.upIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() + 20))
        if self.selectedIndex == 2:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)

        self.lcd.blit(
            self.downIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() - 20))
        if self.selectedIndex == 3:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)

        cord = Coordinate(*main_cord.get_slice(120))
        cord = Coordinate(*cord.get_center_surface(100, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_40.render("START", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 4:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(120))
        cord = Coordinate(*cord.get_center_surface(100, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_40.render("UZUP", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 5:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
Exemplo n.º 12
0
class BottleSettingWindow:

    lcd = None

    barTile = None
    selectedIndex = 0
    tiles = []
    bottles = None
    bottles_names = ['bottle1', 'bottle2', 'bottle3', 'bottle4']

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik",
                               "settings25.png")
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
        self.switch_on_icon = pygame.image.load(
            os.path.join("icons", "switchon50.png"))
        self.switch_off_icon = pygame.image.load(
            os.path.join("icons", "switchoff50.png"))
        self.reset()

    def reset(self):
        self.bottles = dict(bottle1={
            'ON':
            Register.BOTTLE_MOD['bottle1']['ON'],
            'HOUR':
            Register.BOTTLE_MOD['bottle1']['HOUR'],
            'MIN':
            Register.BOTTLE_MOD['bottle1']['MIN'],
            'DOSE':
            Register.BOTTLE_MOD['bottle1']['DOSE'],
            'SEC_PER_ML':
            Register.BOTTLE_MOD['bottle1']['SEC_PER_ML']
        },
                            bottle2={
                                'ON':
                                Register.BOTTLE_MOD['bottle2']['ON'],
                                'HOUR':
                                Register.BOTTLE_MOD['bottle2']['HOUR'],
                                'MIN':
                                Register.BOTTLE_MOD['bottle2']['MIN'],
                                'DOSE':
                                Register.BOTTLE_MOD['bottle2']['DOSE'],
                                'SEC_PER_ML':
                                Register.BOTTLE_MOD['bottle2']['SEC_PER_ML']
                            },
                            bottle3={
                                'ON':
                                Register.BOTTLE_MOD['bottle3']['ON'],
                                'HOUR':
                                Register.BOTTLE_MOD['bottle3']['HOUR'],
                                'MIN':
                                Register.BOTTLE_MOD['bottle3']['MIN'],
                                'DOSE':
                                Register.BOTTLE_MOD['bottle3']['DOSE'],
                                'SEC_PER_ML':
                                Register.BOTTLE_MOD['bottle3']['SEC_PER_ML']
                            },
                            bottle4={
                                'ON':
                                Register.BOTTLE_MOD['bottle4']['ON'],
                                'HOUR':
                                Register.BOTTLE_MOD['bottle4']['HOUR'],
                                'MIN':
                                Register.BOTTLE_MOD['bottle4']['MIN'],
                                'DOSE':
                                Register.BOTTLE_MOD['bottle4']['DOSE'],
                                'SEC_PER_ML':
                                Register.BOTTLE_MOD['bottle4']['SEC_PER_ML']
                            })

    def save(self):
        for bottle in self.bottles_names:
            Register.BOTTLE_MOD[bottle]['ON'] = self.bottles[bottle]['ON']
            Register.BOTTLE_MOD[bottle]['HOUR'] = self.bottles[bottle]['HOUR']
            Register.BOTTLE_MOD[bottle]['MIN'] = self.bottles[bottle]['MIN']
            Register.BOTTLE_MOD[bottle]['DOSE'] = self.bottles[bottle]['DOSE']
            Register.BOTTLE_MOD[bottle]['SEC_PER_ML'] = self.bottles[bottle][
                'SEC_PER_ML']
        settings.save_settings()

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_settingsWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 38

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 1) % 38

        if lirc_event == LircEvents.KEY_UP:
            self.selectedIndex = (self.selectedIndex - 9) % 38

        if lirc_event == LircEvents.KEY_DOWN:
            self.selectedIndex = (self.selectedIndex + 9) % 38

        if lirc_event == LircEvents.KEY_OK:

            if self.selectedIndex == 36:  #reset
                self.reset()
                return
            if self.selectedIndex == 37:  #zapisz
                self.save()
                self.reset()
                return

            i = 0
            if self.selectedIndex in range(0, 9):
                i = 0
            elif self.selectedIndex in range(9, 18):
                i = 1
            elif self.selectedIndex in range(18, 27):
                i = 2
            else:
                i = 3

            method = self.selectedIndex - (i * 9)

            if method == 0:
                self.bottles[self.bottles_names[i]]['ON'] = not self.bottles[
                    self.bottles_names[i]]['ON']
            elif method == 1:
                self.bottles[self.bottles_names[i]]['DOSE'] += 1
            elif method == 2:
                self.bottles[self.bottles_names[i]]['DOSE'] -= 1
                if self.bottles[self.bottles_names[i]]['DOSE'] < 0:
                    self.bottles[self.bottles_names[i]]['DOSE'] = 0
            elif method == 3:
                self.bottles[self.bottles_names[i]]['SEC_PER_ML'] += 0.1
            elif method == 4:
                self.bottles[self.bottles_names[i]]['SEC_PER_ML'] -= 0.1
                if self.bottles[self.bottles_names[i]]['SEC_PER_ML'] < 0:
                    self.bottles[self.bottles_names[i]]['SEC_PER_ML'] = 0
            elif method == 5:
                self.bottles[self.bottles_names[i]]['HOUR'] = (
                    self.bottles[self.bottles_names[i]]['HOUR'] + 1) % 24
            elif method == 6:
                self.bottles[self.bottles_names[i]]['HOUR'] = (
                    self.bottles[self.bottles_names[i]]['HOUR'] - 1) % 24
            elif method == 7:
                self.bottles[self.bottles_names[i]]['MIN'] = (
                    self.bottles[self.bottles_names[i]]['MIN'] + 1) % 60
            elif method == 8:
                self.bottles[self.bottles_names[i]]['MIN'] = (
                    self.bottles[self.bottles_names[i]]['MIN'] - 1) % 60

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        i = 0

        for x in range(0, self.bottles_names.__len__()):
            bottle = self.bottles_names[x]

            main_cord = Coordinate(0, 35 + (35 * x), 400, 30)
            cord = Coordinate(*main_cord.get_slice(50))
            if self.bottles[bottle]['ON'] != Register.BOTTLE_MOD[bottle]['ON']:
                pygame.draw.rect(self.lcd, Colors.RED,
                                 pygame.Rect(cord.size_full()))
            if self.bottles[bottle]['ON']:
                self.lcd.blit(
                    self.switch_on_icon,
                    cord.get_center(self.switch_on_icon.get_width(),
                                    self.switch_on_icon.get_height()))
            else:
                self.lcd.blit(
                    self.switch_off_icon,
                    cord.get_center(self.switch_off_icon.get_width(),
                                    self.switch_off_icon.get_height()))
            if self.selectedIndex == i:
                pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(55))
            text_surface = Fonts.font_40.render(
                Register.BOTTLE_MOD[bottle]['NAME'], True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("D", True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['DOSE'] != Register.BOTTLE_MOD[bottle][
                    'DOSE']:
                pygame.draw.rect(self.lcd, Colors.RED,
                                 pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(
                str(self.bottles[bottle]['DOSE']), True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(
                self.upIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() + 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)
            i += 1
            self.lcd.blit(
                self.downIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() - 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(35))
            text_surface = Fonts.font_20.render("m/s", True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(30))
            if self.bottles[bottle]['SEC_PER_ML'] != Register.BOTTLE_MOD[
                    bottle]['SEC_PER_ML']:
                pygame.draw.rect(self.lcd, Colors.RED,
                                 pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(
                str(self.bottles[bottle]['SEC_PER_ML']), True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(
                self.upIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() + 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)
            i += 1
            self.lcd.blit(
                self.downIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() - 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("H", True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['HOUR'] != Register.BOTTLE_MOD[bottle][
                    'HOUR']:
                pygame.draw.rect(self.lcd, Colors.RED,
                                 pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(
                str(self.bottles[bottle]['HOUR']), True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(
                self.upIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() + 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)
            i += 1
            self.lcd.blit(
                self.downIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() - 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)
            i += 1

            cord = Coordinate(*main_cord.get_slice(25))
            text_surface = Fonts.font_30.render("M", True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(25))
            if self.bottles[bottle]['MIN'] != Register.BOTTLE_MOD[bottle][
                    'MIN']:
                pygame.draw.rect(self.lcd, Colors.RED,
                                 pygame.Rect(cord.locate(0, 0), cord.size()))
            text_surface = Fonts.font_30.render(
                str(self.bottles[bottle]['MIN']), True, Colors.WHITE)
            self.lcd.blit(
                text_surface,
                cord.get_center(text_surface.get_width(),
                                text_surface.get_height()))

            cord = Coordinate(*main_cord.get_slice(20))
            self.lcd.blit(
                self.upIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() + 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 + 26), (20, 18)), 2)
            i += 1
            self.lcd.blit(
                self.downIcon,
                cord.get_center(self.upIcon.get_width(),
                                self.upIcon.get_height() - 20))
            if self.selectedIndex == i:
                pygame.draw.rect(
                    self.lcd, Colors.GRAY,
                    pygame.Rect(cord.get_center(20, 18 - 26), (20, 18)), 2)
            i += 1

        main_cord = Coordinate(0, 190, 400, 40)
        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("RESET", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 36:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("ZAPISZ", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 37:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
Exemplo n.º 13
0
class HeaterSettingWindow():

    lcd = None

    barTile =None
    selectedIndex = 0
    tiles = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "GRZALKA", "settings25.png")
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
        self.temp_set = Register.WATER_TEMP_SET
        self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
        self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_settingsWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 8

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 2) % 8

        if lirc_event == LircEvents.KEY_UP:
            self.selectedIndex = (self.selectedIndex - 2) % 8

        if lirc_event == LircEvents.KEY_DOWN:
            self.selectedIndex = (self.selectedIndex + 2) % 8

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                self.temp_set = (self.temp_set + 0.1) % 30
            if self.selectedIndex == 1:
                self.temp_set = (self.temp_set - 0.1) % 30
            if self.selectedIndex == 2:
                self.temp_alert_delta = (self.temp_alert_delta + 0.1) % 20
            if self.selectedIndex == 3:
                self.temp_alert_delta = (self.temp_alert_delta - 0.1) % 20
            if self.selectedIndex == 4:
                self.temp_on_off_delta = (self.temp_on_off_delta + 0.1) % 3
            if self.selectedIndex == 5:
                self.temp_on_off_delta = (self.temp_on_off_delta - 0.1) % 3
            if self.selectedIndex == 6:  #reset
                self.reset()
            if self.selectedIndex == 7:  #zapisz
                self.save()
                self.reset()

    def reset(self):
        self.temp_set = Register.WATER_TEMP_SET
        self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
        self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA

    def save(self):
        Register.WATER_TEMP_SET = self.temp_set
        Register.WATER_TEMP_ALERT_DELTA = self.temp_alert_delta
        Register.WATER_TEMP_ONOFF_DELTA = self.temp_on_off_delta
        settings.save_settings()

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        main_cord = Coordinate(0, 50, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("TEMP WODY",
                                            True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_SET != self.temp_set:
            pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_set), True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
        if self.selectedIndex == 0:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18+26), (30, 18)), 2)
        self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
        if self.selectedIndex == 1:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18-26), (30, 18)), 2)

        main_cord = Coordinate(0, 90, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("TEMP ALERT DELTA",
                                            True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_ALERT_DELTA != self.temp_alert_delta:
            pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_alert_delta), True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
        if self.selectedIndex == 2:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18+26), (30, 18)), 2)
        self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
        if self.selectedIndex == 3:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18-26), (30, 18)), 2)

        main_cord = Coordinate(0, 130, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("ON/OFF DELTA",
                                            True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_ONOFF_DELTA != self.temp_on_off_delta:
            pygame.draw.rect(self.lcd, Colors.RED, pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_on_off_delta), True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
        if self.selectedIndex == 4:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18+26), (30, 18)), 2)
        self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
        if self.selectedIndex == 5:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(30, 18-26), (30, 18)), 2)

        main_cord = Coordinate(0, 190, 400, 40)
        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("RESET", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 6:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("ZAPISZ", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 7:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
Exemplo n.º 14
0
class HeaterSettingWindow():

    lcd = None

    barTile = None
    selectedIndex = 0
    tiles = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "GRZALKA",
                               "settings25.png")
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
        self.temp_set = Register.WATER_TEMP_SET
        self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
        self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_settingsWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 8

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 2) % 8

        if lirc_event == LircEvents.KEY_UP:
            self.selectedIndex = (self.selectedIndex - 2) % 8

        if lirc_event == LircEvents.KEY_DOWN:
            self.selectedIndex = (self.selectedIndex + 2) % 8

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                self.temp_set = (self.temp_set + 0.1) % 30
            if self.selectedIndex == 1:
                self.temp_set = (self.temp_set - 0.1) % 30
            if self.selectedIndex == 2:
                self.temp_alert_delta = (self.temp_alert_delta + 0.1) % 20
            if self.selectedIndex == 3:
                self.temp_alert_delta = (self.temp_alert_delta - 0.1) % 20
            if self.selectedIndex == 4:
                self.temp_on_off_delta = (self.temp_on_off_delta + 0.1) % 3
            if self.selectedIndex == 5:
                self.temp_on_off_delta = (self.temp_on_off_delta - 0.1) % 3
            if self.selectedIndex == 6:  #reset
                self.reset()
            if self.selectedIndex == 7:  #zapisz
                self.save()
                self.reset()

    def reset(self):
        self.temp_set = Register.WATER_TEMP_SET
        self.temp_alert_delta = Register.WATER_TEMP_ALERT_DELTA
        self.temp_on_off_delta = Register.WATER_TEMP_ONOFF_DELTA

    def save(self):
        Register.WATER_TEMP_SET = self.temp_set
        Register.WATER_TEMP_ALERT_DELTA = self.temp_alert_delta
        Register.WATER_TEMP_ONOFF_DELTA = self.temp_on_off_delta
        settings.save_settings()

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        main_cord = Coordinate(0, 50, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("TEMP WODY", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_SET != self.temp_set:
            pygame.draw.rect(self.lcd, Colors.RED,
                             pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_set), True,
                                            Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(
            self.upIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() + 20))
        if self.selectedIndex == 0:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 + 26), (30, 18)), 2)
        self.lcd.blit(
            self.downIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() - 20))
        if self.selectedIndex == 1:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 - 26), (30, 18)), 2)

        main_cord = Coordinate(0, 90, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("TEMP ALERT DELTA", True,
                                            Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_ALERT_DELTA != self.temp_alert_delta:
            pygame.draw.rect(self.lcd, Colors.RED,
                             pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_alert_delta), True,
                                            Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(
            self.upIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() + 20))
        if self.selectedIndex == 2:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 + 26), (30, 18)), 2)
        self.lcd.blit(
            self.downIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() - 20))
        if self.selectedIndex == 3:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 - 26), (30, 18)), 2)

        main_cord = Coordinate(0, 130, 400, 30)

        cord = Coordinate(*main_cord.get_slice(300))
        text_surface = Fonts.font_40.render("ON/OFF DELTA", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(60))
        if Register.WATER_TEMP_ONOFF_DELTA != self.temp_on_off_delta:
            pygame.draw.rect(self.lcd, Colors.RED,
                             pygame.Rect(cord.locate(0, 0), cord.size()))
        text_surface = Fonts.font_40.render(str(self.temp_on_off_delta), True,
                                            Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        self.lcd.blit(
            self.upIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() + 20))
        if self.selectedIndex == 4:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 + 26), (30, 18)), 2)
        self.lcd.blit(
            self.downIcon,
            cord.get_center(self.upIcon.get_width(),
                            self.upIcon.get_height() - 20))
        if self.selectedIndex == 5:
            pygame.draw.rect(
                self.lcd, Colors.GRAY,
                pygame.Rect(cord.get_center(30, 18 - 26), (30, 18)), 2)

        main_cord = Coordinate(0, 190, 400, 40)
        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("RESET", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 6:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(200))
        cord = Coordinate(*cord.get_center_surface(150, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_30.render("ZAPISZ", True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
        if self.selectedIndex == 7:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)
Exemplo n.º 15
0
 def __init__(self):
     self.lcd = Register.LCD
     self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik", "home25.png")
     self.offIcon = pygame.image.load(os.path.join('icons', "tube70.png"))
     self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
     self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))
Exemplo n.º 16
0
class BottleWindow():
    lcd = None

    barTile = None
    selectedIndex = 0
    selected_bottle = 0
    bottles_on = []

    def __init__(self):
        self.lcd = Register.LCD
        self.barTile = BarTile(Coordinate(0, 0, 400, 25), "Dozownik", "home25.png")
        self.offIcon = pygame.image.load(os.path.join('icons', "tube70.png"))
        self.upIcon = pygame.image.load(os.path.join('icons', "up30.png"))
        self.downIcon = pygame.image.load(os.path.join('icons', "down30.png"))

    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_LEFT:
            self.selectedIndex = (self.selectedIndex - 1) % 6
        if lirc_event == LircEvents.KEY_RIGHT:
            self.selectedIndex = (self.selectedIndex + 1) % 6

        if lirc_event == LircEvents.KEY_OK:
            if self.selectedIndex == 0:
                self.selected_bottle = (self.selected_bottle - 1) % len(self.bottles_on)
            if self.selectedIndex == 1:
                self.selected_bottle = (self.selected_bottle + 1) % len(self.bottles_on)
            if self.selectedIndex == 2:
                BottleLogic.up_dose(1)
            if self.selectedIndex == 3:
                BottleLogic.down_dose(1)
            if self.selectedIndex == 4:
                BottleLogic.set_bottle(self.bottles_on[self.selected_bottle])
            if self.selectedIndex == 5:
                BottleLogic.refill_bottle(self.bottles_on[self.selected_bottle])

    def draw(self):

        self.lcd.fill(Colors.BLACK)
        self.barTile.draw_tile()

        self.bottles_on = []

        start = 0
        for x in ('bottle1', 'bottle2', 'bottle3', 'bottle4', 'bottle5', 'bottle6', 'bottle7', 'bottle8'):

            if Register.BOTTLE_MOD[x]['ON']:
                self.bottles_on.append(x)

                cord = Coordinate(10 + start, 40, 70, 120)

                height = int(Register.BOTTLE_MOD[x]['PERCENT'] / 1.85)
                height += 8

                pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.locate(28, 65), (15, -height)))

                self.lcd.blit(self.offIcon, cord.locate(0, 0))
                text_surface = Fonts.font_30.render(Register.BOTTLE_MOD[x]['NAME'], True, Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(27, 75))
                text_surface = Fonts.font_20.render(str(Register.BOTTLE_MOD[x]['STATE']), True, Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(25, 95))

                text_surface = Fonts.font_20.render("(" + str(Register.BOTTLE_MOD[x]["PERCENT"]) + "%)",
                                                    True, Colors.WHITE)
                self.lcd.blit(text_surface, cord.locate(15, 110))
            start += 45

        # przyciski

        main_cord = Coordinate(0, 160, 400, 80)

        cord = Coordinate(*main_cord.get_slice(50))
        text_surface = Fonts.font_40.render(Register.BOTTLE_MOD[self.bottles_on[self.selected_bottle]]['NAME'],
                                                True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(20))
        self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
        if self.selectedIndex == 0:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)

        self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
        if self.selectedIndex == 1:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)


        cord = Coordinate(*main_cord.get_slice(40))
        text_surface = Fonts.font_40.render(str(Register.BOTTLE_MANUAL_DOSE), True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(30))
        text_surface = Fonts.font_30.render("ml", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))

        cord = Coordinate(*main_cord.get_slice(20))
        self.lcd.blit(self.upIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()+20))
        if self.selectedIndex == 2:
                pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18+26), (20, 18)), 2)

        self.lcd.blit(self.downIcon, cord.get_center(self.upIcon.get_width(), self.upIcon.get_height()-20))
        if self.selectedIndex == 3:
            pygame.draw.rect(self.lcd, Colors.GRAY, pygame.Rect(cord.get_center(20, 18-26), (20, 18)), 2)


        cord = Coordinate(*main_cord.get_slice(120))
        cord = Coordinate(*cord.get_center_surface(100, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_40.render("START", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 4:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)

        cord = Coordinate(*main_cord.get_slice(120))
        cord = Coordinate(*cord.get_center_surface(100, 40))
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(cord.size_full()))
        text_surface = Fonts.font_40.render("UZUP", True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
        if self.selectedIndex == 5:
            pygame.draw.rect(self.lcd, Colors.GRAY, cord.size_full(), 2)