Skip to content

Commit

Permalink
Turn LCD backlight on and off as appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 27, 2019
1 parent cd4a4e6 commit c35d327
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions marquee-displaydaemon.c
Expand Up @@ -578,6 +578,16 @@ static SDL_bool iterate(void)
return SDL_TRUE;
}

static void set_backlight(const SDL_bool value)
{
// we don't care if any of this fails.
FILE *io = fopen("/sys/class/backlight/rpi_backlight/bl_power", "w");
if (io) {
fputs(value ? "0" : "1", io); // yes, this looks backwards.
fclose(io);
}
}

static void deinitialize(void)
{
#if USE_DBUS
Expand Down Expand Up @@ -630,6 +640,8 @@ static void deinitialize(void)
}

SDL_Quit();

set_backlight(SDL_FALSE);
}

static SDL_Texture *build_keyboard_texture(void)
Expand Down Expand Up @@ -852,6 +864,8 @@ static SDL_bool initialize(const int argc, char **argv)
SDL_RenderPresent(renderer);
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);

set_backlight(SDL_TRUE);

/* on some systems, your window doesn't show up until the event queue gets pumped. */
SDL_Event e;
while (SDL_PollEvent(&e)) {
Expand Down

0 comments on commit c35d327

Please sign in to comment.