Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LibGUI, and updates to EventDemo #22

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions sdcard/horus/WIDGETS/EventDemo/loadable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ local function evt2str(event)
end
end

-- Returns a function to animate tap events on the square
-- Sets a function to animate tap events on the square
local function TapAnimation(tapCount)
local delta = 20
local maxS = 250
Expand All @@ -73,7 +73,7 @@ local function TapAnimation(tapCount)
end


local function a()
animate = function()
lcd.drawText(x, y, txt, VCENTER + CENTER + DBLSIZE + ORANGE)
s = s + delta
lcd.drawRectangle(x - 0.5 * s, y - 0.5 * s, s, s)
Expand All @@ -82,16 +82,14 @@ local function TapAnimation(tapCount)
animate = nil
end
end

return a
end

-- Returns a function to animate swipe events shooting little bullets
-- Sets a function to animate swipe events shooting little bullets
local function SwipeAnimation(deltaX, deltaY)
local x = x
local y = y

local function a()
animate = function()
local x2 = x + deltaX
local y2 = y + deltaY

Expand All @@ -102,8 +100,6 @@ local function SwipeAnimation(deltaX, deltaY)
animate = nil
end
end

return a
end

function widget.refresh(event, touchState)
Expand Down Expand Up @@ -143,25 +139,25 @@ function widget.refresh(event, touchState)
-- If the finger hit the square, then play the animation
if stick then
playTone(200, 50, 100, PLAY_NOW)
animate = TapAnimation(touchState.tapCount)
TapAnimation(touchState.tapCount)
end

elseif event == EVT_TOUCH_SLIDE then -- Sliding the finger gives a SLIDE instead of BREAK or TAP
-- A fast vertical or horizontal slide gives a true swipe* value in touchState (only once per 500ms)
if touchState.swipeRight then
animate = SwipeAnimation(20, 0)
SwipeAnimation(20, 0)
playTone(10000, 200, 100, PLAY_NOW, -60)

elseif touchState.swipeLeft then
animate = SwipeAnimation(-20, 0)
SwipeAnimation(-20, 0)
playTone(10000, 200, 100, PLAY_NOW, -60)

elseif touchState.swipeUp then
animate = SwipeAnimation(0, -20)
SwipeAnimation(0, -20)
playTone(10000, 200, 100, PLAY_NOW, -60)

elseif touchState.swipeDown then
animate = SwipeAnimation(0, 20)
SwipeAnimation(0, 20)
playTone(10000, 200, 100, PLAY_NOW, -60)

elseif stick then
Expand Down
2 changes: 1 addition & 1 deletion sdcard/horus/WIDGETS/EventDemo/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ return {
options = options,
update = update,
background = background
}
}
Loading