aboutsummaryrefslogtreecommitdiffstats
path: root/drv_GLCD2USB.c
diff options
context:
space:
mode:
authorharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-11-19 09:02:34 +0000
committerharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-11-19 09:02:34 +0000
commit4447e1d46ca5cdb1839c9ece0426fd26db1b2817 (patch)
treecccbf2508627696e761b2c88e7f763ac770402ba /drv_GLCD2USB.c
parent3c658ef2174cfbaa5926a6b932ebd967b52aed08 (diff)
downloadlcd4linux-4447e1d46ca5cdb1839c9ece0426fd26db1b2817.tar.gz
Added brightness support for GLCD2USB
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1133 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'drv_GLCD2USB.c')
-rw-r--r--drv_GLCD2USB.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/drv_GLCD2USB.c b/drv_GLCD2USB.c
index e597159..0453bda 100644
--- a/drv_GLCD2USB.c
+++ b/drv_GLCD2USB.c
@@ -397,6 +397,28 @@ static void drv_GLCD2USB_blit(const int row, const int col, const int height, co
}
}
+static int drv_GLCD2USB_brightness(int brightness)
+{
+ int err = 0;
+
+ printf("setting bright to %d\n", brightness);
+
+ if (brightness < 0)
+ brightness = 0;
+ if (brightness > 255)
+ brightness = 255;
+
+ buffer.bytes[0] = GLCD2USB_RID_SET_BL;
+ buffer.bytes[1] = brightness;
+ if((err = usbSetReport(dev, USB_HID_REPORT_TYPE_FEATURE, buffer.bytes, 2)) != 0) {
+ error("%s: Error freeing display: %s\n", Name, usbErrorMessage(err));
+ usbCloseDevice(dev);
+ return -1;
+ }
+
+ return brightness;
+}
+
static void drv_GLCD2USB_timer(void __attribute__ ((unused)) * notused)
{
/* request button state */
@@ -424,6 +446,7 @@ static void drv_GLCD2USB_timer(void __attribute__ ((unused)) * notused)
static int drv_GLCD2USB_start(const char *section)
{
+ int brightness;
char *s;
int err = 0, len;
@@ -493,6 +516,10 @@ static int drv_GLCD2USB_start(const char *section)
/* buffers button presses internally */
timer_add(drv_GLCD2USB_timer, NULL, 100, 0);
+ if (cfg_number(section, "Brightness", 0, 0, 255, &brightness) > 0) {
+ drv_GLCD2USB_brightness(brightness);
+ }
+
return 0;
}
@@ -502,8 +529,13 @@ static int drv_GLCD2USB_start(const char *section)
/*** plugins ***/
/****************************************/
-/* none at the moment... */
+static void plugin_brightness(RESULT * result, RESULT * arg1)
+{
+ double brightness;
+ brightness = drv_GLCD2USB_brightness(R2N(arg1));
+ SetResult(&result, R_NUMBER, &brightness);
+}
/****************************************/
/*** widget callbacks ***/
@@ -565,8 +597,7 @@ int drv_GLCD2USB_init(const char *section, const __attribute__ ((unused))
return ret;
/* register plugins */
- /* none at the moment... */
-
+ AddFunction("LCD::brightness", 1, plugin_brightness);
return 0;
}