Buttons rename (#287)

* renaming up/down/click to released/pressed/bump

* missing images

* fixing signature issue

* updated strings

* white lego logo
This commit is contained in:
Peli de Halleux
2018-01-31 08:28:00 -08:00
committed by GitHub
parent ba1b9a54b4
commit ea956f1a73
50 changed files with 151 additions and 102 deletions

View File

@ -1,5 +1,4 @@
{
"TouchSensorEvent": "Touch sensor interactions",
"sensors.TouchSensor.isPressed": "Check if touch sensor is touched.",
"sensors.TouchSensor.onEvent": "Do something when a touch sensor is touched...",
"sensors.TouchSensor.onEvent|param|body": "code to run when the event is raised",

View File

@ -1,7 +1,4 @@
{
"TouchSensorEvent.Bumped|block": "bumped",
"TouchSensorEvent.Pressed|block": "pressed",
"TouchSensorEvent.Released|block": "released",
"sensors.TouchSensor.isPressed|block": "%sensor|is pressed",
"sensors.TouchSensor.onEvent|block": "on %sensor|%event",
"sensors.TouchSensor.pauseUntil|block": "pause until %sensor|%event",

View File

@ -1,7 +1,7 @@
# Touch Sensor
```cards
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
sensors.touch1.isPressed();

View File

@ -1,7 +1,7 @@
# On Event
```sig
sensors.touch1.onEvent(TouchSensorEvent.Released, function () { })
sensors.touch1.onEvent(ButtonEvent.Released, function () { })
```
# Parameters
@ -10,7 +10,7 @@ sensors.touch1.onEvent(TouchSensorEvent.Released, function () { })
```blocks
sensors.touch1.onEvent(TouchSensorEvent.Released, function () {
sensors.touch1.onEvent(ButtonEvent.Released, function () {
brick.showImage(images.expressionsSick)
})
```

View File

@ -1,8 +1,8 @@
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
})
sensors.touch2.onEvent(TouchSensorEvent.Bumped, function () {
sensors.touch2.onEvent(ButtonEvent.Bumped, function () {
})
sensors.touch3.onEvent(TouchSensorEvent.Released, function () {
sensors.touch3.onEvent(ButtonEvent.Released, function () {
})
sensors.touch4.isPressed();
sensors.touch4.wasPressed();

View File

@ -1,17 +1,5 @@
// keep TouchSensorEvent in sync with ButtonEvent
/**
* Touch sensor interactions
*/
const enum TouchSensorEvent {
//% block="pressed"
Pressed = 4,
//% block="bumped"
Bumped = 1,
//% block="released"
Released = 3,
}
namespace sensors {
//% fixedInstances
@ -48,8 +36,8 @@ namespace sensors {
//% sensor.fieldEditor="ports"
//% weight=99 blockGap=8
//% group="Touch Sensor"
onEvent(ev: TouchSensorEvent, body: () => void) {
this.button.onEvent(<ButtonEvent><number>ev, body)
onEvent(ev: ButtonEvent, body: () => void) {
this.button.onEvent(ev, body)
}
/**
@ -64,7 +52,7 @@ namespace sensors {
//% sensor.fieldEditor="ports"
//% weight=98 blockGap=8
//% group="Touch Sensor"
pauseUntil(ev: TouchSensorEvent) {
pauseUntil(ev: ButtonEvent) {
this.button.pauseUntil(<ButtonEvent><number>ev);
}