2019-02-14 10:20:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// CTimerManager
|
|
|
|
//
|
|
|
|
// This provides management of the timers
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __TIMERMANAGER_H__
|
|
|
|
#define __TIMERMANAGER_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-02-14 19:36:13 +00:00
|
|
|
struct sTimer;
|
|
|
|
|
2019-02-14 10:20:15 +00:00
|
|
|
class CTimerManager {
|
|
|
|
public:
|
2019-02-20 10:50:28 +00:00
|
|
|
static const int _dayMinutes = 24*60;
|
2019-07-28 07:40:12 +00:00
|
|
|
static bool createOneShotMap(sTimer& timer, uint16_t* timerMap = NULL, uint16_t* timerIDs = NULL);
|
2019-02-20 10:50:28 +00:00
|
|
|
static void createMap(int timermask = 0x3fff, uint16_t* timerMap = NULL, uint16_t* timerIDs = NULL);
|
|
|
|
static void createMap(sTimer& timer, uint16_t* timerMap = NULL, uint16_t* timerIDs = NULL);
|
|
|
|
static void condenseMap(uint16_t timerMap[_dayMinutes], int factor);
|
|
|
|
static void condenseMap(uint8_t timerMap[7][120]);
|
2019-02-14 19:36:13 +00:00
|
|
|
static int conflictTest(sTimer& timer);
|
2019-03-05 09:40:00 +00:00
|
|
|
static int conflictTest(int ID);
|
2019-02-20 10:50:28 +00:00
|
|
|
static int manageTime(int hour, int minute, int dow);
|
|
|
|
static int findNextTimer(int hour, int minute, int dow);
|
|
|
|
static int getNextTimer();
|
2019-08-03 02:42:49 +00:00
|
|
|
static int getActiveTimer();
|
2019-02-20 10:50:28 +00:00
|
|
|
static void getTimer(int idx, sTimer& timerInfo);
|
|
|
|
static int setTimer(sTimer& timerInfo);
|
2019-08-03 02:42:49 +00:00
|
|
|
static bool hasTimerChanged() { return _timerChanged; };
|
2019-02-20 10:50:28 +00:00
|
|
|
private:
|
2019-08-03 02:42:49 +00:00
|
|
|
static int _activeTimer;
|
|
|
|
static int _activeDow;
|
|
|
|
static int _prevState;
|
|
|
|
static int _nextTimer;
|
|
|
|
static int _nextStart;
|
|
|
|
static uint8_t _weekMap[7][_dayMinutes]; // b[7] = repeat flag, b[3..0] = timer ID
|
|
|
|
static bool _timerChanged;
|
2019-02-14 10:20:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__TIMERMANAGER_H__
|