From dd76586ebe5b7efa98c48f145fa3a6809f2c38d0 Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Sun, 27 Mar 2022 17:14:46 +0200 Subject: [PATCH] Triangle trend indicator for voltage page --- lib/obp60task/OBP60ExtensionPort.cpp | 10 ++++++++++ lib/obp60task/OBP60ExtensionPort.h | 3 +++ lib/obp60task/PageVoltage.cpp | 17 +++++++---------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/obp60task/OBP60ExtensionPort.cpp b/lib/obp60task/OBP60ExtensionPort.cpp index bd1007b..cdb4ecb 100644 --- a/lib/obp60task/OBP60ExtensionPort.cpp +++ b/lib/obp60task/OBP60ExtensionPort.cpp @@ -111,6 +111,16 @@ void setBuzzerPower(uint power){ buzzerpower = power; } +// Show a triangle for trend direction high (x, y is the left edge) +void displayTrendHigh(int16_t x, int16_t y, uint16_t size, uint16_t color){ + display.fillTriangle(x, y, x+size*2, y, x+size, y-size*2, color); +} + +// Show a triangle for trend direction low (x, y is the left edge) +void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color){ + display.fillTriangle(x, y, x+size*2, y, x+size, y+size*2, color); +} + void displayHeader(CommonData &commonData, GwApi::BoatValue *hdop, GwApi::BoatValue *date, GwApi::BoatValue *time){ static bool heartbeat = false; diff --git a/lib/obp60task/OBP60ExtensionPort.h b/lib/obp60task/OBP60ExtensionPort.h index 52ae142..eeb6052 100644 --- a/lib/obp60task/OBP60ExtensionPort.h +++ b/lib/obp60task/OBP60ExtensionPort.h @@ -37,6 +37,9 @@ void setBlinkingLED(bool on); // Set blinking LED active void buzzer(uint frequency, uint duration); // Buzzer function void setBuzzerPower(uint power); // Set buzzer power +void displayTrendHigh(int16_t x, int16_t y, uint16_t size, uint16_t color); +void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color); + void displayHeader(CommonData &commonData, GwApi::BoatValue *hdop, GwApi::BoatValue *date, GwApi::BoatValue *time); // Draw display header #endif \ No newline at end of file diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index a248b43..06d15e7 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -223,23 +223,20 @@ public: } // Trend indicator - display.setTextColor(textcolor); - display.setFont(&Ubuntu_Bold32pt7b); + // Show trend indicator if(trend == true){ - display.setCursor(310, 240); - display.print(" "); + display.fillRect(310, 240, 40, 120, bgcolor); // Clear area + display.fillRect(315, 183, 35, 4, textcolor); // Draw separator if(int(raw * 10) > int(valueTrend * 10)){ - display.setCursor(310, 240); - display.print("+ "); + displayTrendHigh(320, 174, 11, textcolor); // Show high indicator } if(int(raw * 10) < int(valueTrend * 10)){ - display.setCursor(310, 240); - display.print("- "); + displayTrendLow(320, 195, 11, textcolor); // Show low indicator } } + // No trend indicator else{ - display.setCursor(310, 240); - display.print(" "); + display.fillRect(310, 240, 40, 120, bgcolor); // Clear area }