https://github.com/waveshareteam/joystick
https://github.com/waveshareteam/joystick
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/waveshareteam/joystick
- Owner: waveshareteam
- Created: 2018-03-21T07:46:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-22T01:40:33.000Z (almost 8 years ago)
- Last Synced: 2025-04-03T17:11:14.459Z (11 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 7
- Watchers: 2
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WSJoyStick
Waveshare electronic
## TODO
- [ ] Add a reference for your blocks here
- [ ] Add "icon.png" image (300x200) in the root folder
- [ ] Add "- beta" to the GitHub project description if you are still iterating it.
- [ ] Turn on your automated build on https://travis-ci.org
- [ ] Use "pxt bump" to create a tagged release on GitHub
- [ ] Get your package reviewed and approved https://makecode.microbit.org/packages/approval
Read more at https://makecode.microbit.org/packages/build-your-own
## License
MIT
## Supported targets
* for PXT/microbit
(The metadata above is needed for package search.)
##################
#initialization
#First use this module need to initialize the module, otherwise the rocker does not work
WSJoyStick.JoyStickInit()
##################
#Listening button
KEY = P, A, B, C, D, E, F,
if (WSJoyStick.Listen_Key(KEY.P)) {
#event
}
WSJoyStick.onKey(KEY.P, () => {
#event
})
#example 1:
WSJoyStick.onKey(KEY.P, () => {
basic.showLeds(`
. # # # .
. # . # .
. # # # .
. # . . .
. # . . .
`)
})
#example 2:
if (WSJoyStick.Listen_Key(KEY.P)) {
basic.showLeds(`
. # # # .
. # . # .
. # # # .
. # . . .
. # . . .
`)
}
##################
#Listening rocker
DIR = NONE, U, D, L, R, U_L, U_R, D_L, D_R
if (WSJoyStick.Listen_Dir(DIR.NONE)) {
}
#example:
if (WSJoyStick.Listen_Dir(DIR.NONE)) {
images.arrowImage(ArrowNames.North).showImage(0)
}
##################
#Play Music
#example:
WSJoyStick.PlayMusic(262, music.beat(BeatFraction.Whole))