Skip to content

Commit

Permalink
smaller int range for memory stack
Browse files Browse the repository at this point in the history
  • Loading branch information
mcguirepr89 committed Oct 21, 2024
1 parent 0e42b9d commit 52e3247
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
31 changes: 15 additions & 16 deletions movement/watch_faces/complication/sunrise_sunset_alt_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ static void check_and_update_sunriset(double event_type, watch_date_time *event_
}
}

static void display_time(watch_date_time *time, const char *prefix, movement_settings_t *settings, watch_date_time *date_time, sunrise_sunset_alt_state_t *state) {
static void display_time(watch_date_time *time, const char *prefix, movement_settings_t *settings, sunrise_sunset_alt_state_t *state) {
bool set_leading_zero = false;
char buf[14];

watch_set_colon();
// Handle 12-hour mode and PM indicator
if (!settings->bit.clock_mode_24h) {
if (watch_utility_convert_to_12_hour(time)) {
Expand Down Expand Up @@ -157,7 +158,6 @@ static void sunrise_sunset_alt_face_update(movement_settings_t *settings, sunris
civil_twilight(scratch_time.unit.year + WATCH_RTC_REFERENCE_YEAR, scratch_time.unit.month, scratch_time.unit.day, lon, lat, &civ_start, &civ_end);
nautical_twilight(scratch_time.unit.year + WATCH_RTC_REFERENCE_YEAR, scratch_time.unit.month, scratch_time.unit.day, lon, lat, &naut_start, &naut_end);

watch_set_colon();
if (settings->bit.clock_mode_24h && !settings->bit.clock_24h_leading_zero) watch_set_indicator(WATCH_INDICATOR_24H);

naut_start += hours_from_utc;
Expand All @@ -175,37 +175,37 @@ static void sunrise_sunset_alt_face_update(movement_settings_t *settings, sunris
check_and_update_sunriset(naut_end, &naut_end_time, utc_now, date_time);

SolarEvent events[] = {
{naut_start_time.reg, &naut_start_time, "naut_start_time", "nt"},
{civ_start_time.reg, &civ_start_time, "civ_start_time", "cI"},
{rise_time.reg, &rise_time, "rise_time", "rI"},
{set_time.reg, &set_time, "set_time", "SE"},
{civ_end_time.reg, &civ_end_time, "civ_end_time", "cI"},
{naut_end_time.reg, &naut_end_time, "naut_end_time", "nt"}
{naut_start_time.reg, &naut_start_time, "nt"},
{civ_start_time.reg, &civ_start_time, "cI"},
{rise_time.reg, &rise_time, "rI"},
{set_time.reg, &set_time, "SE"},
{civ_end_time.reg, &civ_end_time, "cI"},
{naut_end_time.reg, &naut_end_time, "nt"}
};

int n = sizeof(events) / sizeof(events[0]);
uint8_t n = sizeof(events) / sizeof(events[0]);

// Sort the array of events
qsort(events, n, sizeof(SolarEvent), compare);

switch (state->rise_index) {
case 0:
display_time(events[0].event, events[0].abreviation, settings, &date_time, state);
display_time(events[0].event, events[0].abreviation, settings, state);
break;
case 1:
display_time(events[1].event, events[1].abreviation, settings, &date_time, state);
display_time(events[1].event, events[1].abreviation, settings, state);
break;
case 2:
display_time(events[2].event, events[2].abreviation, settings, &date_time, state);
display_time(events[2].event, events[2].abreviation, settings, state);
break;
case 3:
display_time(events[3].event, events[3].abreviation, settings, &date_time, state);
display_time(events[3].event, events[3].abreviation, settings, state);
break;
case 4:
display_time(events[4].event, events[4].abreviation, settings, &date_time, state);
display_time(events[4].event, events[4].abreviation, settings, state);
break;
case 5:
display_time(events[5].event, events[5].abreviation, settings, &date_time, state);
display_time(events[5].event, events[5].abreviation, settings, state);
break;
default:
break;
Expand Down Expand Up @@ -430,7 +430,6 @@ bool sunrise_sunset_alt_face_loop(movement_event_t event, movement_settings_t *s
sunrise_sunset_alt_face_update_settings_display(event, context);
} else {
state->rise_index = (state->rise_index + 1) % 6;
printf("state->rise_index = %d\n", state->rise_index);
sunrise_sunset_alt_face_update(settings, state);
}
break;
Expand Down
3 changes: 1 addition & 2 deletions movement/watch_faces/complication/sunrise_sunset_alt_face.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ typedef struct {
} sunrise_sunset_alt_state_t;

typedef struct {
int timestamp;
uint32_t timestamp;
watch_date_time *event;
const char *name;
const char *abreviation;
} SolarEvent;

Expand Down

0 comments on commit 52e3247

Please sign in to comment.