コード例 #1
0
class CentralManager:
    def __init__(self, chat_id, token):
        token = '?'
        telebot_sender = TelebotSender(token, chat_id)

        self.commands = [
            SendScreenCommand(1, 1, telebot_sender),
            SendTextCommand(1, 2, '1', telebot_sender),
            SendTextCommand(1, 3, '2', telebot_sender),
            SendTextCommand(1, 4, '3', telebot_sender),
            SendTextCommand(1, 5, '4', telebot_sender),
            SendTextCommand(1, 6, '5', telebot_sender),
            SendTextCommand(1, 7, '6', telebot_sender),
            SendTextCommand(1, 12, 'Хочу', telebot_sender),
            SendTextCommand(1, 13, 'Решаю', telebot_sender),
            SendTextCommand(1, 14, 'Уноси', telebot_sender),
            SendTextCommand(2, 2, 'Да', telebot_sender),
            SendTextCommand(2, 3, 'Нет', telebot_sender),
        ]
        self.command_index = 0
        self.keyboard_grid = ChromaGrid('Keyboard')
        self.show_signs = True
        self.chroma_app = get_chroma_app()
        self.blink()

    def switch_command_up(self):
        self.command_index += 1

        if self.command_index >= len(self.commands):
            self.command_index = 0

        self.update_light()

    def execute_command(self):
        self.commands[self.command_index].execute()
        self.blink()

    def update_light(self):
        if not self.show_signs:
            self.chroma_app.Keyboard.setStatic(Colors.YELLOW)
        else:
            command = self.commands[self.command_index]
            self.keyboard_grid.set(hexcolor="#FFFF00")
            self.keyboard_grid[command.x][command.y].set(red=0, green=255, blue=0)
            self.chroma_app.Keyboard.setCustomGrid(self.keyboard_grid)
            self.chroma_app.Keyboard.applyGrid()

    def blink(self):
        self.chroma_app.Keyboard.setNone()
        sleep(0.3)
        self.chroma_app.Keyboard.setStatic(Colors.YELLOW)
        sleep(0.3)
        self.chroma_app.Keyboard.setNone()
        sleep(0.3)
        self.chroma_app.Keyboard.setStatic(Colors.YELLOW)
        self.update_light()
コード例 #2
0
print(App.Keyboard.setStatic(Colors.GREEN))
print(App.Mousepad.setStatic(Colors.BLUE))
print(App.Mouse.setStatic(Colors.YELLOW))

sleep(2)
# Oldschool
# KeyboardGrid = [[ChromaColor(red=255, blue=0, green=0) for x in range(22)] for y in range(6)]
# MouseGrid = [[ChromaColor(red=255, blue=0, green=0) for x in range(7)] for y in range(9)]
# MousepadGrid = [ChromaColor(red=255, blue=0, green=0) for x in range(15)]
# New
KeyboardGrid = ChromaGrid('Keyboard')
MouseGrid = ChromaGrid('Mouse')
MousepadGrid = ChromaGrid('Mousepad')

print('Setting all devices to red')
KeyboardGrid.set(hexcolor="#FF0000")
MousepadGrid.set(red=255, blue=0, green=0)
MouseGrid.set(hexcolor="0xFF0000")
print(App.Mousepad.setCustomGrid(MousepadGrid))
print(App.Mouse.setCustomGrid(MouseGrid))
print(App.Keyboard.setCustomGrid(KeyboardGrid))
print(App.Mouse.applyGrid())
print(App.Mousepad.applyGrid())
print(App.Keyboard.applyGrid())

sleep(2)

print('Starting animations')
print('Running mouse-animation')

for i in range(0, len(MouseGrid)):
コード例 #3
0
ファイル: chromamess.py プロジェクト: Chrigi2486/ChromaMess
for y in range(keyboard.MaxRow - 1, -1,
               -1):  # goes through all keys one at a time and sets the colour
    for x in range(keyboard.MaxColumn):
        keyboard.setPosition(ChromaColor(255, 0, 0), x=x, y=y)
        keyboard.applyGrid()
        sleep(0.01)
for x in range(keyboard.MaxColumn - 1, -1,
               -1):  # same as before but in a different order
    for y in range(keyboard.MaxRow):
        keyboard.setPosition(ChromaColor(0, 255, 0), x=x, y=y)
        keyboard.applyGrid()
        sleep(0.01)

newGrid = ChromaGrid('Keyboard')
newGrid.set(
    0, 255, 0
)  # makes the whole grid (all the keys in the grid) green. Basically cycles through them and makes every individual one green

for x in range(len(newGrid)):  # makes every column red going downwards
    for y in range(len(newGrid[x])):
        newGrid[x][y].set(
            255, 0, 0
        )  # this is how you set the color of a key (key.set(r, g, b)) keys are of the ChromaColor class so basically you're changing the color of a ChromaColor object
    keyboard.setCustomGrid(newGrid)  # tells it which grid to use
    keyboard.applyGrid()  # updates the keyboard to use the grid set
    sleep(0.1)

ymax = keyboard.MaxColumn
for y in range(
        int(ymax / 2)
):  # this colours the keys blue coming from the sides, approaching the middle and stopping there