mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-24 20:53:07 +01:00
Actualize PageAutopilot
This commit is contained in:
@@ -940,8 +940,8 @@ void generatorGraphic(uint x, uint y, int pcolor, int bcolor){
|
|||||||
getdisplay().print("G");
|
getdisplay().print("G");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display rudder position as horizontal bargraph +/-30 degrees
|
// Display rudder position as horizontal bargraph with configurable +/- range (degrees)
|
||||||
void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_t fg, uint16_t bg){
|
void displayRudderPosition(int rudderPosition, uint8_t rangeDeg, uint16_t cx, uint16_t cy, uint16_t fg, uint16_t bg){
|
||||||
const int w = 360;
|
const int w = 360;
|
||||||
const int h = 20;
|
const int h = 20;
|
||||||
const int t = 3; // Line thickness
|
const int t = 3; // Line thickness
|
||||||
@@ -951,8 +951,12 @@ void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_
|
|||||||
int left = int(cx) - halfw;
|
int left = int(cx) - halfw;
|
||||||
int top = int(cy) - halfh;
|
int top = int(cy) - halfh;
|
||||||
|
|
||||||
// Pixels per degree for +/-30° -> 60° span
|
// clamp provided range to allowed bounds [10,45]
|
||||||
const float pxPerDeg = float(w) / 60.0f; // =5.0
|
if (rangeDeg < 10) rangeDeg = 10;
|
||||||
|
if (rangeDeg > 45) rangeDeg = 45;
|
||||||
|
|
||||||
|
// Pixels per degree for +/-rangeDeg -> total span = 2*rangeDeg
|
||||||
|
const float pxPerDeg = float(w) / (2.0f * float(rangeDeg));
|
||||||
|
|
||||||
// Draw outer border (thickness t)
|
// Draw outer border (thickness t)
|
||||||
for (int i = 0; i < t; i++) {
|
for (int i = 0; i < t; i++) {
|
||||||
@@ -962,9 +966,9 @@ void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_
|
|||||||
// Fill inner area with background
|
// Fill inner area with background
|
||||||
getdisplay().fillRect(left + t, top + t, w - 2 * t, h - 2 * t, bg);
|
getdisplay().fillRect(left + t, top + t, w - 2 * t, h - 2 * t, bg);
|
||||||
|
|
||||||
// Clamp rudder position to -30..30
|
// Clamp rudder position to -rangeDeg..rangeDeg
|
||||||
if (rudderPosition > 30) rudderPosition = 30;
|
if (rudderPosition > (int)rangeDeg) rudderPosition = (int)rangeDeg;
|
||||||
if (rudderPosition < -30) rudderPosition = -30;
|
if (rudderPosition < -((int)rangeDeg)) rudderPosition = -((int)rangeDeg);
|
||||||
|
|
||||||
// Compute fill width in pixels
|
// Compute fill width in pixels
|
||||||
int fillPx = int(round(rudderPosition * pxPerDeg)); // positive -> right
|
int fillPx = int(round(rudderPosition * pxPerDeg)); // positive -> right
|
||||||
@@ -984,7 +988,7 @@ void displayRudderPosition(int rudderPosition, uint16_t cx, uint16_t cy, uint16_
|
|||||||
// Draw tick marks every 5° and labels outside the bar
|
// Draw tick marks every 5° and labels outside the bar
|
||||||
getdisplay().setTextColor(fg);
|
getdisplay().setTextColor(fg);
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
for (int angle = -30; angle <= 30; angle += 5) {
|
for (int angle = -((int)rangeDeg); angle <= (int)rangeDeg; 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 + 2, fg);
|
getdisplay().drawLine(xpos, top, xpos, top + h + 2, fg);
|
||||||
|
|||||||
@@ -128,8 +128,9 @@ void solarGraphic(uint x, uint y, int pcolor, int bcolor); // S
|
|||||||
void generatorGraphic(uint x, uint y, int pcolor, int bcolor); // Generator graphic
|
void generatorGraphic(uint x, uint y, int pcolor, int bcolor); // Generator graphic
|
||||||
void startLedTask(GwApi *api);
|
void startLedTask(GwApi *api);
|
||||||
|
|
||||||
// Display rudder position as horizontal bargraph +/-30 degrees
|
// Display rudder position as horizontal bargraph with configurable +/- range (degrees)
|
||||||
void displayRudderPosition(int rudderPosition, uint16_t x, uint16_t y, uint16_t fg, uint16_t bg);
|
// 'rangeDeg' is unsigned and will be clamped to [10,45]
|
||||||
|
void displayRudderPosition(int rudderPosition, uint8_t rangeDeg, uint16_t x, uint16_t y, uint16_t fg, uint16_t bg);
|
||||||
|
|
||||||
void doImageRequest(GwApi *api, int *pageno, const PageStruct pages[MAX_PAGE_NUMBER], AsyncWebServerRequest *request);
|
void doImageRequest(GwApi *api, int *pageno, const PageStruct pages[MAX_PAGE_NUMBER], AsyncWebServerRequest *request);
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ 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);
|
displayRudderPosition(12, 20, 200, 160, commonData->fgcolor, commonData->bgcolor);
|
||||||
|
|
||||||
return PAGE_UPDATE;
|
return PAGE_UPDATE;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user