diff --git a/movement_faces.h b/movement_faces.h index 0ac1545e..63d65bc9 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -50,4 +50,5 @@ #include "chirpy_demo_face.h" #include "finetune_face.h" #include "nanosec_face.h" +#include "mars_time_face.h" // New includes go above this line. diff --git a/watch-faces.mk b/watch-faces.mk index 8a9d29c8..182e54fd 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -2,6 +2,7 @@ SRCS += \ ./watch-faces/clock/clock_face.c \ ./watch-faces/clock/beats_face.c \ ./watch-faces/clock/world_clock_face.c \ + ./watch-faces/clock/mars_time_face.c \ ./watch-faces/complication/alarm_face.c \ ./watch-faces/complication/advanced_alarm_face.c \ ./watch-faces/complication/countdown_face.c \ diff --git a/legacy/watch_faces/clock/mars_time_face.c b/watch-faces/clock/mars_time_face.c similarity index 86% rename from legacy/watch_faces/clock/mars_time_face.c rename to watch-faces/clock/mars_time_face.c index 5c55cd19..2d068263 100644 --- a/legacy/watch_faces/clock/mars_time_face.c +++ b/watch-faces/clock/mars_time_face.c @@ -31,25 +31,25 @@ // note: lander coordinates come from Mars24's `marslandmarks.xml` file static double site_longitudes[MARS_TIME_NUM_SITES] = { 0, // Mars Coordinated Time, at the meridian - 360.0 - 109.9, // Zhurong lander site 360.0 - 77.45088572, // Perseverance lander site - 360.0 - 135.623447, // InSight lander site 360.0 - 137.441635, // Curiosity lander site }; -static char site_names[MARS_TIME_NUM_SITES][3] = { +static char site_names_classic[MARS_TIME_NUM_SITES][3] = { "MC", - "ZH", "PE", - "IN", "CU", }; +static char site_names_custom[MARS_TIME_NUM_SITES][4] = { + "MTC", + "PER", + "CUR", +}; + static uint16_t landing_sols[MARS_TIME_NUM_SITES] = { 0, - 52387, 52304, - 51511, 49269, }; @@ -68,8 +68,8 @@ static void _h_to_hms(mars_clock_hms_t *date_time, double h) { } static void _update(mars_time_state_t *state) { - char buf[11]; - watch_date_time_t date_time = watch_rtc_get_date_time(); + char buf[8]; + watch_date_time_t date_time = movement_get_local_date_time(); uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()); // TODO: I'm skipping over some steps here. // https://www.giss.nasa.gov/tools/mars24/help/algorithm.html @@ -88,22 +88,25 @@ static void _update(mars_time_state_t *state) { lmt = fmod(lmst + 24, 24); } + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, site_names_custom[state->current_site], site_names_classic[state->current_site]); + if (state->displaying_sol) { // TODO: this is not right, mission sol should turn over at midnight local time? uint16_t sol = floor(msd) - landing_sols[state->current_site]; - if (sol < 1000) sprintf(&buf[0], "%s Sol%3d", site_names[state->current_site], sol); - else sprintf(&buf[0], "%s $%6d", site_names[state->current_site], sol); + sprintf(buf, "%6d", sol); + watch_display_text(WATCH_POSITION_TOP_RIGHT, " $"); + watch_display_text(WATCH_POSITION_BOTTOM, buf); watch_clear_colon(); watch_clear_indicator(WATCH_INDICATOR_24H); } else { mars_clock_hms_t mars_time; _h_to_hms(&mars_time, lmt); - sprintf(&buf[0], "%s %02d%02d%02d", site_names[state->current_site], mars_time.hour, mars_time.minute, mars_time.second); + sprintf(buf, "%02d%02d%02d", mars_time.hour, mars_time.minute, mars_time.second); + watch_display_text(WATCH_POSITION_TOP_RIGHT, " "); + watch_display_text(WATCH_POSITION_BOTTOM, buf); watch_set_colon(); watch_set_indicator(WATCH_INDICATOR_24H); } - - watch_display_string(buf, 0); } void mars_time_face_setup(uint8_t watch_face_index, void ** context_ptr) { diff --git a/legacy/watch_faces/clock/mars_time_face.h b/watch-faces/clock/mars_time_face.h similarity index 98% rename from legacy/watch_faces/clock/mars_time_face.h rename to watch-faces/clock/mars_time_face.h index ddb43e64..8895c056 100644 --- a/legacy/watch_faces/clock/mars_time_face.h +++ b/watch-faces/clock/mars_time_face.h @@ -55,9 +55,7 @@ typedef enum { MARS_TIME_MERIDIAN, - MARS_TIME_ZHURONG_SITE, MARS_TIME_PERSEVERANCE_SITE, - MARS_TIME_INSIGHT_SITE, MARS_TIME_CURIOSITY_SITE, MARS_TIME_NUM_SITES, } mars_time_site_t;