Skip to content

Commit

Permalink
Make FSM sensitive to multi zone touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
ngandrass committed Sep 6, 2024
1 parent 75d3d30 commit b8412ae
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
2 changes: 2 additions & 0 deletions include/FSMEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*/
enum class FSMEvent {
NoOp,
AllShortpress,
AllLongpress,
FingerprintTouch,
FingerprintRelease,
FingerprintShortpress,
Expand Down
9 changes: 9 additions & 0 deletions include/FSMState.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ class FSMState {
*/
virtual std::unique_ptr<FSMState> touchEventNoseLongpress();

/**
* @brief Executed on FSMEvent::AllShortpress
*/
virtual std::unique_ptr<FSMState> touchEventAllShortpress();

/**
* @brief Executed on FSMEvent::AllLongpress
*/
virtual std::unique_ptr<FSMState> touchEventAllLongpress();
};

/**
Expand Down
28 changes: 19 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ void setup() {
*/
void loop() {
// Handler: ISR Events
if (isrEvents.allLongpress) {
fsm.queueEvent(FSMEvent::AllLongpress);
isrEvents.noseLongpress = false;
isrEvents.noseShortpress = false;
isrEvents.noseRelease = false;
isrEvents.fingerprintLongpress = false;
isrEvents.fingerprintShortpress = false;
isrEvents.fingerprintRelease = false;
isrEvents.allLongpress = false;
isrEvents.allShortpress = false;
}
if (isrEvents.allShortpress) {
fsm.queueEvent(FSMEvent::AllShortpress);
isrEvents.noseShortpress = false;
isrEvents.noseRelease = false;
isrEvents.fingerprintShortpress = false;
isrEvents.fingerprintRelease = false;
isrEvents.allShortpress = false;
}
if (isrEvents.fingerprintTouch) {
fsm.queueEvent(FSMEvent::FingerprintTouch);
isrEvents.fingerprintTouch = false;
Expand Down Expand Up @@ -285,15 +304,6 @@ void loop() {
fsm.queueEvent(FSMEvent::NoseRelease);
isrEvents.noseRelease = false;
}
if (isrEvents.allLongpress) {
LOG_INFO("ALL LONG");
isrEvents.allLongpress = false;
isrEvents.allShortpress = false;
}
if (isrEvents.allShortpress) {
LOG_INFO("ALL SHORT");
isrEvents.allShortpress = false;
}

// Task: Handle FSM
if (task_fsm_handle < millis()) {
Expand Down
8 changes: 8 additions & 0 deletions src/states/FSMState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ std::unique_ptr<FSMState> FSMState::touchEventNoseShortpress() {
std::unique_ptr<FSMState> FSMState::touchEventNoseLongpress() {
return nullptr;
}

std::unique_ptr<FSMState> FSMState::touchEventAllShortpress() {
return nullptr;
}

std::unique_ptr<FSMState> FSMState::touchEventAllLongpress() {
return nullptr;
}

0 comments on commit b8412ae

Please sign in to comment.