mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-11 23:52:14 +00:00
Update Screen.cpp
Add option to switch between static/non-static North.
This commit is contained in:
parent
97a2bf6221
commit
20d7d1b162
@ -64,6 +64,11 @@ namespace graphics
|
|||||||
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
||||||
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
||||||
static char btPIN[16] = "888888";
|
static char btPIN[16] = "888888";
|
||||||
|
|
||||||
|
// This defines the layout of the compass.
|
||||||
|
// If true, North with remain static at the top of the compass.
|
||||||
|
// If false, your current heading is static at the top of the compass.
|
||||||
|
bool compassNorthTop = false;
|
||||||
|
|
||||||
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
||||||
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
||||||
@ -687,6 +692,10 @@ static void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t comp
|
|||||||
// Draw north
|
// Draw north
|
||||||
static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
||||||
{
|
{
|
||||||
|
//If north is supposed to be at the top of the compass we want rotation to be +0
|
||||||
|
if(compassNorthTop)
|
||||||
|
myHeading = -0;
|
||||||
|
|
||||||
Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f);
|
Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f);
|
||||||
Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f);
|
Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f);
|
||||||
Point *rosePoints[] = {&N1, &N2, &N3, &N4};
|
Point *rosePoints[] = {&N1, &N2, &N3, &N4};
|
||||||
@ -780,8 +789,11 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
|
|
||||||
float bearingToOther =
|
float bearingToOther =
|
||||||
GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
||||||
float headingRadian = bearingToOther - myHeading;
|
// If the top of the compass is a static north then bearingToOther can be drawn on the compass directly
|
||||||
drawNodeHeading(display, compassX, compassY, headingRadian);
|
// If the top of the compass is not a static north we need adjust bearingToOther based on heading
|
||||||
|
if(!compassNorthTop)
|
||||||
|
float bearingToOther = bearingToOther - myHeading;
|
||||||
|
drawNodeHeading(display, compassX, compassY, bearingToOther);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasNodeHeading)
|
if (!hasNodeHeading)
|
||||||
|
Loading…
Reference in New Issue
Block a user