Skip to content

Commit ec4710b

Browse files
committed
Define KEY_INFO_SIZE constant for keyInfo array and update related code for clarity
1 parent 68113a1 commit ec4710b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tdeck/tdeck.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#define BOARD_I2C_SDA 18
1818
#define BOARD_I2C_SCL 8
1919

20-
uint8_t keyInfo[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // key_value, alt, ctrl, shift, mic, speaker
20+
#define KEY_INFO_SIZE 6
21+
22+
uint8_t keyInfo[KEY_INFO_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // key_value, alt, ctrl, shift, mic, speaker
2123

2224
/**
2325
* @brief Setup function to initialize serial communication, power on the board, and check the keyboard.
@@ -61,8 +63,8 @@ void setup()
6163
void loop()
6264
{
6365
// Read key value from esp32c3
64-
Wire.requestFrom(LILYGO_KB_SLAVE_ADDRESS, 6);
65-
for (int i = 0; i < 6 && Wire.available() > 0; i++)
66+
Wire.requestFrom(LILYGO_KB_SLAVE_ADDRESS, KEY_INFO_SIZE);
67+
for (int i = 0; i < KEY_INFO_SIZE && Wire.available() > 0; i++)
6668
{
6769
keyInfo[i] = Wire.read();
6870
}

0 commit comments

Comments
 (0)