Trunk fix

This commit is contained in:
HarukiToreda 2025-10-13 17:07:26 -04:00
parent 8fb825e0e0
commit 214aa8b59d

View File

@ -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,11 +61,11 @@ 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();
} }
@ -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);
@ -112,7 +119,6 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
? 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())) {
const meshtastic_PositionLite &op = ourNode->position; const meshtastic_PositionLite &op = ourNode->position;
@ -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);
} }
} }