timer: modify class to have one common constructor
This commit is contained in:
parent
8f54fe85aa
commit
9492081fbb
@ -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 ();
|
||||
|
||||
/**
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -18,20 +18,14 @@ extern "C"
|
||||
}
|
||||
}
|
||||
|
||||
Timer::Timer (uint32_t freq) : freq (freq)
|
||||
Timer::Timer (uint32_t freq, bool setup) : freq (freq), mode (setup)
|
||||
{
|
||||
if (mode)
|
||||
{
|
||||
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;
|
||||
resetCounter ();
|
||||
timer = 0;
|
||||
systicks.store (0, std::memory_order_relaxed);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user