static const struct telem_layout2 *_get_telem_layout2() { const struct telem_layout2 *page; if (TELEMETRY_Type() == TELEM_DEVO) page = &devo_page[current_page]; else if (TELEMETRY_Type() == TELEM_DSM) page = &dsm_page[current_page]; else page = &frsky_page[current_page]; return page; }
static void _press_cb(guiObject_t *obj, const void *data) { (void)obj; (void)data; current_page = current_page == telemetry_gps?telemetry_basic: telemetry_gps; _show_page(TELEMETRY_Type() == TELEM_DEVO ? &devo_page[current_page] : &dsm_page[current_page]); }
void PAGE_TelemtestEvent() { if (current_page == telemetry_off) return; struct Telemetry cur_telem = Telemetry; int current_row = GUI_ScrollableCurrentRow(&gui->scrollable); int visible_rows = GUI_ScrollableVisibleRows(&gui->scrollable); const struct telem_layout *ptr = TELEMETRY_Type() == TELEM_DEVO ? devo_page[current_page].layout : dsm_page[current_page].layout; for (long i = 0; ptr->source; ptr++, i++) { if ((ptr->row_type & 0x0f) < current_row) continue; if ((ptr->row_type & 0x0f) >= current_row + visible_rows) break; if (!( ptr->row_type & 0x80)) continue; long cur_val = _TELEMETRY_GetValue(&cur_telem, ptr->source); long last_val = _TELEMETRY_GetValue(&tp->telem, ptr->source); struct LabelDesc *font; font = &TELEM_FONT; if (cur_val != last_val) { GUI_Redraw(&gui->box[i]); } else if(! TELEMETRY_IsUpdated(ptr->source)) { font = &TELEM_ERR_FONT; } GUI_SetLabelDesc(&gui->box[i], font); } tp->telem = cur_telem; }
const char * TELEMETRY_GetValueStrByValue(char *str, u8 telem, s32 value) { int h, m, s, ss; switch(telem) { case TELEM_GPS_LONG: h = value / 1000 / 60 / 60; m = (value - h * 1000 * 60 * 60) / 1000 / 60; s = (value - h * 1000 * 60 * 60 - m * 1000 * 60) / 1000; ss = value % 1000; sprintf(str, "%03d %02d %02d.%03d", h, m, s, ss); break; case TELEM_GPS_LAT: h = value / 1000 / 60 / 60; m = (value - h * 1000 * 60 * 60) / 1000 / 60; s = (value - h * 1000 * 60 * 60 - m * 1000 * 60) / 1000; ss = value % 1000; sprintf(str, "%03d %02d %02d.%03d", h, m, s, ss); break; case TELEM_GPS_ALT: if (Transmitter.telem & TELEMUNIT_FEET) { value = value * 328 / 100; sprintf(str, "%d.%03dft", (int)value / 1000, (int)value % 1000); } else { sprintf(str, "%d.%03dm", (int)value / 1000, (int)value % 1000); } break; case TELEM_GPS_SPEED: if (Transmitter.telem & TELEMUNIT_FEET) { value = value * 2237 / 1000; sprintf(str, "%d.%02dmph", (int)value / 1000, (int)(value / 10) % 100); } else { sprintf(str, "%d.%03dm/s", (int)value / 1000, (int)value % 1000); } break; case TELEM_GPS_TIME: { int year = 2000 + (((u32)Telemetry.gps.time >> 26) & 0x3F); int month = ((u32)Telemetry.gps.time >> 22) & 0x0F; int day = ((u32)Telemetry.gps.time >> 17) & 0x1F; int hour = ((u32)Telemetry.gps.time >> 12) & 0x1F; int min = ((u32)Telemetry.gps.time >> 6) & 0x3F; int sec = ((u32)Telemetry.gps.time >> 0) & 0x3F; sprintf(str, "%02d:%02d:%02d %04d-%02d-%02d", hour, min, sec, year, month, day); break; } default: return TELEMETRY_Type() == TELEM_DEVO ? _devo_str_by_value(str, telem, value) : _dsm_str_by_value(str, telem, value); } return str; }
void PAGE_TelemtestInit(int page) { (void)okcancel_cb; (void)page; PAGE_SetModal(0); PAGE_SetActionCB(_action_cb); if (telem_state_check() == 0) { current_page = telemetry_off; GUI_CreateLabelBox(&gui->msg, 20, 10, 0, 0, &DEFAULT_FONT, NULL, NULL, tempstring); return; } _show_page(TELEMETRY_Type() == TELEM_DEVO ? &devo_page[current_page] : &dsm_page[current_page]); }
const char * TELEMETRY_ShortName(char *str, u8 telem) { switch(telem) { case TELEM_GPS_LONG: strcpy(str, _tr("Longitude")); break; case TELEM_GPS_LAT: strcpy(str, _tr("Latitude")); break; case TELEM_GPS_ALT: strcpy(str, _tr("Altitude")); break; case TELEM_GPS_SPEED: strcpy(str, _tr("Speed")); break; case TELEM_GPS_TIME: strcpy(str, _tr("Time")); break; default: return TELEMETRY_Type() == TELEM_DEVO ? _devo_short_name(str, telem) : _dsm_short_name(str, telem); } return str; }
s32 _TELEMETRY_GetValue(struct Telemetry *t, int idx) { switch (idx) { case TELEM_GPS_LONG: return t->gps.longitude; case TELEM_GPS_LAT: return t->gps.latitude; case TELEM_GPS_ALT: return t->gps.altitude; case TELEM_GPS_SPEED: return t->gps.velocity; case TELEM_GPS_TIME: return t->gps.time; } return TELEMETRY_Type() == TELEM_DEVO ? _devo_value(t, idx) : _dsm_value(t, idx); }
s32 TELEMETRY_GetMaxValue(u8 telem) { return TELEMETRY_Type() == TELEM_DEVO ? _devo_get_max_value(telem) : _dsm_get_max_value(telem); }
const char * TELEMETRY_Name(char *str, u8 telem) { return (TELEMETRY_Type() == TELEM_DEVO) ? _devo_name(str, telem) : _dsm_name(str, telem); }