mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Trunk fix
This commit is contained in:
parent
8fb825e0e0
commit
214aa8b59d
@ -14,8 +14,14 @@
|
|||||||
|
|
||||||
WaypointModule *waypointModule;
|
WaypointModule *waypointModule;
|
||||||
|
|
||||||
static inline float degToRad(float deg) { return deg * PI / 180.0f; }
|
static inline float degToRad(float deg)
|
||||||
static inline float radToDeg(float rad) { return rad * 180.0f / PI; }
|
{
|
||||||
|
return deg * PI / 180.0f;
|
||||||
|
}
|
||||||
|
static inline float radToDeg(float rad)
|
||||||
|
{
|
||||||
|
return rad * 180.0f / PI;
|
||||||
|
}
|
||||||
|
|
||||||
ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp)
|
ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp)
|
||||||
{
|
{
|
||||||
@ -55,15 +61,15 @@ ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp)
|
|||||||
bool WaypointModule::shouldDraw()
|
bool WaypointModule::shouldDraw()
|
||||||
{
|
{
|
||||||
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
||||||
if (!screen || !devicestate.has_rx_waypoint) return false;
|
if (!screen || !devicestate.has_rx_waypoint)
|
||||||
|
return false;
|
||||||
|
|
||||||
meshtastic_Waypoint wp{}; // <- replaces memset
|
meshtastic_Waypoint wp{}; // <- replaces memset
|
||||||
if (pb_decode_from_bytes(devicestate.rx_waypoint.decoded.payload.bytes,
|
if (pb_decode_from_bytes(devicestate.rx_waypoint.decoded.payload.bytes, devicestate.rx_waypoint.decoded.payload.size,
|
||||||
devicestate.rx_waypoint.decoded.payload.size,
|
|
||||||
&meshtastic_Waypoint_msg, &wp)) {
|
&meshtastic_Waypoint_msg, &wp)) {
|
||||||
return wp.expire > getTime();
|
return wp.expire > getTime();
|
||||||
}
|
}
|
||||||
return false; // no LOG_ERROR, no flag writes
|
return false; // no LOG_ERROR, no flag writes
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -72,7 +78,8 @@ bool WaypointModule::shouldDraw()
|
|||||||
/// Draw the last waypoint we received
|
/// Draw the last waypoint we received
|
||||||
void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
if (!screen) return;
|
if (!screen)
|
||||||
|
return;
|
||||||
// Prepare to draw
|
// Prepare to draw
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
@ -109,9 +116,8 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
const uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(w, h);
|
const uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(w, h);
|
||||||
const int16_t compassX = x + w - (compassDiam / 2) - 5;
|
const int16_t compassX = x + w - (compassDiam / 2) - 5;
|
||||||
const int16_t compassY = (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT)
|
const int16_t compassY = (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT)
|
||||||
? y + h / 2
|
? y + h / 2
|
||||||
: y + FONT_HEIGHT_SMALL + (h - FONT_HEIGHT_SMALL) / 2;
|
: y + FONT_HEIGHT_SMALL + (h - FONT_HEIGHT_SMALL) / 2;
|
||||||
|
|
||||||
|
|
||||||
// If our node has a position:
|
// If our node has a position:
|
||||||
if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading())) {
|
if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading())) {
|
||||||
@ -143,13 +149,11 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
float d = GeoCoord::latLongToMeter(DegD(wp.latitude_i), DegD(wp.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
float d = GeoCoord::latLongToMeter(DegD(wp.latitude_i), DegD(wp.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
||||||
if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) {
|
if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) {
|
||||||
float feet = d * METERS_TO_FEET;
|
float feet = d * METERS_TO_FEET;
|
||||||
snprintf(distStr, sizeof(distStr),
|
snprintf(distStr, sizeof(distStr), feet < (2 * MILES_TO_FEET) ? "%.0fft %.0f°" : "%.1fmi %.0f°",
|
||||||
feet < (2 * MILES_TO_FEET) ? "%.0fft %.0f°" : "%.1fmi %.0f°",
|
feet < (2 * MILES_TO_FEET) ? feet : feet / MILES_TO_FEET, bearingToOtherDegrees);
|
||||||
feet < (2 * MILES_TO_FEET) ? feet : feet / MILES_TO_FEET, bearingToOtherDegrees);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(distStr, sizeof(distStr),
|
snprintf(distStr, sizeof(distStr), d < 2000 ? "%.0fm %.0f°" : "%.1fkm %.0f°", d < 2000 ? d : d / 1000,
|
||||||
d < 2000 ? "%.0fm %.0f°" : "%.1fkm %.0f°",
|
bearingToOtherDegrees);
|
||||||
d < 2000 ? d : d / 1000, bearingToOtherDegrees);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +162,7 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
|
|
||||||
// ? in the distance field
|
// ? in the distance field
|
||||||
snprintf(distStr, sizeof(distStr), "? %s ?°",
|
snprintf(distStr, sizeof(distStr), "? %s ?°",
|
||||||
(config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) ? "mi" : "km");
|
(config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) ? "mi" : "km");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw compass circle
|
// Draw compass circle
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user