mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-10 15:40:29 -04:00
Adsb rx airline display fix (#1847)
* This doesn't do anything, just gives me some sanity :D * Don’t abuse std * Only look for airline info if the callsign is received * Format… * Let the airline update when callsign is received
This commit is contained in:
parent
b8073bca0f
commit
f2c008602d
5 changed files with 36 additions and 34 deletions
|
@ -64,9 +64,9 @@ static std::string mmsi(
|
|||
|
||||
static std::string mid(
|
||||
const ais::MMSI& mmsi) {
|
||||
std::database db;
|
||||
database db;
|
||||
std::string mid_code = "";
|
||||
std::database::MidDBRecord mid_record = {};
|
||||
database::MidDBRecord mid_record = {};
|
||||
int return_code = 0;
|
||||
|
||||
// Try getting the country name from mids.db using MID code for given MMSI
|
||||
|
|
|
@ -127,8 +127,8 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
|
|||
text_icao_address.set(entry.icao_str);
|
||||
|
||||
// Try getting the aircraft information from icao24.db
|
||||
std::database db{};
|
||||
std::database::AircraftDBRecord aircraft_record;
|
||||
database db{};
|
||||
database::AircraftDBRecord aircraft_record;
|
||||
auto return_code = db.retrieve_aircraft_record(&aircraft_record, entry.icao_str);
|
||||
switch (return_code) {
|
||||
case DATABASE_RECORD_FOUND:
|
||||
|
@ -233,24 +233,6 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
|||
&button_aircraft_details,
|
||||
&button_see_map});
|
||||
|
||||
// The following won't change for a given airborne aircraft.
|
||||
// Try getting the airline's name from airlines.db.
|
||||
// NB: Only works once callsign has been read and won't be updated.
|
||||
std::database db;
|
||||
std::database::AirlinesDBRecord airline_record;
|
||||
std::string airline_code = entry_.callsign.substr(0, 3);
|
||||
auto return_code = db.retrieve_airline_record(&airline_record, airline_code);
|
||||
|
||||
switch (return_code) {
|
||||
case DATABASE_RECORD_FOUND:
|
||||
text_airline.set(airline_record.airline);
|
||||
text_country.set(airline_record.country);
|
||||
break;
|
||||
case DATABASE_NOT_FOUND:
|
||||
text_airline.set("No airlines.db file");
|
||||
break;
|
||||
}
|
||||
|
||||
text_icao_address.set(entry_.icao_str);
|
||||
|
||||
button_aircraft_details.on_select = [this, &nav](Button&) {
|
||||
|
@ -330,6 +312,31 @@ void ADSBRxDetailsView::on_orientation(const OrientationDataMessage* msg) {
|
|||
}
|
||||
|
||||
void ADSBRxDetailsView::refresh_ui() {
|
||||
// The following won't change for a given airborne aircraft.
|
||||
// Try getting the airline's name from airlines.db.
|
||||
if (!airline_checked && !entry_.callsign.empty()) {
|
||||
airline_checked = true;
|
||||
|
||||
database db;
|
||||
database::AirlinesDBRecord airline_record;
|
||||
std::string airline_code = entry_.callsign.substr(0, 3);
|
||||
auto return_code = db.retrieve_airline_record(&airline_record, airline_code);
|
||||
|
||||
switch (return_code) {
|
||||
case DATABASE_RECORD_FOUND:
|
||||
text_airline.set(airline_record.airline);
|
||||
text_country.set(airline_record.country);
|
||||
break;
|
||||
case DATABASE_RECORD_NOT_FOUND:
|
||||
// text_airline.set("-"); // It's what it is constructed with
|
||||
// text_country.set("-"); // It's what it is constructed with
|
||||
break;
|
||||
case DATABASE_NOT_FOUND:
|
||||
text_airline.set("No airlines.db file");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto age = entry_.age;
|
||||
if (age < 60)
|
||||
text_last_seen.set(to_string_dec_uint(age) + " seconds ago");
|
||||
|
|
|
@ -280,6 +280,7 @@ class ADSBRxDetailsView : public View {
|
|||
// NB: Keeping a copy so that it doesn't end up dangling
|
||||
// if removed from the recent entries list.
|
||||
AircraftRecentEntry entry_{AircraftRecentEntry::invalid_key};
|
||||
bool airline_checked{false};
|
||||
|
||||
Labels labels{
|
||||
{{0 * 8, 1 * 16}, "ICAO:", Color::light_grey()},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue