summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gui/action.cpp5
-rw-r--r--gui/blanktimer.cpp40
-rw-r--r--gui/blanktimer.hpp4
-rw-r--r--gui/devices/landscape/res/landscape.xml2
-rw-r--r--gui/devices/portrait/res/portrait.xml2
-rw-r--r--gui/devices/watch/res/watch.xml2
6 files changed, 21 insertions, 34 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index b77e7e751..c471533ef 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -824,6 +824,11 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
return 0;
}
+ if (function == "setbrightness")
+ {
+ return TWFunc::Set_Brightness(arg);
+ }
+
if (isThreaded)
{
if (function == "fileexists")
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 383b15724..1b184297b 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -97,11 +97,11 @@ int blanktimer::setClockTimer(void) {
if (sleepTimer > 2 && diff.tv_sec > (sleepTimer - 2) && conblank == 0) {
orig_brightness = getBrightness();
setConBlank(1);
- setBrightness(5);
+ TWFunc::Set_Brightness("5");
}
if (sleepTimer && diff.tv_sec > sleepTimer && conblank < 2) {
setConBlank(2);
- setBrightness(0);
+ TWFunc::Set_Brightness("0");
screenoff = true;
TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank");
PageManager::ChangeOverlay("lock");
@@ -115,39 +115,20 @@ int blanktimer::setClockTimer(void) {
return -1; //shouldn't get here
}
-int blanktimer::getBrightness(void) {
- string results;
+string blanktimer::getBrightness(void) {
+ string result;
string brightness_path;
DataManager::GetValue("tw_brightness_file", brightness_path);
- if ((TWFunc::read_file(brightness_path, results)) != 0)
- return -1;
- int result = atoi(results.c_str());
- if (result == 0) {
- int tw_brightness;
- DataManager::GetValue("tw_brightness", tw_brightness);
- if (tw_brightness) {
- result = tw_brightness;
- } else {
- result = 255;
- }
+ if (brightness_path == "/nobrightness")
+ return brightness_path;
+ DataManager::GetValue("tw_brightness", result);
+ if (result == "") {
+ result = "255";
}
return result;
}
-int blanktimer::setBrightness(int brightness) {
- string brightness_path;
- string bstring;
- char buff[100];
- DataManager::GetValue("tw_brightness_file", brightness_path);
- sprintf(buff, "%d", brightness);
- bstring = buff;
- if ((TWFunc::write_file(brightness_path, bstring)) != 0)
- return -1;
- gui_forceRender();
- return 0;
-}
-
void blanktimer::resetTimerAndUnblank(void) {
setTimer();
switch (conblank) {
@@ -165,7 +146,8 @@ void blanktimer::resetTimerAndUnblank(void) {
screenoff = false;
// No break here, we want to keep going
case 1:
- setBrightness(orig_brightness);
+ if (orig_brightness != "/nobrightness")
+ TWFunc::Set_Brightness(orig_brightness);
setConBlank(0);
break;
}
diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp
index 01c1dfb0c..c8159f643 100644
--- a/gui/blanktimer.hpp
+++ b/gui/blanktimer.hpp
@@ -41,7 +41,7 @@ private:
void setConBlank(int blank);
void setTimer(void);
timespec getTimer(void);
- int getBrightness(void);
+ string getBrightness(void);
int setBrightness(int brightness);
int setBlankTimer(void);
int setClockTimer(void);
@@ -51,7 +51,7 @@ private:
int conblank;
timespec btimer;
unsigned long long sleepTimer;
- int orig_brightness;
+ string orig_brightness;
bool screenoff;
};
diff --git a/gui/devices/landscape/res/landscape.xml b/gui/devices/landscape/res/landscape.xml
index 902994917..2bed2a578 100644
--- a/gui/devices/landscape/res/landscape.xml
+++ b/gui/devices/landscape/res/landscape.xml
@@ -2589,7 +2589,7 @@
<action function="set">tw_brightness=%tw_brightness_max%</action>
<action function="compute">tw_brightness*%tw_brightness_pct%</action>
<action function="compute">tw_brightness/100</action>
- <action function="cmd">echo %tw_brightness% > &quot;%tw_brightness_file%&quot;</action>
+ <action function="setbrightness">%tw_brightness%</action>
</actions>
</object>
diff --git a/gui/devices/portrait/res/portrait.xml b/gui/devices/portrait/res/portrait.xml
index 6a3618e62..0be685517 100644
--- a/gui/devices/portrait/res/portrait.xml
+++ b/gui/devices/portrait/res/portrait.xml
@@ -2628,7 +2628,7 @@
<action function="set">tw_brightness=%tw_brightness_max%</action>
<action function="compute">tw_brightness*%tw_brightness_pct%</action>
<action function="compute">tw_brightness/100</action>
- <action function="cmd">echo %tw_brightness% > &quot;%tw_brightness_file%&quot;</action>
+ <action function="setbrightness">%tw_brightness%</action>
</actions>
</object>
diff --git a/gui/devices/watch/res/watch.xml b/gui/devices/watch/res/watch.xml
index b4b7062fe..686b24b3f 100644
--- a/gui/devices/watch/res/watch.xml
+++ b/gui/devices/watch/res/watch.xml
@@ -2592,7 +2592,7 @@
<action function="set">tw_brightness=%tw_brightness_max%</action>
<action function="compute">tw_brightness*%tw_brightness_pct%</action>
<action function="compute">tw_brightness/100</action>
- <action function="cmd">echo %tw_brightness% > &quot;%tw_brightness_file%&quot;</action>
+ <action function="setbrightness">%tw_brightness%</action>
</actions>
</object>