Fix autobahn segment display and calculation
This commit is contained in:
parent
72acf9f585
commit
64cb33ba67
|
@ -69,7 +69,7 @@ class PageAutobahn : public Page{
|
||||||
String backlightMode = config->getString(config->backlight);
|
String backlightMode = config->getString(config->backlight);
|
||||||
|
|
||||||
String trackStep = config->getString(config->trackStep);
|
String trackStep = config->getString(config->trackStep);
|
||||||
double seg_deg = trackStep.toFloat(); // degrees per display segment
|
double seg_step = trackStep.toFloat() * PI / 180;
|
||||||
|
|
||||||
// Optical warning by limit violation (unused)
|
// Optical warning by limit violation (unused)
|
||||||
if(String(flashLED) == "Limit Violation"){
|
if(String(flashLED) == "Limit Violation"){
|
||||||
|
@ -136,20 +136,26 @@ class PageAutobahn : public Page{
|
||||||
getdisplay().setCursor(360-w, 257);
|
getdisplay().setCursor(360-w, 257);
|
||||||
getdisplay().print(sval_btw);
|
getdisplay().print(sval_btw);
|
||||||
|
|
||||||
|
bool valid = bv_cog->valid && bv_btw->valid;
|
||||||
|
|
||||||
// autobahn view
|
// autobahn view
|
||||||
|
|
||||||
// draw ship symbol (as bitmap)
|
// draw ship symbol (as bitmap)
|
||||||
getdisplay().drawXBitmap(184, 68, ship_bits, ship_width, ship_height, pixelcolor);
|
getdisplay().drawXBitmap(184, 68, ship_bits, ship_width, ship_height, pixelcolor);
|
||||||
|
|
||||||
// draw next waypoint name
|
// draw next waypoint name
|
||||||
String sval_wpname = "Tonne 122";
|
String sval_wpname = "no data";
|
||||||
|
|
||||||
|
if (valid) {
|
||||||
|
sval_wpname = "Tonne 122";
|
||||||
|
}
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold10pt7b);
|
getdisplay().setFont(&Ubuntu_Bold10pt7b);
|
||||||
getdisplay().getTextBounds(sval_wpname, 0, 150, &x, &y, &w, &h);
|
getdisplay().getTextBounds(sval_wpname, 0, 150, &x, &y, &w, &h);
|
||||||
// TODO if text don't fix use smaller font size.
|
// TODO if text don't fix use smaller font size.
|
||||||
// if smallest size does not fit use 2 lines
|
// if smallest size does not fit use 2 lines
|
||||||
// last resort: clip with ellipsis
|
// last resort: clip with ellipsis
|
||||||
getdisplay().setCursor(200 - w / 2, 60);
|
getdisplay().setCursor(200 - w / 2, 60);
|
||||||
|
|
||||||
getdisplay().print(sval_wpname);
|
getdisplay().print(sval_wpname);
|
||||||
|
|
||||||
// draw course segments
|
// draw course segments
|
||||||
|
@ -161,21 +167,26 @@ class PageAutobahn : public Page{
|
||||||
diff -= 360;
|
diff -= 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
// default all segments activated
|
// as default all segments activated if valid calculation
|
||||||
bool seg[6] = {true, true, true, true, true, true};
|
// values are available
|
||||||
|
bool seg[6]; // segment layout: [2][1][0] | [3][4][5]
|
||||||
|
for (int i=0; i<6; i++) {
|
||||||
|
seg[i] = valid;
|
||||||
|
}
|
||||||
|
|
||||||
// number of inactive segments
|
// number of inactive segments
|
||||||
int nseg = std::min(static_cast<int>(std::floor(std::abs(diff) / seg_deg)), 5);
|
int nseg = std::min(static_cast<int>(std::floor(std::abs(diff) / seg_step)), 5);
|
||||||
|
|
||||||
int order[6];
|
int order[6];
|
||||||
if (diff < 0) {
|
if (diff > 0) {
|
||||||
// right
|
// right
|
||||||
order[0] = 6; order[1] = 5; order[2] = 4;
|
order[0] = 3; order[1] = 4; order[2] = 5;
|
||||||
order[3] = 1; order[4] = 2; order[5] = 3;
|
order[3] = 0; order[4] = 1; order[5] = 2;
|
||||||
}
|
}
|
||||||
else if (diff > 0) {
|
else if (diff < 0) {
|
||||||
// left
|
// left
|
||||||
order[0] = 3; order[1] = 2; order[2] = 1;
|
order[0] = 0; order[1] = 1; order[2] = 2;
|
||||||
order[3] = 4; order[4] = 5; order[5] = 6;
|
order[3] = 3; order[4] = 4; order[5] = 5;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (nseg > 0) {
|
while (nseg > 0) {
|
||||||
|
@ -185,13 +196,13 @@ class PageAutobahn : public Page{
|
||||||
}
|
}
|
||||||
|
|
||||||
// left segments
|
// left segments
|
||||||
drawSegment(0, 54, 46, 24, 75, 24, 0, 90, pixelcolor, seg[0]);
|
drawSegment(0, 54, 46, 24, 75, 24, 0, 90, pixelcolor, seg[2]);
|
||||||
drawSegment(0, 100, 82, 24, 112, 24, 50, 100, pixelcolor, seg[1]);
|
drawSegment(0, 100, 82, 24, 112, 24, 50, 100, pixelcolor, seg[1]);
|
||||||
drawSegment(60, 100, 117, 24, 147, 24, 110, 100, pixelcolor,seg[2]);
|
drawSegment(60, 100, 117, 24, 147, 24, 110, 100, pixelcolor,seg[0]);
|
||||||
// right segments
|
// right segments
|
||||||
drawSegment(399, 54, 354, 24, 325, 24, 399, 90, pixelcolor, seg[3]);
|
drawSegment(340, 100, 283, 24, 253, 24, 290, 100, pixelcolor, seg[3]);
|
||||||
drawSegment(399, 100, 318, 24, 289, 24, 350, 100, pixelcolor, seg[4]);
|
drawSegment(399, 100, 318, 24, 289, 24, 350, 100, pixelcolor, seg[4]);
|
||||||
drawSegment(340, 100, 283, 24, 253, 24, 290, 100, pixelcolor, seg[5]);
|
drawSegment(399, 54, 354, 24, 325, 24, 399, 90, pixelcolor, seg[5]);
|
||||||
|
|
||||||
// Key Layout
|
// Key Layout
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||||
|
|
Loading…
Reference in New Issue