Sample page apparent wind
This commit is contained in:
parent
d39c233a39
commit
d3e7aae21a
|
@ -97,7 +97,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||||
result.unit = "";
|
result.unit = "";
|
||||||
}
|
}
|
||||||
//########################################################
|
//########################################################
|
||||||
else if (value->getFormat() == "formatCourse"){
|
else if (value->getFormat() == "formatCourse" || value->getFormat() == "formatWind"){
|
||||||
double course = 0;
|
double course = 0;
|
||||||
if(usesimudata == false) {
|
if(usesimudata == false) {
|
||||||
course = value->value;
|
course = value->value;
|
||||||
|
@ -118,7 +118,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||||
result.unit = "Deg";
|
result.unit = "Deg";
|
||||||
}
|
}
|
||||||
//########################################################
|
//########################################################
|
||||||
else if (value->getFormat() == "formatKnots" || value->getFormat() == "formatWind"){
|
else if (value->getFormat() == "formatKnots"){
|
||||||
double speed = 0;
|
double speed = 0;
|
||||||
if(usesimudata == false) {
|
if(usesimudata == false) {
|
||||||
speed = value->value;
|
speed = value->value;
|
||||||
|
|
|
@ -101,14 +101,8 @@ int readKeypad() {
|
||||||
buzzer(TONE4, 1000);
|
buzzer(TONE4, 1000);
|
||||||
keylock = false;
|
keylock = false;
|
||||||
delay(keydelay);
|
delay(keydelay);
|
||||||
|
|
||||||
keyoff = !keyoff;
|
keyoff = !keyoff;
|
||||||
if(keyoff == true){
|
keystatus = 11;
|
||||||
keystatus = 11;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
keystatus = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect swipe right
|
// Detect swipe right
|
||||||
|
|
|
@ -3,42 +3,181 @@
|
||||||
|
|
||||||
class PageApparentWind : public Page
|
class PageApparentWind : public Page
|
||||||
{
|
{
|
||||||
int dummy=0; //an example on how you would maintain some status
|
bool keylock = false; // Keylock
|
||||||
//for a page
|
int16_t lp = 80; // Pointer length
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageApparentWind(CommonData &common){
|
PageApparentWind(CommonData &common){
|
||||||
common.logger->logDebug(GwLog::LOG,"created PageApparentWind");
|
common.logger->logDebug(GwLog::LOG,"Show PageApparentWind");
|
||||||
dummy=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
if(key == 3){
|
// Reduce instrument size
|
||||||
dummy++;
|
if(key == 2){ // Code for reduce
|
||||||
return 0; // Commit the key
|
lp = lp - 10;
|
||||||
|
if(lp < 10){
|
||||||
|
lp = 10;
|
||||||
|
}
|
||||||
|
return 0; // Commit the key
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enlarge instrument size
|
||||||
|
if(key == 5){ // Code for enlarge
|
||||||
|
lp = lp + 10;
|
||||||
|
if(lp > 80){
|
||||||
|
lp = 80;
|
||||||
|
}
|
||||||
|
return 0; // Commit the key
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keylock function
|
||||||
|
if(key == 11){ // Code for keylock
|
||||||
|
keylock = !keylock; // Toggle keylock
|
||||||
|
return 0; // Commit the key
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayPage(CommonData &commonData, PageData &pageData)
|
virtual void displayPage(CommonData &commonData, PageData &pageData)
|
||||||
{
|
{
|
||||||
GwLog *logger = commonData.logger;
|
|
||||||
|
|
||||||
GwConfigHandler *config = commonData.config;
|
GwConfigHandler *config = commonData.config;
|
||||||
String test = config->getString(config->lengthFormat);
|
GwLog *logger=commonData.logger;
|
||||||
|
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
static String svalue1old = "";
|
||||||
|
static String unit1old = "";
|
||||||
|
static String svalue2old = "";
|
||||||
|
static String unit2old = "";
|
||||||
|
|
||||||
dummy++;
|
// Get config data
|
||||||
for (int i = 0; i < 2; i++)
|
String lengthformat = config->getString(config->lengthFormat);
|
||||||
{
|
bool simulation = config->getBool(config->useSimuData);
|
||||||
GwApi::BoatValue *value = pageData.values[i];
|
String displaycolor = config->getString(config->displaycolor);
|
||||||
if (value == NULL)
|
bool holdvalues = config->getBool(config->holdvalues);
|
||||||
continue;
|
String flashLED = config->getString(config->flashLED);
|
||||||
LOG_DEBUG(GwLog::LOG, "drawing at PageApparentWind(%d),dummy=%d, p=%s,v=%f",
|
String backlightMode = config->getString(config->backlight);
|
||||||
i,
|
|
||||||
dummy,
|
// Get boat values for AWS
|
||||||
value->getName().c_str(),
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
value->valid ? value->value : -1.0);
|
String name1 = bvalue1->getName().c_str(); // Value name
|
||||||
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
|
String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
// Get boat values for AWD
|
||||||
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue)
|
||||||
|
String name2 = bvalue2->getName().c_str(); // Value name
|
||||||
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
|
String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
// Optical warning by limit violation (unused)
|
||||||
|
if(String(flashLED) == "Limit Violation"){
|
||||||
|
setBlinkingLED(false);
|
||||||
|
setPortPin(OBP_FLASH_LED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logging boat values
|
||||||
|
if (bvalue1 == NULL) return;
|
||||||
|
LOG_DEBUG(GwLog::LOG,"Drawing at PageApparentWind, %s:%f, %s:%f", name1, value1, name2, value2);
|
||||||
|
|
||||||
|
// Draw page
|
||||||
|
//***********************************************************
|
||||||
|
|
||||||
|
// Set background color and text color
|
||||||
|
int textcolor = GxEPD_BLACK;
|
||||||
|
int pixelcolor = GxEPD_BLACK;
|
||||||
|
int bgcolor = GxEPD_WHITE;
|
||||||
|
if(displaycolor == "Normal"){
|
||||||
|
textcolor = GxEPD_BLACK;
|
||||||
|
pixelcolor = GxEPD_BLACK;
|
||||||
|
bgcolor = GxEPD_WHITE;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
textcolor = GxEPD_WHITE;
|
||||||
|
pixelcolor = GxEPD_WHITE;
|
||||||
|
bgcolor = GxEPD_BLACK;
|
||||||
|
}
|
||||||
|
// Clear display by call in obp60task.cpp in main loop
|
||||||
|
|
||||||
|
// Show values AWS
|
||||||
|
display.setFont(&Ubuntu_Bold20pt7b);
|
||||||
|
display.setCursor(20, 50);
|
||||||
|
if(holdvalues == false){
|
||||||
|
display.print(name1); // Value name
|
||||||
|
display.print(": ");
|
||||||
|
display.print(svalue1); // Value
|
||||||
|
display.print(" ");
|
||||||
|
display.print(unit1); // Unit
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print(name1); // Value name
|
||||||
|
display.print(": ");
|
||||||
|
display.print(svalue1old); // Value old
|
||||||
|
display.print(" ");
|
||||||
|
display.print(unit1old); // Unit old
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show values AWD
|
||||||
|
display.setFont(&Ubuntu_Bold20pt7b);
|
||||||
|
display.setCursor(20, 260);
|
||||||
|
if(holdvalues == false){
|
||||||
|
display.print(name2); // Value name
|
||||||
|
display.print(": ");
|
||||||
|
display.print(svalue2); // Value
|
||||||
|
display.print(" ");
|
||||||
|
display.print(unit2); // Unit
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print(name2); // Value name
|
||||||
|
display.print(": ");
|
||||||
|
display.print(svalue2old); // Value old
|
||||||
|
display.print(" ");
|
||||||
|
display.print(unit2old); // Unit old
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw wind pointer
|
||||||
|
static int16_t x0 = 200; // Center point
|
||||||
|
static int16_t y0 = 145;
|
||||||
|
static int16_t x1 = x0; // Start point for pointer
|
||||||
|
static int16_t y1 = y0;
|
||||||
|
static int16_t x2 = x0; // End point for pointer
|
||||||
|
static int16_t y2 = y0;
|
||||||
|
|
||||||
|
//Draw instrument
|
||||||
|
display.fillCircle(x0, y0, lp + 5, pixelcolor); // Black circle
|
||||||
|
display.fillCircle(x0, y0, lp + 1, bgcolor); // White circle
|
||||||
|
|
||||||
|
// Calculation end point of pointer
|
||||||
|
value2 = value2 - 3.14 / 2;
|
||||||
|
x1 = x0 + cos(value2) * lp * 0.6;
|
||||||
|
y1 = y0 + sin(value2) * lp * 0.6;
|
||||||
|
x2 = x0 + cos(value2) * lp;
|
||||||
|
y2 = y0 + sin(value2) * lp;
|
||||||
|
|
||||||
|
display.drawLine(x1, y1, x2, y2, pixelcolor);
|
||||||
|
|
||||||
|
// Key Layout
|
||||||
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
|
display.setCursor(115, 290);
|
||||||
|
if(keylock == false){
|
||||||
|
display.print(" [ <<<<<< >>>>>> ]");
|
||||||
|
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||||
|
display.setCursor(343, 290);
|
||||||
|
display.print("[ILUM]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print(" [ Keylock active ]");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update display
|
||||||
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,9 +192,9 @@ static Page *createPage(CommonData &common){
|
||||||
* and will will provide the names of the fixed values we need
|
* and will will provide the names of the fixed values we need
|
||||||
*/
|
*/
|
||||||
PageDescription registerPageApparentWind(
|
PageDescription registerPageApparentWind(
|
||||||
"apparentWind",
|
"apparentWind", // Page name
|
||||||
createPage,
|
createPage, // Action
|
||||||
0,
|
0, // Number of bus values depends on selection in Web configuration
|
||||||
{"AWS","AWD"},
|
{"AWS","AWA"}, // Bus values we need in the page
|
||||||
false
|
true // Show display header on/off
|
||||||
);
|
);
|
|
@ -2,7 +2,21 @@
|
||||||
#include "OBP60ExtensionPort.h"
|
#include "OBP60ExtensionPort.h"
|
||||||
|
|
||||||
class PageOneValue : public Page{
|
class PageOneValue : public Page{
|
||||||
|
bool keylock = false; // Keylock
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PageOneValue(CommonData &common){
|
||||||
|
common.logger->logDebug(GwLog::LOG,"Show PageOneValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int handleKey(int key){
|
||||||
|
if(key == 11){ // Code for keylock
|
||||||
|
keylock = !keylock; // Toggle keylock
|
||||||
|
return 0; // Commit the key
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void displayPage(CommonData &commonData, PageData &pageData){
|
virtual void displayPage(CommonData &commonData, PageData &pageData){
|
||||||
GwConfigHandler *config = commonData.config;
|
GwConfigHandler *config = commonData.config;
|
||||||
GwLog *logger=commonData.logger;
|
GwLog *logger=commonData.logger;
|
||||||
|
@ -85,7 +99,7 @@ class PageOneValue : public Page{
|
||||||
display.setCursor(20, 240);
|
display.setCursor(20, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show bus data or using simulation data
|
// Show bus data
|
||||||
if(holdvalues == false){
|
if(holdvalues == false){
|
||||||
display.print(svalue1); // Real value as formated string
|
display.print(svalue1); // Real value as formated string
|
||||||
}
|
}
|
||||||
|
@ -100,16 +114,16 @@ class PageOneValue : public Page{
|
||||||
// Key Layout
|
// Key Layout
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
display.setCursor(115, 290);
|
display.setCursor(115, 290);
|
||||||
if(commonData.keylock == false){
|
if(keylock == false){
|
||||||
display.print(" [ <<<<<< >>>>>> ]");
|
display.print(" [ <<<<<< >>>>>> ]");
|
||||||
|
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||||
|
display.setCursor(343, 290);
|
||||||
|
display.print("[ILUM]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
display.print(" [ Keylock active ]");
|
display.print(" [ Keylock active ]");
|
||||||
}
|
}
|
||||||
if(String(backlightMode) == "Control by Key"){
|
|
||||||
display.setCursor(343, 290);
|
|
||||||
display.print("[ILUM]");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update display
|
// Update display
|
||||||
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
||||||
|
@ -117,7 +131,9 @@ class PageOneValue : public Page{
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static Page* createPage(CommonData &common){return new PageOneValue();}
|
static Page* createPage(CommonData &common){
|
||||||
|
return new PageOneValue(common);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* with the code below we make this page known to the PageTask
|
* with the code below we make this page known to the PageTask
|
||||||
|
@ -127,7 +143,7 @@ static Page* createPage(CommonData &common){return new PageOneValue();}
|
||||||
* this will be number of BoatValue pointers in pageData.values
|
* this will be number of BoatValue pointers in pageData.values
|
||||||
*/
|
*/
|
||||||
PageDescription registerPageOneValue(
|
PageDescription registerPageOneValue(
|
||||||
"oneValue", // Name of page
|
"oneValue", // Page name
|
||||||
createPage, // Action
|
createPage, // Action
|
||||||
1, // Number of bus values depends on selection in Web configuration
|
1, // Number of bus values depends on selection in Web configuration
|
||||||
true // Show display header on/off
|
true // Show display header on/off
|
||||||
|
|
|
@ -3,17 +3,16 @@
|
||||||
|
|
||||||
class PageVoltage : public Page
|
class PageVoltage : public Page
|
||||||
{
|
{
|
||||||
int dummy=0; //an example on how you would maintain some status
|
bool keylock = false; // Keylock
|
||||||
//for a page
|
|
||||||
public:
|
public:
|
||||||
PageVoltage(CommonData &common){
|
PageVoltage(CommonData &common){
|
||||||
common.logger->logDebug(GwLog::LOG,"created PageApparentWind");
|
common.logger->logDebug(GwLog::LOG,"Show PageVoltage");
|
||||||
dummy=1;
|
|
||||||
}
|
}
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
if(key == 3){
|
if(key == 11){ // Code for keylock
|
||||||
dummy++;
|
keylock = !keylock; // Toggle keylock
|
||||||
return 0; // Commit the key
|
return 0; // Commit the key
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -117,8 +116,13 @@ public:
|
||||||
// Key Layout
|
// Key Layout
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
display.setCursor(115, 290);
|
display.setCursor(115, 290);
|
||||||
display.print(" [ <<<<<< >>>>>> ]");
|
if(keylock == false){
|
||||||
if(String(backlightMode) == "Control by Key"){
|
display.print(" [ <<<<<< >>>>>> ]");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print(" [ Keylock active ]");
|
||||||
|
}
|
||||||
|
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||||
display.setCursor(343, 290);
|
display.setCursor(343, 290);
|
||||||
display.print("[ILUM]");
|
display.print("[ILUM]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ typedef struct{
|
||||||
GwApi::Status status;
|
GwApi::Status status;
|
||||||
GwLog *logger=NULL;
|
GwLog *logger=NULL;
|
||||||
GwConfigHandler *config=NULL;
|
GwConfigHandler *config=NULL;
|
||||||
bool keylock = false;
|
|
||||||
} CommonData;
|
} CommonData;
|
||||||
|
|
||||||
//a base class that all pages must inherit from
|
//a base class that all pages must inherit from
|
||||||
|
|
|
@ -50,14 +50,13 @@ void underVoltageDetection(){
|
||||||
Timer1.stop(); // Stop Timer1
|
Timer1.stop(); // Stop Timer1
|
||||||
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
|
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
|
||||||
setPortPin(OBP_FLASH_LED, false); // Flash LED Off
|
setPortPin(OBP_FLASH_LED, false); // Flash LED Off
|
||||||
buzzer(TONE4, 20); // Buzzer tone 4kHz 20% 20ms
|
|
||||||
setPortPin(OBP_POWER_50, false); // Power rail 5.0V Off
|
|
||||||
setPortPin(OBP_POWER_33, false); // Power rail 3.3V Off
|
setPortPin(OBP_POWER_33, false); // Power rail 3.3V Off
|
||||||
|
buzzer(TONE4, 20); // Buzzer tone 4kHz 20ms
|
||||||
|
setPortPin(OBP_POWER_50, false); // Power rail 5.0V Off
|
||||||
// Shutdown EInk display
|
// Shutdown EInk display
|
||||||
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
|
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
|
||||||
// display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); // Partial update
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); // Partial update
|
||||||
display.update();
|
display.update();
|
||||||
// display._sleep(); // Display shut dow
|
|
||||||
// Stop system
|
// Stop system
|
||||||
while(true){
|
while(true){
|
||||||
esp_deep_sleep_start(); // Deep Sleep without weakup. Weakup only after power cycle (restart).
|
esp_deep_sleep_start(); // Deep Sleep without weakup. Weakup only after power cycle (restart).
|
||||||
|
@ -484,13 +483,6 @@ void OBP60Task(GwApi *api){
|
||||||
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
|
||||||
display.update(); // Full update
|
display.update(); // Full update
|
||||||
}
|
}
|
||||||
// #11 Keylock
|
|
||||||
/*
|
|
||||||
if (keyboardMessage == 11)
|
|
||||||
{
|
|
||||||
commonData.keylock = !commonData.keylock; // Toggle keylock
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
|
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue