mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-27 18:53:51 +08:00
finalise BBUI
This commit is contained in:
@@ -69,6 +69,7 @@ const int viz_w = vwp_w-(bdr_s*2);
|
||||
const int header_h = 420;
|
||||
const int footer_h = 280;
|
||||
const int footer_y = vwp_h-bdr_s-footer_h;
|
||||
const int bdr_is = 30;
|
||||
|
||||
const int UI_FREQ = 30; // Hz
|
||||
|
||||
@@ -1495,6 +1496,42 @@ static void ui_draw_infobar(UIState *s) {
|
||||
nvgText(s->vg, rect_x + 720 + sidebar_offset, rect_y + 35, infobar, NULL);
|
||||
}
|
||||
|
||||
//BB START: functions added for the display of various items
|
||||
static int bb_ui_draw_measure(UIState *s, const char* bb_value, const char* bb_uom, const char* bb_label,
|
||||
int bb_x, int bb_y, int bb_uom_dx,
|
||||
NVGcolor bb_valueColor, NVGcolor bb_labelColor, NVGcolor bb_uomColor,
|
||||
int bb_valueFontSize, int bb_labelFontSize, int bb_uomFontSize ) {
|
||||
const UIScene *scene = &s->scene;
|
||||
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE);
|
||||
int dx = 0;
|
||||
if (strlen(bb_uom) > 0) {
|
||||
dx = (int)(bb_uomFontSize*2.5/2);
|
||||
}
|
||||
//print value
|
||||
nvgFontFace(s->vg, "sans-semibold");
|
||||
nvgFontSize(s->vg, bb_valueFontSize*2.5);
|
||||
nvgFillColor(s->vg, bb_valueColor);
|
||||
nvgText(s->vg, bb_x-dx/2, bb_y+ (int)(bb_valueFontSize*2.5)+5, bb_value, NULL);
|
||||
//print label
|
||||
nvgFontFace(s->vg, "sans-regular");
|
||||
nvgFontSize(s->vg, bb_labelFontSize*2.5);
|
||||
nvgFillColor(s->vg, bb_labelColor);
|
||||
nvgText(s->vg, bb_x, bb_y + (int)(bb_valueFontSize*2.5)+5 + (int)(bb_labelFontSize*2.5)+5, bb_label, NULL);
|
||||
//print uom
|
||||
if (strlen(bb_uom) > 0) {
|
||||
nvgSave(s->vg);
|
||||
int rx =bb_x + bb_uom_dx + bb_valueFontSize -3;
|
||||
int ry = bb_y + (int)(bb_valueFontSize*2.5/2)+25;
|
||||
nvgTranslate(s->vg,rx,ry);
|
||||
nvgRotate(s->vg, -1.5708); //-90deg in radians
|
||||
nvgFontFace(s->vg, "sans-regular");
|
||||
nvgFontSize(s->vg, (int)(bb_uomFontSize*2.5));
|
||||
nvgFillColor(s->vg, bb_uomColor);
|
||||
nvgText(s->vg, 0, 0, bb_uom, NULL);
|
||||
nvgRestore(s->vg);
|
||||
}
|
||||
return (int)((bb_valueFontSize + bb_labelFontSize)*2.5) + 5;
|
||||
}
|
||||
|
||||
static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) {
|
||||
const UIScene *scene = &s->scene;
|
||||
@@ -1675,11 +1712,10 @@ static void ui_draw_vision_footer(UIState *s) {
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
ui_draw_vision_map(s);
|
||||
#endif
|
||||
if (&s->dragon_bbui) {
|
||||
if (s->dragon_bbui) {
|
||||
ui_draw_bbui(s);
|
||||
} else {
|
||||
ui_draw_infobar(s);
|
||||
}
|
||||
ui_draw_infobar(s);
|
||||
}
|
||||
|
||||
static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
|
||||
@@ -2580,6 +2616,7 @@ int main(int argc, char* argv[]) {
|
||||
read_param_bool_timeout(&s->longitudinal_control, "LongitudinalControl", &s->longitudinal_control_timeout);
|
||||
read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout);
|
||||
read_param_float_timeout(&s->speed_lim_off, "SpeedLimitOffset", &s->limit_set_speed_timeout);
|
||||
read_param_bool_timeout(&s->dragon_bbui, "DragonBBUI", &s->dragon_bbui_timeout);
|
||||
|
||||
pthread_mutex_unlock(&s->lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user