aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-02-08 16:18:49 +0530
committerAkshay Nair <phenax5@gmail.com>2026-02-08 16:18:49 +0530
commit20d86bf1e3dfdfb4c0a3ea557b54f0bea0f5c214 (patch)
tree86a7a23ac0b49bb9ff6d29f6c6f5e45209d42d94 /src/main.c
parenteef689b2e209dcf84c149ee4866c2a007676dc71 (diff)
downloaddaft-watch-20d86bf1e3dfdfb4c0a3ea557b54f0bea0f5c214.tar.gz
daft-watch-20d86bf1e3dfdfb4c0a3ea557b54f0bea0f5c214.zip
Handle button state
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index cf6f7a8..6f621af 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <util/delay.h>
+#include "button.h"
#include "display.h"
#include "rtc.h"
@@ -15,17 +16,14 @@ FUSES = {
.extended = 0xff,
};
-// Display
-// timer 0 has lower priority than timer 1, so some ticks could get skipped due
-// to interrupt starvation
+// Display interrupt
+// Timer 0 has lower priority than timer 1, so some ticks could get skipped on
+// interrupt starvation
ISR(TIM0_COMPA_vect, ISR_FLATTEN) { display_render(); }
// RTC interrupt
ISR(TIM1_COMPA_vect, ISR_FLATTEN) { rtc_increment(); }
-#define IS_BUTTON_ON() ((PINA & (1 << PA0)) == 0)
-#define ENABLE_BUTTON() (DDRA &= ~(1 << PA0))
-
int main(void) {
PRR = 0b0011; // Power reduction register. Shut down USI and ADC
@@ -35,20 +33,16 @@ int main(void) {
sei();
while (1) {
- // ENABLE_BUTTON();
- // if (IS_BUTTON_ON()) {
- // cli();
- // ENABLE_BUTTON();
- // _delay_ms(25); // Debounced
- // if (IS_BUTTON_ON()) {
- // seconds += 1;
- // sei();
- // _delay_ms(50);
- // continue;
- // }
+ // switch (button_tick()) {
+ // case BUTTON_PRESSED:
+ // seconds += 5;
+ // break;
+ // case BUTTON_LONG_PRESSED:
+ // seconds += 10;
+ // break;
+ // default:
+ // break;
// }
- // sei();
-
#ifdef STUBBED
stub_run_timers();
_delay_ms(100);