if (*context_ptr == NULL) {
*context_ptr = malloc(sizeof(day_night_percentage_state_t));
day_night_percentage_state_t *state = (day_night_percentage_state_t *)*context_ptr;
- watch_date_time utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60, 0);
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0);
recalculate(utc_now, state);
}
}
char buf[12];
watch_date_time date_time = watch_rtc_get_date_time();
- watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0);
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0);
switch (event.event_type) {
case EVENT_ACTIVATE:
static void _update(movement_settings_t *settings, mars_time_state_t *state) {
char buf[11];
watch_date_time date_time = watch_rtc_get_date_time();
- uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ 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
double jdut = 2440587.5 + ((double)now / 86400.0);
/* Determine current time at time zone and store date/time */
date_time = watch_rtc_get_date_time();
- timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
date_time = watch_utility_date_time_from_unix_time(timestamp, movement_timezone_offsets[state->current_zone] * 60);
previous_date_time = state->previous_date_time;
state->previous_date_time = date_time.reg;
#endif
watch_date_time date_time = watch_rtc_get_date_time();
- uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
date_time = watch_utility_date_time_from_unix_time(timestamp, 0);
double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
/* Return time zone offset */
static inline int32_t _get_tz_offset(movement_settings_t *settings)
{
- return movement_timezone_offsets[settings->bit.time_zone] * 60;
+ return movement_get_current_timezone_offset();
}
/* Beep for a button press*/
state->period_today = 0;
state->current_page = 0;
state->reset_tracking = 0;
- state->utc_offset = movement_timezone_offsets[settings->bit.time_zone] * 60;
+ state->utc_offset = movement_get_current_timezone_offset();
movement_request_tick_frequency(4); // we need to manually blink some pixels
}
(void)state;
char buf[11];
watch_date_time date_time = watch_rtc_get_date_time();
- uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60) + offset;
- date_time = watch_utility_date_time_from_unix_time(now, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()) + offset;
+ date_time = watch_utility_date_time_from_unix_time(now, movement_get_current_timezone_offset());
double currentfrac = fmod(now - FIRST_MOON, LUNAR_SECONDS) / LUNAR_SECONDS;
double currentday = currentfrac * LUNAR_DAYS;
uint8_t phase_index = 0;
static void _orrery_face_recalculate(movement_settings_t *settings, orrery_state_t *state) {
watch_date_time date_time = watch_rtc_get_date_time();
- uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
date_time = watch_utility_date_time_from_unix_time(timestamp, 0);
double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
double et = astro_convert_jd_to_julian_millenia_since_j2000(jd);
state->no_location = false;
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
- watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
watch_date_time scratch_time; // scratchpad, contains different values at different times
watch_date_time midnight;
scratch_time.reg = midnight.reg = utc_now.reg;
double lon = (double)lon_centi / 100.0;
// save UTC offset
- state->utc_offset = ((double)movement_timezone_offsets[settings->bit.time_zone]) / 60.0;
+ state->utc_offset = ((double)movement_get_current_timezone_offset()) / 3600.0;
// calculate sunrise and sunset of current day in decimal hours after midnight
sun_rise_set(scratch_time.unit.year + WATCH_RTC_REFERENCE_YEAR, scratch_time.unit.month, scratch_time.unit.day, lon, lat, &sunrise, &sunset);
// get current time
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
- watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
current_hour_epoch = watch_utility_date_time_to_unix_time(utc_now, 0);
// set the current planetary hour as default screen
state->no_location = false;
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
- watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
watch_date_time scratch_time; // scratchpad, contains different values at different times
watch_date_time midnight;
scratch_time.reg = midnight.reg = utc_now.reg;
double lon = (double)lon_centi / 100.0;
// save UTC offset
- state->utc_offset = ((double)movement_timezone_offsets[settings->bit.time_zone]) / 60.0;
+ state->utc_offset = ((double)movement_get_current_timezone_offset()) / 3600.0;
// get UNIX epoch time
now_epoch = watch_utility_date_time_to_unix_time(utc_now, 0);
watch_set_colon();
// get current time and convert to UTC
- state->scratch = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60, 0);
+ state->scratch = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0);
// when current phase ends calculate the next phase
if ( watch_utility_date_time_to_unix_time(state->scratch, 0) >= state->phase_end ) {
#define DEFAULT_MINUTES { 5,4,1,0,0,0 }
static inline int32_t get_tz_offset(movement_settings_t *settings) {
- return movement_timezone_offsets[settings->bit.time_zone] * 60;
+ return movement_get_current_timezone_offset();
}
static int lap = 0;
static void calculate_datetimes(solstice_state_t *state, movement_settings_t *settings) {
for (int i = 0; i < 4; i++) {
// TODO: handle DST changes
- state->datetimes[i] = jde_to_date_time(calculate_solstice_equinox(2020 + state->year, i) + (movement_timezone_offsets[settings->bit.time_zone] / (60.0*24.0)));
+ state->datetimes[i] = jde_to_date_time(calculate_solstice_equinox(2020 + state->year, i) + (movement_get_current_timezone_offset() / (3600.0*24.0)));
}
}
}
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
- watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60, 0); // the current date / time in UTC
+ watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
watch_date_time scratch_time; // scratchpad, contains different values at different times
scratch_time.reg = utc_now.reg;
// sunriset returns the rise/set times as signed decimal hours in UTC.
// this can mean hours below 0 or above 31, which won't fit into a watch_date_time struct.
// to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time.
- double hours_from_utc = ((double)movement_timezone_offsets[settings->bit.time_zone]) / 60.0;
+ double hours_from_utc = ((double)movement_get_current_timezone_offset()) / 3600.0;
// we loop twice because if it's after sunset today, we need to recalculate to display values for tomorrow.
for(int i = 0; i < 2; i++) {
static uint8_t _beeps_to_play; // temporary counter for ring signals playing
static inline int32_t _get_tz_offset(movement_settings_t *settings) {
- return movement_timezone_offsets[settings->bit.time_zone] * 60;
+ return movement_get_current_timezone_offset();
}
static void _signal_callback() {
static uint8_t break_min = 5;
static inline int32_t get_tz_offset(movement_settings_t *settings) {
- return movement_timezone_offsets[settings->bit.time_zone] * 60;
+ return movement_get_current_timezone_offset();
}
static uint8_t get_length(tomato_state_t *state) {
}
static inline uint32_t totp_compute_base_timestamp(movement_settings_t *settings) {
- return watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60);
+ return watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset());
}
void totp_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
}
#endif
- totp_state->timestamp = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_timezone_offsets[settings->bit.time_zone] * 60);
+ totp_state->timestamp = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset());
totp_face_set_record(totp_state, 0);
}
accelerometer_data_acquisition_record_t record;
watch_date_time date_time = watch_rtc_get_date_time();
- state->starting_timestamp = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
+ state->starting_timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
record.header.info.record_type = ACCELEROMETER_DATA_ACQUISITION_HEADER;
record.header.info.range = ACCELEROMETER_RANGE;
record.header.info.temperature = lis2dw_get_temperature();
sprintf(buf,
"%s %3d%02d ",
set_time_hackwatch_face_titles[current_page],
- (int8_t)(movement_timezone_offsets[settings->bit.time_zone] / 60),
- (int8_t)(movement_timezone_offsets[settings->bit.time_zone] % 60) * (movement_timezone_offsets[settings->bit.time_zone] < 0 ? -1 : 1));
+ (int8_t)(movement_get_current_timezone_offset() / 3600),
+ (int8_t)(movement_get_current_timezone_offset() % 3600) * (movement_get_current_timezone_offset() < 0 ? -1 : 1));
}
}