summaryrefslogtreecommitdiffstats
path: root/Smol Watch Project/My Project/main.c
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-05-09 12:19:40 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-05-09 12:19:40 -0400
commit7e9ef16a18ce8dfcb9f2950eb2fb327886d33480 (patch)
tree513556649b3058f5176b82599919ea0ea42e06b9 /Smol Watch Project/My Project/main.c
parent7ff91a2f678a5eb1f6b985a257a8e59bde6a973f (diff)
downloadSensor-Watch-7e9ef16a18ce8dfcb9f2950eb2fb327886d33480.tar.gz
Sensor-Watch-7e9ef16a18ce8dfcb9f2950eb2fb327886d33480.tar.bz2
Sensor-Watch-7e9ef16a18ce8dfcb9f2950eb2fb327886d33480.zip
More low power work
Diffstat (limited to 'Smol Watch Project/My Project/main.c')
-rw-r--r--Smol Watch Project/My Project/main.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/Smol Watch Project/My Project/main.c b/Smol Watch Project/My Project/main.c
index b803fb6d..053840a2 100644
--- a/Smol Watch Project/My Project/main.c
+++ b/Smol Watch Project/My Project/main.c
@@ -11,9 +11,6 @@ void calendar_callback(struct calendar_descriptor *const calendar) {
static void mode_callback() {
local = !local;
- struct calendar_date_time date_time;
- calendar_get_date_time(&CALENDAR_0, &date_time);
- update_display(&watch, date_time, local);
}
static void light_callback() {
@@ -21,7 +18,6 @@ static void light_callback() {
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, local);
}
static void alarm_callback() {
@@ -29,19 +25,29 @@ static void alarm_callback() {
calendar_get_date_time(&CALENDAR_0, &date_time);
date_time.time.sec = 0;
watch_set_date_time(date_time);
- update_display(&watch, date_time, local);
}
static void tick_callback() {
- struct calendar_date_time date_time;
- calendar_get_date_time(&CALENDAR_0, &date_time);
- update_display(&watch, date_time, local);
}
int main(void)
{
atmel_start_init();
+ watch_init(&watch);
+
+ watch_enable_date_time(&watch);
+ struct calendar_date_time date_time;
+ date_time.date.year = 2021;
+ date_time.date.month = 5;
+ date_time.date.day = 8;
+ date_time.time.hour = 19;
+ date_time.time.min = 40;
+ date_time.time.sec = 0;
+ watch_set_date_time(date_time);
+ update_display(&watch, date_time, local);
+ watch_enable_tick(tick_callback);
+
gpio_set_pin_level(RED, false);
gpio_set_pin_direction(RED, GPIO_DIRECTION_OUT);
gpio_set_pin_function(RED, GPIO_PIN_FUNCTION_OFF);
@@ -49,38 +55,19 @@ int main(void)
gpio_set_pin_direction(GREEN, GPIO_DIRECTION_OUT);
gpio_set_pin_function(GREEN, GPIO_PIN_FUNCTION_OFF);
- watch_init(&watch);
-
- watch_enable_display(&watch);
- watch_display_pixel(&watch, 1, 16);
-
watch_enable_buttons(&watch);
watch_register_button_callback(&watch, BTN_MODE, &mode_callback);
watch_register_button_callback(&watch, BTN_ALARM, &alarm_callback);
watch_register_button_callback(&watch, BTN_LIGHT, &light_callback);
- watch_enable_date_time(&watch);
- struct calendar_date_time date_time;
- date_time.date.year = 2021;
- date_time.date.month = 5;
- date_time.date.day = 6;
- date_time.time.hour = 23;
- date_time.time.min = 30;
- date_time.time.sec = 0;
- watch_set_date_time(date_time);
-/* 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;
- calendar_set_alarm(&CALENDAR_0, &alarm, &calendar_callback);
-*/
- update_display(&watch, date_time, local);
- watch_enable_tick(tick_callback);
+ watch_enable_display(&watch);
+ watch_display_pixel(&watch, 1, 16);
while (1) {
sleep(4);
+ struct calendar_date_time date_time;
+ calendar_get_date_time(&CALENDAR_0, &date_time);
+ update_display(&watch, date_time, local);
}
return 0;