diff --git a/Color Screen Widget/EdgeTX/Dark Theme/main.lua b/Color Screen Widget/EdgeTX/Dark Theme/main.lua index b4f97c3..f5347e0 100644 --- a/Color Screen Widget/EdgeTX/Dark Theme/main.lua +++ b/Color Screen Widget/EdgeTX/Dark Theme/main.lua @@ -1,5 +1,5 @@ ---- ######################################################################### ------# TaraniTunes v.4.3 # +-----# TaraniTunes v.4.4 # ---- # License GPLv3: http://www.gnu.org/licenses/gpl-3.0.html # ---- # # ---- # This program is free software; you can redistribute it and/or modify # @@ -26,26 +26,38 @@ local songList= "garage", } --- Options +--Options local options = { } - +--[[ +Custom Function Switch numbers based on Edge Version Installed + Edge 2.8 switch = 132,func = 16,name = playlist[playingSong][2] + Edge 2.9 switch = 144,func = 16,name = playlist[playingSong][2] + Edge 2.10 switch = 228,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1 +Change the song Controls below at the refresh section +]]-- -- create zones local function create(zone, options) local tunes = { zone=zone, options=options} - model.setGlobalVariable(7,0,1) + model.setGlobalVariable(7,0,1) model.setGlobalVariable(8,0,1) - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1})--resets playing song on to the 1st song on startup + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]})--resets playing song on to the 1st song on startup aircraft = Bitmap.open("/IMAGES/" .. model.getInfo().bitmap) return tunes end --- Update zones and options +-- control functions +local function error(strings) + errorStrings = strings + errorOccured = true +end + +--Update zones and options local function update(tunes, options) tunes.options = options end --- BackGround +--BackGround local function background(tunes) local long=playlist[playingSong][3] if model.getTimer(2).value >= long then @@ -53,98 +65,93 @@ local function background(tunes) model.setGlobalVariable(7,0,1) playingSong = model.getGlobalVariable(7,0) flushAudio() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) else flushAudio() playingSong = playingSong +1 model.setGlobalVariable(7,0,playingSong) - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) end end end - - -- Following is the various widgets zones from top bar to full screen (make changes as desired) - -- Zone size: top bar widgets local function refreshZoneTiny(tunes) local selection=playingSong lcd.drawText(tunes.zone.x, tunes.zone.y,songList[1], SMLSIZE) - lcd.drawText(tunes.zone.x, tunes.zone.y+15,"> ".. playlist[selection][2],YELLOW+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+15,"> ".. playlist[selection][2],SMLSIZE) end --- Zone size: 160x32 1/8th local function refreshZoneSmall(tunes) local selection=playingSong lcd.drawText(tunes.zone.x, tunes.zone.y+2,title, SMLSIZE) - lcd.drawText(tunes.zone.x, tunes.zone.y+17, playlist[selection][1], YELLOW+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+17, playlist[selection][1], INVERS+SMLSIZE) end --- Zone size: 180x70 1/4th (with sliders/trim) --- Zone size: 225x98 1/4th (no sliders/trim) +--- Zone size: 180x70 1/4th (with sliders/trim) +--- Zone size: 225x98 1/4th (no sliders/trim) local function refreshZoneMedium(tunes) - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local long=playlist[playingSong][3] local k = math.floor((upTime/long)*12)*10 lcd.drawTimer(tunes.zone.x,tunes.zone.y, upTime, SMLSIZE+INVERS) lcd.drawTimer(tunes.zone.x+145,tunes.zone.y, long, SMLSIZE+INVERS) - lcd.setColor(CUSTOM_COLOR,lcd.RGB(219,172,52)) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) lcd.drawFilledRectangle(tunes.zone.x+35,tunes.zone.y+2,k,8,CUSTOM_COLOR) local selection=playingSong lcd.drawText(tunes.zone.x, tunes.zone.y+16,"Playing > ".. title, SMLSIZE) - if selection == #playlist then lcd.drawText(tunes.zone.x, tunes.zone.y+30, playlist[selection - 2][1],SMLSIZE) lcd.drawText(tunes.zone.x, tunes.zone.y+45, playlist[selection - 1][1],SMLSIZE) - lcd.drawText(tunes.zone.x, tunes.zone.y+60, string.char(126) .. playlist[selection][1],YELLOW+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+60, string.char(126) .. playlist[selection][1],INVERS+SMLSIZE) else if selection == 1 then - lcd.drawText(tunes.zone.x, tunes.zone.y+30, string.char(126) .. playlist[selection][1],YELLOW+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+30, string.char(126) .. playlist[selection][1],INVERS+SMLSIZE) lcd.drawText(tunes.zone.x, tunes.zone.y+45, playlist[selection + 1][1],SMLSIZE) lcd.drawText(tunes.zone.x, tunes.zone.y+60, playlist[selection + 2][1],SMLSIZE) else lcd.drawText(tunes.zone.x, tunes.zone.y+30, playlist[selection - 1][1],SMLSIZE) - lcd.drawText(tunes.zone.x, tunes.zone.y+45, string.char(126) .. playlist[selection][1], YELLOW+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+45, string.char(126) .. playlist[selection][1], INVERS+SMLSIZE) lcd.drawText(tunes.zone.x, tunes.zone.y+60, playlist[selection + 1][1],SMLSIZE) end end end --- Zone size: 192x152 1/2 +--- Zone size: 192x152 1/2 local function refreshZoneLarge(tunes) lcd.drawText(tunes.zone.x+2, tunes.zone.y," iTunes Music", MIDSIZE) - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local long=playlist[playingSong][3] local k = math.floor((upTime/long)*12)*10 lcd.drawTimer(tunes.zone.x,tunes.zone.y+40, upTime, SMLSIZE+INVERS) lcd.drawTimer(tunes.zone.x+160,tunes.zone.y+40, long, SMLSIZE+INVERS) - lcd.setColor(CUSTOM_COLOR,lcd.RGB(219,172,52)) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) lcd.drawFilledRectangle(tunes.zone.x+35,tunes.zone.y+40,k,18,CUSTOM_COLOR) local selection=playingSong lcd.drawText(tunes.zone.x, tunes.zone.y+60,"Playing > ".. title, SMLSIZE) - if selection == #playlist then lcd.drawText(tunes.zone.x, tunes.zone.y+85, playlist[selection - 2][1]) lcd.drawText(tunes.zone.x, tunes.zone.y+105, playlist[selection - 1][1]) - lcd.drawText(tunes.zone.x, tunes.zone.y+125, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(tunes.zone.x, tunes.zone.y+125, string.char(126) .. playlist[selection][1],INVERS) else if selection == 1 then - lcd.drawText(tunes.zone.x, tunes.zone.y+85, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(tunes.zone.x, tunes.zone.y+85, string.char(126) .. playlist[selection][1],INVERS) lcd.drawText(tunes.zone.x, tunes.zone.y+105, playlist[selection + 1][1]) lcd.drawText(tunes.zone.x, tunes.zone.y+125, playlist[selection + 2][1]) else lcd.drawText(tunes.zone.x, tunes.zone.y+85, playlist[selection - 1][1]) - lcd.drawText(tunes.zone.x, tunes.zone.y+105, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(tunes.zone.x, tunes.zone.y+105, string.char(126) .. playlist[selection][1],INVERS) lcd.drawText(tunes.zone.x, tunes.zone.y+125, playlist[selection + 1][1]) end end end --- Zone size: 390x172 1/1 (with sliders and trims) +--- Zone size: 390x172 1/1 (with sliders and trims) local function refreshZoneXLarge(tunes) - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local long=playlist[playingSong][3] function round(num, decimals) @@ -152,25 +159,25 @@ local function refreshZoneXLarge(tunes) return math.floor(num * mult + .5) / mult end --- Current Model Information +--Current Model Information - lcd.drawText(150,60, model.getInfo().name, MIDSIZE) --adjust for right look - lcd.drawBitmap(aircraft,180,70,75) --adjust location and % for right look + lcd.drawText(150,60, model.getInfo().name, MIDSIZE)--adjust for right look + lcd.drawBitmap(aircraft,180,70,75)--adjust location and % for right look --- Transmitter battery +--Transmitter battery local batt = getValue("tx-voltage") lcd.drawText(40, 51,"TX Batt "..round(batt,1).."v") --- Flight Time +--Flight Time local fly=model.getTimer(1).value --flight duration timer: 0=timer1, 1=timer2 lcd.drawText(355, 51, "Flight Time") - lcd.drawTimer(380, 72, fly, 2+GREEN) + lcd.drawTimer(380, 72, fly, 2) - -- Flight Battery - --I use different capacity batteries the timers are adjusted using SF depending on the battery I'm flying - + -- Flight Battery Loaded + --[[ I use different capacity batteries the timers are + adjusted using SF depending on the battery I'm flying ]]-- lcd.drawFilledRectangle(40,73,100,2) - local battsw = getValue('se') + local battsw = getValue('sg') lcd.drawText(40, 90, "Flight Battery",SMLSIZE) lcd.drawFilledRectangle(40,105,100,2) if battsw == -1024 then @@ -180,73 +187,75 @@ local function refreshZoneXLarge(tunes) lcd.drawSwitch(40,75,14) lcd.drawText(90,75,"REG 4.2", SMLSIZE) else lcd.drawSwitch(60,75,15) - lcd.drawText(90,75,"HV 4.35", SMLSIZE) + lcd.drawText(90,75,"4.35 PACK", SMLSIZE) end end -- Cell Voltage lcd.drawFilledRectangle(365,96,78,2) - lcd.drawText(370, 98, "Lipo") - lcd.drawChannel(380, 119,"Cel", PREC2+ORANGE) + lcd.drawText(375, 98, "Lipo Cell") + lcd.drawChannel(390, 119,"LCEL", PREC2+INVERS) --displays a custom telementry sensor (lowest cell)calculated from "cels" sensor --- Altitude from Altimeter ("Alt") or GPS Sensor ("GAlt") +-- Altitude lcd.drawText(40,110,"HEIGHT= ", SMLSIZE) lcd.drawChannel(100,110,"Alt",SMLSIZE) lcd.drawText(42, 125,"Max", SMLSIZE) lcd.drawChannel(82,125,"Alt+",2+SMLSIZE) --- Tementry Separator Bar +--Tementry separator bar local y = 160 - lcd.drawFilledRectangle(40,y-18,400,6,RED) + lcd.drawFilledRectangle(40,y-18,400,6,GREY_DEFAULT) ---Music Progress Bar - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played +--Music +-- Progressbar + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local k = math.floor((upTime/long)*33)*10 lcd.drawTimer(44, y-10, upTime, SMLSIZE+INVERS) lcd.drawTimer(400,y-10, long, SMLSIZE+INVERS) - lcd.setColor(CUSTOM_COLOR,lcd.RGB(219,172,52)) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) lcd.drawFilledRectangle(80,y-10,k,18,CUSTOM_COLOR) ---Music Display +--music display local selection=playingSong lcd.drawText(90, y+5, "Selected Playlist >>",SMLSIZE) lcd.drawText(220, y+5, title, SMLSIZE) if selection == #playlist then lcd.drawText(40, y+20, playlist[selection - 2][1]) lcd.drawText(40, y+38, playlist[selection - 1][1]) - lcd.drawText(40, y+56, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(40, y+56, string.char(126) .. playlist[selection][1],INVERS) else if selection == 1 then - lcd.drawText(40, y+20, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(40, y+20, string.char(126) .. playlist[selection][1],INVERS) lcd.drawText(40, y+38, playlist[selection + 1][1]) lcd.drawText(40, y+56, playlist[selection + 2][1]) else lcd.drawText(40, y+20, playlist[selection - 1][1]) - lcd.drawText(40, y+38, string.char(126) .. playlist[selection][1],YELLOW) + lcd.drawText(40, y+38, string.char(126) .. playlist[selection][1], INVERS) lcd.drawText(40, y+56, playlist[selection + 1][1]) end end end --- Zone size: 460x252 1/1 (no sliders/trim/topbar) +elogo = Bitmap.open("/THEMES/edge.png") +--- Zone size: 460x252 1/1 (no sliders/trim/topbar) local function refreshZoneFull(tunes) - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local long=playlist[playingSong][3] - - function round(num, decimals) + + function round(num, decimals) local mult = 10^(decimals or 0) return math.floor(num * mult + .5) / mult end --- Current time, EdgeTX Version & Model Information +--Current time, EdgeTX Version & Model Information local datenow = getDateTime() local timemins = (string.format("%02d",datenow.min)) lcd.drawText(63,24,"Time "..datenow.hour12..":"..timemins.." "..datenow.suffix) local ver = getVersion() --EdgeTX Version lcd.drawBitmap(elogo,4,0,50) lcd.drawText(63,4,"V. "..ver) - lcd.drawText(185,5, model.getInfo().name,DBLSIZE) --adjust as needed - lcd.drawBitmap(aircraft,160,45,90) --adjust as needed + lcd.drawText(185,5, model.getInfo().name,DBLSIZE)--adjust as needed + lcd.drawBitmap(aircraft,170,45,90)--adjust as needed --Transmitter battery local batt = getValue("tx-voltage") @@ -258,13 +267,14 @@ local function refreshZoneFull(tunes) lcd.drawChannel(160,50,"RxBt") -- Flight Battery Loaded - --[[ I use different capacity batteries, the timers are adjusted using SF depending on the battery capactity ]]-- + --[[ I use different capacity batteries, the timers are + adjusted using SF depending on the battery capactity ]]-- lcd.drawFilledRectangle(8,73,130,2) lcd.drawText(10, 95, "Battery Loaded") lcd.drawFilledRectangle(8,116,130,2) local battsw = getValue('se') if battsw == -1024 then - lcd.drawText(50,77,"SHORT 4.2") --older Battery + lcd.drawText(50,77,"SHORT 4.2") lcd.drawSwitch(10,77,13)else if battsw == 0 then lcd.drawSwitch(10,77,14) @@ -274,11 +284,9 @@ local function refreshZoneFull(tunes) end end --- Separators + -- Flight Mode lcd.drawFilledRectangle(341,60,125,2) lcd.drawFilledRectangle(341,105,125,2) - --- Flight Mode -- local fmno, fmname = getFlightMode() -- if fmname == "" then -- fmname = "FM".. fmno @@ -293,44 +301,45 @@ local function refreshZoneFull(tunes) lcd.drawText(341,83,"Top Spd= ") lcd.drawChannel(420,83,"GSpd+",2+YELLOW) --- Flight Time +--Flight Time local fly=model.getTimer(1).value --flight duration timer: 0=timer1, 1=timer2 lcd.drawText(384, 4, "Flight Time") lcd.drawTimer(380, 22, fly, DBLSIZE+PREC2+GREEN) -- Cell Voltage - lcd.drawText(387, 104, "Lipo",MIDSIZE) - lcd.drawChannel(370, 130,"Cels", DBLSIZE+PREC2+ORANGE) + lcd.drawText(372, 104, "Lipo Cell",MIDSIZE) + lcd.drawChannel(380, 130,"LCEL", DBLSIZE+PREC2+ORANGE) --displays a custom telementry sensor (lowest cell)calculated from "cels" sensor --- RSSI +--rssi lcd.drawText(8,122,"RSSI Sig ") lcd.drawChannel(80,122,"RSSI") lcd.drawText(123,122," //MIN ") lcd.drawChannel(170,122,"RSSI-") --- Altitude from Altimeter ("Alt") or GPS Sensor ("GAlt") + --Altitude lcd.drawText(8,143,"HEIGHT= ") lcd.drawChannel(80,143,"GAlt") - lcd.drawText(135, 143,"//Max") - lcd.drawChannel(190,143,"GAlt+",2) + lcd.drawText(130, 143,"//Max") + lcd.drawChannel(185,143,"GAlt+",2) -- GPS - lcd.drawText(320,232,"GPS Location") - lcd.drawChannel(285,250,"GPS") +lcd.drawText(320,232,"GPS Location") +lcd.drawChannel(290,250,"GPS") --Tementry separator bar local y = 185 lcd.drawFilledRectangle(6,y-18,462,6,RED) --- Music Progress Bar - local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played +--Music +-- Progressbar + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played local k = math.floor((upTime/long)*40)*10 lcd.drawTimer(7, y-10, upTime, SMLSIZE+BRIGHTGREEN) lcd.drawTimer(434,y-10, long, SMLSIZE+BRIGHTGREEN) lcd.setColor(CUSTOM_COLOR,lcd.RGB(219,172,52)) lcd.drawFilledRectangle(44,y-10,k,14,CUSTOM_COLOR) --- Music Display +--music display local selection=playingSong lcd.drawText(150, y+4, "Selected Playlist >> ".. title, SMLSIZE) if selection == #playlist then @@ -351,37 +360,39 @@ local function refreshZoneFull(tunes) end function refresh(tunes) ---[[ +--SF commands for songs to play based on Version Installed +--[[ Custom Function Switch numbers based on Edge Version Installed - Edge 2.8 switch = 132 - Edge 2.9 switch = 144 - Edge 2.10 switch = 228 + Edge 2.8 switch = 132,func = 16,name = playlist[playingSong][2] + Edge 2.9 switch = 144,func = 16,name = playlist[playingSong][2] + Edge 2.10 switch = 228,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1 +Change the song Controls below at the refresh section ]]-- -listP = getValue("ls63") -listN = getValue("ls64") -prevS = getValue("ls61") -nextS = getValue("ls62") - - --Song Over + listP = getValue("ls63") + listN = getValue("ls64") + prevS = getValue("ls61") + nextS = getValue("ls62") + + --song over local long=playlist[playingSong][3] if model.getTimer(2).value >= long then if playingSong == #playlist then model.setGlobalVariable(7,0,1) playingSong = model.getGlobalVariable(7,0) flushAudio() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) else flushAudio() playingSong = playingSong +1 model.setGlobalVariable(7,0,playingSong) - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) end + end - --- Next Song +-- Next song if nextS > -1 then if not nextSongSwitchPressed then if playingSong == #playlist then @@ -391,14 +402,14 @@ nextS = getValue("ls62") playingSong = model.getGlobalVariable(7,0) end flushAudio() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) else nextSongSwitchPressed = false end end --- Change Previous Playlist +--Change Previous Playlist if listP > -1 then if not prevListSwitchPressed then if model.getGlobalVariable(8,0)<= 0 then @@ -410,7 +421,7 @@ nextS = getValue("ls62") playingSong = 1 end loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setGlobalVariable(7,0,1) flushAudio() model.setTimer(2,{value=0}) @@ -419,10 +430,10 @@ nextS = getValue("ls62") end end --- Change next Playlist +--Change next Playlist if listN > -1 then if not nextListSwitchPressed then - if model.getGlobalVariable(8,0) > #songList then + if model.getGlobalVariable(8,0) >= #songList then set2 = songList[1] model.setGlobalVariable(8,0,1) playingSong = 1 @@ -430,8 +441,9 @@ nextS = getValue("ls62") set2 = songList[model.getGlobalVariable(8,0)] playingSong = 1 end + loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setGlobalVariable(7,0,1) flushAudio() model.setTimer(2,{value=0}) @@ -439,8 +451,7 @@ nextS = getValue("ls62") nextListSwitchPressed = false end end - --- Previous Song +-- previous song if prevS > -1 then if not prevSongSwitchPressed then if playingSong == 1 then @@ -450,14 +461,15 @@ nextS = getValue("ls62") playingSong = model.getGlobalVariable(7,0) end flushAudio() - model.setCustomFunction(62,{switch=228,func=FUNC_BACKGND_MUSIC,name=playlist[playingSong][2],active=1}) + model.setCustomFunction(62,{switch = 144, func=16,name=playlist[playingSong][2]}) model.setTimer(2,{value=0}) end else prevSongSwitchPressed = false end --- Widget Display by Size + +--Widget Display by Size if tunes.zone.w > 450 and tunes.zone.h > 240 then refreshZoneFull(tunes) elseif tunes.zone.w > 200 and tunes.zone.h > 165 then refreshZoneXLarge(tunes) elseif tunes.zone.w > 180 and tunes.zone.h > 145 then refreshZoneLarge(tunes) diff --git a/Color Screen Widget/EdgeTX/Dark Theme/theme.yml b/Color Screen Widget/EdgeTX/Dark Theme/theme.yml index 38ece17..ae806ed 100644 --- a/Color Screen Widget/EdgeTX/Dark Theme/theme.yml +++ b/Color Screen Widget/EdgeTX/Dark Theme/theme.yml @@ -5,13 +5,13 @@ summary: info: "A dark theme with contrast." colors: PRIMARY1: 0xF8FCF8 - PRIMARY2: 0xF84040 - PRIMARY3: 0xC0E4B0 - SECONDARY1: 0x606060 - SECONDARY2: 0xF8B038 + PRIMARY2: 0xF80000 + PRIMARY3: 0xF0F8C0 + SECONDARY1: 0x282828 + SECONDARY2: 0xF0D498 SECONDARY3: 0x000000 - FOCUS: 0xF8B038 - EDIT: 0xD0D0E0 + FOCUS: 0x2030C8 + EDIT: 0x404440 ACTIVE: 0xF8B038 WARNING: 0xE83030 DISABLED: 0xA07420 diff --git a/Color Screen Widget/EdgeTX/main.lua b/Color Screen Widget/EdgeTX/main.lua index bad82cb..54421e6 100644 --- a/Color Screen Widget/EdgeTX/main.lua +++ b/Color Screen Widget/EdgeTX/main.lua @@ -30,6 +30,478 @@ local songList= local options = { } +--[[ +Custom Function Switch numbers based on Edge Version Installed + Edge 2.8 switch = 132,func = 16,name = playlist[playingSong][2] + Edge 2.9 switch = 144,func = 16,name = playlist[playingSong][2] + Edge 2.10 switch = 228,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1 +Change the song Controls below at the refresh section +]]-- + +-- Create Zones +local function create(zone, options) + local tunes = { zone=zone, options=options} + model.setGlobalVariable(7,0,1) + model.setGlobalVariable(8,0,1) + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]})--resets playing song on to the 1st song on startup + aircraft = Bitmap.open("/IMAGES/" .. model.getInfo().bitmap) + return tunes +end + +-- Update zones and options +local function update(tunes, options) +tunes.options = options +end + +-- BackGround +local function background(tunes) + local long=playlist[playingSong][3] + if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + end + end +end + +-- Following is the various widgets zones from top bar to full screen (make changes as desired) + +-- Zone: Top Bar Widget Only +local function refreshZoneTiny(tunes) + local selection=playingSong + lcd.drawText(tunes.zone.x, tunes.zone.y,songList[1], SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+15,"> ".. playlist[selection][2],SMLSIZE) +end + +-- Zone size: 160x32 1/8th +local function refreshZoneSmall(tunes) + local selection=playingSong + lcd.drawText(tunes.zone.x, tunes.zone.y+2,title, SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+17, playlist[selection][1], INVERS+SMLSIZE) +end + +-- Zone size: 180x70 1/4th (with sliders/trim) +-- Zone size: 225x98 1/4th (no sliders/trim) +local function refreshZoneMedium(tunes) + local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local long=playlist[playingSong][3] + local k = math.floor((upTime/long)*12)*10 + lcd.drawTimer(tunes.zone.x,tunes.zone.y, upTime, SMLSIZE+INVERS) + lcd.drawTimer(tunes.zone.x+145,tunes.zone.y, long, SMLSIZE+INVERS) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) + lcd.drawFilledRectangle(tunes.zone.x+35,tunes.zone.y+2,k,8,CUSTOM_COLOR) + local selection=playingSong + lcd.drawText(tunes.zone.x, tunes.zone.y+16,"Playing > ".. title, SMLSIZE) + if selection == #playlist then + lcd.drawText(tunes.zone.x, tunes.zone.y+30, playlist[selection - 2][1],SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+45, playlist[selection - 1][1],SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+60, string.char(126) .. playlist[selection][1],INVERS+SMLSIZE) + else + if selection == 1 then + lcd.drawText(tunes.zone.x, tunes.zone.y+30, string.char(126) .. playlist[selection][1],INVERS+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+45, playlist[selection + 1][1],SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+60, playlist[selection + 2][1],SMLSIZE) + else + lcd.drawText(tunes.zone.x, tunes.zone.y+30, playlist[selection - 1][1],SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+45, string.char(126) .. playlist[selection][1], INVERS+SMLSIZE) + lcd.drawText(tunes.zone.x, tunes.zone.y+60, playlist[selection + 1][1],SMLSIZE) + end + end +end + +-- Zone size: 192x152 1/2 +local function refreshZoneLarge(tunes) + lcd.drawText(tunes.zone.x+2, tunes.zone.y," iTunes Music", MIDSIZE) + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local long=playlist[playingSong][3] + local k = math.floor((upTime/long)*12)*10 + lcd.drawTimer(tunes.zone.x,tunes.zone.y+40, upTime, SMLSIZE+INVERS) + lcd.drawTimer(tunes.zone.x+160,tunes.zone.y+40, long, SMLSIZE+INVERS) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) + lcd.drawFilledRectangle(tunes.zone.x+35,tunes.zone.y+40,k,18,CUSTOM_COLOR) + local selection=playingSong + lcd.drawText(tunes.zone.x, tunes.zone.y+60,"Playing > ".. title, SMLSIZE) + if selection == #playlist then + lcd.drawText(tunes.zone.x, tunes.zone.y+85, playlist[selection - 2][1]) + lcd.drawText(tunes.zone.x, tunes.zone.y+105, playlist[selection - 1][1]) + lcd.drawText(tunes.zone.x, tunes.zone.y+125, string.char(126) .. playlist[selection][1],INVERS) + else + if selection == 1 then + lcd.drawText(tunes.zone.x, tunes.zone.y+85, string.char(126) .. playlist[selection][1],INVERS) + lcd.drawText(tunes.zone.x, tunes.zone.y+105, playlist[selection + 1][1]) + lcd.drawText(tunes.zone.x, tunes.zone.y+125, playlist[selection + 2][1]) + else + lcd.drawText(tunes.zone.x, tunes.zone.y+85, playlist[selection - 1][1]) + lcd.drawText(tunes.zone.x, tunes.zone.y+105, string.char(126) .. playlist[selection][1],INVERS) + lcd.drawText(tunes.zone.x, tunes.zone.y+125, playlist[selection + 1][1]) + end + end +end + +-- Zone size: 390x172 1/1 (with sliders and trims) +local function refreshZoneXLarge(tunes) + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local long=playlist[playingSong][3] + function round(num, decimals) + local mult = 10^(decimals or 0) + return math.floor(num * mult + .5) / mult + end + +-- Current Model Information + lcd.drawText(150,60, model.getInfo().name, MIDSIZE) --adjust for right look + lcd.drawBitmap(aircraft,180,70,75) --adjust location and % for right look + +-- Transmitter battery + local batt = getValue("tx-voltage") + lcd.drawText(40, 51,"TX Batt "..round(batt,1).."v") + +-- Flight Time + local fly=model.getTimer(1).value --flight duration timer: 0=timer1, 1=timer2 + lcd.drawText(355, 51, "Flight Time") + lcd.drawTimer(380, 72, fly, 2) + + -- Flight Battery Loaded + -- I use different capacity batteries the timers are adjusted using SF depending on the battery I'm flying + lcd.drawFilledRectangle(40,73,100,2) + local battsw = getValue('se') + lcd.drawText(40, 90, "Flight Battery",SMLSIZE) + lcd.drawFilledRectangle(40,105,100,2) + if battsw == -1024 then + lcd.drawText(90,75,"SHORT 4.2",SMLSIZE) + lcd.drawSwitch(60,75,13) + else + if battsw == 0 then + lcd.drawSwitch(40,75,14) + lcd.drawText(90,75,"REG 4.2", SMLSIZE) + else + lcd.drawSwitch(60,75,15) + lcd.drawText(90,75,"4.35", SMLSIZE) + end + end + +-- Cell Voltage + lcd.drawFilledRectangle(365,96,78,2) + lcd.drawText(370, 98, "Lipo") + lcd.drawChannel(380, 119,"Cel", PREC2+INVERS) + +-- Altitude from Altimeter ("Alt") or GPS Sensor ("GAlt") + lcd.drawText(40,110,"HEIGHT= ", SMLSIZE) + lcd.drawChannel(100,110,"GAlt",SMLSIZE) + lcd.drawText(42, 125,"Max", SMLSIZE) + lcd.drawChannel(82,125,"GAlt+",2+SMLSIZE) + +-- Tementry separator bar + local y = 160 + lcd.drawFilledRectangle(40,y-18,400,6,GREY_DEFAULT) + +-- Music Progress bar + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local k = math.floor((upTime/long)*33)*10 + lcd.drawTimer(44, y-10, upTime, SMLSIZE+INVERS) + lcd.drawTimer(400,y-10, long, SMLSIZE+INVERS) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) + lcd.drawFilledRectangle(80,y-10,k,18,CUSTOM_COLOR) + +-- Music Dispay + local selection=playingSong + lcd.drawText(90, y+5, "Selected Playlist >>",SMLSIZE) + lcd.drawText(220, y+5, title, SMLSIZE) + if selection == #playlist then + lcd.drawText(40, y+20, playlist[selection - 2][1]) + lcd.drawText(40, y+38, playlist[selection - 1][1]) + lcd.drawText(40, y+56, string.char(126) .. playlist[selection][1],INVERS) + else + if selection == 1 then + lcd.drawText(40, y+20, string.char(126) .. playlist[selection][1],INVERS) + lcd.drawText(40, y+38, playlist[selection + 1][1]) + lcd.drawText(40, y+56, playlist[selection + 2][1]) + else + lcd.drawText(40, y+20, playlist[selection - 1][1]) + lcd.drawText(40, y+38, string.char(126) .. playlist[selection][1], INVERS) + lcd.drawText(40, y+56, playlist[selection + 1][1]) + end + end +end + +-- Zone size: 460x252 1/1 (no sliders/trim/topbar) +local function refreshZoneFull(tunes) + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local long=playlist[playingSong][3] + + function round(num, decimals) + local mult = 10^(decimals or 0) + return math.floor(num * mult + .5) / mult + end + +--Current time, EdgeTX Version & Model Information + local datenow = getDateTime() + local timemins = (string.format("%02d",datenow.min)) + lcd.drawText(63,24,"Time "..datenow.hour12..":"..timemins.." "..datenow.suffix) + local ver = getVersion() --EdgeTX Version + lcd.drawBitmap(elogo,3,0,53) + lcd.drawText(63,4,"V. "..ver) + lcd.drawText(185,5, model.getInfo().name,DBLSIZE) --adjust as needed + lcd.drawBitmap(aircraft,170,45,90) --adjust as needed + +--Transmitter battery + local batt = getValue("tx-voltage") + lcd.drawText(8, 50,"TX Batt "..round(batt,1).."v") + + --Receiver Voltage battery + lcd.drawText(100, 50,"RX Batt ") + lcd.drawChannel(160,50,"RxBt") + + -- Flight Battery Loaded + --I use different capacity batteries, the timers are adjusted using SF depending on the battery capactity + lcd.drawFilledRectangle(8,73,130,2) + lcd.drawText(10, 95, "Battery Loaded") + lcd.drawFilledRectangle(8,116,130,2) + local battsw = getValue('se') + if battsw == -1024 then + lcd.drawText(65,75,"SHORT 4.2", INVERS) --older Battery + lcd.drawSwitch(30,75,13)else + if battsw == 0 then + lcd.drawSwitch(30,75,14) + lcd.drawText(65,75,"REG 4.2", INVERS) else + lcd.drawSwitch(30,75,15) + lcd.drawText(65,75,"HV 4.35", INVERS) + end + end + +-- Separators + lcd.drawFilledRectangle(341,60,125,2) + lcd.drawFilledRectangle(341,105,125,2) + +-- Flight Mode +-- local fmno, fmname = getFlightMode() +-- if fmname == "" then +-- fmname = "FM".. fmno +-- lcd.drawText(410, 63, fmname)else +-- lcd.drawText(410, 63, "FM"..fmno) +-- lcd.drawText(380,83, fmname) +-- end + +-- Speed + lcd.drawText(355,63,"Speed= ") + lcd.drawChannel(420,63,"GSpd") + lcd.drawText(341,83,"Top Spd= ") + lcd.drawChannel(420,83,"GSpd+",2) + +-- Flight Time + local fly=model.getTimer(1).value --flight duration timer: 0=timer1, 1=timer2 + lcd.drawText(384, 4, "Flight Time") + lcd.drawTimer(380, 28, fly, DBLSIZE+PREC2) + +-- Cell Voltage + lcd.drawText(387, 104, "Lipo",MIDSIZE) + lcd.drawChannel(370, 130,"Cels", DBLSIZE+PREC2+INVERS) + +-- RSSI + lcd.drawText(8,122,"RSSI Sig ") + lcd.drawChannel(80,122,"RSSI") + lcd.drawText(123,122," //MIN ") + lcd.drawChannel(170,122,"RSSI-") + +-- Altitude + lcd.drawText(8,143,"HEIGHT= ") + lcd.drawChannel(80,143,"GAlt") + lcd.drawText(130, 143,"//Max") + lcd.drawChannel(185,143,"GAlt+",2) + +-- GPS + lcd.drawText(320,232,"GPS Location") + lcd.drawChannel(285,250,"GPS") + +-- Tementry Separator Bar + local y = 185 + lcd.drawFilledRectangle(6,y-18,462,6,GREY_DEFAULT) + +-- Music Progressbar + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local k = math.floor((upTime/long)*40)*10 + lcd.drawTimer(7, y-10, upTime, SMLSIZE+INVERS) + lcd.drawTimer(434,y-10, long, SMLSIZE+INVERS) + lcd.setColor(CUSTOM_COLOR,lcd.RGB(0,100,0)) + lcd.drawFilledRectangle(44,y-10,k,18,CUSTOM_COLOR) + +-- Musci Display + local selection=playingSong + lcd.drawText(90, y+4, "Selected Playlist >>".. title, SMLSIZE) + if selection == #playlist then + lcd.drawText(12, y+20, playlist[selection - 2][1]) + lcd.drawText(12, y+40, playlist[selection - 1][1]) + lcd.drawText(12, y+60, string.char(126) .. playlist[selection][1],INVERS) + else + if selection == 1 then + lcd.drawText(12, y+20, string.char(126) .. playlist[selection][1],INVERS) + lcd.drawText(12, y+40, playlist[selection + 1][1]) + lcd.drawText(12, y+60, playlist[selection + 2][1]) + else + lcd.drawText(12, y+20, playlist[selection - 1][1]) + lcd.drawText(12, y+40, string.char(126) .. playlist[selection][1], INVERS) + lcd.drawText(12, y+60, playlist[selection + 1][1]) + end + end +end + +function refresh(tunes) +--[[ + Custom Function Switch numbers based on Edge Version Installed + Edge 2.8 switch = 132,func = 16,name = playlist[playingSong][2] + Edge 2.9 switch = 144,func = 16,name = playlist[playingSong][2] + Edge 2.10 switch = 228,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1 + ]]-- + +listP = getValue("ls63") +listN = getValue("ls64") +prevS = getValue("ls61") +nextS = getValue("ls62") + +-- Song Over + local long=playlist[playingSong][3] + if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + end + end + +-- Next song + if nextS > -1 then + if not nextSongSwitchPressed then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + else + playingSong = model.getGlobalVariable(7,0) + end + flushAudio() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + else + nextSongSwitchPressed = false + end + end + +-- Change Previous Playlist + if listP > -1 then + if not prevListSwitchPressed then + if model.getGlobalVariable(8,0)<= 0 then + model.setGlobalVariable(8,0,#songList) + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + else + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + end + loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setGlobalVariable(7,0,1) + flushAudio() + model.setTimer(2,{value=0}) + else + prevListSwitchPressed = false + end + end + +-- Change next Playlist + if listN > -1 then + if not nextListSwitchPressed then + if model.getGlobalVariable(8,0) > #songList then + set2 = songList[1] + model.setGlobalVariable(8,0,1) + playingSong = 1 + else + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + end + loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setGlobalVariable(7,0,1) + flushAudio() + model.setTimer(2,{value=0}) + else + nextListSwitchPressed = false + end + end + +-- previous song + if prevS > -1 then + if not prevSongSwitchPressed then + if playingSong == 1 then + model.setGlobalVariable(7,0,#playlist) + playingSong = model.getGlobalVariable(7,0) + else + playingSong = model.getGlobalVariable(7,0) + end + flushAudio() + model.setCustomFunction(62,{switch = 144,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + end + else + prevSongSwitchPressed = false + end + +-- Widget Display by Size + if tunes.zone.w > 450 and tunes.zone.h > 240 then refreshZoneFull(tunes) + elseif tunes.zone.w > 200 and tunes.zone.h > 165 then refreshZoneXLarge(tunes) + elseif tunes.zone.w > 180 and tunes.zone.h > 145 then refreshZoneLarge(tunes) + elseif tunes.zone.w > 170 and tunes.zone.h > 65 then refreshZoneMedium(tunes) + elseif tunes.zone.w > 150 and tunes.zone.h > 28 then refreshZoneSmall(tunes) + elseif tunes.zone.w > 65 and tunes.zone.h > 35 then refreshZoneTiny(tunes) + end +end + +return { name="iTunes", options=options, create=create, update=update, refresh=refresh, background=background }---- ######################################################################### +-----# TaraniTunes v.4.4 # +---- # 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 # +---- # published by the Free Software Foundation. # +---- # # +---- # This program is distributed in the hope that it will be useful # +---- # but WITHOUT ANY WARRANTY; without even the implied warranty of # +---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +---- # GNU General Public License for more details. # +---- # # +---- ######################################################################### + +-- Locals +local playingSong = 1 +local errorOccured = false +elogo = Bitmap.open("/THEMES/edge.png") +loadScript("/SOUNDS/lists/bubba_mix/playlist.lua")() --1st playlist in songList (see sample list below) + +-- Playlists folders names i.e. /SONGS/lists/"foldername" below are sample names +local songList= +{"bubba_mix", +"rock", +"garage", +} + +--Options +local options = { +} + --[[ Custom Function Switch numbers based on Edge Version Installed Edge 2.8 switch = 132 diff --git a/Color Screen Widget/main.lua b/Color Screen Widget/main.lua index fe6139d..669b892 100644 --- a/Color Screen Widget/main.lua +++ b/Color Screen Widget/main.lua @@ -24,17 +24,7 @@ loadScript("/SOUNDS/lists/bubba_mix/playlist.lua")() --1st playlist in songList --Playlists folders names i.e. /SONGS/lists/"foldername" below are sample names local songList= {"bubba_mix", -"classic_country", -"country_rock", -"easy", -"fun_country", -"todays", -"funrock", -"hard", -"laid_back", -"modern", "rock", -"soundtracks", "garage", "upbeat", } @@ -48,7 +38,7 @@ local function create(zone, options) local tunes = { zone=zone, options=options} model.setGlobalVariable(7,0,1) model.setGlobalVariable(8,0,1) - model.setCustomFunction(62,{switch = 132,func = 16,name = playlist[1][2]})--resets playing song on to the 1st song on startup + model.setCustomFunction(62,{switch = 132,func = 16,name = playlist[1][2]})--resets playing song on to the 1st song on startup aircraft = Bitmap.open("/IMAGES/" .. model.getInfo().bitmap) return tunes end @@ -66,6 +56,22 @@ end --BackGround local function background(tunes) + local long=playlist[playingSong][3] + if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch=228,func = 16,name=playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch=228,func = 16,name=playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + end + end end -- Following is the various widgets zones from top bar to full screen (make changes as desired) @@ -87,7 +93,7 @@ end --- Zone size: 180x70 1/4th (with sliders/trim) --- Zone size: 225x98 1/4th (no sliders/trim) local function refreshZoneMedium(tunes) - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local long=playlist[playingSong][3] local k = math.floor((upTime/long)*12)*10 lcd.drawTimer(tunes.zone.x,tunes.zone.y, upTime, SMLSIZE+INVERS) @@ -116,7 +122,7 @@ end --- Zone size: 192x152 1/2 local function refreshZoneLarge(tunes) lcd.drawText(tunes.zone.x+2, tunes.zone.y," iTunes Music", MIDSIZE) - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local long=playlist[playingSong][3] local k = math.floor((upTime/long)*12)*10 lcd.drawTimer(tunes.zone.x,tunes.zone.y+40, upTime, SMLSIZE+INVERS) @@ -144,7 +150,7 @@ end --- Zone size: 390x172 1/1 (with sliders and trims) local function refreshZoneXLarge(tunes) - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local long=playlist[playingSong][3] function round(num, decimals) @@ -199,7 +205,7 @@ local function refreshZoneXLarge(tunes) --Music -- Progressbar - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local k = math.floor((upTime/long)*33)*10 lcd.drawTimer(44, y-10, upTime, SMLSIZE+INVERS) lcd.drawTimer(400,y-10, long, SMLSIZE+INVERS) @@ -229,7 +235,7 @@ end --- Zone size: 460x252 1/1 (no sliders/trim/topbar) local function refreshZoneFull(tunes) - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local long=playlist[playingSong][3] function round(num, decimals) @@ -302,9 +308,8 @@ local function refreshZoneFull(tunes) local y = 185 lcd.drawFilledRectangle(6,y-18,462,6,GREY_DEFAULT) ---Music --- Progressbar - --local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played +--Music Progressbar + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local k = math.floor((upTime/long)*40)*10 lcd.drawTimer(7, y-10, upTime, SMLSIZE+INVERS) lcd.drawTimer(434,y-10, long, SMLSIZE+INVERS) @@ -353,8 +358,8 @@ function refresh(tunes) model.setCustomFunction(62,{switch = 132,func = 16,name = playlist[playingSong][2]}) model.setTimer(2,{value=0}) end - end + -- Next song if nextS > -1 then if not nextSongSwitchPressed then @@ -396,7 +401,7 @@ function refresh(tunes) --Change next Playlist if listN > -1 then if not nextListSwitchPressed then - if model.getGlobalVariable(8,0) >= #songList then + if model.getGlobalVariable(8,0) > #songList then set2 = songList[1] model.setGlobalVariable(8,0,1) playingSong = 1 @@ -414,6 +419,7 @@ function refresh(tunes) nextListSwitchPressed = false end end + -- previous song if prevS > -1 then if not prevSongSwitchPressed then @@ -431,7 +437,6 @@ function refresh(tunes) prevSongSwitchPressed = false end - --Widget Display by Size if tunes.zone.w > 450 and tunes.zone.h > 240 then refreshZoneFull(tunes) elseif tunes.zone.w > 200 and tunes.zone.h > 165 then refreshZoneXLarge(tunes) diff --git a/Grayscale Radios/iTunes-v210.lua b/Grayscale Radios/iTunes-v210.lua new file mode 100644 index 0000000..38a765d --- /dev/null +++ b/Grayscale Radios/iTunes-v210.lua @@ -0,0 +1,253 @@ +--[[ ######################################################################### + # TaraniTunes v.4.1 # + # B&W Radios # + # 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 # + # published by the Free Software Foundation. # + # # + # This program is distributed in the hope that it will be useful # + # but WITHOUT ANY WARRANTY; without even the implied warranty of # + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # + # GNU General Public License for more details. # + #########################################################################--]] + +--Locals +local playingSong = 1 +local errorOccured = false +local ver = getVersion() --EdgeTX Version +loadScript("/SOUNDS/lists/bubba_mix/playlist.lua")() --1st playlist in songList (see sample list below) + +--Playlists folders names i.e. /SONGS/lists/"foldername" below are sample names +local songList= +{"bubba_mix", +"rock", +"upbeat", +} + +-- Initiate Program +local function init() + model.setGlobalVariable(7,0,1) + model.setGlobalVariable(8,0,1) + shPresent =getValue("sh") + if shPresent== 0 then + sw1=180 + elseif LCD_W==212 then + sw1=160 + else + sw1=180 + end + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[1][2],active=1})--resets playing song on to the 1st song on startup + return tunes +end + +-- error Control functions +local function error(strings) + errorStrings = strings + errorOccured = true +end + +--BackGround +local function background(tunes) +if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + end + end +end + +local function run(tunes) +--Update Locals + lcd.clear() + local selection=playingSong + local long=playlist[playingSong][3] --do not change this value it is the length of the current song playing + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played + local batt = getValue("tx-voltage") + local datenow = getDateTime() + local timemins = (string.format("%02d",datenow.min)) + local fly=model.getTimer(1).value --flight duration timer: 0=timer1, 1=timer2 + local altN=getValue("Alt")--current altitude from telementry + local altM=getValue("Alt+")--max altitude from telementry + local shPresent =getValue("sh") + + -- LS60 Switch Number controled by Radio profile + if shPresent== 0 then + sw1=180 + elseif LCD_W==212 then + sw1=160 + else + sw1=180 + end + +--Math + function round(num, decimals) + local mult = 10^(decimals or 0) + return math.floor(num * mult + .5) / mult + end + +--Current time, OpenTX Version & Model Name + lcd.drawText(1,10,datenow.hour12..":"..timemins..datenow.suffix,SMLSIZE) + lcd.drawText(1,2,"OTX "..ver,SMLSIZE) + if LCD_W == 212 then + lcd.drawText(LCD_W/2-(string.len(model.getInfo().name)/2)*6,2,model.getInfo().name) + else + lcd.drawText(LCD_W/2-(string.len(model.getInfo().name)/2)*5,13,model.getInfo().name) + end + + --Transmitter battery + lcd.drawText(14, 18,"TX "..round(batt,1).."v",PREC1+SMLSIZE) + + -- Altitude + lcd.drawText(1, 26,"Alt= "..round(altN,2).."/"..round(altM,2),SMLSIZE) + +--Flight Time + lcd.drawTimer(LCD_W-32, 20, fly, MIDSIZE) + +--rssi + lcd.drawText(LCD_W-51,1,"RSSI "..getValue("RSSI").."/"..getValue("RSSI-")) + +--Cell Voltage + lcd.drawChannel(LCD_W-(string.len("LCEL"))*6, 11,"LCEL", PREC2) --displays a custom telementry sensor (lowest cell)calculated from "cels" sensor + +--Music Display + local y = 23; +--Playlist title + lcd.drawLine(0, y+10, LCD_W, y+10,SOLID,FORCE) + lcd.drawText(LCD_W/2-(string.len(title))/2*5, y+12, title, SMLSIZE) + +-- Progressbar + local k = math.floor((upTime/long)*33)*10 + lcd.drawLine(0, y+18, LCD_W, y+18,SOLID,FORCE) + lcd.drawFilledRectangle(20, y+11, math.floor((upTime/long)*(LCD_W-43)), 7) + lcd.drawTimer(1, y+12, upTime, SMLSIZE+INVERS) + lcd.drawTimer(LCD_W-22, y+12, long, SMLSIZE+INVERS) + +--Song display + if selection == #playlist then + lcd.drawText(6, y+19, playlist[selection - 1][1],SMLSIZE) + lcd.drawText(1, y+26, string.char(126) .. playlist[selection][1],SMLSIZE) + lcd.drawText(6, y+33, playlist[1][1],SMLSIZE) + else + if selection == 1 then + lcd.drawText(6, y+19, playlist[#playlist][1],SMLSIZE) + lcd.drawText(1, y+26, string.char(126) .. playlist[selection][1],SMLSIZE) + lcd.drawText(6, y+33, playlist[selection + 1][1],SMLSIZE) + else + lcd.drawText(6, y+19, playlist[selection - 1][1],SMLSIZE) + lcd.drawText(1, y+26, string.char(126) .. playlist[selection][1], SMLSIZE) + lcd.drawText(6, y+33, playlist[selection + 1][1],SMLSIZE) + end + end + +-- Music Controls + listP = getValue("ls63") + listN = getValue("ls64") + prevS = getValue("ls61") + nextS = getValue("ls62") + +--song over + if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + end + end + +-- Next song + if nextS > -1 then + if not nextSongSwitchPressed then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + else + playingSong = model.getGlobalVariable(7,0) + end + flushAudio() + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + else + nextSongSwitchPressed = false + end + end + +--Change Previous Playlist + if listP > -1 then + if not prevListSwitchPressed then + if model.getGlobalVariable(8,0)<= 0 then + model.setGlobalVariable(8,0,#songList) + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + else + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + end + loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setGlobalVariable(7,0,1) + flushAudio() + model.setTimer(2,{value=0}) + else + prevListSwitchPressed = false + end + end + +--Change next Playlist + if listN > -1 then + if not nextListSwitchPressed then + if model.getGlobalVariable(8,0) >= #songList then + set2 = songList[1] + model.setGlobalVariable(8,0,1) + playingSong = 1 + else + set2 = songList[model.getGlobalVariable(8,0)] + playingSong = 1 + end + loadScript("/SOUNDS/lists/"..set2.."/playlist.lua")() + model.setCustomFunction(62,{62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setGlobalVariable(7,0,1) + flushAudio() + model.setTimer(2,{value=0}) + else + nextListSwitchPressed = false + end + end + +-- previous song + if prevS > -1 then + if not prevSongSwitchPressed then + if playingSong == 1 then + model.setGlobalVariable(7,0,#playlist) + playingSong = model.getGlobalVariable(7,0) + else + playingSong = model.getGlobalVariable(7,0) + end + flushAudio() + model.setCustomFunction(62,{switch = sw1,func = FUNC_BACKGND_MUSIC,name = playlist[playingSong][2],active=1}) + model.setTimer(2,{value=0}) + end + else + prevSongSwitchPressed = false + end +end + +return {run = run, background = background, init = init} diff --git a/Grayscale Radios/iTunes.lua b/Grayscale Radios/iTunes.lua index 76d6868..5fc0a2e 100644 --- a/Grayscale Radios/iTunes.lua +++ b/Grayscale Radios/iTunes.lua @@ -16,24 +16,13 @@ --Locals local playingSong = 1 local errorOccured = false -local ver = getVersion() --OpenTX Version +local ver = getVersion() --EdgeTX Version loadScript("/SOUNDS/lists/bubba_mix/playlist.lua")() --1st playlist in songList (see sample list below) --Playlists folders names i.e. /SONGS/lists/"foldername" below are sample names local songList= {"bubba_mix", -"classic_country", -"country_rock", -"easy", -"fun_country", -"todays", -"funrock", -"hard", -"laid_back", -"modern", "rock", -"soundtracks", -"garage", "upbeat", } @@ -61,14 +50,29 @@ end --BackGround local function background(tunes) +if model.getTimer(2).value >= long then + if playingSong == #playlist then + model.setGlobalVariable(7,0,1) + playingSong = model.getGlobalVariable(7,0) + flushAudio() + model.setCustomFunction(62,{switch = sw1,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + else + flushAudio() + playingSong = playingSong +1 + model.setGlobalVariable(7,0,playingSong) + model.setCustomFunction(62,{switch = sw1,func = 16,name = playlist[playingSong][2]}) + model.setTimer(2,{value=0}) + end + end end local function run(tunes) --Update Locals lcd.clear() local selection=playingSong - local long=playlist[playingSong][3]--do not change this value it is the length of the current song playing - local upTime=model.getTimer(2).value--do not change this value it is how long the current song has played + local long=playlist[playingSong][3] --do not change this value it is the length of the current song playing + local upTime=model.getTimer(2).value --do not change this value it is how long the current song has played local batt = getValue("tx-voltage") local datenow = getDateTime() local timemins = (string.format("%02d",datenow.min)) @@ -123,7 +127,7 @@ local function run(tunes) lcd.drawText(LCD_W/2-(string.len(title))/2*5, y+12, title, SMLSIZE) -- Progressbar - --local k = math.floor((upTime/long)*33)*10 + local k = math.floor((upTime/long)*33)*10 lcd.drawLine(0, y+18, LCD_W, y+18,SOLID,FORCE) lcd.drawFilledRectangle(20, y+11, math.floor((upTime/long)*(LCD_W-43)), 7) lcd.drawTimer(1, y+12, upTime, SMLSIZE+INVERS)