-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added FA-18C Hornet support: backlight
- Loading branch information
1 parent
f60bd77
commit 83a87f5
Showing
2 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
------------------------------------------------------------------------------- | ||
-- | ||
-- fa-18c_hornet_lamps.lua | ||
-- | ||
-- Use at own risk without warranty. | ||
-- | ||
-- Utility functions for retrieving DCS F/A-18C Hornet simulation data | ||
-- and packaging for TCP packet transmission to Thrustmaster Target | ||
-- TMHotasLEDSync.tmc script. | ||
-- | ||
-- Author: slughead | ||
-- Date: 2/12/2023 | ||
-- | ||
------------------------------------------------------------------------------ | ||
|
||
local P = {} | ||
fa_18c_hornet_lamps = P | ||
|
||
P.CONSOLE_LIGHT_DIAL = 413 | ||
|
||
P.speedbrakes_value = nil | ||
P.console_light_value = nil | ||
|
||
|
||
local function get_console_light_value( current_value ) | ||
local updated = false | ||
local value = 0 | ||
|
||
local device = Export.GetDevice(0) | ||
if type(device) ~= "number" and device ~= nil then | ||
local aircraft_lamp_utils = require("fa-18c_hornet_lamps") | ||
|
||
-- get engine info | ||
local lEngInfo = Export.LoGetEngineInfo() | ||
|
||
if (lEngInfo.RPM.left > 60) then | ||
value = device:get_argument_value(aircraft_lamp_utils.CONSOLE_LIGHT_DIAL) | ||
value = math.floor(value * 5) | ||
end | ||
|
||
if current_value ~= value then | ||
updated = true | ||
end | ||
end | ||
|
||
return updated, value | ||
end | ||
|
||
local function get_speedbrake_value( current_value ) | ||
|
||
local updated = false | ||
local value = 0 | ||
|
||
local lMechInfo = Export.LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,... | ||
if (lMechInfo ~= nil) then | ||
value = lMechInfo.speedbrakes.value | ||
|
||
-- ensure full range is used for aircraft that almost reach 1.0 | ||
if (value >= 0.9) then value = 1.0 end | ||
|
||
value = math.floor(value * 5) | ||
|
||
if (current_value ~= value) then | ||
updated = true; | ||
end | ||
end | ||
|
||
return updated, value | ||
end | ||
|
||
function P.create_lamp_status_payload( self ) | ||
|
||
local updated = false | ||
local status_changed = false | ||
local payload | ||
|
||
local device = Export.GetDevice(0) | ||
if type(device) ~= "number" and device ~= nil then | ||
status_changed, self.speedbrakes_value = get_speedbrake_value( self.speedbrakes_value ) | ||
updated = updated or status_changed | ||
|
||
status_changed, self.console_light_value = get_console_light_value( self.console_light_value ) | ||
updated = updated or status_changed | ||
|
||
payload = string.format( "%d%d", | ||
self.speedbrakes_value, | ||
self.console_light_value ) | ||
else | ||
payload = "00" | ||
end | ||
|
||
return updated, payload | ||
|
||
end | ||
|
||
return fa_18c_hornet_lamps |