support for is-gesture (#1873)
* support for is-gesture * updated shims * activate shake button * refactor * refactor shake button
This commit is contained in:
@ -13,6 +13,7 @@ input.onPinPressed(TouchPin.P0, () => {
|
||||
|
||||
});
|
||||
input.buttonIsPressed(Button.A);
|
||||
input.isGesture(Gesture.Shake);
|
||||
input.compassHeading();
|
||||
input.pinIsPressed(TouchPin.P0);
|
||||
input.temperature();
|
||||
@ -27,4 +28,6 @@ input.setAccelerometerRange(AcceleratorRange.OneG);
|
||||
|
||||
## See also
|
||||
|
||||
[onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed), [compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference/input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range), [calibrate-compass](/reference/input/calibrate-compass)
|
||||
[onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed),
|
||||
[is gesture](/reference/input/is-gesture),
|
||||
[compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference/input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range), [calibrate-compass](/reference/input/calibrate-compass)
|
||||
|
28
docs/reference/input/is-gesture.md
Normal file
28
docs/reference/input/is-gesture.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Is Gesture
|
||||
|
||||
Tests if a gesture is currently detected.
|
||||
|
||||
```sig
|
||||
input.isGesture(Gesture.Shake)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* ``gesture`` means the way you hold or move the @boardname@. This can be `shake`, `logo up`, `logo down`, `screen up`, `screen down`, `tilt left`, `tilt right`, `free fall`, `3g`, or `6g`.
|
||||
|
||||
## Example: random number
|
||||
|
||||
This program shows a number from `2` to `9` when you shake the @boardname@.
|
||||
|
||||
```blocks
|
||||
forever(function() {
|
||||
if (input.isGesture(Gesture.Shake)) {
|
||||
let x = Math.randomRange(2, 9)
|
||||
basic.showNumber(x)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[on gesture](/reference/input/on-gesture)
|
@ -24,3 +24,6 @@ input.onGesture(Gesture.Shake,() => {
|
||||
})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[is gesture](/reference/input/is-gesture)
|
Reference in New Issue
Block a user