From 371e301a519387eaae861778efd15b27e63d359d Mon Sep 17 00:00:00 2001 From: Charlie <30303272+charliefoxtwo@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:12:58 -0700 Subject: [PATCH] OH-58D: Add Standby Altimeter (#884) Fixes #753 --- Scripts/DCS-BIOS/doc/Addresses.h | 7 ++++ .../lib/modules/aircraft_modules/OH-58D.lua | 38 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Scripts/DCS-BIOS/doc/Addresses.h b/Scripts/DCS-BIOS/doc/Addresses.h index b6cc74fab..99e774776 100644 --- a/Scripts/DCS-BIOS/doc/Addresses.h +++ b/Scripts/DCS-BIOS/doc/Addresses.h @@ -28943,6 +28943,13 @@ #define OH_58D_AIR_VENT_CPLT_A 0x8B3E #define OH_58D_AIR_VENT_PLT 0x8B3C, 0xFFFF, 0 #define OH_58D_AIR_VENT_PLT_A 0x8B3C +#define OH_58D_ALTIMETER_KNOB 0x8C5E, 0xFFFF, 0 +#define OH_58D_ALTIMETER_KNOB_A 0x8C5E +#define OH_58D_ALTIMETER_NEEDLE 0x8C60, 0xFFFF, 0 +#define OH_58D_ALTIMETER_NEEDLE_A 0x8C60 +#define OH_58D_ALTIMETER_PRESSURE_A 0x8C62 +#define OH_58D_ALTIMETER_TEN_THOUSANDS_FLAG 0x8C4A, 0x00C0, 6 +#define OH_58D_ALTIMETER_VALUE_A 0x8C66 #define OH_58D_ARMAMENT_ARMED 0x8A46, 0x0100, 8 #define OH_58D_ARMAMENT_ARMED_AM 0x8A46, 0x0100 #define OH_58D_ARMAMENT_GUN 0x8A46, 0x0060, 5 diff --git a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/OH-58D.lua b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/OH-58D.lua index c73cc6214..47983eaee 100644 --- a/Scripts/DCS-BIOS/lib/modules/aircraft_modules/OH-58D.lua +++ b/Scripts/DCS-BIOS/lib/modules/aircraft_modules/OH-58D.lua @@ -978,7 +978,40 @@ OH_58D:definePotentiometer("RWR_BRIGHTNESS", devices.SYNC, 3001, 36, { 0, 0.8 }, OH_58D:defineToggleSwitch("RWR_DAY_NIGHT", devices.SYNC, 3002, 37, RWR, "Day/Night Switch") -- Standby Altimeter --- local STANDBY_ALTIMETER = "Standby Altimeter" +local STANDBY_ALTIMETER = "Standby Altimeter" + +OH_58D:defineRotary("ALTIMETER_KNOB", devices.SENSORS, 3001, 62, STANDBY_ALTIMETER, "Barometric Knob") + +OH_58D:defineFloat("ALTIMETER_NEEDLE", 61, { 0, 1 }, STANDBY_ALTIMETER, "Needle") -- this goes -1 to 1 in modelviewer, but in testing the value never drops below 0 +OH_58D:defineString("ALTIMETER_PRESSURE", function(dev0) + return tostring(Module.build_gauge_from_arguments(dev0, { 66, 65, 64, 63 })) +end, 4, STANDBY_ALTIMETER, "Pressure Setting (inHg)") + +OH_58D:defineString("ALTIMETER_VALUE", function(dev0) + local value = Module.round(dev0:get_argument_value(68) * 10) % 10 + + local ten_thousands = Module.round(dev0:get_argument_value(67) * 10) % 10 + + if ten_thousands >= 2 then + value = value + ((ten_thousands - 1) * 10) + end + + return Functions.pad_left(tostring(value) .. "000", 5) +end, 5, STANDBY_ALTIMETER, "Barometric Altitude") + +OH_58D:defineIntegerFromGetter("ALTIMETER_TEN_THOUSANDS_FLAG", function(dev0) + local ten_thousands = Module.round(dev0:get_argument_value(67) * 10) % 10 + + if ten_thousands == 0 then + return 2 + end + + if ten_thousands == 1 then + return 1 + end + + return 0 +end, 2, STANDBY_ALTIMETER, "Ten Thousands Flag (0 = no flag, 1 = yellow, 2 = red)") -- Standby Airspeed Indicator -- local STANDBY_AIRSPEED_INDICATOR = "Standby Airspeed Indicator" @@ -998,6 +1031,9 @@ OH_58D:defineToggleSwitch("RWR_DAY_NIGHT", devices.SYNC, 3002, 37, RWR, "Day/Nig -- MMS Control Panel -- local MMS_CONTROL_PANEL = "MMS Control Panel" +-- PDU +-- local PDU = "Pilot Display Unit" + -- CMWS -- local CMWS = "CMWS" -- indication 10