From 8d2adb5b2ef673989be09c45829ba4faa409048c Mon Sep 17 00:00:00 2001 From: Scott Vincent Date: Mon, 11 Nov 2024 06:39:22 +0000 Subject: [PATCH] Add fbw A380 --- README.md | 4 +- power-lights-panel/globals.cpp | 110 ++++++++++++----------- power-lights-panel/globals.h | 10 +-- power-lights-panel/powerLights-panel.cpp | 2 +- power-lights-panel/powerLights.cpp | 8 +- power-lights-panel/simvarDefs.cpp | 2 +- release.sh | 2 +- 7 files changed, 67 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index fafd6d1..6f3ddfc 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Download the following two files. -Link: [Latest release of Power/Lights Panel for Raspberry Pi Zero W](https://github.com/scott-vincent/power-lights-panel/releases/latest/download/power-lights-panel-v1.5.3-raspi.tar.gz) +Link: [Latest release of Power/Lights Panel for Raspberry Pi Zero W](https://github.com/scott-vincent/power-lights-panel/releases/latest/download/power-lights-panel-v1.5.4-raspi.tar.gz) -Link: [Latest release of Instrument Data Link for Windows](https://github.com/scott-vincent/instrument-data-link/releases/latest/download/instrument-data-link-v2.0.3-windows-x64.zip) +Link: [Latest release of Instrument Data Link for Windows](https://github.com/scott-vincent/instrument-data-link/releases/latest/download/instrument-data-link-v2.0.4-windows-x64.zip) Unzip instrument-data-link into its own folder and double-click instrument-data-link.exe to run it. diff --git a/power-lights-panel/globals.cpp b/power-lights-panel/globals.cpp index fd1150a..811a1b4 100644 --- a/power-lights-panel/globals.cpp +++ b/power-lights-panel/globals.cpp @@ -10,62 +10,66 @@ void identifyAircraft(char* aircraft) { // Identify aircraft if (strcmp(aircraft, globals.lastAircraft) != 0) { - if (strncmp(aircraft, globals.Cessna_152_Text, globals.Cessna_152_Len) == 0) { - globals.aircraft = CESSNA_152; - } - else if (strncmp(aircraft, globals.Cessna_172_Text, globals.Cessna_172_Len) == 0) { - globals.aircraft = CESSNA_172; - } - else if (strncmp(aircraft, globals.Cessna_CJ4_Text, globals.Cessna_CJ4_Len) == 0) { - globals.aircraft = CESSNA_CJ4; - } - else if (strncmp(aircraft, globals.Savage_Cub_Text, globals.Savage_Cub_Len) == 0) { - globals.aircraft = SAVAGE_CUB; - } - else if (strncmp(aircraft, globals.Shock_Ultra_Text, globals.Shock_Ultra_Len) == 0) { - globals.aircraft = SHOCK_ULTRA; - } - else if (strncmp(aircraft, globals.Airbus_A310_Text, globals.Airbus_A310_Len) == 0) { - globals.aircraft = AIRBUS_A310; - } - else if (strncmp(aircraft, globals.IniBuilds_A310_Text, globals.IniBuilds_A310_Len) == 0) { - globals.aircraft = AIRBUS_A310; - } - else if (strncmp(aircraft, globals.Airbus_A320_Text, globals.Airbus_A320_Len) == 0) { - globals.aircraft = FBW_A320; - } - else if (strncmp(aircraft, globals.FBW_A320_Text, globals.FBW_A320_Len) == 0) { - globals.aircraft = FBW_A320; - } - else if (strncmp(aircraft, globals.Boeing_747_Text, globals.Boeing_747_Len) == 0) { - globals.aircraft = BOEING_747; - } - else if (strncmp(aircraft, globals.Salty_Boeing_747_Text, globals.Salty_Boeing_747_Len) == 0) { - globals.aircraft = BOEING_747; - } - else if (strncmp(aircraft, globals.Boeing_787_Text, globals.Boeing_787_Len) == 0) { - globals.aircraft = BOEING_787; - } - else if (strncmp(aircraft, globals.Supermarine_Spitfire_Text, globals.Supermarine_Spitfire_Len) == 0) { - globals.aircraft = SUPERMARINE_SPITFIRE; - } - else if (strncmp(aircraft, globals.F15_Eagle_Text, globals.F15_Eagle_Len) == 0) { - globals.aircraft = F15_EAGLE; - } - else if (strncmp(aircraft, globals.F18_Hornet_Text, globals.F18_Hornet_Len) == 0) { - globals.aircraft = F18_HORNET; - } - else if (strncmp(aircraft, globals.JustFlight_PA28_Text, globals.JustFlight_PA28_Len) == 0) { - globals.aircraft = JUSTFLIGHT_PA28; + bool foundAircraft = false; + + char* pos = strchr(aircraft, '3'); + if (pos && *(pos - 1) == 'A') { + if (*(pos + 1) == '1') { + globals.aircraft = AIRBUS_A310; + foundAircraft = true; + } + else if (*(pos + 1) == '2' || *(pos + 1) == '8') { + globals.aircraft = FBW; + foundAircraft = true; + } } - else { - // Need to flip between other aircraft so that instruments - // can detect the aircraft has changed. - if (globals.aircraft == OTHER_AIRCRAFT) { - globals.aircraft = OTHER_AIRCRAFT2; + + if (!foundAircraft) { + if (strncmp(aircraft, globals.Cessna_152_Text, globals.Cessna_152_Len) == 0) { + globals.aircraft = CESSNA_152; + } + else if (strncmp(aircraft, globals.Cessna_172_Text, globals.Cessna_172_Len) == 0) { + globals.aircraft = CESSNA_172; + } + else if (strncmp(aircraft, globals.Cessna_CJ4_Text, globals.Cessna_CJ4_Len) == 0) { + globals.aircraft = CESSNA_CJ4; + } + else if (strncmp(aircraft, globals.Savage_Cub_Text, globals.Savage_Cub_Len) == 0) { + globals.aircraft = SAVAGE_CUB; + } + else if (strncmp(aircraft, globals.Shock_Ultra_Text, globals.Shock_Ultra_Len) == 0) { + globals.aircraft = SHOCK_ULTRA; + } + else if (strncmp(aircraft, globals.Boeing_747_Text, globals.Boeing_747_Len) == 0) { + globals.aircraft = BOEING_747; + } + else if (strncmp(aircraft, globals.Salty_Boeing_747_Text, globals.Salty_Boeing_747_Len) == 0) { + globals.aircraft = BOEING_747; + } + else if (strncmp(aircraft, globals.Boeing_787_Text, globals.Boeing_787_Len) == 0) { + globals.aircraft = BOEING_787; + } + else if (strncmp(aircraft, globals.Supermarine_Spitfire_Text, globals.Supermarine_Spitfire_Len) == 0) { + globals.aircraft = SUPERMARINE_SPITFIRE; + } + else if (strncmp(aircraft, globals.F15_Eagle_Text, globals.F15_Eagle_Len) == 0) { + globals.aircraft = F15_EAGLE; + } + else if (strncmp(aircraft, globals.F18_Hornet_Text, globals.F18_Hornet_Len) == 0) { + globals.aircraft = F18_HORNET; + } + else if (strncmp(aircraft, globals.JustFlight_PA28_Text, globals.JustFlight_PA28_Len) == 0) { + globals.aircraft = JUSTFLIGHT_PA28; } else { - globals.aircraft = OTHER_AIRCRAFT; + // Need to flip between other aircraft so that instruments + // can detect the aircraft has changed. + if (globals.aircraft == OTHER_AIRCRAFT) { + globals.aircraft = OTHER_AIRCRAFT2; + } + else { + globals.aircraft = OTHER_AIRCRAFT; + } } } strcpy(globals.lastAircraft, aircraft); diff --git a/power-lights-panel/globals.h b/power-lights-panel/globals.h index 502a63e..a7ef955 100644 --- a/power-lights-panel/globals.h +++ b/power-lights-panel/globals.h @@ -17,7 +17,7 @@ enum Aircraft { SAVAGE_CUB, SHOCK_ULTRA, AIRBUS_A310, - FBW_A320, + FBW, BOEING_747, BOEING_787, SUPERMARINE_SPITFIRE, @@ -40,14 +40,6 @@ struct globalVars const int Savage_Cub_Len = 16; const char* Shock_Ultra_Text = "Savage Shock Ultra"; const int Shock_Ultra_Len = 18; - const char* Airbus_A310_Text = "Airbus A310"; - const int Airbus_A310_Len = 11; - const char* IniBuilds_A310_Text = "A310"; - const int IniBuilds_A310_Len = 4; - const char* Airbus_A320_Text = "Airbus A320"; - const int Airbus_A320_Len = 11; - const char* FBW_A320_Text = "FBW"; - const int FBW_A320_Len = 3; const char* Boeing_747_Text = "Boeing 747-8"; const int Boeing_747_Len = 12; const char* Salty_Boeing_747_Text = "Salty Boeing 747"; diff --git a/power-lights-panel/powerLights-panel.cpp b/power-lights-panel/powerLights-panel.cpp index 9e874e3..1558892 100644 --- a/power-lights-panel/powerLights-panel.cpp +++ b/power-lights-panel/powerLights-panel.cpp @@ -13,7 +13,7 @@ #include "simvars.h" #include "powerLights.h" -const char* powerLightsVersion = "v1.5.3"; +const char* powerLightsVersion = "v1.5.4"; const bool Debug = false; struct globalVars globals; diff --git a/power-lights-panel/powerLights.cpp b/power-lights-panel/powerLights.cpp index 08ccd27..2f0b8c3 100644 --- a/power-lights-panel/powerLights.cpp +++ b/power-lights-panel/powerLights.cpp @@ -106,7 +106,7 @@ void powerLights::update() // Only update local values from sim if they are not currently being adjusted. // This stops them from jumping around due to lag of fetch/update cycle. if (lastApuMasterAdjust == 0) { - if (loadedAircraft == AIRBUS_A310 || loadedAircraft == FBW_A320) { + if (loadedAircraft == AIRBUS_A310 || loadedAircraft == FBW) { apuMaster = simVars->apuMasterSw > 0; } else if (simVars->apuStartSwitch > 0) { @@ -138,7 +138,7 @@ void powerLights::update() if (lastApuBleedAdjust == 0) { // Only relevant to A32NX - if (loadedAircraft == AIRBUS_A310 || loadedAircraft == FBW_A320) { + if (loadedAircraft == AIRBUS_A310 || loadedAircraft == FBW) { apuBleed = simVars->apuBleed > 0; } else { @@ -181,7 +181,7 @@ void powerLights::gpioSwitchesInput() // This allows a toggle to be switched without causing an // action (to fix an inverted toggle). if (prevApuBleedPush % 2 == 1) { - if (globals.aircraft == AIRBUS_A310 || globals.aircraft == FBW_A320) { + if (globals.aircraft == AIRBUS_A310 || globals.aircraft == FBW) { globals.simVars->write(KEY_ELEC_BAT1, val); } else if (airliner) { @@ -205,7 +205,7 @@ void powerLights::gpioSwitchesInput() if (val != INT_MIN && val != prevBattery2Toggle) { // Switch toggled (ignore if APU Bleed being pressed) if (prevApuBleedPush % 2 == 1) { - if (globals.aircraft == AIRBUS_A310 || globals.aircraft == FBW_A320) { + if (globals.aircraft == AIRBUS_A310 || globals.aircraft == FBW) { globals.simVars->write(KEY_ELEC_BAT2, val); } else if (airliner) { diff --git a/power-lights-panel/simvarDefs.cpp b/power-lights-panel/simvarDefs.cpp index 530f912..74dfc1d 100644 --- a/power-lights-panel/simvarDefs.cpp +++ b/power-lights-panel/simvarDefs.cpp @@ -1,7 +1,7 @@ #include #include "simvarDefs.h" -const char* versionString = "v2.0.3"; +const char* versionString = "v2.0.4"; const char* SimVarDefs[][2] = { // Vars for Jetbridge (must come first) diff --git a/release.sh b/release.sh index fc5d98c..22117da 100644 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ -rel=v1.5.3 +rel=v1.5.4 mkdir release >/dev/null 2>&1 rm -rf release/$rel >/dev/null 2>&1 mkdir release/$rel