event type / subsecond refactor
This commit is contained in:
@@ -17,16 +17,15 @@ void simple_clock_widget_activate(LauncherSettings *settings, void *context) {
|
||||
*((uint32_t *)context) = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, uint8_t subsecond, void *context) {
|
||||
void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, void *context) {
|
||||
printf("simple_clock_widget_loop\n");
|
||||
(void) subsecond;
|
||||
const char weekdays[7][3] = {"SA", "SU", "MO", "TU", "WE", "TH", "FR"};
|
||||
char buf[11];
|
||||
uint8_t pos;
|
||||
|
||||
watch_date_time date_time;
|
||||
uint32_t previous_date_time;
|
||||
switch (event) {
|
||||
switch (event.bit.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
case EVENT_TICK:
|
||||
case EVENT_SCREENSAVER:
|
||||
@@ -34,11 +33,11 @@ void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, u
|
||||
previous_date_time = *((uint32_t *)context);
|
||||
*((uint32_t *)context) = date_time.reg;
|
||||
|
||||
if (date_time.reg >> 6 == previous_date_time >> 6 && event != EVENT_SCREENSAVER) {
|
||||
if (date_time.reg >> 6 == previous_date_time >> 6 && event.bit.event_type != EVENT_SCREENSAVER) {
|
||||
// everything before seconds is the same, don't waste cycles setting those segments.
|
||||
pos = 8;
|
||||
sprintf(buf, "%02d", date_time.unit.second);
|
||||
} else if (date_time.reg >> 12 == previous_date_time >> 12 && event != EVENT_SCREENSAVER) {
|
||||
} else if (date_time.reg >> 12 == previous_date_time >> 12 && event.bit.event_type != EVENT_SCREENSAVER) {
|
||||
// everything before minutes is the same.
|
||||
pos = 6;
|
||||
sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second);
|
||||
@@ -55,7 +54,7 @@ void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, u
|
||||
if (date_time.unit.hour == 0) date_time.unit.hour = 12;
|
||||
}
|
||||
pos = 0;
|
||||
if (event == EVENT_SCREENSAVER) {
|
||||
if (event.bit.event_type == EVENT_SCREENSAVER) {
|
||||
sprintf(buf, "%s%2d%2d%02d ", weekdays[simple_clock_widget_get_weekday(date_time.unit.year, date_time.unit.month, date_time.unit.day)], date_time.unit.day, date_time.unit.hour, date_time.unit.minute);
|
||||
} else {
|
||||
sprintf(buf, "%s%2d%2d%02d%02d", weekdays[simple_clock_widget_get_weekday(date_time.unit.year, date_time.unit.month, date_time.unit.day)], date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
void simple_clock_widget_setup(LauncherSettings *settings, void ** context_ptr);
|
||||
void simple_clock_widget_activate(LauncherSettings *settings, void *context);
|
||||
void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, uint8_t subsecond, void *context);
|
||||
void simple_clock_widget_loop(LauncherEvent event, LauncherSettings *settings, void *context);
|
||||
void simple_clock_widget_resign(LauncherSettings *settings, void *context);
|
||||
|
||||
uint8_t simple_clock_widget_get_weekday(uint16_t day, uint16_t month, uint16_t year);
|
||||
|
||||
Reference in New Issue
Block a user