void widget_debug_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("free"), x, y); char text[8]; sprintf_P(text, PSTR("%d"), freeRam()); widget_value_int(text, x, y + lh, w, h - lh); }
void widget_temperature_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("Temp"), x, y); char tmp[5], sub[5]; sprintf_P(tmp, PSTR("%d.%d"), fc.temperature / 10, fc.temperature % 10); sprintf_P(sub, PSTR("%d%%"), fc.humidity / 100); widget_value_int_sub(tmp, sub, x, y + lh, w, h - lh); }
void widget_acc_total_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("TotAcc"), x, y); float val = fc.acc.total_gui_filtered; char text[10]; sprintf_P(text, PSTR("%0.1f"), val); widget_value_int(text, x, y + lh, w, h - lh); }
void widget_accx_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("Acc X"), x, y); float val = fc.acc_data.x / 100.0; char text[10]; sprintf_P(text, PSTR("%0.1f"), val); widget_value_int(text, x, y + lh, w, h - lh); }
void widget_flight_time_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("FTime"), x, y); char tmp[7]; if (fc.flight_state == FLIGHT_FLIGHT) { uint32_t diff = (task_get_ms_tick() - fc.flight_timer) / 1000; uint8_t hour, min; hour = diff / 3600; diff %= 3600; min = diff / 60; diff %= 60; if (hour > 0) { sprintf_P(tmp, PSTR("%02d:%02d"), hour, min); } else sprintf_P(tmp, PSTR("%02d.%02d"), min, diff); widget_value_int(tmp, x, y + lh, w, h - lh); } if (fc.flight_state == FLIGHT_LAND) { uint32_t diff = fc.flight_timer / 1000; uint8_t hour, min; hour = diff / 3600; diff %= 3600; min = diff / 60; diff %= 60; if (hour > 0) { sprintf_P(tmp, PSTR("%02d:%02d"), hour, min); } else sprintf_P(tmp, PSTR("%02d.%02d"), min, diff); widget_value_int(tmp, x, y + lh, w, h - lh); } if (fc.flight_state == FLIGHT_WAIT) { sprintf_P(tmp, PSTR("Start")); widget_value_txt(tmp, x, y + lh, w, h - lh); } }
void widget_ghdg_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("GHdg"), x, y); char tmp[5]; if (fc.gps_data.valid) sprintf_P(tmp, PSTR("%0.0f"), fc.gps_data.heading); else sprintf_P(tmp, PSTR("---")); widget_value_int(tmp, x, y + lh, w, h - lh); }
void widget_time_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t sec; uint8_t min; uint8_t hour; time_from_epoch(time_get_local(), &sec, &min, &hour); uint8_t lh = widget_label_P(PSTR("Time"), x, y); char tmp[7]; sprintf_P(tmp, PSTR("%02d:%02d"), hour, min); widget_value_int(tmp, x, y + lh, w, h - lh); }
void widget_gpos_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("GPos"), x, y); if (fc.gps_data.valid) { widget_value_txt2((char *)fc.gps_data.cache_gui_latitude, (char *)fc.gps_data.cache_gui_longtitude, x, y + lh, w, h - lh); } else { char tmp[4]; sprintf_P(tmp, PSTR("---")); widget_value_int(tmp, x, y + lh, w, h - lh); } }
void widget_ghdg_arrow_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("GHdgA"), x, y); y += lh / 2; if (fc.gps_data.valid) { uint8_t s = min(w, h); uint8_t mx = x + w / 2; uint8_t my = y + h / 2; float fsin = disp.get_sin(fc.gps_data.heading); float fcos = disp.get_cos(fc.gps_data.heading); uint8_t x1 = mx + fsin * s / 3; uint8_t y1 = my + fcos * s / 3; uint8_t x2 = mx - fsin * s / 5; uint8_t y2 = my - fcos * s / 5; fsin = disp.get_sin(fc.gps_data.heading + 25); fcos = disp.get_cos(fc.gps_data.heading + 25); uint8_t x3 = mx - fsin * s / 3; uint8_t y3 = my - fcos * s / 3; fsin = disp.get_sin(fc.gps_data.heading + 335); fcos = disp.get_cos(fc.gps_data.heading + 335); uint8_t x4 = mx - fsin * s / 3; uint8_t y4 = my - fcos * s / 3; disp.DrawLine(x1, y1, x3, y3, 1); disp.DrawLine(x2, y2, x3, y3, 1); disp.DrawLine(x2, y2, x4, y4, 1); disp.DrawLine(x1, y1, x4, y4, 1); } else { char tmp[5]; sprintf_P(tmp, PSTR("---")); widget_value_int(tmp, x, y + lh, w, h - lh); } }
void widget_avg_vario_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("Avg"), x, y); float val = fc.avg_vario; if (config.vario.flags & VARIO_UNITS_I) val *= FC_MPS_TO_100FPM; if (abs(val) < 0.09) val = 0; char text[10]; if (fc.baro_valid) sprintf_P(text, PSTR("%0.1f"), val); else sprintf_P(text, PSTR("-.-"), val); widget_value_int(text, x, y + lh, w, h - lh); }
void widget_date_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t sec; uint8_t min; uint8_t hour; uint8_t day; uint8_t wday; uint8_t month; uint16_t year; datetime_from_epoch(time_get_local(), &sec, &min, &hour, &day, &wday, &month, &year); uint8_t lh = widget_label_P(PSTR("Date"), x, y); char tmp[7]; sprintf_P(tmp, PSTR("%02d/%02d"), day, month); widget_value_int(tmp, x, y + lh, w, h - lh); }
void widget_gspd_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("GSpd"), x, y); char tmp[5]; if (fc.gps_data.valid) { float val; switch(config.connectivity.gps_format_flags & GPS_SPD_MASK) { case(GPS_SPD_KPH): val = fc.gps_data.groud_speed * FC_KNOTS_TO_KPH; break; case(GPS_SPD_MS): val = fc.gps_data.groud_speed * FC_KNOTS_TO_MPS; break; case(GPS_SPD_MPH): val = fc.gps_data.groud_speed * FC_KNOTS_TO_MPH; break; case(GPS_SPD_KNOT): val = fc.gps_data.groud_speed; break; } sprintf_P(tmp, PSTR("%0.0f"), val); } else sprintf_P(tmp, PSTR("---")); widget_value_int(tmp, x, y + lh, w, h - lh); }
void widget_gpos_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags) { uint8_t lh = widget_label_P(PSTR("GPos"), x, y); char tmp1[16]; char tmp2[16]; float decimal; float deg; float min; float sec; uint8_t c; if (fc.gps_data.valid) { switch (config.connectivity.gps_format_flags & GPS_FORMAT_MASK) { case(GPS_DDdddddd): sprintf_P(tmp1, PSTR("%+02.6f"), fc.gps_data.latitude); sprintf_P(tmp2, PSTR("%+03.6f"), fc.gps_data.longtitude); break; case(GPS_DDMMmmm): c = (fc.gps_data.latitude < 0) ? 'S' : 'N'; decimal = abs(fc.gps_data.latitude); deg = floor(decimal); min = (decimal - deg) * 60; sprintf_P(tmp1, PSTR("%02.0f*%02.3f%c"), deg, min, c); c = (fc.gps_data.longtitude < 0) ? 'W' : 'E'; decimal = abs(fc.gps_data.longtitude); deg = floor(decimal); min = (decimal - deg) * 60; sprintf_P(tmp2, PSTR("%03.0f*%02.3f%c"), deg, min, c); break; case(GPS_DDMMSS): c = (fc.gps_data.latitude < 0) ? 'S' : 'N'; decimal = abs(fc.gps_data.latitude); deg = floor(decimal); min = floor((decimal - deg) * 60); sec = floor((decimal - deg - min / 60) * 3600); sprintf_P(tmp1, PSTR("%02.0f*%02.0f'%02.0f\"%c"), deg, min, sec, c); c = (fc.gps_data.longtitude < 0) ? 'W' : 'E'; decimal = abs(fc.gps_data.longtitude); deg = floor(decimal); min = floor((decimal - deg) * 60); sec = floor((decimal - deg - min / 60) * 3600); sprintf_P(tmp2, PSTR("%03.0f*%02.0f'%02.0f\"%c"), deg, min, sec, c); break; } widget_value_txt2(tmp1, tmp2, x, y + lh, w, h - lh); } else { sprintf_P(tmp1, PSTR("---")); widget_value_int(tmp1, x, y + lh, w, h - lh); } }