diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-05-02 23:31:07 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-05-02 23:31:07 -0400 |
commit | 471bdc60c0d38459702888c722a10f2ed1a8379b (patch) | |
tree | 2e50fa4bc051d3b5e8eef0abd021e7a80ca64f88 /Smol Watch Project/My Project/main.c | |
parent | 88a38cc2352c2bd0ad2733093796f3d424ebcc9c (diff) | |
download | Sensor-Watch-471bdc60c0d38459702888c722a10f2ed1a8379b.tar.gz Sensor-Watch-471bdc60c0d38459702888c722a10f2ed1a8379b.tar.bz2 Sensor-Watch-471bdc60c0d38459702888c722a10f2ed1a8379b.zip |
sunday low power work
Diffstat (limited to 'Smol Watch Project/My Project/main.c')
-rw-r--r-- | Smol Watch Project/My Project/main.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/Smol Watch Project/My Project/main.c b/Smol Watch Project/My Project/main.c index 45bb5dc0..3af1ed07 100644 --- a/Smol Watch Project/My Project/main.c +++ b/Smol Watch Project/My Project/main.c @@ -4,47 +4,49 @@ #include "mars_clock.h" Watch watch; -int light = 1; +bool locked = true; void calendar_callback(struct calendar_descriptor *const calendar) { - struct calendar_date_time date_time; - calendar_get_date_time(&CALENDAR_0, &date_time); - - update_display(&watch, date_time); -/* - if (date_time.time.min % 2 == 0) { - watch_set_led_color(50, 0); - } else { - watch_set_led_color(0, 50); - } -*/ } static void mode_callback() { + locked = !locked; + gpio_set_pin_level(GREEN, !locked); } static void light_callback() { + if (locked) return; + struct calendar_date_time date_time; + calendar_get_date_time(&CALENDAR_0, &date_time); + date_time.time.min = (date_time.time.min + 1) % 60; + watch_set_date_time(date_time); + update_display(&watch, date_time); } static void alarm_callback() { + if (locked) return; + struct calendar_date_time date_time; + calendar_get_date_time(&CALENDAR_0, &date_time); + date_time.time.sec = 0; + watch_set_date_time(date_time); + update_display(&watch, date_time); } -int lightOn = 0; - static void tick_callback() { - gpio_set_pin_level(GREEN, lightOn == 0); - lightOn = (lightOn + 1) % 10; + struct calendar_date_time date_time; + calendar_get_date_time(&CALENDAR_0, &date_time); + update_display(&watch, date_time); } int main(void) { atmel_start_init(); + gpio_set_pin_level(RED, false); + gpio_set_pin_direction(RED, GPIO_DIRECTION_OUT); + gpio_set_pin_function(RED, GPIO_PIN_FUNCTION_OFF); gpio_set_pin_level(GREEN, false); - - // Set pin direction to output gpio_set_pin_direction(GREEN, GPIO_DIRECTION_OUT); - gpio_set_pin_function(GREEN, GPIO_PIN_FUNCTION_OFF); watch_init(&watch); @@ -59,25 +61,26 @@ int main(void) watch_enable_date_time(&watch); struct calendar_date_time date_time; - date_time.date.year = 2021; - date_time.date.month = 4; - date_time.date.day = 30; - date_time.time.hour = 9; - date_time.time.min = 40; + date_time.date.year = 1; // reference year is 2020, add this to that. + date_time.date.month = 5; + date_time.date.day = 2; + date_time.time.hour = 7; + date_time.time.min = 15; date_time.time.sec = 0; watch_set_date_time(date_time); - struct calendar_alarm alarm; +/* struct calendar_alarm alarm; alarm.cal_alarm.mode = REPEAT; alarm.cal_alarm.datetime = date_time; alarm.cal_alarm.datetime.time.sec = 0; alarm.cal_alarm.option = CALENDAR_ALARM_MATCH_SEC; alarm.callback = calendar_callback; - update_display(&watch, date_time); calendar_set_alarm(&CALENDAR_0, &alarm, &calendar_callback); +*/ + update_display(&watch, date_time); watch_enable_tick(tick_callback); while (1) { - sleep(2); + sleep(4); } return 0; |