taler-mdb

GNU Taler Extensions and Integrations
Log | Files | Refs | Submodules | README | LICENSE

commit a7b2536c88432536abc17994bc33201825dd8630
parent 2ac834c6cc52fe90fb419a0a657e4652254ab929
Author: Boss Marco <bossm8@students.bfh.ch>
Date:   Sat, 16 Nov 2019 14:42:00 +0100

backlight on/off added

Diffstat:
Msrc/main.c | 32+++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -54,6 +54,8 @@ along with #include <sys/ioctl.h> #include <fcntl.h> #include <linux/fb.h> +#include <linux/gpio.h> + /** * Disable i18n support. @@ -146,6 +148,8 @@ struct Display { int devicefd; + int backlightfd; + uint16_t *memory; struct fb_var_screeninfo orig_vinfo; @@ -262,14 +266,18 @@ show_qrcode (const char *uri) unsigned int xoff = x * nwidth / size; unsigned int yoff = y * nwidth / size; unsigned int off = xoff + yoff * qrc->width; - if ( (xoff >= qrc->width) || - (yoff >= qrc->width) ) + if ( (xoff >= (unsigned) qrc->width) || + (yoff >= (unsigned) qrc->width) ) continue; qrDisplay.memory[(y + yOff) * qrDisplay.var_info.xres + (x + xOff)] = (0 == (qrc->data[off] & 1)) ? 0xFFFF : 0x0000; } + QRcode_free (qrc); QRinput_free (qri); + + if (0 < qrDisplay.backlightfd) + write (qrDisplay.backlightfd, "1", 1); } #endif @@ -299,7 +307,8 @@ cleanup_payment (struct PaymentActivity *pa) 0xFF, qrDisplay.var_info.xres * qrDisplay.var_info.yres * sizeof (uint16_t)); - /* FIXME: dimm background light of display */ + if (0 < qrDisplay.backlightfd) + write (qrDisplay.backlightfd, "0", 1); #endif GNUNET_free (pa->taler_pay_uri); } @@ -1069,6 +1078,23 @@ run (void *cls, "failed to map display memory\n"); return; } + + memset (qrDisplay.memory, + 0xFF, + qrDisplay.var_info.xres * qrDisplay.var_info.yres + * sizeof (uint16_t)); + + qrDisplay.backlightfd = open ( + "/sys/class/backlight/soc:backlight/brightness", O_WRONLY); + if (0 > qrDisplay.backlightfd) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "failed to load \"/sys/class/backlight/soc:backlight/brightness\", display backlight will not be changed\n"); + } + else + { + write (qrDisplay.backlightfd, "0", 1); + } } else {