fixed indentation issues
This commit is contained in:
parent
57ae1fbbed
commit
35ac14a0ea
3 changed files with 28 additions and 15 deletions
29
ambientd.c
29
ambientd.c
|
|
@ -40,7 +40,7 @@ int get_luminance_raw (void)
|
|||
}
|
||||
|
||||
// read a string from a file and convert it to int, should only be used for
|
||||
// positive numbers since negative numbers mean an error
|
||||
// positive numbers since negative numbers mean an error
|
||||
int read_int(FILE *fp)
|
||||
{
|
||||
freopen(NULL, "r", fp);
|
||||
|
|
@ -52,7 +52,7 @@ int read_int(FILE *fp)
|
|||
if (r == LONG_MIN || r == LONG_MAX) {
|
||||
return -1;
|
||||
}
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
|
||||
// TODO: add some command line options like:
|
||||
|
|
@ -128,17 +128,17 @@ int main (void)
|
|||
brightness_old = brightness_target;
|
||||
brightness_target = MAX((int)(luminance_percent * max_brightness), min_brightness);
|
||||
brightness_delta = ABS((float)(brightness_target - brightness_old)/brightness_old);
|
||||
|
||||
|
||||
// if the brightness changes by more than 10% reduce the user offset, scaling
|
||||
// with the delta, this accounts for large changes in brightness no longer
|
||||
// corresponding to the adjustments that the user made to the brightness
|
||||
if (brightness_delta > 0.1) {
|
||||
user_offset = user_offset * MAX(MIN(1-(brightness_delta*1.2), 1), 0);
|
||||
// with the delta, this accounts for large changes in brightness no longer
|
||||
// corresponding to the adjustments that the user made to the brightness
|
||||
if (brightness_delta > 0.1) {
|
||||
user_offset = user_offset * MAX(MIN(1-(brightness_delta*1.2), 1), 0);
|
||||
}
|
||||
|
||||
brightness_adjusted = MIN(MAX(brightness_target + user_offset, min_brightness), max_brightness);
|
||||
brightness_adjusted = MIN(MAX(brightness_target + user_offset, min_brightness), max_brightness);
|
||||
// TODO: put this in write_int() function
|
||||
x = snprintf(STR_BUFFER, sizeof(STR_BUFFER), "%d", brightness_adjusted);
|
||||
x = snprintf(STR_BUFFER, sizeof(STR_BUFFER), "%d", brightness_adjusted);
|
||||
if (x <= 0) {
|
||||
fprintf(stderr, "Error in snprintf(): %s\n", strerror(errno));
|
||||
}
|
||||
|
|
@ -159,14 +159,13 @@ int main (void)
|
|||
}
|
||||
|
||||
off = actual_brightness - brightness_target;
|
||||
if (brightness_target != max_brightness || off < 0){
|
||||
user_offset = off;
|
||||
}
|
||||
if (brightness_target != max_brightness || off < 0){
|
||||
user_offset = off;
|
||||
}
|
||||
|
||||
// TODO: option to turn off logging
|
||||
printf("brightness target: %d; user offset: %d; brightness adjusted: %d\n", brightness_target, user_offset, brightness_adjusted);
|
||||
|
||||
printf("brightness target: %d; user offset: %d; brightness adjusted: %d\n", brightness_target, user_offset, brightness_adjusted);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue