aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2016-07-15 14:09:29 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2016-07-15 14:10:51 +1200
commit09de14168c9c5b406a738116ab656f6e12a3fb30 (patch)
treef28aa0720afd784761d3c0825d5b9373e198ee28
parentb198e32600ff3ea8c16d0e627d12e6fdc963be6e (diff)
downloadbrightnessd-09de14168c9c5b406a738116ab656f6e12a3fb30.tar.xz
Remove stale code, add (messy) correction measure for over-stepping target
-rw-r--r--brightnessd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/brightnessd.c b/brightnessd.c
index c808759..893caad 100644
--- a/brightnessd.c
+++ b/brightnessd.c
@@ -23,7 +23,6 @@ int target; // int because overflow checky checky woo yay blah
int now;
FILE *f;
-
int brightness_within_bounds(int bright, int lower, int upper)
{
// to do: make a horrible but funny ternary statement
@@ -57,7 +56,6 @@ int main(int argc, char **argv)
// FIXME : check return val
int fifo = open(FIFO_PATH, O_RDWR);
- FILE *fifo_k = fopen(FIFO_PATH, "w");
struct pollfd fds[1];
@@ -87,19 +85,21 @@ int main(int argc, char **argv)
}
target = brightness_within_bounds(target, 1, 255);
}
- if (now < target)
+ if (now < target) {
now += STEP;
- else if (now > target)
+ if (now > target)
+ now = target;
+ } else if (now > target) {
now -= STEP;
- else if (now == target)
+ if (now < target)
+ now = target;
+ } else if (now == target) {
delay = -1;
-
- now = brightness_within_bounds(now, 1, 255);
+ }
fprintf(f, "%d\n", now);
rewind(f);
}
- // Do I need this?
close(fifo);
remove(FIFO_PATH);
return 0;