-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathjoystick_test.lua
44 lines (36 loc) · 1.09 KB
/
joystick_test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- ChiliPeppr Joystick controller
-- Used to control analog joysticks that are implemented just using
-- variable resistors where you feed in 3.3v and get out a variable voltage
-- based on position of the joystick. Joysticks like the Playstation portable
-- or Xbox joysticks work this way and are readily available on Amazon, Ebay,
-- or Aliexpress.
--
-- Working example of using this library:
-- https://www.youtube.com/watch?v=ITgh5epyPRk
--
-- Visit http://chilipeppr.com/esp32
-- By John Lauer
--
-- There is no license needed to use/modify this software. It is given freely
-- to the open source community. Modify at will.
--
joystick = require("joystick")
joystick.on("xy", function(x, y)
print("Got xy change. x:", x, "y:", y)
end)
-- joystick.on("x", function(x)
-- print("Got x change. x:", x)
-- end)
-- joystick.on("y", function(y)
-- print("Got y change. y:", y)
-- end)
joystick.on("xcenter", function()
print("Got x center")
end)
joystick.on("ycenter", function()
print("Got y center")
end)
joystick.on("button", function(val)
print("Got button:", val)
end)
joystick.init()