diff --git a/examples/FSM/FooContext.hpp b/examples/FSM/FooContext.hpp index 176830f..be25222 100644 --- a/examples/FSM/FooContext.hpp +++ b/examples/FSM/FooContext.hpp @@ -9,7 +9,7 @@ struct FooContext static FState sCooldown; uint8_t count; - uint8_t elapsed; + unsigned long elapsed; FSM* fsm; -}; \ No newline at end of file +}; diff --git a/examples/FSM/States/RunState.cpp b/examples/FSM/States/RunState.cpp index f4c815f..eab755a 100644 --- a/examples/FSM/States/RunState.cpp +++ b/examples/FSM/States/RunState.cpp @@ -18,8 +18,10 @@ static void update(FooContext* const ctx) if (digitalRead(4) == LOW) ctx->fsm->transitionTo(FooContext::sOff); - else if (((ctx->count + 1) % 6) == 0) + else if (((ctx->count + 1) % 6) == 0){ + ctx->count = 0; ctx->fsm->transitionTo(FooContext::sCooldown); + } } -FState FooContext::sRun(enter, update, nullptr); \ No newline at end of file +FState FooContext::sRun(enter, update, nullptr); diff --git a/examples/HSM/FooContext.hpp b/examples/HSM/FooContext.hpp index 8cf49ed..e632e6b 100644 --- a/examples/HSM/FooContext.hpp +++ b/examples/HSM/FooContext.hpp @@ -10,8 +10,8 @@ struct FooContext static HState sCooldown; uint8_t count; - uint8_t current; - uint8_t elapsed; + unsigned long current; + unsigned long elapsed; HSM* hsm; -}; \ No newline at end of file +}; diff --git a/examples/HSM/States/RunState.cpp b/examples/HSM/States/RunState.cpp index c5baedb..dc37633 100644 --- a/examples/HSM/States/RunState.cpp +++ b/examples/HSM/States/RunState.cpp @@ -13,8 +13,10 @@ static void update(FooContext* const ctx) ctx->count++; } - if (((ctx->count +1) % 6) == 0) + if (((ctx->count +1) % 6) == 0){ + ctx->count = 0; ctx->transitionTo(FooContext::sCooldown); + } } -HState FooContext::sRun(&FooContext::sOnGroup, enter, update, nullptr); \ No newline at end of file +HState FooContext::sRun(&FooContext::sOnGroup, enter, update, nullptr);