mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-24 20:53:07 +01:00
Implement rudder bargraf in PageAutopilot
This commit is contained in:
@@ -942,7 +942,7 @@ void generatorGraphic(uint x, uint y, int pcolor, int bcolor){
|
|||||||
|
|
||||||
// Display rudder position as horizontal bargraph +/-30 degrees
|
// Display rudder position as horizontal bargraph +/-30 degrees
|
||||||
void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_t fg, uint16_t bg){
|
void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_t fg, uint16_t bg){
|
||||||
const int w = 300;
|
const int w = 360;
|
||||||
const int h = 20;
|
const int h = 20;
|
||||||
const int t = 3; // Line thickness
|
const int t = 3; // Line thickness
|
||||||
const int halfw = w/2;
|
const int halfw = w/2;
|
||||||
@@ -987,15 +987,14 @@ void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_
|
|||||||
for (int angle = -30; angle <= 30; angle += 5) {
|
for (int angle = -30; angle <= 30; angle += 5) {
|
||||||
int xpos = int(round(centerx + angle * pxPerDeg));
|
int xpos = int(round(centerx + angle * pxPerDeg));
|
||||||
// Vertical tick inside bar
|
// Vertical tick inside bar
|
||||||
getdisplay().drawLine(xpos, top, xpos, top + h, fg);
|
getdisplay().drawLine(xpos, top, xpos, top + h + 2, fg);
|
||||||
// Label outside: below the bar
|
// Label outside: below the bar
|
||||||
String lbl = String(angle);
|
String lbl = String(angle);
|
||||||
lbl += "\u00B0"; // Degree symbol
|
|
||||||
int16_t bx, by;
|
int16_t bx, by;
|
||||||
uint16_t bw, bh;
|
uint16_t bw, bh;
|
||||||
getdisplay().getTextBounds(lbl, 0, 0, &bx, &by, &bw, &bh);
|
getdisplay().getTextBounds(lbl, 0, 0, &bx, &by, &bw, &bh);
|
||||||
int16_t tx = xpos - bw/2;
|
int16_t tx = xpos - bw/2;
|
||||||
int16_t ty = top + h + bh + 2; // A little spacing
|
int16_t ty = top + h + bh + 5; // A little spacing
|
||||||
getdisplay().setCursor(tx, ty);
|
getdisplay().setCursor(tx, ty);
|
||||||
getdisplay().print(lbl);
|
getdisplay().print(lbl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ const int ShowDTW = 7;
|
|||||||
const int ShowBTW = 8;
|
const int ShowBTW = 8;
|
||||||
|
|
||||||
const int Compass_X0 = 200; // X center point of compass band
|
const int Compass_X0 = 200; // X center point of compass band
|
||||||
const int Compass_Y0 = 220; // Y position of compass lines
|
const int Compass_Y0 = 90; // Y position of compass lines
|
||||||
const int Compass_LineLength = 22; // Length of compass lines
|
//const int Compass_LineLength = 22; // Length of compass lines
|
||||||
|
const int Compass_LineLength = 15; // Length of compass lines
|
||||||
const float Compass_LineDelta = 8.0;// Compass band: 1deg = 5 Pixels, 10deg = 50 Pixels
|
const float Compass_LineDelta = 8.0;// Compass band: 1deg = 5 Pixels, 10deg = 50 Pixels
|
||||||
|
|
||||||
class PageAutopilot : public Page
|
class PageAutopilot : public Page
|
||||||
@@ -38,8 +39,11 @@ class PageAutopilot : public Page
|
|||||||
|
|
||||||
virtual void setupKeys(){
|
virtual void setupKeys(){
|
||||||
Page::setupKeys();
|
Page::setupKeys();
|
||||||
commonData->keydata[0].label = "CMP";
|
commonData->keydata[0].label = "-10";
|
||||||
commonData->keydata[1].label = "SRC";
|
commonData->keydata[1].label = "-1";
|
||||||
|
commonData->keydata[2].label = "Auto";
|
||||||
|
commonData->keydata[3].label = "+1";
|
||||||
|
commonData->keydata[4].label = "+10";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
@@ -106,15 +110,13 @@ class PageAutopilot : public Page
|
|||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
setFlashLED(false);
|
setFlashLED(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bvalue == NULL) return PAGE_OK; // WTF why this statement?
|
|
||||||
|
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
||||||
// Set display in partial refresh mode
|
// Set display in partial refresh mode
|
||||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
||||||
getdisplay().setTextColor(commonData->fgcolor);
|
getdisplay().setTextColor(commonData->fgcolor);
|
||||||
|
/*
|
||||||
// Horizontal line 2 pix top & bottom
|
// Horizontal line 2 pix top & bottom
|
||||||
// Print data on top half
|
// Print data on top half
|
||||||
getdisplay().fillRect(0, 130, 400, 2, commonData->fgcolor);
|
getdisplay().fillRect(0, 130, 400, 2, commonData->fgcolor);
|
||||||
@@ -138,7 +140,7 @@ class PageAutopilot : public Page
|
|||||||
OldDataText[WhichDataDisplay] = DataText[WhichDataDisplay]; // Save the old value
|
OldDataText[WhichDataDisplay] = DataText[WhichDataDisplay]; // Save the old value
|
||||||
OldDataUnits[WhichDataDisplay] = DataUnits[WhichDataDisplay]; // Save the old unit
|
OldDataUnits[WhichDataDisplay] = DataUnits[WhichDataDisplay]; // Save the old unit
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Now draw compass band
|
// Now draw compass band
|
||||||
// Get the data
|
// Get the data
|
||||||
double TheAngle = DataValue[WhichDataCompass];
|
double TheAngle = DataValue[WhichDataCompass];
|
||||||
@@ -152,13 +154,13 @@ class PageAutopilot : public Page
|
|||||||
buffer[0]=0;
|
buffer[0]=0;
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().setCursor(10, Compass_Y0-60);
|
getdisplay().setCursor(10, Compass_Y0-40);
|
||||||
getdisplay().print(DataName[WhichDataCompass]); // Page name
|
getdisplay().print(DataName[WhichDataCompass]); // Page name
|
||||||
|
|
||||||
|
|
||||||
// Draw compass base line and pointer
|
// Draw compass base line and pointer
|
||||||
getdisplay().fillRect(0, Compass_Y0, 400, 3, commonData->fgcolor);
|
getdisplay().fillRect(0, Compass_Y0, 400, 3, commonData->fgcolor);
|
||||||
getdisplay().fillTriangle(Compass_X0,Compass_Y0-40,Compass_X0-10,Compass_Y0-80,Compass_X0+10,Compass_Y0-80,commonData->fgcolor);
|
//getdisplay().fillTriangle(Compass_X0,Compass_Y0-40,Compass_X0-10,Compass_Y0-80,Compass_X0+10,Compass_Y0-80,commonData->fgcolor);
|
||||||
|
getdisplay().fillTriangle(Compass_X0,Compass_Y0-30,Compass_X0-10,Compass_Y0-60,Compass_X0+10,Compass_Y0-60,commonData->fgcolor);
|
||||||
// Draw trendlines
|
// Draw trendlines
|
||||||
for ( int i = 1; i < abs(TheTrend) / 2; i++){
|
for ( int i = 1; i < abs(TheTrend) / 2; i++){
|
||||||
int x1;
|
int x1;
|
||||||
@@ -238,6 +240,8 @@ class PageAutopilot : public Page
|
|||||||
// if ( x_test > 390)
|
// if ( x_test > 390)
|
||||||
// x_test = 320;
|
// x_test = 320;
|
||||||
|
|
||||||
|
displayRudderPosition(12, 200, 160, commonData->fgcolor, commonData->bgcolor);
|
||||||
|
|
||||||
return PAGE_UPDATE;
|
return PAGE_UPDATE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user