Skip to content

elrsV3.lua: added editing of parameter type string #2995

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

Open
wants to merge 5 commits into
base: 3.x.x-maintenance
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
use maxlen of STRING parameter and a built-in maximum length of 16 chars
  • Loading branch information
wimalopaan committed Oct 21, 2024
commit d4be9c03819be6188696d70efc991028c1b6101f
12 changes: 10 additions & 2 deletions src/lua/elrsV3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ local function getField(line)
end

local subFieldIndex = 1
local stringPossibleChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#-."
local stringPossibleChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#-. "
local maxStringLength = 16
local function incrCharInTextField(field, step)
local c = string.sub(field.value, subFieldIndex, subFieldIndex)
local idx = string.find(stringPossibleChars, c, 1, true)
Expand All @@ -84,11 +85,18 @@ end
local function incrSubField(step)
local field = getField(lineIndex)
subFieldIndex = subFieldIndex + step
if (subFieldIndex > #field.value) then
local maxlength = maxStringLength
if (field.maxlen) then
maxlength = field.maxlen
end
if (subFieldIndex > maxlength) then
subFieldIndex = 1
elseif (subFieldIndex < 1) then
subFieldIndex = #field.value
end
if (subFieldIndex > #field.value) then
field.value = field.value .. " "
end
end

local function incrField(step)
Expand Down