Dees_Troy | 2f9117a | 2013-02-17 19:52:09 -0600 | [diff] [blame] | 1 | /* |
| 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_Troy | 2f9117a | 2013-02-17 19:52:09 -0600 | [diff] [blame] | 22 | #include <sys/time.h> |
| 23 | |
| 24 | using namespace std; |
| 25 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 26 | class blanktimer |
| 27 | { |
| 28 | public: |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 29 | blanktimer(); |
Dees_Troy | 2f9117a | 2013-02-17 19:52:09 -0600 | [diff] [blame] | 30 | |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 31 | // set timeout in seconds |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 32 | void setTime(int newtime); |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 33 | |
| 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 Mower | 9472ba1 | 2016-01-20 18:12:47 -0600 | [diff] [blame] | 40 | // call this when power button is pressed |
| 41 | void toggleBlank(void); |
| 42 | |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 43 | bool isScreenOff(); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 44 | |
Sean hoyt | c387622 | 2018-07-15 06:16:09 +0200 | [diff] [blame] | 45 | void blank(void); |
| 46 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 47 | private: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 48 | void setTimer(void); |
xNUTx | e85f02d | 2014-07-18 01:30:58 +0200 | [diff] [blame] | 49 | string getBrightness(void); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 50 | |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 51 | pthread_mutex_t mutex; |
| 52 | enum State { kOn = 0, kDim = 1, kOff = 2, kBlanked = 3 }; |
| 53 | State state; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 54 | timespec btimer; |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 55 | long sleepTimer; |
xNUTx | e85f02d | 2014-07-18 01:30:58 +0200 | [diff] [blame] | 56 | string orig_brightness; |
Dees_Troy | 2f9117a | 2013-02-17 19:52:09 -0600 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | extern blanktimer blankTimer; |
| 60 | |
| 61 | #endif // __BLANKTIMER_HEADER_HPP |