summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulK <contact@paulk.fr>2012-03-26 23:02:06 +0200
committerPaul Kocialkowski <contact@paulk.fr>2012-07-09 00:19:00 +0200
commited2c92540c01ed9d51a25736feb2169cd06ee70b (patch)
tree1a90632c021df3b34639c2e9cb6aaf6068a5de32
parent3dbcaf9b955bbdf85958c705fc61207c5361c085 (diff)
downloaddevice_samsung_aries-common-ed2c92540c01ed9d51a25736feb2169cd06ee70b.zip
device_samsung_aries-common-ed2c92540c01ed9d51a25736feb2169cd06ee70b.tar.gz
device_samsung_aries-common-ed2c92540c01ed9d51a25736feb2169cd06ee70b.tar.bz2
playlpm: added low brightness and various fixes
-rw-r--r--playlpm/playlpm.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/playlpm/playlpm.c b/playlpm/playlpm.c
index dec2691..4dfa0e1 100644
--- a/playlpm/playlpm.c
+++ b/playlpm/playlpm.c
@@ -94,7 +94,8 @@ int lpm_battery_level(void)
int level = -1;
int fd = -1;
- char value[2];
+ int c = -1;
+ char value[3];
char status[6];
fd = open("/sys/class/power_supply/battery/capacity", O_RDONLY);
@@ -104,7 +105,8 @@ int lpm_battery_level(void)
return 0;
}
- read(fd, value, sizeof(value));
+ c = read(fd, value, sizeof(value));
+ value[c] = '\0';
close(fd);
@@ -140,11 +142,37 @@ int lpm_battery_level(void)
return level;
}
+void lpm_backlight_brightness(char *brightness)
+{
+ int fd = -1;
+ int length;
+
+ if(brightness == NULL)
+ {
+ LOGE("brightness isn't set, aborting");
+ return;
+ }
+
+ fd = open("/sys/class/backlight/s5p_bl/brightness", O_WRONLY);
+ if(fd < 0)
+ {
+ LOGE("Failed to open brightness node, aborting");
+ return;
+ }
+
+ length = strlen(brightness);
+
+ LOGD("Setting brightness to: %s", brightness);
+ write(fd, brightness, length);
+
+ close(fd);
+}
+
// This is the main loop function, where we check battery state
void lpm_loop(void)
{
int level = -1;
- int l;
+ int l = -1;
while(1)
{
@@ -152,7 +180,11 @@ void lpm_loop(void)
// Only refresh the image if the battery level changed
if(level != l)
+ {
+ // Setting brightness to a very low level to reduce battery usage while charging
+ lpm_backlight_brightness("5");
lpm_display_level(level);
+ }
l = level;