add handling of gestures (we only have 2g, 6g ... no 3g), add mac/idea ignored files
This commit is contained in:
parent
47f46553e0
commit
f10ac93268
4
.gitignore
vendored
4
.gitignore
vendored
@ -24,3 +24,7 @@ clients/electron/projects
|
|||||||
*.db
|
*.db
|
||||||
*.suo
|
*.suo
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
42
libs/calliope-test/calliope.ts
Normal file
42
libs/calliope-test/calliope.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
basic.showString("RGB LED")
|
||||||
|
basic.setLedColor(Colors.Blue)
|
||||||
|
basic.pause(500)
|
||||||
|
basic.setLedColor(Colors.Red)
|
||||||
|
basic.pause(500)
|
||||||
|
basic.setLedColor(Colors.Green)
|
||||||
|
basic.pause(500)
|
||||||
|
basic.setLedColor(Colors.Violet)
|
||||||
|
basic.pause(500)
|
||||||
|
basic.setLedColor(0);
|
||||||
|
basic.showString("Gestures")
|
||||||
|
input.onGesture(Gesture.Shake, () => {
|
||||||
|
basic.showString("S")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.LogoUp, () => {
|
||||||
|
basic.showString("U")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.LogoDown, () => {
|
||||||
|
basic.showString("D")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.ScreenUp, () => {
|
||||||
|
basic.showString("+")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.TiltRight, () => {
|
||||||
|
basic.showString("R")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.FreeFall, () => {
|
||||||
|
basic.showString("F")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.ScreenDown, () => {
|
||||||
|
basic.showString("-")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.TiltLeft, () => {
|
||||||
|
basic.showString("L")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.ThreeG, () => {
|
||||||
|
basic.showString("3")
|
||||||
|
})
|
||||||
|
input.onGesture(Gesture.SixG, () => {
|
||||||
|
basic.showString("6")
|
||||||
|
})
|
||||||
|
|
11
libs/calliope-test/pxt.json
Normal file
11
libs/calliope-test/pxt.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "calliope",
|
||||||
|
"description": "Test of Calliope Parts",
|
||||||
|
"files": [
|
||||||
|
"calliope.ts"
|
||||||
|
],
|
||||||
|
"public": true,
|
||||||
|
"dependencies": {
|
||||||
|
"core": "file:../core"
|
||||||
|
}
|
||||||
|
}
|
1
libs/core/dal.d.ts
vendored
1
libs/core/dal.d.ts
vendored
@ -426,6 +426,7 @@ declare const enum DAL {
|
|||||||
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
||||||
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
||||||
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 400,
|
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 400,
|
||||||
|
MICROBIT_ACCELEROMETER_2G_TOLERANCE = 2048,
|
||||||
MICROBIT_ACCELEROMETER_3G_TOLERANCE = 3072,
|
MICROBIT_ACCELEROMETER_3G_TOLERANCE = 3072,
|
||||||
MICROBIT_ACCELEROMETER_6G_TOLERANCE = 6144,
|
MICROBIT_ACCELEROMETER_6G_TOLERANCE = 6144,
|
||||||
MICROBIT_ACCELEROMETER_8G_TOLERANCE = 8192,
|
MICROBIT_ACCELEROMETER_8G_TOLERANCE = 8192,
|
||||||
|
@ -130,7 +130,7 @@ namespace input {
|
|||||||
//% parts="accelerometer"
|
//% parts="accelerometer"
|
||||||
void onGesture(Gesture gesture, Action body) {
|
void onGesture(Gesture gesture, Action body) {
|
||||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||||
uBit.accelerometer.setRange(4);
|
uBit.accelerometer.setRange(6);
|
||||||
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
||||||
uBit.accelerometer.setRange(8);
|
uBit.accelerometer.setRange(8);
|
||||||
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
||||||
|
Loading…
Reference in New Issue
Block a user