From fb759d45f5c95e3184ffc9c35b57a0a463a6d1ab Mon Sep 17 00:00:00 2001 From: that Date: Sun, 11 Jan 2015 12:16:53 +0100 Subject: gui: simplify blanktimer - get rid of separate thread, check timer in rendering thread instead - use an enum for the blanking state instead of magic integers - move #ifdefs for TW_NO_SCREEN_TIMEOUT inside blanktimer class - move some #includes and enum TOUCH_STATE to pages.hpp Change-Id: Id4b104e3680dc5db41d8ba85e32d722cf4086299 --- gui/blanktimer.hpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'gui/blanktimer.hpp') diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp index c8159f643..5e617901f 100644 --- a/gui/blanktimer.hpp +++ b/gui/blanktimer.hpp @@ -19,7 +19,6 @@ #ifndef __BLANKTIMER_HEADER_HPP #define __BLANKTIMER_HEADER_HPP -#include #include using namespace std; @@ -27,32 +26,29 @@ using namespace std; class blanktimer { public: - blanktimer(void); + blanktimer(); - int setTimerThread(void); - void resetTimerAndUnblank(void); + // set timeout in seconds void setTime(int newtime); - bool IsScreenOff(); -private: - typedef int (blanktimer::*ThreadPtr)(void); - typedef void* (*PThreadPtr)(void*); + // call this in regular intervals + void checkForTimeout(); + + // call this when an input event is received or when an operation is finished + void resetTimerAndUnblank(); - void setConBlank(int blank); + bool isScreenOff(); + +private: void setTimer(void); - timespec getTimer(void); string getBrightness(void); - int setBrightness(int brightness); - int setBlankTimer(void); - int setClockTimer(void); - pthread_mutex_t conblankmutex; - pthread_mutex_t timermutex; - int conblank; + pthread_mutex_t mutex; + enum State { kOn = 0, kDim = 1, kOff = 2, kBlanked = 3 }; + State state; timespec btimer; - unsigned long long sleepTimer; + long sleepTimer; string orig_brightness; - bool screenoff; }; extern blanktimer blankTimer; -- cgit v1.2.3