|
21 | 21 | Set the device to use with the library. Only a single device is |
22 | 22 | supported. If multiple devices of the same model are connected, the |
23 | 23 | first encountered is set to control. |
24 | | - :param model: enum Model of device to set |
25 | | - :return: enum Result code |
| 24 | + :param model: Model number of device to set |
| 25 | + :return: result code (SUCCESS or ERR*) |
26 | 26 | :raises: TypeError upon invalid argument type |
27 | 27 |
|
28 | 28 | int enable_control() |
29 | 29 | Send the control packet to the keyboard set to control. |
30 | | - :return: enum Result code |
| 30 | + :return: result code (SUCCESS or ERR*) |
31 | 31 |
|
32 | 32 | int disable_control() |
33 | 33 | Send the packet to release control to the keyboard set to control. |
34 | | - :return: enum Result code |
| 34 | + :return: result code (SUCCESS or ERR*) |
35 | 35 |
|
36 | 36 | int set_effect(effect) |
37 | 37 | Set one of the built-in LED effects on the keyboard. |
38 | | - :param effect: enum Effect to enable |
39 | | - :return: enum Result code |
| 38 | + :param effect: Effect number (EFF*) |
| 39 | + :return: result code (SUCCESS or ERR*) |
40 | 40 | :raises: TypeError upon invalid argument type |
41 | 41 |
|
42 | 42 | int set_full_led_color(r, g, b) |
43 | 43 | Set the color of all the LEDs on the keyboard to a single color. |
44 | 44 | :param r: Red color value, 0-255 (two symbol HEX) |
45 | 45 | :param g: Green color value |
46 | 46 | :param b: Blue color value |
47 | | - :return: enum Result code |
| 47 | + :return: result code (SUCCESS or ERR*) |
48 | 48 | :raises: TypeError upon invalid argument type or count |
49 | 49 |
|
50 | 50 | int set_all_led_color(layout) |
51 | 51 | Set the color of all the LEDs on the keyboard from a list of lists |
52 | 52 | :param layout: List of lists of tuples ([row][col][index]) |
53 | | - :return: enum Result code |
| 53 | + :return: result code (SUCCESS or ERR*) |
54 | 54 | :raises: TypeError if invalid type in the argument |
55 | 55 | :raises: ValueError if invalid amount of elements in the argument |
56 | 56 |
|
|
59 | 59 | conjunction with the set_full_led_color function. |
60 | 60 | :param row, col: Coordinates of LED to set color of |
61 | 61 | :param r, g, b: Color values |
62 | | - :return: enum Result code |
| 62 | + :return: result code (SUCCESS or ERR*) |
63 | 63 | :raises: TypeError upon invalid argument type |
64 | 64 | """ |
65 | | -from enum import Enum |
66 | 65 | from .masterkeys import * |
67 | 66 |
|
68 | 67 |
|
69 | 68 | MAX_ROWS = 7 |
70 | 69 | MAX_COLS = 24 |
71 | 70 |
|
72 | | - |
73 | | -class Result(Enum): |
74 | | - """Describes error codes that are used in libmk""" |
75 | | - # Success codes |
76 | | - SUCCESS = 0 |
77 | | - |
78 | | - # Device Errors |
79 | | - ERR_INVALID_DEV = 1 |
80 | | - ERR_DEV_NOT_CONNECTED = 2 |
81 | | - ERR_DEV_NOT_SET = 3 |
82 | | - ERR_UNKNOWN_LAYOUT = 14 |
83 | | - ERR_DEV_NOT_CLOSED = 15 |
84 | | - ERR_DEV_RESET_FAILED = 16 |
85 | | - |
86 | | - # Interface Errors |
87 | | - ERR_IFACE_CLAIM_FAILED = 4 |
88 | | - ERR_IFACE_RELEASE_FAILED = 5 |
89 | | - ERR_DEV_CLOSE_FAILED = 6 |
90 | | - ERR_DEV_OPEN_FAILED = 7 |
91 | | - |
92 | | - # Kernel Driver Errors |
93 | | - ERR_KERNEL_DRIVER = 8 |
94 | | - |
95 | | - # Communication Errors |
96 | | - ERR_DEV_LIST = 9 |
97 | | - ERR_TRANSFER = 10 |
98 | | - ERR_DESCR = 11 # Descriptor |
99 | | - ERR_SEND = 12 |
100 | | - |
101 | | - # Protocol Errors |
102 | | - ERR_PROTOCOL = 13 |
103 | | - |
104 | | - |
105 | | -class Effect(Enum): |
106 | | - """Describes built-in LED Effect numbers""" |
107 | | - EFF_FULL_ON = 0 |
108 | | - EFF_BREATH = 1 |
109 | | - EFF_BREATH_CYCLE = 2 |
110 | | - EFF_SINGLE = 3 |
111 | | - EFF_WAVE = 4 |
112 | | - EFF_RIPPLE = 5 |
113 | | - EFF_CROSS = 6 |
114 | | - EFF_RAIN = 7 |
115 | | - EFF_STAR = 8 |
116 | | - EFF_SNAKE = 9 |
117 | | - EFF_REC = 10 |
118 | | - EFF_SPECTRUM = 11 |
119 | | - EFF_RAPID_FIRE = 12 |
120 | | - |
121 | | - |
122 | | -class Model(Enum): |
123 | | - """Describes models supported by this library""" |
124 | | - RGB_L = 0 |
125 | | - RGB_M = 5 |
126 | | - RGB_S = 1 |
127 | | - |
128 | | - WHITE_L = 2 |
129 | | - WHITE_M = 3 |
130 | | - WHITE_S = 7 |
131 | | - |
132 | | - NOT_SET = -1 |
133 | | - ANY = -2 |
134 | | - UNKNOWN = -3 |
| 71 | +# Success codes |
| 72 | +SUCCESS = 0 |
| 73 | + |
| 74 | +# Device Errors |
| 75 | +ERR_INVALID_DEV = 1 |
| 76 | +ERR_DEV_NOT_CONNECTED = 2 |
| 77 | +ERR_DEV_NOT_SET = 3 |
| 78 | +ERR_UNKNOWN_LAYOUT = 14 |
| 79 | +ERR_DEV_NOT_CLOSED = 15 |
| 80 | +ERR_DEV_RESET_FAILED = 16 |
| 81 | + |
| 82 | +# Interface Errors |
| 83 | +ERR_IFACE_CLAIM_FAILED = 4 |
| 84 | +ERR_IFACE_RELEASE_FAILED = 5 |
| 85 | +ERR_DEV_CLOSE_FAILED = 6 |
| 86 | +ERR_DEV_OPEN_FAILED = 7 |
| 87 | + |
| 88 | +# Kernel Driver Errors |
| 89 | +ERR_KERNEL_DRIVER = 8 |
| 90 | + |
| 91 | +# Communication Errors |
| 92 | +ERR_DEV_LIST = 9 |
| 93 | +ERR_TRANSFER = 10 |
| 94 | +ERR_DESCR = 11 # Descriptor |
| 95 | +ERR_SEND = 12 |
| 96 | + |
| 97 | +# Protocol Errors |
| 98 | +ERR_PROTOCOL = 13 |
| 99 | + |
| 100 | +# Effects |
| 101 | +EFF_FULL_ON = 0 |
| 102 | +EFF_BREATH = 1 |
| 103 | +EFF_BREATH_CYCLE = 2 |
| 104 | +EFF_SINGLE = 3 |
| 105 | +EFF_WAVE = 4 |
| 106 | +EFF_RIPPLE = 5 |
| 107 | +EFF_CROSS = 6 |
| 108 | +EFF_RAIN = 7 |
| 109 | +EFF_STAR = 8 |
| 110 | +EFF_SNAKE = 9 |
| 111 | +EFF_REC = 10 |
| 112 | +EFF_SPECTRUM = 11 |
| 113 | +EFF_RAPID_FIRE = 12 |
| 114 | + |
| 115 | +# Models |
| 116 | +MODEL_RGB_L = 0 |
| 117 | +MODEL_RGB_M = 5 |
| 118 | +MODEL_RGB_S = 1 |
| 119 | + |
| 120 | +MODEL_WHITE_L = 2 |
| 121 | +MODEL_WHITE_M = 3 |
| 122 | +MODEL_WHITE_S = 7 |
| 123 | + |
| 124 | +MODEL_NOT_SET = -1 |
| 125 | +MODEL_ANY = -2 |
| 126 | +MODEL_UNKNOWN = -3 |
135 | 127 |
|
136 | 128 |
|
137 | 129 | def set_all_led_color_dict(keys): |
|
0 commit comments