Files
gunner47-GyverLamp/firmware/GyverLamp_v1.4/TimerManager.h

34 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
class TimerManager
{
public:
static bool TimerRunning; // флаг "таймер взведён"
static bool TimerHasFired; // флаг "таймер отработал"
static uint8_t TimerOption; // индекс элемента в списке List Picker'а
static uint64_t TimeToFire; // время, в которое должен сработать таймер (millis)
static void HandleTimer( // функция, обрабатывающая срабатывание таймера, гасит матрицу
bool* ONflag,
void (*changePower)())
{
if (!TimerManager::TimerHasFired &&
TimerManager::TimerRunning &&
millis() >= TimerManager::TimeToFire)
{
#ifdef GENERAL_DEBUG
Serial.printf("Выключение по таймеру\n\n");
#endif
TimerManager::TimerRunning = false;
TimerManager::TimerHasFired = true;
FastLED.clear();
delay(2);
FastLED.show();
*ONflag = !(*ONflag);
changePower();
}
}
};