Distinguish military planes - #61
Conversation
|
Hardware & testing methodology: ESP32-C3 Super Mini ( Results: two real bugs, fixed locally in my integration build (not yet upstreamed to this PR branch): 1. Wrong array indexed in the beyond-ring-dot color loop, // Before (bug): iterates `dots[]` but indexes `items[]`
for (size_t d = 0; d < dot_count; ++d) {
const size_t i = items[d].index;
drawBeyondRingDot(dots[d].x, dots[d].y,
planes[i].isMilitary ? radar::kColorMilitaryAircraft : radar::kColorAircraft);
}
// After (fix)
for (size_t d = 0; d < dot_count; ++d) {
const size_t i = dots[d].index;
drawBeyondRingDot(dots[d].x, dots[d].y,
planes[i].isMilitary ? radar::kColorMilitaryAircraft : radar::kColorAircraft);
}
2. // Before (bug): dbFlags is an integer bitmask, not a bool
bool isMilitary(const JsonObject& plane) {
return plane["dbFlags"].is<bool>() && plane["dbFlags"].as<bool>();
}
// After (fix): bit 0 marks military per the ADS-B feed's convention
bool isMilitary(const JsonObject& plane) {
return plane["dbFlags"].is<int>() && (plane["dbFlags"].as<int>() & 1) != 0;
}As written, After both fixes, military-flagged aircraft rendered in the distinct color correctly on hardware. Recommend applying these before merge. |
Retrieves whether a plane is military or civilian. Uses the DBFlags field to determine this.
Draws the military planes in a orange color so they are easily distinguished.