diff options
Diffstat (limited to 'Smol Watch Project/My Project/main.c')
-rw-r--r-- | Smol Watch Project/My Project/main.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Smol Watch Project/My Project/main.c b/Smol Watch Project/My Project/main.c new file mode 100644 index 00000000..27f77317 --- /dev/null +++ b/Smol Watch Project/My Project/main.c @@ -0,0 +1,48 @@ +#include <atmel_start.h> +#include "watch-library/watch.h" + +int main(void) +{ + atmel_start_init(); + + Watch watch; + struct calendar_date_time date_time; + date_time.date.year = 2021; + date_time.date.month = 4; + date_time.date.day = 25; + date_time.time.hour = 4; + date_time.time.min = 0; + date_time.time.sec = 0; + + watch_init(&watch); + watch_enable_led(); + watch_enable_date_time(); + watch_set_date_time(date_time); + watch_enable_digital_output(A0); + gpio_set_pin_level(A0, true); + watch_enable_i2c(); + + uint8_t chipID = 0; + uint8_t ChipIdRegister = 0xD0; + watch_i2c_send(0x77, &ChipIdRegister, 1); + watch_i2c_receive(0x77, &chipID, 1); + if (chipID == 0x60) { + watch_set_led_green(); + } + + uint8_t last = date_time.time.sec; + + while (1) { + watch_get_date_time(&date_time); + if (date_time.time.sec != last) { + last = date_time.time.sec; + if (last % 2 == 0) { + watch_set_led_red(); + } else { + watch_set_led_green(); + } + } + } + + return 0; +} |