Skip to content

Commit

Permalink
Edge v2.10 code
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwieland authored May 11, 2024
1 parent 32d9842 commit f4bff7e
Showing 1 changed file with 84 additions and 72 deletions.
156 changes: 84 additions & 72 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- #########################################################################
---# F3A Caller V1.0 #
---# F3A Practice Caller V2.0 #
---# Developer: https://github.com/jrwieland #
-- # License GPLv3: http://www.gnu.org/licenses/gpl-3.0.html #
-- # License GPLv3: http://www.gnu.org/licenses/gpl-3.0.html #
-- # #
-- # This program is free software; you can redistribute it and/or modify #
-- # it under the terms of the GNU General Public License version 3 as #
Expand All @@ -16,116 +16,103 @@
--Locals
local currentCall = 1
local errorOccured = false

loadScript("/SOUNDS/lists/f25/playlist.lua")()--1st callList (below)

loadScript("/SOUNDS/lists/p21/playlist.lua")() --1st callList (below)
--Call lists folders names i.e. /SOUNDS/lists/"foldername" below are the foldernames these can be rearranged or deleted to suit your needs.
--Delete the rows that you do not use or the widget will fail since it cannot find the file

local callList=
{"p21",
"f21",
"ama_club",
"ama_sportsman",
"ama_inter",
"ama_advanced",
"ama_masters",
{"f25",
"p25",
"ama_club",
"ama_sportsman",
"ama_inter",
"ama_masters",
}

--Options
local options = {
{ "Use dflt clrs", BOOL, 1 }
{ "switch", SOURCE, DEFAULT_PRACTICE_SWITCH_ID },
{ "TextColor", COLOR, COLOR_THEME_PRIMARY2 },
}

-- create zones
local function create(zone, options)
local tunes = { zone=zone, options=options}
local calls = { zone=zone, options=options}
model.setGlobalVariable(8,0,1) -- resets GV9 to 1 upon startup
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[1][5],active=0})
--[[resets Call List to the Default Maneuver & call on startup
Switch Numbers run consecutive
Sa(up) = 1, through the remainder of the switches --]]
return tunes
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[1][8],active=1,repetition=-1})
return calls
end

--Update zones and options
local function update(tunes, options)
tunes.options = options
local function update(calls, options)
calls.options = options
end

--BackGround
local function background(tunes)
local function background(calls)
end

function refresh(tunes)
function refresh(calls)
--call list and Sequence Controls
nextS = getValue("ls10") --Next Call LS
prevS = getValue("ls11") -- Previous Call LS
advS = getValue("ls12") -- Advance Calls without playing LS
revS = getValue("ls13") --Previous Call through without playing LS
listN = getValue("ls14") --Change to Next Maneuver List LS
listP = getValue("ls15") --Change to Previous Maneuver List LS
-- Advance Calls without playing
if advS >= 1 and model.getTimer(2).value >= 1 then
nextS = getValue("ls50") --Next Call LS
prevS = getValue("ls51") -- Previous Call LS
listN = getValue("ls52") --Change to Next Maneuver List LS
listP = getValue("ls53") --Change to Previous Maneuver List LS
again = getValue(calls.options.switch)

--Move forward to Specific Maneuver
if nextS >=1 and again < -1 then
if currentCall == #playlist then
currentCall = #playlist
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
else
currentCall = currentCall + 1
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
model.setTimer(2,{value=0})
currentCall = currentCall +1
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
end
end
--Previous Call through without playing
if revS >= 1 and model.getTimer(2).value >= 1 then

--Move backwards to Specific Maneuver
if prevS >= 1 and again < -1 then
if currentCall == 1 then
currentCall = 1
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
playFile("/SOUNDS/en/".. playlist[currentCall][8] ..".wav")
else
currentCall = currentCall - 1
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
end
end

-- Repeat call
if again <= 99 and again > -1 and nextS >=1 then
playFile("/SOUNDS/en/".. playlist[currentCall][8] ..".wav")
end

