void Display::update_all() { update_arm(); update_prearm(); update_gps(); update_gps_sats(); update_ekf(); }
void Display::update_all() { update_text(0); update_mode(1); update_battery(2); update_gps(3); //update_gps_sats(4); update_prearm(4); update_ekf(5); }
static gboolean gps_periodic(gpointer data __attribute__ ((unused))) { if (gps_waiting (gpsdata, 500)) { if (gps_read (gpsdata) == -1) { perror("gps read error"); } else { update_gps(gpsdata, NULL, 0); } } return TRUE; }
void command_get_gps() { update_gps(); printf_P( PSTR("GPS : %04i-%02i-%02i %02i:%02i:%02i.%03i (%s) [offset %i]\n"), gps_data.dt.year, gps_data.dt.month, gps_data.dt.date, gps_data.dt.hour, gps_data.dt.minute, gps_data.dt.second, gps_data.dt.millisecond, rtc_dow_names[gps_data.dt.day_of_week], gps_leap_second_offset); }
static gboolean gps_periodic(gpointer data __attribute__ ((unused))) { if (gps_waiting (gpsdata, 500)) { if (gps_read (gpsdata) == -1) { perror("gps read error"); //exit 2; //ret = 2; //running = false; } else { update_gps(gpsdata, NULL, 0); } } }
void Display::update() { static uint8_t timer = 0; // return immediately if not enabled if (!_healthy) { return; } // max update frequency 2Hz if (timer++ < 25) { return; } timer = 0; // check if status has changed if (_flags.armed != AP_Notify::flags.armed) { update_arm(); _flags.armed = AP_Notify::flags.armed; } if (_flags.pre_arm_check != AP_Notify::flags.pre_arm_check) { update_prearm(); _flags.pre_arm_check = AP_Notify::flags.pre_arm_check; } if (_flags.gps_status != AP_Notify::flags.gps_status) { update_gps(); _flags.gps_status = AP_Notify::flags.gps_status; } if (_flags.gps_num_sats != AP_Notify::flags.gps_num_sats) { update_gps_sats(); _flags.gps_num_sats = AP_Notify::flags.gps_num_sats; } if (_flags.ekf_bad != AP_Notify::flags.ekf_bad) { update_ekf(); _flags.ekf_bad = AP_Notify::flags.ekf_bad; } // if somethings has changed, update display if (_need_update) { hw_update(); _need_update = false; } }
void command_set_from_gps(void) { uint8_t rc; if(update_gps()) return; if(gps_data.gps_signal_strength < 3) { printf_P(PSTR("GPS signal strength (%d) is unreliable. Aborting sync!\n"), gps_data.gps_signal_strength); return; } if(gps_data.dt.second < (59 - gps_leap_second_offset)) { /* Adjust to the edge of the next second, don't deal with rollover */ printf_P(PSTR("Sleeping for %d ms to synchronize...\n"), 1000 - gps_data.dt.millisecond - 1); wait_ms(1000 - gps_data.dt.millisecond - 1); gps_data.dt.second += 1 + gps_leap_second_offset; gps_data.dt.millisecond = 0; } rc = rtc_clock_stop(rtc); printf_P(PSTR("Halted clock, rc=%i\n"), rc); rtc_sqw_enable(rtc); rtc_sqw_rate(rtc, 1); printf_P(PSTR("Setting time to %04i-%02i-%02i %02i:%02i:%02i (%s)\n"), gps_data.dt.year, gps_data.dt.month, gps_data.dt.date, gps_data.dt.hour, gps_data.dt.minute, gps_data.dt.second, rtc_dow_names[gps_data.dt.day_of_week]); printf_P(PSTR("Trying to write RTC...\n")); rc = rtc_write(rtc, &gps_data.dt); printf_P(PSTR("Wrote RTC, rc=%i\n"), rc); rc = rtc_clock_start(rtc); printf_P(PSTR("Started clock, rc=%i\n"), rc); }
/** * Update the "h", "m", and "s" sequences, optionally queuing an animation * into "H" or "M" sequences, depending on the new time. This function is * called once per second during the main loop after the interrupt triggered * by the time change marks update_hms_ready. * * The "h", "m", and "s" sequences are updated in-place in order to avoid * additional work and possible memory fragmentation from removing and * re-enqueuing the applicable LED. */ void update_hms(void) { uint8_t rc; rtc_datetime_24h_t offset_time; if(++time_elapsed_since_gps_sync > 1777) { printf_P(PSTR("Maximum time limit exceeded since last GPS sync, syncing...\n")); command_set_from_gps(); time_elapsed_since_gps_sync = 0; } rc = rtc_read(rtc, ¤t_time); if(rc) return; rtc_offset_time(¤t_time, &offset_time, configuration.tz_offset + configuration.dst_offset); if(current_time.hour != last_hour) { configuration.dst_offset = rtc_find_dst_offset(offset_time, usa_dst_dates); rtc_offset_time(¤t_time, &offset_time, configuration.tz_offset + configuration.dst_offset); } led_sequencer_halt(); /* * If the second has changed since the last time the time was checked, * we should update the "second", "minute, and "hour" sequences. In practice * this is nearly always the case, since the interrupts ensure we're only * really called when needed. */ if(current_time.second != last_second) { led_sequencer_sequence_modify_step(step_second, led_mapping_minute[offset_time.second], 255); led_sequencer_sequence_modify_step(step_minute, led_mapping_minute[offset_time.minute], 255); led_sequencer_sequence_modify_step(step_hour, led_mapping_qhour[((offset_time.hour % 12) * 4) + (offset_time.minute / 15)], 255); enqueue_secondly_show(); last_second = current_time.second; } /* Do something nice for New Years */ if(offset_time.month == 1 && offset_time.date == 1 && offset_time.hour == 0 && offset_time.minute == 0 && offset_time.second == 0) { enqueue_nye_show(); last_hour = current_time.hour; last_minute = current_time.minute; } /* * If the hour has changed, enqueue the hourly show. */ else if(current_time.hour != last_hour) { enqueue_hourly_show(); last_hour = current_time.hour; } /* * If the hour is still the same, enqueue the minutely show. */ else if(current_time.minute != last_minute) { enqueue_minutely_show(); last_minute = current_time.minute; } led_sequencer_run(); update_gps(); write_remote_lcd(&offset_time, gps_data.gps_signal_strength); }