fixe compile error

This commit is contained in:
Andrea Baccega 2024-01-26 14:18:37 +01:00
parent 27593e1916
commit 18929e46f8
2 changed files with 8 additions and 5 deletions

View File

@ -21,7 +21,7 @@ Pair<ButtonKind, StateChangeEvent<ButtonState>>* Buttons::handleButtons()
{
StateChangeEvent<ButtonState> *change = __buttons[i]->lastChange();
Serial.println(STATECHANGE_STR((*change)));
Serial.println(String("ButtonStateChange: kind=") + KIND_STR(__buttons[i]->kind) + ", " + STATECHANGE_STR((*change)));
return new Pair<ButtonKind, StateChangeEvent<ButtonState>>(__buttons[i]->kind, *change);
}
}

View File

@ -1,7 +1,6 @@
#ifndef __enums_h__
#define __enums_h__
enum ButtonState
{
IDLE,
@ -18,8 +17,12 @@ enum ButtonKind
NONE
};
#define KIND_STR(kind) (kind == ButtonKind::UP ? "UP" : kind == ButtonKind::DOWN ? "DOWN" : kind == ButtonKind::BACK ? "BACK" : kind == ButtonKind::SELECT ? "SELECT" : "NONE")
#define STATE_STR(state) (state == ButtonState::IDLE ? "IDLE" : state == ButtonState::PRESSED ? "PRESSED" : "RELEASED")
#define STATECHANGE_STR(change) (String("ButtonStateChange: kind=") + KIND_STR(change.kind) + ", " + STATE_STR(change.from) + " -> " + STATE_STR(change.to))
#define KIND_STR(kind) (kind == ButtonKind::UP ? "UP" : kind == ButtonKind::DOWN ? "DOWN" \
: kind == ButtonKind::BACK ? "BACK" \
: kind == ButtonKind::SELECT ? "SELECT" \
: "NONE")
#define STATE_STR(state) (state == ButtonState::IDLE ? "IDLE" : state == ButtonState::PRESSED ? "PRESSED" \
: "RELEASED")
#define STATECHANGE_STR(change) (String(STATE_STR(change.from)) + " -> " + STATE_STR(change.to))
#endif