Skip to content

Commit

Permalink
Update main.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwieland authored May 2, 2024
1 parent ba539c2 commit 42fa77d
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions Color Screen Widget/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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
Expand All @@ -66,6 +66,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)
Expand All @@ -87,7 +103,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)
Expand Down Expand Up @@ -116,7 +132,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)
Expand Down Expand Up @@ -144,7 +160,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)
Expand Down Expand Up @@ -199,7 +215,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)
Expand Down Expand Up @@ -229,7 +245,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)
Expand Down Expand Up @@ -302,9 +318,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)
Expand Down Expand Up @@ -353,8 +368,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
Expand Down Expand Up @@ -396,7 +411,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
Expand All @@ -414,6 +429,7 @@ function refresh(tunes)
nextListSwitchPressed = false
end
end

-- previous song
if prevS > -1 then
if not prevSongSwitchPressed then
Expand All @@ -431,7 +447,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)
Expand Down

1 comment on commit 42fa77d

@jrwieland
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git tag -a v4.4.1

Please sign in to comment.