1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 01:35:21 +03:00

Prep for upcommnig GasSuite firmware update

This commit is contained in:
3djc 2018-09-21 13:02:22 +02:00
parent 1bd8558eeb
commit 26c4927993

View file

@ -1,4 +1,3 @@
---- ######################################################################### ---- #########################################################################
---- # # ---- # #
---- # Copyright (C) OpenTX # ---- # Copyright (C) OpenTX #
@ -16,13 +15,12 @@
---- # # ---- # #
---- ######################################################################### ---- #########################################################################
local version = "v1.01" local version = "v1.1"
local VALUE = 0 local VALUE = 0
local COMBO = 1 local COMBO = 1
local FLPOI = 2 local FLPOI = 2
local edit = false local edit = false
local page = 1 local page = 1
local current = 1 --row local current = 1 --row
@ -40,39 +38,39 @@ local spacing = 8
local configFields = {} local configFields = {}
local counter = 0 local counter = 0
local function drawScreenTitle(title,page, pages) local function drawScreenTitle(title, page, pages)
if math.fmod(math.floor(getTime()/100),10) == 0 then if math.fmod(math.floor(getTime() / 100), 10) == 0 then
title = version title = version
end end
if LCD_W == 480 then if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR) lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR) lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
lcd.drawText(LCD_W-40, 5, page.."/"..pages, MENU_TITLE_COLOR) lcd.drawText(LCD_W - 40, 5, page .. "/" .. pages, MENU_TITLE_COLOR)
else else
lcd.drawScreenTitle(title, page, pages) lcd.drawScreenTitle(title, page, pages)
end end
end end
local interfaceconfig = { local interfaceconfig = {
{"Sensor group select", VALUE, 0x0d10, nil, 0, 15}, { "Sensor group select", VALUE, 0x0d10, nil, 0, 15 },
} }
local settingsFields = { local settingsFields = {
{"Software version", FLPOT, 0x0c, nil, 1, 100 }, { "Software version", FLPOT, 0x0c, nil, 1, 100 },
{"Physical ID", VALUE, 0x01, nil, 0, 26 }, { "Physical ID", VALUE, 0x01, nil, 0, 26 },
{"Application IDgroup", VALUE, 0x0D, nil, 0, 15 }, { "Application IDgroup", VALUE, 0x0D, nil, 0, 15 },
{"Data rate(*100ms)", VALUE, 0x22, nil, 1, 255 }, { "Data rate(*100ms)", VALUE, 0x22, nil, 1, 255 },
} }
local telemetryFields = { local telemetryFields = {
{"TEMP1(C/F)", VALUE, 0x90, nil, -30, 600}, { "TEMP1(C/F)", VALUE, 0x90, nil, -30, 600 },
{"TEMP2(C/F)", VALUE, 0x91, nil, -30, 600}, { "TEMP2(C/F)", VALUE, 0x91, nil, -30, 600 },
{"SPEED(r/min)", VALUE, 0x92, nil, 0, 100000}, { "SPEED(r/min)", VALUE, 0x92, nil, 0, 100000 },
{"Residual Volume(mL)", VALUE, 0x93, nil, 0, 60000}, { "Residual Volume(mL)", VALUE, 0x93, nil, 0, 60000 },
{"Residual Percent(%)", VALUE, 0x94, nil, 0, 100}, { "Residual Percent(%)", VALUE, 0x94, nil, 0, 100 },
{"FLOW(mL/min)", VALUE, 0x95, nil, 0, 2000}, { "FLOW(mL/min)", VALUE, 0x95, nil, 0, 2000 },
{"Max Flow(mL/min)", VALUE, 0x96, nil, 0, 2000}, { "Max Flow(mL/min)", VALUE, 0x96, nil, 0, 2000 },
{"Avg Flow(mL/min)", VALUE, 0x97, nil, 0, 2000}, { "Avg Flow(mL/min)", VALUE, 0x97, nil, 0, 2000 },
} }
-- Change display attribute to current field -- Change display attribute to current field
@ -86,26 +84,26 @@ local function addField(step)
min = 0 min = 0
max = #(field[5]) - 1 max = #(field[5]) - 1
end end
if field[2] ~= FLPOT then --only read ? if field[2] ~= FLPOT then --only read ?
if field[2] == VALUE and field[6] > 256 then if field[2] == VALUE and field[6] > 256 then
if field[4] > 1000 then if field[4] > 1000 then
step = step * 50 step = step * 50
field[4] = math.floor(field[4]/50) field[4] = math.floor(field[4] / 50)
field[4] = field[4] *50 field[4] = field[4] * 50
elseif field[4] > 500 then elseif field[4] > 500 then
step = step * 20 step = step * 20
field[4] = math.floor(field[4]/20) field[4] = math.floor(field[4] / 20)
field[4] = field[4] *20 field[4] = field[4] * 20
elseif field[4] > 200 then elseif field[4] > 200 then
step = step * 10 step = step * 10
field[4] = math.floor(field[4]/10) field[4] = math.floor(field[4] / 10)
field[4] = field[4] *10 field[4] = field[4] * 10
else else
step = step * 1 step = step * 1
field[4] = math.floor(field[4]/1) field[4] = math.floor(field[4] / 1)
field[4] = field[4] *1 field[4] = field[4] * 1
end end
end end
if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then
field[4] = field[4] + step field[4] = field[4] + step
end end
@ -139,12 +137,12 @@ end
local function drawProgressBar() local function drawProgressBar()
if LCD_W == 480 then if LCD_W == 480 then
local width = (300 * refreshIndex) / #fields local width = (300 * refreshIndex) / #fields
lcd.drawRectangle(100, 10, 300, 6) lcd.drawRectangle(100, 10, 300, 6)
lcd.drawFilledRectangle(102, 13, width, 2); lcd.drawFilledRectangle(102, 13, width, 2);
else else
local width = (60 * refreshIndex) / #fields local width = (60 * refreshIndex) / #fields
lcd.drawRectangle(45, 1, 60, 6) lcd.drawRectangle(45, 1, 60, 6)
lcd.drawFilledRectangle(47, 3, width, 2); lcd.drawFilledRectangle(47, 3, width, 2);
end end
end end
@ -156,28 +154,28 @@ local function redrawFieldsPage()
drawProgressBar() drawProgressBar()
end end
for index = 1, 7, 1 do for index = 1, 7, 1 do
local field = fields[pageOffset+index] local field = fields[pageOffset + index]
if field == nil then if field == nil then
break break
end end
local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0 local attr = current == (pageOffset + index) and ((edit == true and BLINK or 0) + INVERS) or 0
lcd.drawText(1, margin+ spacing * index, field[1]) lcd.drawText(1, margin + spacing * index, field[1])
if field[4] == nil then if field[4] == nil then
lcd.drawText(LCD_W, margin+ spacing * index, "---", attr + RIGHT) lcd.drawText(LCD_W, margin + spacing * index, "---", attr + RIGHT)
else else
if field[2] == VALUE then if field[2] == VALUE then
if (field[3] == 0x90 or field[3] == 0x91) and field[4] == 500 then if (field[3] == 0x90 or field[3] == 0x91) and field[4] == 500 then
lcd.drawText(LCD_W, margin+ spacing * index, "---", attr + RIGHT) lcd.drawText(LCD_W, margin + spacing * index, "---", attr + RIGHT)
else else
lcd.drawNumber(LCD_W, margin+ spacing * index, field[4] , attr + RIGHT) lcd.drawNumber(LCD_W, margin + spacing * index, field[4], attr + RIGHT)
end end
elseif field[2] == COMBO then elseif field[2] == COMBO then
if field[4] >= 0 and field[4] < #(field[5]) then if field[4] >= 0 and field[4] < #(field[5]) then
lcd.drawText(LCD_W, margin+ spacing * index, field[5][1+field[4]], attr + RIGHT) lcd.drawText(LCD_W, margin + spacing * index, field[5][1 + field[4]], attr + RIGHT)
end end
elseif field[2] == FLPOT then elseif field[2] == FLPOT then
lcd.drawText(LCD_W, margin+ spacing * index, field[4], attr + RIGHT) lcd.drawText(LCD_W, margin + spacing * index, field[4], attr + RIGHT)
end end
end end
end end
@ -188,32 +186,33 @@ local function telemetryRead(fieldx)
end end
local function telemetryListen(fieldx) local function telemetryListen(fieldx)
return sportTelemetryPush(0x1b, 0, 0, 0) return sportTelemetryPush(0x1b, 0, 0, 0)
end end
local function telemetryWrite(fieldx, valuex) local function telemetryWrite(fieldx, valuex)
return sportTelemetryPush(0x1b, 0x31, 0x0d10, fieldx + valuex*256) return sportTelemetryPush(0x1b, 0x31, 0x0d10, fieldx + valuex * 256)
end end
local telemetryPopTimeout = 0 local telemetryPopTimeout = 0
local function refreshNext() local function refreshNext()
if refreshState == 0 and page ~= 3 then -- if refreshState == 0 and page ~= 3 then
if #modifications > 0 then -- if #modifications > 0 then
if modifications[1][1] ~= 0x0c then --
if modifications[1][1] == 0x22 then if modifications[1][1] ~= 0x0c then
modifications[1][2] = modifications[1][2] + 0xf00 if modifications[1][1] == 0x22 then
end modifications[1][2] = modifications[1][2] + 0xf00
local modificationstmp = modifications[1][2] end
if modifications[1][1] == 0x8a or modifications[1][1] == 0x8b then local modificationstmp = modifications[1][2]
if configFields[12][4]== 1 then if modifications[1][1] == 0x8a or modifications[1][1] == 0x8b then
modificationstmp = (modifications[1][2] - 32)*10 if configFields[12][4] == 1 then
modificationstmp = math.floor(modificationstmp/18) modificationstmp = (modifications[1][2] - 32) * 10
end modificationstmp = math.floor(modificationstmp / 18)
end end
telemetryWrite(modifications[1][1], modificationstmp) end
refreshIndex = 0 telemetryWrite(modifications[1][1], modificationstmp)
refreshIndex = 0
end end
modifications[1] = nil modifications[1] = nil
elseif refreshIndex < #fields then elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1] local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then if telemetryRead(field[3]) == true then
@ -223,9 +222,9 @@ local function refreshNext()
end end
elseif refreshState == 0 and page == 3 then elseif refreshState == 0 and page == 3 then
if #modifications > 0 then if #modifications > 0 then
if modifications[1][1] == 0x96 or modifications[1][1] == 0x97 or modifications[1][1] == 0x93 then if modifications[1][1] == 0x96 or modifications[1][1] == 0x97 or modifications[1][1] == 0x93 then
telemetryWrite(modifications[1][1], 0) telemetryWrite(modifications[1][1], 0)
end end
modifications[1] = nil modifications[1] = nil
elseif refreshIndex < #fields then elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1] local field = fields[refreshIndex + 1]
@ -234,12 +233,12 @@ local function refreshNext()
telemetryPopTimeout = getTime() + 20 telemetryPopTimeout = getTime() + 20
end end
elseif refreshIndex >= #fields then elseif refreshIndex >= #fields then
refreshIndex = 0 refreshIndex = 0
refreshState = 0 refreshState = 0
end end
elseif refreshState == 1 and page ~= 3 then elseif refreshState == 1 and page ~= 3 then
local physicalId, primId, dataId, value = sportTelemetryPop() local physicalId, primId, dataId, value = sportTelemetryPop()
if primId == 0x32 and dataId >= 0x0d00 and dataId <= 0x0d7f then if primId == 0x32 and dataId >= 0x0d00 and dataId <= 0x0d7f then
local fieldId = value % 256 local fieldId = value % 256
local field = fields[refreshIndex + 1] local field = fields[refreshIndex + 1]
if fieldId == field[3] then if fieldId == field[3] then
@ -251,72 +250,72 @@ local function refreshNext()
break break
end end
end end
elseif field[2] == VALUE then elseif field[2] == VALUE then
value = value -- - field[8] + field[5] value = value -- - field[8] + field[5]
end end
if field[1] == "Software version" then if field[1] == "Software version" then
local flo_string = string.char(value/16%16 + 48).."."..string.char(value%16 + 48) local flo_string = string.char(value / 16 % 16 + 48) .. "." .. string.char(value % 16 + 48)
fields[refreshIndex + 1][4] = flo_string fields[refreshIndex + 1][4] = flo_string
else else
fields[refreshIndex + 1][4] = value fields[refreshIndex + 1][4] = value
end end
refreshIndex = refreshIndex + 1 refreshIndex = refreshIndex + 1
refreshState = 0 refreshState = 0
end end
elseif getTime() > telemetryPopTimeout then elseif getTime() > telemetryPopTimeout then
refreshState = 0 refreshState = 0
end end
elseif refreshState == 1 and page == 3 then elseif refreshState == 1 and page == 3 then
local pageID3 = 0 local pageID3 = 0
local physicalId3, primId3, dataId3, value3 = sportTelemetryPop() local physicalId3, primId3, dataId3, value3 = sportTelemetryPop()
if value3 ~= nil then if value3 ~= nil then
pageID3 = value3 % 256 pageID3 = value3 % 256
value3 = math.floor(value3 / 0x100) value3 = math.floor(value3 / 0x100)
end end
if primId3 == 0x32 and value3 ~= nil then if primId3 == 0x32 and value3 ~= nil then
if pageID3 == fields[refreshIndex + 1][3] then if pageID3 == fields[refreshIndex + 1][3] then
local field = fields[refreshIndex + 1] local field = fields[refreshIndex + 1]
if field[2] == COMBO and #field == 6 then if field[2] == COMBO and #field == 6 then
for index = 1, #(field[6]), 1 do for index = 1, #(field[6]), 1 do
if value3 == field[6][index] then if value3 == field[6][index] then
value3 = index - 1 value3 = index - 1
break break
end end
end end
elseif field[2] == VALUE then elseif field[2] == VALUE then
if field[3] == 0x90 or field[3] == 0x91 then if field[3] == 0x90 or field[3] == 0x91 then
value3 = math.floor(value3 % 0x10000) value3 = math.floor(value3 % 0x10000)
if value3 > 0xf000 then if value3 > 0xf000 then
value3 = value3 - 0x10000 value3 = value3 - 0x10000
end end
if configFields[12][4]== 1 and (field[3] == 0x90 or field[3] == 0x91)then if configFields[11][4] == 1 and (field[3] == 0x90 or field[3] == 0x91) then
value3 =(value3*18) value3 = (value3 * 18)
value3 = math.floor(value3/10)+32 value3 = math.floor(value3 / 10) + 32
end end
else else
value3 = value3 value3 = value3
end end
end
fields[refreshIndex + 1][4] = value3
refreshIndex = refreshIndex + 1
refreshState = 0
end end
fields[refreshIndex + 1][4] = value3 elseif getTime() > telemetryPopTimeout then
refreshIndex = refreshIndex + 1
refreshState = 0
end
elseif getTime() > telemetryPopTimeout then
refreshState = 0 refreshState = 0
end end
end end
end end
local function updateField(field) local function updateField(field)
local value = field[4] local value = field[4]
if field[2] == COMBO and #field == 6 then if field[2] == COMBO and #field == 6 then
value = field[6][1+value] value = field[6][1 + value]
elseif field[2] == VALUE and #field == 6 then elseif field[2] == VALUE and #field == 6 then
value = value -- + field[8] - field[5] value = value -- + field[8] - field[5]
elseif field[2] == FLPOT then elseif field[2] == FLPOT then
value = 0 value = 0
end end
modifications[#modifications+1] = {field[3], value} modifications[#modifications + 1] = { field[3], value }
end end
-- Main1 -- Main1
@ -331,15 +330,15 @@ local function runFieldsPage(event)
end end
end end
elseif edit then elseif edit then
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT or event == EVT_RIGHT_FIRST then
addField(1) addField(1)
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT or event == EVT_LEFT_FIRST then
addField(-1) addField(-1)
end end
else else
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_DOWN_FIRST then
selectField(1) selectField(1)
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT or event == EVT_UP_FIRST then
selectField(-1) selectField(-1)
end end
end end
@ -371,120 +370,119 @@ local function init()
spacing = 20 spacing = 20
end end
if LCD_W == 128 then if LCD_W == 128 then
configFields = { configFields = {
{"CDI off speed limit", VALUE, 0x81, nil, 10,10000}, { "CDI off speed limit", VALUE, 0x81, nil, 10, 10000 },
{"Milliliter per pulse", VALUE, 0x80, nil, 1, 2000}, { "Milliliter per pulse", VALUE, 0x80, nil, 1, 2000 },
{"Volume", VALUE, 0x83, nil, 10,60000}, { "Volume", VALUE, 0x83, nil, 10, 60000 },
{"Flow trigger", VALUE, 0x84, nil, 5, 50 }, { "Auto Reset", COMBO, 0x8d, nil, { "ON", "OFF" }, { 0, 1 } }, -- settings is in fact Flow Save, so inverted
{"Auto Reset", COMBO, 0x85, nil, { "ON", "OFF" }, {1 , 0}}, { "Reset settings", COMBO, 0x86, nil, { "YES", "NO" }, { 1, 0 } },
{"Reset settings", COMBO, 0x86, nil,{ "YES", "NO" }, {1 , 0} }, { "Volume alarm(%)", VALUE, 0x87, nil, 0, 90 },
{"Volume alarm(%)", VALUE, 0x87, nil, 0, 90 }, { "Max.Flow alarm", VALUE, 0x88, nil, 0, 2000 },
{"Max.Flow alarm", VALUE, 0x88, nil, 0, 2000 }, { "Over speed alarm", VALUE, 0x89, nil, 0, 10000 },
{"Over speed alarm", VALUE, 0x89, nil, 0, 10000 }, { "Over temp1 alarm", VALUE, 0x8a, nil, 0, 600 },
{"Over temp1 alarm", VALUE, 0x8a, nil, 0, 600 }, { "Over temp2 alarm", VALUE, 0x8b, nil, 0, 600 },
{"Over temp2 alarm", VALUE, 0x8b, nil, 0, 600 }, { "Temperature C/F", COMBO, 0x8c, nil, { "C", "F" }, { 0, 1 } },
{"Temperature C/F", COMBO, 0x8c, nil,{ "C", "F" }, {0 , 1} },
} }
else else
configFields = { configFields = {
{"CDI off speed limit(*100RPM)", VALUE, 0x81, nil, 10,10000}, { "CDI off speed limit(*100RPM)", VALUE, 0x81, nil, 10, 10000 },
{"Milliliter per pulse(*0.001mL/pul)", VALUE, 0x80, nil, 1, 2000}, { "Milliliter per pulse(*0.001mL/pul)", VALUE, 0x80, nil, 1, 2000 },
{"Volume(mL)", VALUE, 0x83, nil, 10,60000}, { "Volume(mL)", VALUE, 0x83, nil, 10, 60000 },
{"Flow trigger(mL/min)", VALUE, 0x84, nil, 5, 50 }, { "Auto Reset", COMBO, 0x8d, nil, { "ON", "OFF" }, { 0, 1 } },
{"Auto Reset", COMBO, 0x85, nil, { "ON", "OFF" }, {1 , 0}}, { "Reset to factory settings", COMBO, 0x86, nil, { "YES", "NO" }, { 1, 0 } },
{"Reset to factory settings", COMBO, 0x86, nil,{ "YES", "NO" }, {1 , 0} }, { "Volume alarm(%)", VALUE, 0x87, nil, 0, 90 },
{"Volume alarm(%)", VALUE, 0x87, nil, 0, 90 }, { "Max.Flow alarm(mL/min)", VALUE, 0x88, nil, 0, 2000 },
{"Max.Flow alarm(mL/min)", VALUE, 0x88, nil, 0, 2000 }, { "Over speed alarm(*100RPM)", VALUE, 0x89, nil, 0, 10000 },
{"Over speed alarm(*100RPM)", VALUE, 0x89, nil, 0, 10000 }, { "Over temperature1 alarm(C/F)", VALUE, 0x8a, nil, 0, 600 },
{"Over temperature1 alarm(C/F)", VALUE, 0x8a, nil, 0, 600 }, { "Over temperature2 alarm(C/F)", VALUE, 0x8b, nil, 0, 600 },
{"Over temperature2 alarm(C/F)", VALUE, 0x8b, nil, 0, 600 }, { "Temperature Celsius/Fahrenheit", COMBO, 0x8c, nil, { "C", "F" }, { 0, 1 } },
{"Temperature Celsius/Fahrenheit", COMBO, 0x8c, nil,{ "C", "F" }, {0 , 1} },
} }
end end
pages = { pages = {
runConfigPage, runConfigPage,
runSettingsPage, runSettingsPage,
runTelemetryPage, runTelemetryPage,
} }
end end
local function background() local function background()
local tonefrq,tonelength,tonepause local tonefrq, tonelength, tonepause
thistime = getTime() thistime = getTime()
lastTime = thistime lastTime = thistime
refreshNext() refreshNext()
if page == 3 then --alarm if page == 3 then
local alarmnum = 0 --alarm
if fields[3][4] ~= nil and configFields[9][4] ~= nil then local alarmnum = 0
local speedtest = fields[3][4] if fields[3][4] ~= nil and configFields[9][4] ~= nil then
local speedover = configFields[9][4]*100 local speedtest = fields[3][4]
if speedtest >= speedover then local speedover = configFields[9][4] * 100
tonefrq = 800 + math.max(0,math.floor((speedtest - speedover)/10)) if speedtest >= speedover then
tonelength = 50 + math.max(0,(150 - math.floor((speedtest - speedover)/10))) tonefrq = 800 + math.max(0, math.floor((speedtest - speedover) / 10))
tonepause = tonelength tonelength = 50 + math.max(0, (150 - math.floor((speedtest - speedover) / 10)))
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10) tonepause = tonelength
alarmnum = alarmnum + 1 playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND, 10)
end alarmnum = alarmnum + 1
end
end
if fields[5][4] ~= nil and configFields[7][4] ~= nil then
local Residualtest = fields[5][4]
local Residualline = configFields[6][4]
if Residualtest < Residualline then
tonefrq = 400
tonelength = 100
tonepause = 1000 + math.floor(Residualline - Residualtest) * 30
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND, 10)
alarmnum = alarmnum + 1
end
end
if fields[6][4] ~= nil and configFields[8][4] ~= nil then
local Flowtest = fields[6][4]
local Flowover = configFields[7][4]
if Flowtest > Flowover then
tonefrq = 400
tonelength = 100
tonepause = 200
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND, 10)
alarmnum = alarmnum + 1
end
end
if fields[1][4] ~= nil and configFields[10][4] ~= nil then
local temp1test = fields[1][4] --
local temp1over = configFields[9][4]
if temp1test > temp1over and (temp1test ~= 500 and temp1test ~= 932) then
tonefrq = 2000
tonelength = 100
tonepause = 900
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND, 10)
alarmnum = alarmnum + 1
end
end
if fields[2][4] ~= nil and configFields[11][4] ~= nil then
local temp2test = fields[2][4]
local temp2over = configFields[10][4]
if temp2test > temp2over and (temp2test ~= 500 and temp2test ~= 932) then
tonefrq = 2000
tonelength = 300
tonepause = 700
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND, 10)
alarmnum = alarmnum + 1
end
end
if alarmnum > 1 then
playTone(2000, 100, 100, PLAY_BACKGROUND, 10)
end
alarmnum = 0
end end
if fields[5][4] ~= nil and configFields[7][4] ~= nil then
local Residualtest = fields[5][4]
local Residualline = configFields[7][4]
if Residualtest < Residualline then
tonefrq = 400
tonelength = 100
tonepause = 1000 + math.floor( Residualline - Residualtest )*30
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[6][4] ~= nil and configFields[8][4] ~= nil then
local Flowtest = fields[6][4] --
local Flowover = configFields[8][4]
if Flowtest > Flowover then
tonefrq = 400
tonelength = 100
tonepause = 200
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[1][4] ~= nil and configFields[10][4] ~= nil then
local temp1test = fields[1][4] --
local temp1over = configFields[10][4]
if temp1test > temp1over and (temp1test ~= 500 and temp1test ~= 932) then
tonefrq = 2000
tonelength = 100
tonepause = 900
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[2][4] ~= nil and configFields[11][4] ~= nil then
local temp2test = fields[2][4]
local temp2over = configFields[11][4]
if temp2test > temp2over and (temp2test ~= 500 and temp2test ~= 932) then
tonefrq = 2000
tonelength = 300
tonepause = 700
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if alarmnum > 1 then
playTone(2000, 100, 100, PLAY_BACKGROUND,10)
end
alarmnum = 0
end
end end
local function run(event) local function run(event)
if event == nil then if event == nil then
error("Cannot be run as a sensor script!") error("Cannot be run as a sensor script!")
return 2 return 2
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST then elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_RIGHT_FIRST then
selectPage(1) selectPage(1)
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST then elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_LEFT_FIRST then
killEvents(event); killEvents(event);
selectPage(-1) selectPage(-1)
end end
@ -496,4 +494,4 @@ local function run(event)
return result return result
end end
return { init=init, background=background, run=run } return { init = init, background = background, run = run }