diff options
| author | spv <spv@spv.sh> | 2025-09-21 00:07:50 -0400 |
|---|---|---|
| committer | spv <spv@spv.sh> | 2025-09-21 00:08:43 -0400 |
| commit | 38d25483657e82eb546ecb8566214f830efba461 (patch) | |
| tree | b9568debc69bffc2595df42266c5550cdf05f3d2 /src/backlight.c | |
| parent | 9ddf37ad959faaca72f1634dc61439cdd3c585f1 (diff) | |
refactoring ftw (now w/ README updates!)
Diffstat (limited to 'src/backlight.c')
| -rw-r--r-- | src/backlight.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/backlight.c b/src/backlight.c new file mode 100644 index 0000000..0824f0b --- /dev/null +++ b/src/backlight.c @@ -0,0 +1,28 @@ +#include "common.h" +#include "config.h" + +static uint32_t curr_brightness; +static FILE* backlight_fp; + +void write_to_backlight(int brightness) { + if (!backlight_fp) { + backlight_fp = fopen(BACKLIGHT_FILE, "w"); + } + + fprintf(backlight_fp, "%d", brightness); + fflush(backlight_fp); + + curr_brightness = brightness; +} + +void backlight_on(void) { + write_to_backlight(MAX_BRIGHTNESS); + + usleep(BACKLIGHT_TIME); +} + +void backlight_off(void) { + if (curr_brightness == 0) return; + + write_to_backlight(0); +} |