--Next Call
local long=playlist[currentCall][6]
if model.getTimer(2).value >= long and nextS >= 1 then
if nextS >=1 and again >= 1 then
if currentCall == #playlist then
currentCall = #playlist
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
else
currentCall = currentCall +1
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
playFile("/SOUNDS/en/".. playlist[currentCall][5] ..".wav")
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
playFile("/SOUNDS/en/".. playlist[currentCall][8] ..".wav")
end
end

--Previous Call
if model.getTimer(2).value >= long and prevS >= 1 then
if prevS >= 1 and again >= 1 then
if currentCall == 1 then
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
playFile("/SOUNDS/en/".. playlist[currentCall][5] ..".wav")
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
playFile("/SOUNDS/en/".. playlist[currentCall][8] ..".wav")
else
currentCall = currentCall - 1
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[currentCall][5],active=0})
playFile("/SOUNDS/en/".. playlist[currentCall][5] ..".wav")
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[currentCall][8],active=1,repetition=-1})
playFile("/SOUNDS/en/".. playlist[currentCall][8] ..".wav")
end
end
--LCD Display
local selection=currentCall
lcd.drawText(tunes.zone.x+80, tunes.zone.y, title, MIDSIZE)
lcd.drawText(tunes.zone.x+130, tunes.zone.y+30, "Maneuver No. "..selection, INVERS)
lcd.drawText(tunes.zone.x, tunes.zone.y+50, playlist[selection][1],SMLSIZE)
lcd.drawText(tunes.zone.x, tunes.zone.y+70, playlist[selection][2],SMLSIZE)
lcd.drawText(tunes.zone.x, tunes.zone.y+90, playlist[selection][3],SMLSIZE)
lcd.drawText(tunes.zone.x, tunes.zone.y+110, playlist[selection][4],SMLSIZE)
if selection >= #playlist then
lcd.drawText(tunes.zone.x+130, tunes.zone.y+130, "End of Manuevers", INVERS)
else
lcd.drawText(tunes.zone.x+130, tunes.zone.y+130, "Maneuver No. "..selection+1, INVERS)
lcd.drawText(tunes.zone.x, tunes.zone.y+150, playlist[selection+1][1],SMLSIZE)
end

--Change to Next Maneuver List
if listN > -1 then
if not nextListSwitchPressed then
Expand All @@ -138,12 +125,13 @@ function refresh(tunes)
set2 = callList[model.getGlobalVariable(8,0)]
end
loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")()
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[1][5],active=0})
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[1][8],active=1,repetition=-1})

else
nextListSwitchPressed = false
end
end

--Change to Previous Maneuver List
if listP > -1 then
if not prevListSwitchPressed then
Expand All @@ -156,11 +144,35 @@ function refresh(tunes)
set2 = callList[model.getGlobalVariable(8,0)]
end
loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")()
model.setCustomFunction(61,{switch = 9,func = 11,name = playlist[1][5],active=0})
model.setTimer(2,{value=0})
model.setCustomFunction(61,{switch = 233,func = 11,name = playlist[1][8],active=1,repetition=-1})

else
prevListSwitchPressed = false
end
end

--LCD Display
local selection=currentCall
if calls.zone.w > 200 and calls.zone.h > 165 then
lcd.drawText(calls.zone.x+75,calls.zone.y, title, calls.options.TextColor)
lcd.drawText(calls.zone.x+130, calls.zone.y+30, "Sequence No. "..selection, INVERS+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+55, playlist[selection][1],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+70, playlist[selection][2],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+85, playlist[selection][3],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+100, playlist[selection][4],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+115, playlist[selection][5],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+130, playlist[selection][6],SMLSIZE+calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+145, playlist[selection][7],SMLSIZE+calls.options.TextColor)
if selection >= #playlist then
lcd.drawText(calls.zone.x+130, calls.zone.y+30, "End of Sequence", INVERS)
end
else
lcd.drawText(calls.zone.x, calls.zone.y, title, calls.options.TextColor)
lcd.drawText(calls.zone.x, calls.zone.y+14, "Sequence No. "..selection, calls.options.TextColor)
if selection >= #playlist then
lcd.drawText(calls.zone.x, calls.zone.y+14, "End of Sequence", INVERS)
end
end
end

return { name="F3A", options=options, create=create, update=update, refresh=refresh, background=background }

0 comments on commit f4bff7e

Please sign in to comment.