Fix the computation of KEY_STATE_SIZE and the byte count to memset in BoolBytesToBits()
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#define PROTOCOL_RESPONSE_GENERIC_ERROR 1
|
#define PROTOCOL_RESPONSE_GENERIC_ERROR 1
|
||||||
|
|
||||||
#define LEFT_KEYBOARD_HALF_KEY_COUNT (KEYBOARD_MATRIX_COLS_NUM*KEYBOARD_MATRIX_ROWS_NUM)
|
#define LEFT_KEYBOARD_HALF_KEY_COUNT (KEYBOARD_MATRIX_COLS_NUM*KEYBOARD_MATRIX_ROWS_NUM)
|
||||||
#define KEY_STATE_SIZE (LEFT_KEYBOARD_HALF_KEY_COUNT/8 + 1)
|
#define KEY_STATE_SIZE (LEFT_KEYBOARD_HALF_KEY_COUNT/8 + (LEFT_KEYBOARD_HALF_KEY_COUNT % 8 ? 1 : 0))
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
void BoolBytesToBits(uint8_t *srcBytes, uint8_t *dstBits, uint8_t byteCount)
|
void BoolBytesToBits(uint8_t *srcBytes, uint8_t *dstBits, uint8_t byteCount)
|
||||||
{
|
{
|
||||||
memset(dstBits, 0, byteCount/8 + 1);
|
memset(dstBits, 0, byteCount/8 + (byteCount % 8 ? 1 : 0));
|
||||||
for (uint8_t i=0; i<byteCount; i++) {
|
for (uint8_t i=0; i<byteCount; i++) {
|
||||||
dstBits[i/8] |= !!srcBytes[i] << (i % 8);
|
dstBits[i/8] |= !!srcBytes[i] << (i % 8);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user