diff --git a/ChromaPython/ChromaApp.py b/ChromaPython/ChromaApp.py index 4b74a5d..74ac036 100644 --- a/ChromaPython/ChromaApp.py +++ b/ChromaPython/ChromaApp.py @@ -1,6 +1,6 @@ import requests from .ChromaBinary import ChromaBcaHandler -from .ChromaDevices import Keyboard, Mouse, Mousepad, ChromaLink, Headset +from .ChromaDevices import Keyboard, Keypad, Mouse, Mousepad, ChromaLink, Headset from .ChromaDatatypes import Heartbeat, ChromaAppInfo @@ -23,6 +23,7 @@ def __init__(self, Info: ChromaAppInfo): self.SessionID, self.URI = response.json()['sessionid'], response.json()['uri'] self.heartbeat = Heartbeat(self.URI) self.Keyboard = Keyboard(self.URI) + self.Keypad = Keypad(self.URI) self.Mouse = Mouse(self.URI) self.Mousepad = Mousepad(self.URI) self.Headset = Headset(self.URI) diff --git a/ChromaPython/ChromaDatatypes.py b/ChromaPython/ChromaDatatypes.py index 201e9f8..1227832 100644 --- a/ChromaPython/ChromaDatatypes.py +++ b/ChromaPython/ChromaDatatypes.py @@ -129,7 +129,7 @@ def getHexRGB(self): class ChromaGrid: def __init__(self, type: str): - self._types = {'Keyboard': [22, 6], 'Mouse': [7, 9], 'Mousepad': [15], 'ChromaLink': [5], 'Keypad': [4, 5], + self._types = {'Keyboard': [22, 6], 'Mouse': [7, 9], 'Mousepad': [15], 'ChromaLink': [5], 'Keypad': [5, 4], 'Headset': [2]} try: self.rearrange(type=type) @@ -145,7 +145,7 @@ def __len__(self): def rearrange(self, type: str): if not type in self._types: print('Unexpected Error!') - raise + raise Exception('Device type not found!') else: self._type = self._types[type] if len(self._type) == 1: diff --git a/ChromaPython/ChromaDevices.py b/ChromaPython/ChromaDevices.py index 8d5a4ba..2a62632 100644 --- a/ChromaPython/ChromaDevices.py +++ b/ChromaPython/ChromaDevices.py @@ -471,7 +471,7 @@ class Keypad: def __init__(self, uri: str): self._MaxRow = 4 self._MaxColumn = 5 - self._ColorGrid = [[ChromaColor(red=0, green=0, blue=0) for x in range(22)] for y in range(6)] + self._ColorGrid = [[ChromaColor(red=0, green=0, blue=0) for x in range(5)] for y in range(4)] self._Keys = KeyboardKeys() try: @@ -529,7 +529,7 @@ def setCustomGrid(self, grid): raise def applyGrid(self): - tmp = [[0 for x in range(22)] for y in range(6)] + tmp = [[0 for x in range(5)] for y in range(4)] for i in range(0, len(self._ColorGrid)): for j in range(0, len(self._ColorGrid[i])): @@ -537,8 +537,9 @@ def applyGrid(self): data = { "effect": "CHROMA_CUSTOM", - "param": [tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]] + "param": [tmp[0], tmp[1], tmp[2], tmp[3]] } + try: return checkresult(requests.put(url=self._URI, json=data).json()) except: diff --git a/Tests/checkall.py b/Tests/checkall.py index bacb671..184af55 100644 --- a/Tests/checkall.py +++ b/Tests/checkall.py @@ -5,7 +5,7 @@ Info.DeveloperName = 'Rick Sanchez' Info.DeveloperContact = 'Wubba-lubba@dub-dub.com' Info.Category = 'application' -Info.SupportedDevices = ['keyboard', 'mouse', 'mousepad'] +Info.SupportedDevices = ['keyboard', 'mouse', 'mousepad', 'keypad'] Info.Description = 'Oh Rick, I don\'t know if that\'s a good idea.' Info.Title = 'Mr Meeseeks Box' @@ -17,11 +17,12 @@ print(App.Version()) print('\n') -print('Setting Keyboard to green, Mouse to yellow and Mousepad to blue') +print('Setting Keyboard to green, Keypad to purple, Mouse to yellow, and Mousepad to blue') print(App.Keyboard.setStatic(Colors.GREEN)) print(App.Mousepad.setStatic(Colors.BLUE)) print(App.Mouse.setStatic(Colors.YELLOW)) +print(App.Keypad.setStatic(Colors.PURPLE)) sleep(2) # Oldschool @@ -30,19 +31,23 @@ # MousepadGrid = [ChromaColor(red=255, blue=0, green=0) for x in range(15)] # New KeyboardGrid = ChromaGrid('Keyboard') +KeypadGrid = ChromaGrid('Keypad') MouseGrid = ChromaGrid('Mouse') MousepadGrid = ChromaGrid('Mousepad') print('Setting all devices to red') KeyboardGrid.set(hexcolor="#FF0000") +KeypadGrid.set(hexcolor="0xFF0000") 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.Keypad.setCustomGrid(KeypadGrid)) print(App.Mouse.applyGrid()) print(App.Mousepad.applyGrid()) print(App.Keyboard.applyGrid()) +print(App.Keypad.applyGrid()) sleep(2) @@ -64,6 +69,14 @@ App.Keyboard.applyGrid() sleep(0.1) +print('Running keypad-animation') +for i in range(0, len(KeypadGrid)): + for j in range(0, len(KeypadGrid[i])): + KeypadGrid[i][j].set(red=255, green=255, blue=0) + App.Keypad.setCustomGrid(KeypadGrid) + App.Keypad.applyGrid() + sleep(0.1) + print('Running mousepad-animation') for i in range(0, len(MousepadGrid)): MousepadGrid[i].set(red=255, green=255, blue=0) @@ -75,6 +88,7 @@ print("Setting all devices to none") App.Keyboard.setNone() +App.Keypad.setNone() App.Mouse.setNone() App.Mousepad.setNone()