macro to write brightness
This commit is contained in:
parent
9ba6ed6136
commit
4bb263c961
1 changed files with 12 additions and 9 deletions
21
ambientd.c3
21
ambientd.c3
|
|
@ -74,9 +74,18 @@ fn void! write_int(String path, int value)
|
|||
fp.write(b)!;
|
||||
}
|
||||
|
||||
// returns the luminance value in percentage between 0 and 1
|
||||
// returns the raw luminance value
|
||||
macro get_luminance_raw() { return read_int(LUMINANCE_DEV); }
|
||||
|
||||
// write the brightness value, on fail log on stderr
|
||||
macro write_brightness(int b)
|
||||
{
|
||||
anyfault e = @catch(write_int(BRIGHTNESS_DEV, b));
|
||||
if (e) {
|
||||
io::eprintfn("Error writing brightness: %s", e);
|
||||
}
|
||||
}
|
||||
|
||||
fn float bezier(float t)
|
||||
{
|
||||
const float B = 0.66;
|
||||
|
|
@ -164,16 +173,10 @@ fn int main()
|
|||
if (brightness_now == brightness_adjusted) { return; }
|
||||
int step = (brightness_adjusted-brightness_now)/(SMOOTH_SAMPLES-1);
|
||||
for (int i; i < SMOOTH_SAMPLES-1; i++) {
|
||||
anyfault e = @catch(write_int(BRIGHTNESS_DEV, brightness_now + step*i));
|
||||
if (e) {
|
||||
io::eprintfn("Error writing brightness: %s", e);
|
||||
}
|
||||
write_brightness(brightness_now + step*i);
|
||||
thread::sleep_ms(SMOOTH_DURATION/SMOOTH_SAMPLES);
|
||||
}
|
||||
anyfault e = @catch(write_int(BRIGHTNESS_DEV, brightness_adjusted));
|
||||
if (e) {
|
||||
io::eprintfn("Error writing brightness: %s", e);
|
||||
}
|
||||
write_brightness(brightness_adjusted);
|
||||
|};
|
||||
|
||||
thread::sleep_ms(SLEEP_DELAY);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue