Fix for compass page
This commit is contained in:
parent
07a1b2388e
commit
d1c620a858
|
@ -20,7 +20,7 @@ const int ShowDBS = 5;
|
||||||
const int Compass_X0 = 200; // center point of compass band
|
const int Compass_X0 = 200; // center point of compass band
|
||||||
const int Compass_Y0 = 220; // position of compass lines
|
const int Compass_Y0 = 220; // position of compass lines
|
||||||
const int Compass_LineLength = 22; // length of compass lines
|
const int Compass_LineLength = 22; // 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 PageCompass : public Page
|
class PageCompass : public Page
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,6 @@ class PageCompass : public Page
|
||||||
GwConfigHandler *config = commonData->config;
|
GwConfigHandler *config = commonData->config;
|
||||||
GwLog *logger = commonData->logger;
|
GwLog *logger = commonData->logger;
|
||||||
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String OldDataText[HowManyValues] = {"", "", "","", "", ""};
|
static String OldDataText[HowManyValues] = {"", "", "","", "", ""};
|
||||||
static String OldDataUnits[HowManyValues] = {"", "", "","", "", ""};
|
static String OldDataUnits[HowManyValues] = {"", "", "","", "", ""};
|
||||||
|
@ -113,9 +112,9 @@ class PageCompass : public Page
|
||||||
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 3 pix top & bottom
|
// Horizontal line 2 pix top & bottom
|
||||||
// print Data on top half
|
// Print data on top half
|
||||||
getdisplay().fillRect(0, 23, 400, 3, commonData->fgcolor);
|
getdisplay().fillRect(0, 130, 400, 2, commonData->fgcolor);
|
||||||
getdisplay().setFont(&Ubuntu_Bold20pt7b);
|
getdisplay().setFont(&Ubuntu_Bold20pt7b);
|
||||||
getdisplay().setCursor(10, 70);
|
getdisplay().setCursor(10, 70);
|
||||||
getdisplay().print(DataName[WhichDataDisplay]); // Page name
|
getdisplay().print(DataName[WhichDataDisplay]); // Page name
|
||||||
|
@ -123,7 +122,7 @@ class PageCompass : public Page
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||||
getdisplay().setCursor(10, 120);
|
getdisplay().setCursor(10, 120);
|
||||||
getdisplay().print(DataUnits[WhichDataDisplay]);
|
getdisplay().print(DataUnits[WhichDataDisplay]);
|
||||||
getdisplay().setCursor(200, 120);
|
getdisplay().setCursor(190, 120);
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic42pt7b);
|
getdisplay().setFont(&DSEG7Classic_BoldItalic42pt7b);
|
||||||
|
|
||||||
if(holdvalues == false){
|
if(holdvalues == false){
|
||||||
|
@ -136,8 +135,9 @@ class PageCompass : 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
|
|
||||||
// get the data
|
// Now draw compass band
|
||||||
|
// Get the data
|
||||||
double TheAngle = DataValue[WhichDataCompass];
|
double TheAngle = DataValue[WhichDataCompass];
|
||||||
static double AvgAngle = 0;
|
static double AvgAngle = 0;
|
||||||
AvgAngle = ( AvgAngle * AverageValues + TheAngle ) / (AverageValues + 1 );
|
AvgAngle = ( AvgAngle * AverageValues + TheAngle ) / (AverageValues + 1 );
|
||||||
|
@ -153,10 +153,10 @@ class PageCompass : public Page
|
||||||
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);
|
||||||
// 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;
|
||||||
if ( TheTrend < 0 )
|
if ( TheTrend < 0 )
|
||||||
|
@ -164,29 +164,28 @@ class PageCompass : public Page
|
||||||
else
|
else
|
||||||
x1 = Compass_X0 - 20 * ( i + 1 );
|
x1 = Compass_X0 - 20 * ( i + 1 );
|
||||||
|
|
||||||
getdisplay().fillRect(x1, Compass_Y0 -60, 10, 6, commonData->fgcolor);
|
getdisplay().fillRect(x1, Compass_Y0 -55, 10, 6, commonData->fgcolor);
|
||||||
}
|
}
|
||||||
// central line + satellite lines
|
// Central line + satellite lines
|
||||||
double NextSector = round(TheAngle / ( M_PI / 9 )) * ( M_PI / 9 ); // get the next 20degree value
|
double NextSector = round(TheAngle / ( M_PI / 9 )) * ( M_PI / 9 ); // Get the next 20degree value
|
||||||
double Offset = - ( NextSector - TheAngle); // offest of the center line compared to TheAngle in Radian
|
double Offset = - ( NextSector - TheAngle); // Offest of the center line compared to TheAngle in Radian
|
||||||
|
|
||||||
int Delta_X = int ( Offset * 180.0 / M_PI * Compass_LineDelta );
|
int Delta_X = int ( Offset * 180.0 / M_PI * Compass_LineDelta );
|
||||||
for ( int i = 0; i <=4; i++ )
|
for ( int i = 0; i <=4; i++ ){
|
||||||
{
|
|
||||||
int x0;
|
int x0;
|
||||||
x0 = Compass_X0 + Delta_X + 2 * i * 5 * Compass_LineDelta;
|
x0 = Compass_X0 + Delta_X + 2 * i * 5 * Compass_LineDelta;
|
||||||
getdisplay().fillRect(x0-1, Compass_Y0 - 2 * Compass_LineLength,3, 2 * Compass_LineLength, commonData->fgcolor);
|
getdisplay().fillRect(x0-2, Compass_Y0 - 2 * Compass_LineLength, 5, 2 * Compass_LineLength, commonData->fgcolor);
|
||||||
x0 = Compass_X0 + Delta_X + ( 2 * i + 1 ) * 5 * Compass_LineDelta;
|
x0 = Compass_X0 + Delta_X + ( 2 * i + 1 ) * 5 * Compass_LineDelta;
|
||||||
getdisplay().fillRect(x0-1, Compass_Y0 - Compass_LineLength,3, Compass_LineLength, commonData->fgcolor);
|
getdisplay().fillRect(x0-1, Compass_Y0 - Compass_LineLength, 3, Compass_LineLength, commonData->fgcolor);
|
||||||
|
|
||||||
x0 = Compass_X0 + Delta_X - 2 * i * 5 * Compass_LineDelta;
|
x0 = Compass_X0 + Delta_X - 2 * i * 5 * Compass_LineDelta;
|
||||||
getdisplay().fillRect(x0-1, Compass_Y0 - 2 * Compass_LineLength,3, 2 * Compass_LineLength, commonData->fgcolor);
|
getdisplay().fillRect(x0-2, Compass_Y0 - 2 * Compass_LineLength, 5, 2 * Compass_LineLength, commonData->fgcolor);
|
||||||
x0 = Compass_X0 + Delta_X - ( 2 * i + 1 ) * 5 * Compass_LineDelta;
|
x0 = Compass_X0 + Delta_X - ( 2 * i + 1 ) * 5 * Compass_LineDelta;
|
||||||
getdisplay().fillRect(x0-1, Compass_Y0 - Compass_LineLength,3, Compass_LineLength, commonData->fgcolor);
|
getdisplay().fillRect(x0-1, Compass_Y0 - Compass_LineLength, 3, Compass_LineLength, commonData->fgcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
getdisplay().fillRect(0, Compass_Y0, 400, 3, commonData->fgcolor);
|
getdisplay().fillRect(0, Compass_Y0, 400, 3, commonData->fgcolor);
|
||||||
// add the numbers to the compass band
|
// Add the numbers to the compass band
|
||||||
int x0;
|
int x0;
|
||||||
float AngleToDisplay = NextSector * 180.0 / M_PI;
|
float AngleToDisplay = NextSector * 180.0 / M_PI;
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ class PageCompass : public Page
|
||||||
do {
|
do {
|
||||||
getdisplay().setCursor(x0 - 40, Compass_Y0 + 40);
|
getdisplay().setCursor(x0 - 40, Compass_Y0 + 40);
|
||||||
snprintf(buffer,bsize,"%03.0f", AngleToDisplay);
|
snprintf(buffer,bsize,"%03.0f", AngleToDisplay);
|
||||||
// quick and dirty way to prevent wrapping text in next line
|
// Quick and dirty way to prevent wrapping text in next line
|
||||||
if ( ( x0 - 40 ) > 380 )
|
if ( ( x0 - 40 ) > 380 )
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
else if ( ( x0 - 40 ) > 355 )
|
else if ( ( x0 - 40 ) > 355 )
|
||||||
|
|
|
@ -1187,6 +1187,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -1466,6 +1467,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -1742,6 +1744,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -2015,6 +2018,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -2285,6 +2289,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -2552,6 +2557,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -2816,6 +2822,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -3077,6 +3084,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -3335,6 +3343,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
@ -3590,6 +3599,7 @@
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
"Clock",
|
"Clock",
|
||||||
|
"Compass",
|
||||||
"DST810",
|
"DST810",
|
||||||
"Fluid",
|
"Fluid",
|
||||||
"FourValues",
|
"FourValues",
|
||||||
|
|
|
@ -285,6 +285,8 @@ void registerAllPages(PageList &list){
|
||||||
list.add(®isterPageDST810);
|
list.add(®isterPageDST810);
|
||||||
extern PageDescription registerPageClock;
|
extern PageDescription registerPageClock;
|
||||||
list.add(®isterPageClock);
|
list.add(®isterPageClock);
|
||||||
|
extern PageDescription registerPageCompass;
|
||||||
|
list.add(®isterPageCompass);
|
||||||
extern PageDescription registerPageWhite;
|
extern PageDescription registerPageWhite;
|
||||||
list.add(®isterPageWhite);
|
list.add(®isterPageWhite);
|
||||||
extern PageDescription registerPageBME280;
|
extern PageDescription registerPageBME280;
|
||||||
|
|
Loading…
Reference in New Issue