keyboard: fix key to digit
parent
fe220120cc
commit
fe37eea8de
|
@ -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 {
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue