blob: 6aca27087879ebb976080e6d7adad58498a94371 [file] [log] [blame]
Dees_Troy2f9117a2013-02-17 19:52:09 -06001/*
2 Copyright 2012 bigbiff/Dees_Troy TeamWin
3 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef __BLANKTIMER_HEADER_HPP
20#define __BLANKTIMER_HEADER_HPP
21
Dees_Troy2f9117a2013-02-17 19:52:09 -060022#include <sys/time.h>
23
24using namespace std;
25
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020026class blanktimer
27{
28public:
thatfb759d42015-01-11 12:16:53 +010029 blanktimer();
Dees_Troy2f9117a2013-02-17 19:52:09 -060030
thatfb759d42015-01-11 12:16:53 +010031 // set timeout in seconds
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020032 void setTime(int newtime);
thatfb759d42015-01-11 12:16:53 +010033
34 // call this in regular intervals
35 void checkForTimeout();
36
37 // call this when an input event is received or when an operation is finished
38 void resetTimerAndUnblank();
39
Matt Mower9472ba12016-01-20 18:12:47 -060040 // call this when power button is pressed
41 void toggleBlank(void);
42
thatfb759d42015-01-11 12:16:53 +010043 bool isScreenOff();
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020044
Sean hoytc3876222018-07-15 06:16:09 +020045 void blank(void);
46
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020047private:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020048 void setTimer(void);
xNUTxe85f02d2014-07-18 01:30:58 +020049 string getBrightness(void);
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020050
thatfb759d42015-01-11 12:16:53 +010051 pthread_mutex_t mutex;
52 enum State { kOn = 0, kDim = 1, kOff = 2, kBlanked = 3 };
53 State state;
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020054 timespec btimer;
thatfb759d42015-01-11 12:16:53 +010055 long sleepTimer;
xNUTxe85f02d2014-07-18 01:30:58 +020056 string orig_brightness;
Dees_Troy2f9117a2013-02-17 19:52:09 -060057};
58
59extern blanktimer blankTimer;
60
61#endif // __BLANKTIMER_HEADER_HPP