From 338bcea5ce464f72d80f4fa6e882bc25083cad95 Mon Sep 17 00:00:00 2001 From: Vasily Davydov Date: Sun, 16 Oct 2022 13:55:00 +0300 Subject: [PATCH] timer: place global timer as a global variable --- Timer/.gitignore | 1 + Timer/inc/Timer.h | 3 ++- esp-vent-main/src/esp-vent-main.cpp | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Timer/.gitignore diff --git a/Timer/.gitignore b/Timer/.gitignore new file mode 100644 index 0000000..3df573f --- /dev/null +++ b/Timer/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/Timer/inc/Timer.h b/Timer/inc/Timer.h index 55ca9a1..8cb737d 100644 --- a/Timer/inc/Timer.h +++ b/Timer/inc/Timer.h @@ -12,6 +12,8 @@ #include #include +static volatile std::atomic_int timer; + extern "C" { /** @@ -69,7 +71,6 @@ public: private: volatile std::atomic_int counter; - volatile std::atomic_int timer; uint32_t freq; }; diff --git a/esp-vent-main/src/esp-vent-main.cpp b/esp-vent-main/src/esp-vent-main.cpp index 231a6aa..31c9f59 100644 --- a/esp-vent-main/src/esp-vent-main.cpp +++ b/esp-vent-main/src/esp-vent-main.cpp @@ -19,6 +19,7 @@ #include "DigitalIoPin.h" #include "LiquidCrystal.h" #include "StateHandler.h" +#include "Timer.h" #include @@ -65,6 +66,8 @@ main (void) int16_t pressure = 1; + Timer glob_time; + while (1) { if (b_up.read ()) @@ -101,6 +104,7 @@ main (void) * - Update current pressure to eTick */ ventMachine.HandleState (Event (Event::eTick, pressure)); + glob_time.tickCounter(1); } return 0;