コード例 #1
0
ファイル: MovingAgent.py プロジェクト: emabe390/TradingGame
 def __init__(self,
              name=None,
              suffix=None,
              prefix=None,
              ship=None,
              image=None):
     Agent.__init__(self, name=name, suffix=suffix, prefix=prefix)
     GraphicalEntity.__init__(self)
     self.pos = Coordinate()
     self.ship = ship
     self.target = self.pos
     self.image = image
コード例 #2
0
ファイル: MenuTile.py プロジェクト: Mateo89/AquaPC-BACKEND
    def draw(self):
        self.coordinate.reset_slice()

        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(self.coordinate.size_full()))
        if self.selected:
            pygame.draw.rect(self.lcd, Colors.WHITE,  pygame.Rect(self.coordinate.size_full()), 5)

        cord = Coordinate(*self.coordinate.get_slice(40))
        self.lcd.blit(self.icon, cord.get_center(self.icon.get_width(), self.icon.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(100))
        text_surface = Fonts.font_30.render(self.name, True, Colors.WHITE)
        self.lcd.blit(text_surface,  cord.locate_vertical_center(0, text_surface.get_height()))
コード例 #3
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()
コード例 #4
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"))
コード例 #5
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
コード例 #6
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()
コード例 #7
0
def reverse_transform(x, y, coordinate=True):
    w_scale = width / current_scroll()
    h_scale = height / current_scroll()
    w_half = width / 2
    h_half = height / 2
    wcx = (x - w_half) / w_scale - w_half + middle_x
    wcy = (y - h_half) / h_scale - h_half + middle_y
    if coordinate:
        return Coordinate(wcx, wcy)
    else:
        return wcx, wcy
コード例 #8
0
ファイル: Game.py プロジェクト: emabe390/TradingGame
 def __init__(self):
     resources = ResourceLoader.load_resources()
     self.locations = {}
     self.location_ids = []
     n = 5
     for x in range(n):
         for i in range(n):
             #if random.randint(0,101) > 20:
             #    continue
             location = Location(name="", image=resources["station"], position=Coordinate())
             self.locations[location.id] = location
             self.location_ids.append(location.id)
     self.agents = {}
     for _ in range(150):
         agent = TradingAgent(image=resources["ship"])
         self.agents[agent.id] = agent
コード例 #9
0
ファイル: BarTile.py プロジェクト: Mateo89/AquaPC-BACKEND
    def draw_tile(self):
        self.coordinate.reset_slice()
        pygame.draw.rect(self.lcd, Colors.BLUE,
                         pygame.Rect(self.coordinate.size_full()))

        cord = Coordinate(*self.coordinate.get_slice(30))
        self.lcd.blit(
            self.icon,
            cord.get_center(self.icon.get_width(), self.icon.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(300))
        text_surface = Fonts.font_30.render(self.name, True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.locate_vertical_center(10, text_surface.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(50))
        text_surface = Fonts.font_30.render(
            datetime.now().strftime('%H:%M:%S'), True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.get_center(text_surface.get_width(),
                            text_surface.get_height()))
コード例 #10
0
ファイル: BarTile.py プロジェクト: Mateo89/AquaPC-BACKEND
    def draw_tile(self):
        self.coordinate.reset_slice()
        pygame.draw.rect(self.lcd, Colors.BLUE, pygame.Rect(self.coordinate.size_full()))

        cord = Coordinate(*self.coordinate.get_slice(30))
        self.lcd.blit(self.icon, cord.get_center(self.icon.get_width(), self.icon.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(300))
        text_surface = Fonts.font_30.render(self.name, True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.locate_vertical_center(10, text_surface.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(50))
        text_surface = Fonts.font_30.render(datetime.now().strftime('%H:%M:%S'), True, Colors.WHITE)
        self.lcd.blit(text_surface, cord.get_center(text_surface.get_width(), text_surface.get_height()))
コード例 #11
0
ファイル: MovingAgent.py プロジェクト: emabe390/TradingGame
class MovingAgent(Agent, GraphicalEntity):
    def __init__(self,
                 name=None,
                 suffix=None,
                 prefix=None,
                 ship=None,
                 image=None):
        Agent.__init__(self, name=name, suffix=suffix, prefix=prefix)
        GraphicalEntity.__init__(self)
        self.pos = Coordinate()
        self.ship = ship
        self.target = self.pos
        self.image = image

    def set_target(self, target):
        self.target = target
        self.alive = True

    def step(self, dt, batch):
        shouldUpdate = Agent.step(self, dt, batch)
        rotation = None
        if shouldUpdate:
            if self.target is not None:
                rotation = self._move(self.target, dt)
        #self.draw_text(batch, self.id, self.pos)
        self.draw_sprite(batch, self.image, self.pos, rotation)
        return shouldUpdate

    def _move(self, target, dt):
        if self.ship is not None:
            moveCoord = self.pos.deltaCoord(self.target,
                                            self.ship.velocity * dt * 120)
            if not moveCoord.isZero():
                self.pos = self.pos + moveCoord
                return math.atan2(moveCoord.y, -moveCoord.x) * 180 / math.pi
            else:
                #Enter location
                self.alive = False
コード例 #12
0
ファイル: MenuTile.py プロジェクト: Mateo89/AquaPC-BACKEND
    def draw(self):
        self.coordinate.reset_slice()

        pygame.draw.rect(self.lcd, Colors.BLUE,
                         pygame.Rect(self.coordinate.size_full()))
        if self.selected:
            pygame.draw.rect(self.lcd, Colors.WHITE,
                             pygame.Rect(self.coordinate.size_full()), 5)

        cord = Coordinate(*self.coordinate.get_slice(40))
        self.lcd.blit(
            self.icon,
            cord.get_center(self.icon.get_width(), self.icon.get_height()))

        cord = Coordinate(*self.coordinate.get_slice(100))
        text_surface = Fonts.font_30.render(self.name, True, Colors.WHITE)
        self.lcd.blit(
            text_surface,
            cord.locate_vertical_center(0, text_surface.get_height()))
コード例 #13
0
    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)
コード例 #14
0
    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)
コード例 #15
0
    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)
コード例 #16
0
    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)
コード例 #17
0
    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)
コード例 #18
0
    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)