diff --git a/esp-vent-main/inc/Timer.h b/esp-vent-main/inc/Timer.h index 884b444..a297876 100644 --- a/esp-vent-main/inc/Timer.h +++ b/esp-vent-main/inc/Timer.h @@ -33,9 +33,8 @@ public: * @brief Initalize the systick configuration with your frequency * */ - Timer (uint32_t freq = 1000); + Timer (uint32_t freq = 1000, bool mode = true); - Timer (bool mode); virtual ~Timer (); /** diff --git a/esp-vent-main/inc/common_control_values.h b/esp-vent-main/inc/common_control_values.h index ece8273..3f29b07 100644 --- a/esp-vent-main/inc/common_control_values.h +++ b/esp-vent-main/inc/common_control_values.h @@ -13,6 +13,8 @@ #define BROKER_IP "192.168.1.254" #define BROKER_PORT 1883 +#define ONE_K_HZ 1000 + enum _global_values { LCD_SIZE = 16, diff --git a/esp-vent-main/src/Timer.cpp b/esp-vent-main/src/Timer.cpp index 4da4031..6183cbe 100644 --- a/esp-vent-main/src/Timer.cpp +++ b/esp-vent-main/src/Timer.cpp @@ -18,20 +18,14 @@ extern "C" } } -Timer::Timer (uint32_t freq) : freq (freq) +Timer::Timer (uint32_t freq, bool setup) : freq (freq), mode (setup) { - mode = true; - Chip_Clock_SetSysTickClockDiv (1); - uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate (); - SysTick_Config (sysTickRate / freq); - resetCounter (); - timer = 0; - systicks.store (0, std::memory_order_relaxed); -} - -Timer::Timer (bool mode) -{ - this->mode = false; + if (mode) + { + Chip_Clock_SetSysTickClockDiv (1); + uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate (); + SysTick_Config (sysTickRate / freq); + } resetCounter (); timer = 0; systicks.store (0, std::memory_order_relaxed); diff --git a/esp-vent-main/src/esp-vent-main.cpp b/esp-vent-main/src/esp-vent-main.cpp index 63d570d..d115ee8 100644 --- a/esp-vent-main/src/esp-vent-main.cpp +++ b/esp-vent-main/src/esp-vent-main.cpp @@ -40,8 +40,11 @@ main (void) lcd.print ("Vent-Machine"); /* Timers */ - Timer glob_time; - Timer switch_time (false); + Timer glob_time (ONE_K_HZ, true); + /* Currently not used, but if we have time left, + * quick button increment is needed + * Timer switch_time (ONE_K_HZ, false); + */ /* Modbus Fan setup */ ModbusMaster fan (1);