Merge with latest 2.3
This commit is contained in:
@@ -72,7 +72,7 @@ local function incrField(step)
|
||||
end
|
||||
else
|
||||
local min, max = 0, 0
|
||||
if field.type <= 5 then
|
||||
if ((field.type <= 5) or (field.type == 8)) then
|
||||
min = field.min
|
||||
max = field.max
|
||||
step = field.step * step
|
||||
@@ -239,25 +239,21 @@ local function fieldFloatLoad(field, data, offset)
|
||||
field.default = fieldGetValue(data, offset+12, 4)
|
||||
fieldUnsignedToSigned(field, 4)
|
||||
field.prec = data[offset+16]
|
||||
if field.prec > 2 then
|
||||
field.prec = 2
|
||||
if field.prec > 3 then
|
||||
field.prec = 3
|
||||
end
|
||||
field.step = fieldGetValue(data, offset+17, 4)
|
||||
field.unit, offset = fieldGetString(data, offset+21)
|
||||
end
|
||||
|
||||
local function formatFloat(num, decimals)
|
||||
local mult = 10^(decimals or 0)
|
||||
local val = num / mult
|
||||
return string.format("%." .. decimals .. "f", val)
|
||||
end
|
||||
|
||||
local function fieldFloatDisplay(field, y, attr)
|
||||
local attrnum
|
||||
if field.prec == 1 then
|
||||
attrnum = LEFT + attr + PREC1
|
||||
elseif field.prec == 2 then
|
||||
attrnum = LEFT + attr + PREC2
|
||||
else
|
||||
attrnum = LEFT + attr
|
||||
end
|
||||
-- lcd.drawNumber(140, y, field.value, attrnum) -- NOTE: original code getLastPos not available in Horus
|
||||
-- lcd.drawText(lcd.getLastPos(), y, field.unit, attr) -- NOTE: original code getLastPos not available in Horus
|
||||
lcd.drawText(140, y, field.value .. field.unit, attr) -- NOTE: Concenated fields instead of get lastPos
|
||||
lcd.drawText(140, y, formatFloat(field.value, field.prec) .. field.unit, attr)
|
||||
end
|
||||
|
||||
local function fieldFloatSave(field)
|
||||
@@ -423,7 +419,7 @@ end
|
||||
|
||||
-- Main
|
||||
local function runDevicePage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
if edit == true then
|
||||
edit = false
|
||||
local field = getField(lineIndex)
|
||||
@@ -455,9 +451,9 @@ local function runDevicePage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_VIRTUAL_INC then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
incrField(1)
|
||||
elseif event == EVT_VIRTUAL_DEC then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
incrField(-1)
|
||||
end
|
||||
else
|
||||
|
||||
@@ -273,11 +273,6 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_SHIFT_BREAK then
|
||||
--selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_SHIFT_LONG then
|
||||
--killEvents(event);
|
||||
--selectPage(-1)
|
||||
end
|
||||
local result = pages[page](event)
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][5] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -101,15 +101,15 @@ local function runFieldsPage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -465,9 +465,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif (event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST) and page < #pages-1 then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE and page < #pages-1 then
|
||||
selectPage(1)
|
||||
elseif (event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST) and page > 1 then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE and page > 1 then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
@@ -91,9 +91,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][5] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -101,15 +101,15 @@ local function runFieldsPage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -465,9 +465,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif (event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST) and page < #pages-1 then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE and page < #pages-1 then
|
||||
selectPage(1)
|
||||
elseif (event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST) and page > 1 then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE and page > 1 then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user