Mini compass screen shape change

This commit is contained in:
HarukiToreda 2025-04-05 22:37:05 -04:00
parent 9cdeedfcbd
commit afc710a868

View File

@ -2203,7 +2203,6 @@ void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
display->setFont(FONT_SMALL); display->setFont(FONT_SMALL);
display->drawStringMaxWidth(x, y, nameMaxWidth, nodeName); display->drawStringMaxWidth(x, y, nameMaxWidth, nodeName);
} }
void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, float myHeading, void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth, float myHeading,
double userLat, double userLon) double userLat, double userLon)
{ {
@ -2212,31 +2211,46 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
int screenWidth = display->getWidth(); int screenWidth = display->getWidth();
bool isLeftCol = (x < screenWidth / 2); bool isLeftCol = (x < screenWidth / 2);
int arrowXOffset = (screenWidth > 128) ? (isLeftCol ? 22 : 24) : (isLeftCol ? 12 : 18);
int centerX = x + columnWidth - arrowXOffset;
int centerY = y + FONT_HEIGHT_SMALL / 2;
double nodeLat = node->position.latitude_i * 1e-7; double nodeLat = node->position.latitude_i * 1e-7;
double nodeLon = node->position.longitude_i * 1e-7; double nodeLon = node->position.longitude_i * 1e-7;
float bearingToNode = calculateBearing(userLat, userLon, nodeLat, nodeLon); float bearingToNode = calculateBearing(userLat, userLon, nodeLat, nodeLon);
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360); float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
float arrowAngle = relativeBearing * DEG_TO_RAD; float angle = relativeBearing * DEG_TO_RAD;
// Compass position // Shrink size by 2px
int arrowXOffset = (screenWidth > 128) ? (isLeftCol ? 22 : 24) : (isLeftCol ? 12 : 18); int size = FONT_HEIGHT_SMALL - 5;
int compassX = x + columnWidth - arrowXOffset; float halfSize = size / 2.0;
int compassY = y + FONT_HEIGHT_SMALL / 2;
int radius = FONT_HEIGHT_SMALL / 2 - 3; // Point of the arrow
int tipX = centerX + halfSize * cos(angle);
int tipY = centerY - halfSize * sin(angle);
// Arrow should go from center to edge (not beyond) float baseAngle = radians(35);
int xEnd = compassX + radius * cos(arrowAngle); float sideLen = halfSize * 0.95;
int yEnd = compassY - radius * sin(arrowAngle); float notchInset = halfSize * 0.35;
// Draw circle outline // Left and right corners
display->drawCircle(compassX, compassY, radius); int leftX = centerX + sideLen * cos(angle + PI - baseAngle);
int leftY = centerY - sideLen * sin(angle + PI - baseAngle);
// Draw thin arrow line from center to circle edge int rightX = centerX + sideLen * cos(angle + PI + baseAngle);
display->drawLine(compassX, compassY, xEnd, yEnd); int rightY = centerY - sideLen * sin(angle + PI + baseAngle);
// Center notch (cut-in)
int notchX = centerX - notchInset * cos(angle);
int notchY = centerY + notchInset * sin(angle);
// Draw the chevron-style arrowhead
display->fillTriangle(tipX, tipY, leftX, leftY, notchX, notchY);
display->fillTriangle(tipX, tipY, notchX, notchY, rightX, rightY);
} }
// Public screen entry for compass // Public screen entry for compass
static void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) static void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {