aboutsummaryrefslogtreecommitdiff
path: root/src/backlight.c
blob: 5ff2555a42aa82324a87d42fb202c1143b160d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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);
}

void backlight_off(void) {
	if (curr_brightness == 0) return;

	write_to_backlight(0);
}