Fix the computation of KEY_STATE_SIZE and the byte count to memset in BoolBytesToBits()

This commit is contained in:
László Monda
2017-09-26 20:18:26 +02:00
parent 1839be81b6
commit 145443c65c
2 changed files with 2 additions and 2 deletions

View File

@@ -13,7 +13,7 @@
#define PROTOCOL_RESPONSE_GENERIC_ERROR 1
#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:

View File

@@ -3,7 +3,7 @@
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++) {
dstBits[i/8] |= !!srcBytes[i] << (i % 8);
}