diff options
author | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 18:48:43 +0000 |
---|---|---|
committer | root <root@ka-ata-killa.ourano.james.local> | 2021-03-20 19:01:35 +0000 |
commit | f211fe6461aae73f5ffdbe58961dbe3dd1309854 (patch) | |
tree | a4b698a5146f1ec2584f09db5b7f73f263d6bc4a /app/alarm.c | |
parent | 5b8f47a70a57765ba04a4d75dfa31a2f55f75029 (diff) | |
download | clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.tar.gz clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.tar.bz2 clock-f211fe6461aae73f5ffdbe58961dbe3dd1309854.zip |
make the interval bisection work properly for events in the next hour, add an alarm output
Diffstat (limited to 'app/alarm.c')
-rw-r--r-- | app/alarm.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/alarm.c b/app/alarm.c new file mode 100644 index 0000000..ed503db --- /dev/null +++ b/app/alarm.c @@ -0,0 +1,35 @@ +#include "project.h" + +#define ALARM_LENGTH 30 + +EPOCH alarm; + +static void alarm_off (void) +{ + led5_set (0); +} + + +static void alarm_on (void) +{ + led5_set (1); +} + + + +void alarm_dispatch (void) +{ + uint64_t abs = ref_get(); + EPOCH d, e = ref_decompose (abs); + + d = time_epoch_sub (e, alarm); + + if ((d.s < 0) || (d.s > ALARM_LENGTH)) alarm_off(); + else alarm_on(); +} + + + + + + |