Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FC3 migration to Module #276

Merged
merged 10 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Scripts/DCS-BIOS/lib/meta_files/DCS_API_defs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ EngineSide = {}
--- @field HydraulicPressure EngineSide
--- @diagnostic disable-next-line: duplicate-doc-field
--- @field FuelConsumption EngineSide
--- @diagnostic disable-next-line: duplicate-doc-field
--- @field fuel_internal number
---@diagnostic disable-next-line: duplicate-doc-field
--- @field fuel_external number
EngineInformation = {}

--- @func Returns engine information
Expand All @@ -207,6 +211,8 @@ function LoGetEngineInfo() end
--- @field right number
--- @diagnostic disable-next-line: duplicate-doc-field
--- @field left number
--- @diagnostic disable-next-line: duplicate-doc-field
--- @field value number Gear status
GearValue = {}

--- @class MechanicalInformation
Expand Down
23 changes: 23 additions & 0 deletions Scripts/DCS-BIOS/lib/modules/Module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ function Module:defineFloat(identifier, arg_number, limits, category, descriptio
return control
end

function Module:define8BitFloatFromGetter(identifier, func, limits, category, description)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to add documentation, and also tests for any new control

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you be adding tests to ModuleTests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I will try.

-- same as defineFloat, but only allocates an 8-bit int
local max_value = 255
local intervalLength = limits[2] - limits[1]
local alloc = self:allocateInt(max_value)

self:addExportHook(function()
alloc:setValue(((func() - limits[1]) / intervalLength) * 255)
end)

local alloc = moduleBeingDefined.memoryMap:allocateInt({ maxValue = 255 })
jdahlblom marked this conversation as resolved.
Show resolved Hide resolved
moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks + 1] = function(dev0)
alloc:setValue(((func() - limits[1]) / intervalLength) * 255)
end

local control = Control:new(category, ControlType.metadata, identifier, description, {}, {
IntegerOutput:new(alloc, Suffix.none, description),
})
self:addControl(control)

return control
end

--- Adds a new indicator light control which will enable the LED when the argument value is greater than or equal to 0.3
--- @param identifier string the unique identifier for the control
--- @param arg_number integer the dcs argument number
Expand Down
Loading