keyboard: fix key to digit

main
radex 2024-02-28 14:05:15 +01:00
parent fe220120cc
commit fe37eea8de
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
3 changed files with 10 additions and 10 deletions

View File

@ -114,7 +114,7 @@ void debugHandleInput(Input input) {
Serial.print(allKeys[input.key]);
auto digit = getPressedDigit(input.key);
if (digit != KEY_NONE) {
if (digit != -1) {
Serial.print(", digit: ");
Serial.print(digit);
} else {

View File

@ -21,12 +21,12 @@ row/col 0 1 2 3
const char *allKeys = " 123A456B789C*0#D";
const uint8_t digits[17] =
{ KEY_NONE,
1, 2, 3, KEY_NONE,
4, 5, 6, KEY_NONE,
7, 8, 9, KEY_NONE,
KEY_NONE, 0, KEY_NONE, KEY_NONE};
const int8_t digits[17] =
{ -1,
1, 2, 3, -1,
4, 5, 6, -1,
7, 8, 9, -1,
-1, 0, -1, -1};
bool setupKeyboard() {
if (!kbd.begin()) {
@ -126,7 +126,7 @@ Key getPressedKey() {
return (rowPressed * 4) + colPressed + 1;
}
uint8_t getPressedDigit(Key key) {
int8_t getPressedDigit(Key key) {
return digits[key];
}

View File

@ -29,8 +29,8 @@ bool setupKeyboard();
Key handleKeyboard();
/**
* Returns pressed digit or KEY_NONE if the key is not a digit
* Returns pressed digit or -1 if the key is not a digit
*/
uint8_t getPressedDigit(Key key);
int8_t getPressedDigit(Key key);
Key handleDebugKeyboard(char key);