Map and clean deprecated functions (#175)

* add image and deprecated arrow functions

* update locales

* map basic.showArrow

* map arrow blocks

* map & remove arrow images

* remove arrow blocks

* update locales

* remove & patch:
rgbw -> rgb
button/pin pressed -> button/pin event
loudness -> soundLevel

* update ts mappings for arrows

* add wip ts patch rules

* update .blocks files

* use Click instead of Down as default in Documentation and tests

* patch test.blocks

* fix lowercase name tag

* update test.blocks

* update blocks test files

* update blocks test files

* format block files

* pass blocks file tests

* fix ts mapping

* fix color.defl value

closes https://github.com/microsoft/pxt-calliope/issues/136

* fix ts mappings

- add optional spacing at the end of rgbw()
- map up to v4.0.19

* add suggested changes

* replace innerText by textContent

Co-authored-by: JW <gitkraken@juriwolf.de>
Co-authored-by: Juri <info@juriwolf.de>
This commit is contained in:
authored and GitHub committed 2022-04-26 10:28:42 -07:00
1 parent 3b9d90e551
commit a93febb5b7
102 files changed
+1458 -740

No files matched your search

+2 -17
View File
@@ -254,11 +254,6 @@
"basic.plotLeds": "Draws an image on the LED screen.",
"basic.plotLeds|param|leds": "pattern of LEDs to turn on/off",
"basic.rgb": "Converts red, green, blue channels into a RGB color",
"basic.rgbw": "Converts red, green, blue channels into a RGB color",
"basic.rgbw|param|blue": "value of the blue channel between 0 and 255. eg: 255",
"basic.rgbw|param|green": "value of the green channel between 0 and 255. eg: 255",
"basic.rgbw|param|red": "value of the red channel between 0 and 255. eg: 255",
"basic.rgbw|param|white": "value of the white channel between 0 and 255. eg: 0",
"basic.rgb|param|blue": "value of the blue channel between 0 and 255. eg: 255",
"basic.rgb|param|green": "value of the green channel between 0 and 255. eg: 255",
"basic.rgb|param|red": "value of the red channel between 0 and 255. eg: 255",
@@ -441,25 +436,15 @@
"input.isGesture": "Tests if a gesture is currently detected.",
"input.isGesture|param|gesture": "the type of gesture to detect, eg: Gesture.Shake",
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
"input.loudness": "gets the level of loudness from 0 (silent) to 255 (loud)",
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
"input.magneticForce|param|dimension": "the x, y, or z dimension, eg: Dimension.X",
"input.onButtonEvent": "Do something when a button (A, B or both A+B) receives an event.",
"input.onButtonEvent|param|body": "code to run when event is raised",
"input.onButtonEvent|param|button": "the button",
"input.onButtonEvent|param|eventType": "event Type",
"input.onButtonPressed": "Do something when a button (A, B or both A+B) is pushed down and released again.",
"input.onButtonPressed|param|body": "code to run when event is raised",
"input.onButtonPressed|param|button": "the button that needs to be pressed",
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
"input.onGesture|param|body": "code to run when gesture is raised",
"input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake",
"input.onPinPressed": "Do something when a pin is touched and released again (while also touching the GND pin).",
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
"input.onPinReleased": "Do something when a pin is released.",
"input.onPinReleased|param|body": "the code to run when the pin is released",
"input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0",
"input.onPinTouchEvent": "Do something when a pin receives an touch event (while also touching the GND pin).",
"input.onPinTouchEvent|param|body": "the code to run when event is fired on pin",
"input.onPinTouchEvent|param|name": "the pin, eg: TouchPin.P0",
@@ -700,7 +685,7 @@
"storage.putValueInt|param|key": "the key for accesing the value",
"storage.putValueInt|param|value": "value to store",
"storage.remove": "Removes a key value pair from the non volatile storage",
"storage.removeKeyInt": "Deletes the key from the non volatile storage",
"storage.removeKeyInt|param|key": "the key for accesing the value",
"storage.removeNumber": "Deletes the key from the non volatile storage",
"storage.removeNumber|param|key": "the key for accesing the value",
"storage.remove|param|key": "the key for accesing the value"
}
+1 -6
View File
@@ -276,7 +276,6 @@
"basic.color|block": "%c",
"basic.forever|block": "forever",
"basic.pause|block": "pause (ms) %pause",
"basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
"basic.rgb|block": "red %red|green %green|blue %blue",
"basic.setLedColor|block": "set led to %color=colorNumberPicker",
"basic.showArrow|block": "show arrow %i=device_arrow",
@@ -344,13 +343,9 @@
"input.isCalibratedCompass|block": "is compass calibrated",
"input.isGesture|block": "is %gesture gesture",
"input.lightLevel|block": "light level",
"input.loudness|block": "Loudness",
"input.magneticForce|block": "magnetic force (µT)|%NAME",
"input.onButtonEvent|block": "on button %NAME| %eventType=control_button_event_value_id",
"input.onButtonPressed|block": "on button|%NAME|pressed",
"input.onGesture|block": "on |%NAME",
"input.onPinPressed|block": "on pin %name|pressed",
"input.onPinReleased|block": "on pin %NAME|released",
"input.onPinTouchEvent|block": "on pin %name| %eventType=control_button_event_value_id",
"input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME",
@@ -451,7 +446,7 @@
"storage.getValueInt|block": "get number from %key",
"storage.putNumber|block": "Save into number %key a value of %value",
"storage.putValueInt|block": "Put into %key a value of %value as Int",
"storage.removeKeyInt|block": "Clear number %key",
"storage.removeNumber|block": "Clear number %key",
"storage.remove|block": "remove %key",
"storage|block": "storage",
"{id:category}AnalogInPin": "AnalogInPin",
+1
View File
@@ -118,6 +118,7 @@ namespace basic {
*/
//% blockId=device_set_led_color
//% block="set led to %color=colorNumberPicker"
//% color.defl=0xff0000
//% weight=10
//% group="RGB LED"
void setLedColor(int color) {
-16
View File
@@ -82,22 +82,6 @@ namespace basic {
return ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF);
}
/**
* Converts red, green, blue channels into a RGB color
* @param red value of the red channel between 0 and 255. eg: 255
* @param green value of the green channel between 0 and 255. eg: 255
* @param blue value of the blue channel between 0 and 255. eg: 255
* @param white value of the white channel between 0 and 255. eg: 0
*/
//% weight=2
//% blockId="core_rgbw" block="red %red|green %green|blue %blue|white %white"
//% group="RGB LED"
//% deprecated=true
export function rgbw(red: number, green: number, blue: number, white:number): number {
return ((white & 0xFF) << 24) | ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF);
}
}
/**
+124 -52
View File
@@ -1,53 +1,125 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="PGGhch1kuMF##st8~wFr">receivedNumber</variable>
</variables>
<block type="pxt-on-start" x="77" y="38">
<statement name="HANDLER">
<block type="device_show_number">
<value name="number">
<shadow type="math_number">
<field name="NUM">12</field>
</shadow>
</value>
<next>
<block type="basic_show_icon">
<field name="i">IconNames.Umbrella</field>
<next>
<block type="device_print_message">
<value name="text">
<shadow type="text">
<field name="TEXT">hi!</field>
</shadow>
</value>
<next>
<block type="device_pause">
<value name="pause">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
<next>
<block type="device_clear_display">
<next>
<block type="device_pause">
<value name="pause">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_forever" x="418" y="25"></block>
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="PGGhch1kuMF##st8~wFr">receivedNumber</variable>
</variables>
<block type="pxt-on-start" x="-307" y="-128">
<statement name="HANDLER">
<block type="device_show_number">
<value name="number">
<shadow type="math_number">
<field name="NUM">12</field>
</shadow>
</value>
<next>
<block type="device_show_number">
<value name="number">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="basic_show_icon">
<field name="i">IconNames.Umbrella</field>
<next>
<block type="basic_show_icon">
<field name="i">IconNames.Heart</field>
<next>
<block type="device_print_message">
<value name="text">
<shadow type="text">
<field name="TEXT">hi!</field>
</shadow>
</value>
<next>
<block type="device_print_message">
<value name="text">
<shadow type="text">
<field name="TEXT">hi!</field>
</shadow>
</value>
<next>
<block type="device_pause">
<value name="pause">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
<next>
<block type="device_clear_display">
<next>
<block type="device_show_leds">
<field name="LEDS">`
. . . . #
. . . # .
. . # . .
. # . . .
# . . . .
`</field>
<next>
<block type="device_set_led_color">
<value name="color">
<shadow type="colorNumberPicker">
<field name="value">0xff0000</field>
</shadow>
</value>
<next>
<block type="device_show_number">
<value name="number">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="core_rgb">
<value name="red">
<shadow type="math_number">
<field name="NUM">255</field>
</shadow>
</value>
<value name="green">
<shadow type="math_number">
<field name="NUM">255</field>
</shadow>
</value>
<value name="blue">
<shadow type="math_number">
<field name="NUM">255</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="basic_show_compass">
<value name="interval">
<shadow type="timePicker">
<field name="ms">600</field>
</shadow>
</value>
<next>
<block type="device_turn_rgb_led_off" />
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_forever" x="412" y="-30" />
</xml>
+52 -37
View File
@@ -1,38 +1,53 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="tgDN]qF_Ah1Z*?=|+?^Y">item</variable>
</variables>
<block type="pxt-on-start" x="-29" y="116">
<statement name="HANDLER">
<block type="device_show_image_offset">
<value name="sprite">
<block type="builtin_image">
<field name="i">IconNames.Heart</field>
</block>
</value>
<value name="offset">
<shadow type="math_number" id="KX(1%=^vQUd=Q`UHhD*n">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="device_scroll_image">
<value name="frameoffset">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
<value name="delay">
<shadow type="math_number">
<field name="NUM">200</field>
</shadow>
</value>
</block>
</next>
</block>
</statement>
</block>
<block type="variables_get" disabled="true" x="145" y="168">
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y" variabletype="">item</field>
</block>
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="tgDN]qF_Ah1Z*?=|+?^Y">item</variable>
</variables>
<block type="pxt-on-start" x="48" y="151">
<statement name="HANDLER">
<block type="variables_set">
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y">item</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="builtin_image">
<field name="i">IconNames.Yes</field>
</block>
</value>
<next>
<block type="device_show_image_offset">
<value name="sprite">
<block type="builtin_image">
<field name="i">IconNames.Heart</field>
</block>
</value>
<value name="offset">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="device_scroll_image">
<value name="sprite">
<block type="variables_get">
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y">item</field>
</block>
</value>
<value name="frameoffset">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
<value name="delay">
<shadow type="math_number">
<field name="NUM">200</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>
+123 -114
View File
@@ -1,132 +1,141 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="wUkGVHoc@p^mter~Rc7h">item</variable>
<variable type="" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</variable>
</variables>
<block type="device_button_event" x="-6" y="17">
<field name="NAME">Button.AB</field>
<statement name="HANDLER">
<block type="variables_set">
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h" variabletype="">item</field>
<value name="VALUE">
<shadow type="math_number" id="*jGI?[NsA.f}=qk0RHHf">
<field name="NUM">0</field>
</shadow>
<block type="device_get_button2">
<field name="NAME">Button.B</field>
</block>
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="wUkGVHoc@p^mter~Rc7h">item</variable>
<variable id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</variable>
</variables>
<block type="device_button_selected_event" x="0" y="0">
<field name="NAME">Button.AB</field>
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h" variabletype="">item</field>
<value name="VALUE">
<shadow type="math_number" id="*jGI?[NsA.f}=qk0RHHf">
<field name="NUM">0</field>
</shadow>
<block type="device_pin_is_pressed">
<field name="NAME">TouchPin.P1</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<statement name="HANDLER">
<block type="variables_set">
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h">item</field>
<value name="VALUE">
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
<field name="NUM">0</field>
</shadow>
<block type="device_acceleration">
<field name="NAME">Dimension.Y</field>
</block>
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_button2">
<field name="NAME">Button.B</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
<field name="NUM">0</field>
</shadow>
<block type="device_get_light_level"></block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<block type="variables_set">
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h">item</field>
<value name="VALUE">
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
<field name="NUM">0</field>
</shadow>
<block type="device_heading"></block>
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_pin_is_pressed">
<field name="NAME">TouchPin.P1</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
<field name="NUM">0</field>
</shadow>
<block type="device_temperature"></block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number" id="o~k},FK*r@[O2)Cy!lM}">
<field name="NUM">0</field>
</shadow>
<block type="device_get_rotation">
<field name="NAME">Rotation.Roll</field>
</block>
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_acceleration">
<field name="NAME">Dimension.Y</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number" id="Uu,ZpYs7!BzIpX`%V_^!">
<field name="NUM">0</field>
</shadow>
<block type="device_get_magnetic_force">
<field name="NAME">Dimension.Z</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number" id="s{USu#UBc84Ao*jy(EQC">
<field name="NUM">0</field>
</shadow>
<block type="device_get_running_time"></block>
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_light_level" />
</value>
<next>
<block type="device_set_accelerometer_range">
<field name="range">AcceleratorRange.TwoG</field>
</block>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_heading" />
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_temperature" />
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_rotation">
<field name="NAME">Rotation.Roll</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_magnetic_force">
<field name="NAME">Dimension.Z</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_running_time" />
</value>
<next>
<block type="device_set_accelerometer_range">
<field name="range">AcceleratorRange.TwoG</field>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</block>
</next>
</block>
</next>
</block>
</block>
</next>
</block>
</next>
</block>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_gesture_event" x="472" y="-8">
<field name="NAME">Gesture.SixG</field>
</block>
<block type="device_pin_event" x="555" y="96">
<field name="name">TouchPin.P2</field>
</block>
<block type="device_pin_released" x="188" y="435">
<field name="NAME">TouchPin.P2</field>
</block>
</block>
</statement>
</block>
<block type="device_gesture_event" x="555" y="30">
<field name="NAME">Gesture.SixG</field>
</block>
<block type="device_pin_custom_event" x="556" y="156">
<field name="name">TouchPin.P0</field>
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
</block>
<block type="device_pin_custom_event" x="560" y="274">
<field name="name">TouchPin.P0</field>
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
</block>
</xml>
+29
View File
@@ -0,0 +1,29 @@
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="pxt-on-start" x="20" y="20">
<statement name="HANDLER">
<block type="motor_on">
<value name="percent">
<shadow type="speedPicker">
<field name="speed">100</field>
</shadow>
</value>
<next>
<block type="motor_command">
<field name="command">MotorCommand.Break</field>
<next>
<block type="block_dual_motor">
<field name="motor">Motor.A</field>
<value name="percent">
<shadow type="speedPicker">
<field name="speed">100</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_forever" x="294" y="22" />
</xml>
+83 -84
View File
@@ -1,95 +1,94 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="I3xB5Q]ehg#-~(sq{[|E">item</variable>
</variables>
<block type="melody_on_event" x="-27" y="128">
<field name="value">MusicEvent.BackgroundMelodyStarted</field>
<statement name="HANDLER">
<block type="device_play_note">
<value name="note">
<shadow type="device_note">
<field name="name">175</field>
</shadow>
</value>
<value name="duration">
<shadow type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</shadow>
</value>
<next>
<block type="device_ring">
<value name="note">
<shadow type="device_note">
<field name="name">147</field>
</shadow>
</value>
<next>
<block type="device_rest">
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="I3xB5Q]ehg#-~(sq{[|E">item</variable>
</variables>
<block type="device_forever" x="21" y="128">
<statement name="HANDLER">
<block type="device_play_note">
<value name="note">
<shadow type="device_note">
<field name="name">175</field>
</shadow>
</value>
<value name="duration">
<shadow type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</shadow>
<shadow type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</shadow>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
<value name="VALUE">
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
<field name="NUM">0</field>
</shadow>
<block type="device_note">
<field name="name">466</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
<value name="VALUE">
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
<field name="NUM">0</field>
</shadow>
<block type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</block>
<block type="device_ring">
<value name="note">
<shadow type="device_note">
<field name="name">147</field>
</shadow>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
<value name="VALUE">
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
<field name="NUM">0</field>
</shadow>
<block type="device_tempo"></block>
</value>
<next>
<block type="device_change_tempo">
<value name="value">
<shadow type="math_number">
<field name="NUM">1242</field>
</shadow>
<block type="device_rest">
<value name="duration">
<shadow type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</shadow>
</value>
<next>
<block type="device_set_tempo">
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_note">
<field name="name">466</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_tempo" />
</value>
<next>
<block type="device_change_tempo">
<value name="value">
<shadow type="math_number">
<field name="NUM">1242</field>
</shadow>
</value>
<next>
<block type="device_set_tempo">
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</block>
</next>
</block>
</next>
</block>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</block>
</statement>
</block>
</xml>
+2 -2
View File
@@ -59,8 +59,8 @@
</value>
<next>
<block type="serial_redirect">
<field name="tx">SerialPin.P12</field>
<field name="rx">SerialPin.P13</field>
<field name="tx">SerialPin.C16</field>
<field name="rx">SerialPin.C17</field>
<field name="rate">BaudRate.BaudRate28800</field>
<next>
<block type="serial_writebuffer">
+684 -1
View File
@@ -1 +1,684 @@
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="2w47B[B-y%SK,+8+DQGz">booltest</variable><variable id="Uv6@%!N7Ts}XI7t+j[zB">myImage</variable><variable id="7BPQp@}m*I210zEM4S=3">strtest</variable></variables><block type="pxt-on-start" x="481" y="68"><statement name="HANDLER"><block type="device_show_number"><value name="number"><shadow type="math_number"><field name="NUM">123</field></shadow><block type="control_event_value&quot;"/></value><next><block type="device_show_leds"><field name="LEDS">`&#10; # . . # . &#10; # . . # . &#10; . # . . . &#10; . # # . . &#10; . . . . .&#10; `</field><next><block type="basic_show_icon"><field name="i">IconNames.Heart</field><next><block type="device_pause"><value name="pause"><shadow type="timePicker"><field name="ms">500</field></shadow></value><next><block type="device_clear_display"><next><block type="basic_show_icon"><field name="i">IconNames.Heart</field><next><block type="device_show_image_offset"><value name="sprite"><block type="variables_get"><field name="VAR" id="Uv6@%!N7Ts}XI7t+j[zB">myImage</field></block></value><value name="offset"><shadow type="math_number"><field name="NUM">0</field></shadow></value><next><block type="device_scroll_image"><value name="sprite"><block type="variables_get"><field name="VAR" id="Uv6@%!N7Ts}XI7t+j[zB">myImage</field></block></value><value name="frameoffset"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="control_device_serial_number"/></value><value name="delay"><shadow type="math_number"><field name="NUM">3</field></shadow></value><next><block type="variables_set"><field name="VAR" id="7BPQp@}m*I210zEM4S=3">strtest</field><value name="VALUE"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="serial_read_until"><value name="delimiter"><shadow type="serial_delimiter_conv"><field name="del">Delimiters.Hash</field></shadow></value></block></value><next><block type="variables_set"><field name="VAR" id="7BPQp@}m*I210zEM4S=3">strtest</field><value name="VALUE"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="serial_read_buffer"/></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type="device_pin_event" x="2407" y="0"><field name="name">TouchPin.P2</field><statement name="HANDLER"><block type="device_led_toggle"><value name="x"><shadow type="math_number_minmax"><mutation min="0" max="4" label="X" precision="1"/><field name="SLIDER">1</field></shadow></value><value name="y"><shadow type="math_number_minmax"><mutation min="0" max="4" label="Y" precision="1"/><field name="SLIDER">2</field></shadow></value><next><block type="device_plot_bar_graph"><value name="value"><shadow type="math_number"><field name="NUM">5</field></shadow></value><value name="high"><shadow type="math_number"><field name="NUM">45</field></shadow></value><next><block type="led_set_display_mode"><field name="mode">DisplayMode.Greyscale</field><next><block type="device_set_analog_pin"><field name="name">AnalogPin.P2</field><value name="value"><shadow type="math_number_minmax"><mutation min="0" max="1023" label="Value"/><field name="SLIDER">1023</field></shadow><block type="device_get_analog_pin"><field name="name">AnalogPin.P2</field></block></value><next><block type="device_set_digital_pin"><field name="name">DigitalPin.P1</field><value name="value"><shadow type="math_number_minmax"><mutation min="0" max="1" label="Value"/><field name="SLIDER">0</field></shadow><block type="device_get_digital_pin"><field name="name">DigitalPin.P1</field></block></value><next><block type="device_set_analog_period"><field name="pin">AnalogPin.P2</field><value name="micros"><shadow type="math_number"><field name="NUM">1234</field></shadow><block type="pin_map"><value name="value"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="device_temperature"/></value><value name="fromLow"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="device_heading"/></value><value name="fromHigh"><shadow type="math_number"><field name="NUM">1023</field></shadow><block type="device_get_rotation"><field name="NAME">Rotation.Roll</field></block></value><value name="toLow"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="device_get_magnetic_force"><field name="NAME">Dimension.Y</field></block></value><value name="toHigh"><shadow type="math_number"><field name="NUM">4</field></shadow><block type="device_get_running_time"/></value></block></value><next><block type="device_set_servo_pin"><field name="name">AnalogPin.P2</field><value name="value"><shadow type="math_number_minmax"><mutation min="0" max="180" label="Value"/><field name="SLIDER">180</field></shadow><block type="device_acceleration"><field name="NAME">Dimension.Z</field></block></value><next><blocLine truncated
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="2w47B[B-y%SK,+8+DQGz">booltest</variable>
<variable id="Uv6@%!N7Ts}XI7t+j[zB">myImage</variable>
<variable id="7BPQp@}m*I210zEM4S=3">strtest</variable>
</variables>
<block type="pxt-on-start" x="0" y="0">
<statement name="HANDLER">
<block type="device_show_number">
<value name="number">
<shadow type="math_number">
<field name="NUM">123</field>
</shadow>
<block type="control_event_value&quot;" />
</value>
<next>
<block type="device_show_leds">
<field name="LEDS">`
# . . # .
# . . # .
. # . . .
. # # . .
. . . . .
`</field>
<next>
<block type="basic_show_icon">
<field name="i">IconNames.Heart</field>
<next>
<block type="device_pause">
<value name="pause">
<shadow type="timePicker">
<field name="ms">500</field>
</shadow>
</value>
<next>
<block type="device_clear_display">
<next>
<block type="basic_show_icon">
<field name="i">IconNames.Heart</field>
<next>
<block type="variables_set">
<field name="VAR" id="Uv6@%!N7Ts}XI7t+j[zB">myImage</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_build_image">
<field name="LEDS">`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`</field>
</block>
</value>
<next>
<block type="device_show_image_offset">
<value name="sprite">
<block type="variables_get">
<field name="VAR" id="Uv6@%!N7Ts}XI7t+j[zB">myImage</field>
</block>
</value>
<value name="offset">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="device_scroll_image">
<value name="sprite">
<block type="variables_get">
<field name="VAR" id="Uv6@%!N7Ts}XI7t+j[zB">myImage</field>
</block>
</value>
<value name="frameoffset">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="control_device_serial_number" />
</value>
<value name="delay">
<shadow type="math_number">
<field name="NUM">3</field>
</shadow>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="7BPQp@}m*I210zEM4S=3">strtest</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="serial_read_until">
<value name="delimiter">
<shadow type="serial_delimiter_conv">
<field name="del">Delimiters.Hash</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="7BPQp@}m*I210zEM4S=3">strtest</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="serial_read_buffer" />
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_pin_custom_event" x="2009" y="121">
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
<statement name="HANDLER">
<block type="device_led_toggle">
<value name="x">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="X" precision="1" />
<field name="SLIDER">1</field>
</shadow>
</value>
<value name="y">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="Y" precision="1" />
<field name="SLIDER">2</field>
</shadow>
</value>
<next>
<block type="device_plot_bar_graph">
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
<value name="high">
<shadow type="math_number">
<field name="NUM">45</field>
</shadow>
</value>
<next>
<block type="led_set_display_mode">
<field name="mode">DisplayMode.Greyscale</field>
<next>
<block type="device_set_analog_pin">
<field name="name">AnalogPin.P2</field>
<value name="value">
<shadow type="math_number_minmax">
<mutation min="0" max="1023" label="Value" />
<field name="SLIDER">1023</field>
</shadow>
<block type="device_get_analog_pin">
<field name="name">AnalogPin.P2</field>
</block>
</value>
<next>
<block type="device_set_digital_pin">
<field name="name">DigitalPin.P1</field>
<value name="value">
<shadow type="math_number_minmax">
<mutation min="0" max="1" label="Value" />
<field name="SLIDER">0</field>
</shadow>
<block type="device_get_digital_pin">
<field name="name">DigitalPin.P1</field>
</block>
</value>
<next>
<block type="device_set_analog_period">
<field name="pin">AnalogPin.P2</field>
<value name="micros">
<shadow type="math_number">
<field name="NUM">1234</field>
</shadow>
<block type="pin_map">
<value name="value">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_temperature" />
</value>
<value name="fromLow">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_heading" />
</value>
<value name="fromHigh">
<shadow type="math_number">
<field name="NUM">1023</field>
</shadow>
<block type="device_get_rotation">
<field name="NAME">Rotation.Roll</field>
</block>
</value>
<value name="toLow">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_magnetic_force">
<field name="NAME">Dimension.Y</field>
</block>
</value>
<value name="toHigh">
<shadow type="math_number">
<field name="NUM">4</field>
</shadow>
<block type="device_get_running_time" />
</value>
</block>
</value>
<next>
<block type="device_set_servo_pin">
<field name="name">AnalogPin.P2</field>
<value name="value">
<shadow type="math_number_minmax">
<mutation min="0" max="180" label="Value" />
<field name="SLIDER">180</field>
</shadow>
<block type="device_acceleration">
<field name="NAME">Dimension.Z</field>
</block>
</value>
<next>
<block type="device_set_servo_pulse">
<field name="value">AnalogPin.P2</field>
<value name="micros">
<shadow type="math_number">
<field name="NUM">1500</field>
</shadow>
<block type="device_get_light_level" />
</value>
<next>
<block type="device_play_note">
<value name="note">
<shadow type="device_note">
<field name="name">220</field>
</shadow>
</value>
<value name="duration">
<shadow type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</shadow>
</value>
<next>
<block type="device_ring">
<value name="note">
<shadow type="device_note">
<field name="name">659</field>
</shadow>
</value>
<next>
<block type="device_rest">
<value name="duration">
<shadow type="device_beat">
<field name="fraction">BeatFraction.Double</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_gesture_event" x="1172" y="177">
<field name="NAME">Gesture.TiltLeft</field>
<statement name="HANDLER">
<block type="device_unplot">
<value name="x">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="X" precision="1" />
<field name="SLIDER">1</field>
</shadow>
<block type="control_event_value_id">
<field name="id">EventBusValue.MICROBIT_PIN_EVT_PULSE_HI</field>
</block>
</value>
<value name="y">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="Y" precision="1" />
<field name="SLIDER">2</field>
</shadow>
</value>
<next>
<block type="serial_writebuffer">
<value name="buffer">
<shadow type="serial_readbuffer">
<value name="length">
<shadow type="math_number">
<field name="NUM">64</field>
</shadow>
</value>
</shadow>
</value>
</block>
</next>
</block>
</statement>
</block>
<block type="control_in_background" x="-584" y="273">
<statement name="HANDLER">
<block type="control_wait_us">
<value name="micros">
<shadow type="math_number">
<field name="NUM">4</field>
</shadow>
<block type="control_event_timestamp&quot;" />
</value>
<next>
<block type="control_raise_event">
<value name="src">
<shadow type="control_event_source_id">
<field name="id">EventBusSource.MICROBIT_ID_IO_P0</field>
</shadow>
</value>
<value name="value">
<shadow type="control_event_value_id">
<field name="id">EventBusValue.MES_ALERT_EVT_ALARM1</field>
</shadow>
</value>
</block>
</next>
</block>
</statement>
</block>
<block type="device_forever" x="774" y="363">
<statement name="HANDLER">
<block type="variables_set">
<field name="VAR" id="2w47B[B-y%SK,+8+DQGz">booltest</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_get_button2">
<field name="NAME">Button.B</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="2w47B[B-y%SK,+8+DQGz">booltest</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_pin_is_pressed">
<field name="NAME">TouchPin.P2</field>
</block>
</value>
<next>
<block type="variables_set">
<field name="VAR" id="2w47B[B-y%SK,+8+DQGz">booltest</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
<block type="device_point">
<value name="x">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="X" precision="1" />
<field name="SLIDER">3</field>
</shadow>
</value>
<value name="y">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="Y" precision="1" />
<field name="SLIDER">4</field>
</shadow>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="serial_on_data_received" x="-572" y="562">
<value name="delimiters">
<shadow type="serial_delimiter_conv">
<field name="del">Delimiters.Colon</field>
</shadow>
</value>
<statement name="HANDLER">
<block type="serial_redirect">
<field name="tx">SerialPin.P0</field>
<field name="rx">SerialPin.P1</field>
<field name="rate">BaudRate.BaudRate19200</field>
<next>
<block type="serial_redirect_to_usb" />
</next>
</block>
</statement>
</block>
<block type="device_button_selected_event" x="896" y="634">
<field name="NAME">Button.AB</field>
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
<statement name="HANDLER">
<block type="device_plot">
<value name="x">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="X" precision="1" />
<field name="SLIDER">1</field>
</shadow>
<block type="device_beat">
<field name="fraction">BeatFraction.Sixteenth</field>
</block>
</value>
<value name="y">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="Y" precision="1" />
<field name="SLIDER">2</field>
</shadow>
</value>
<next>
<block type="device_plot_brightness">
<value name="x">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="X" precision="1" />
<field name="SLIDER">3</field>
</shadow>
<block type="device_tempo" />
</value>
<value name="y">
<shadow type="math_number_minmax">
<mutation min="0" max="4" label="Y" precision="1" />
<field name="SLIDER">5</field>
</shadow>
</value>
<value name="brightness">
<shadow type="math_number_minmax">
<mutation min="0" max="255" label="Brightness" />
<field name="SLIDER">255</field>
</shadow>
<block type="device_get_brightness" />
</value>
<next>
<block type="device_set_brightness">
<value name="value">
<shadow type="math_number_minmax">
<mutation min="0" max="255" label="Value" />
<field name="SLIDER">255</field>
</shadow>
<block type="device_note">
<field name="name">440</field>
</block>
</value>
<next>
<block type="device_stop_animation">
<next>
<block type="device_led_enable">
<value name="on">
<shadow type="logic_boolean">
<field name="BOOL">TRUE</field>
</shadow>
</value>
<next>
<block type="input_compass_calibrate" />
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="device_pin_custom_event" x="478" y="950">
<value name="eventType">
<shadow type="control_button_event_value_id"></shadow>
</value>
<statement name="HANDLER"></statement>
</block>
<block type="pins_on_pulsed" x="1140" y="1050">
<field name="pin">DigitalPin.P1</field>
<field name="pulse">PulseValue.Low</field>
<statement name="HANDLER">
<block type="i2c_writenumber">
<field name="format">NumberFormat.UInt8BE</field>
<value name="address">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<value name="value">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<value name="repeat">
<shadow type="logic_boolean">
<field name="BOOL">FALSE</field>
</shadow>
</value>
<next>
<block type="device_analog_pitch">
<value name="frequency">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<value name="ms">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="device_set_pin_events">
<field name="pin">DigitalPin.P0</field>
<field name="type">PinEventType.Touch</field>
<next>
<block type="spi_frequency">
<value name="frequency">
<shadow type="math_number">
<field name="NUM">1000000</field>
</shadow>
</value>
<next>
<block type="device_analog_set_pitch_pin">
<field name="name">AnalogPin.P2</field>
<next>
<block type="device_set_pull">
<field name="pin">DigitalPin.P2</field>
<field name="pull">PinPullMode.PullDown</field>
<next>
<block type="spi_format">
<value name="bits">
<shadow type="math_number">
<field name="NUM">8</field>
</shadow>
</value>
<value name="mode">
<shadow type="math_number">
<field name="NUM">3</field>
</shadow>
</value>
<next>
<block type="spi_pins">
<field name="mosi">DigitalPin.P1</field>
<field name="miso">DigitalPin.P1</field>
<field name="sck">DigitalPin.P1</field>
<next>
<block type="control_reset" />
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="melody_on_event" x="461" y="1123">
<field name="value">MusicEvent.BackgroundMelodyNotePlayed</field>
<statement name="HANDLER">
<block type="device_change_tempo">
<value name="value">
<shadow type="math_number">
<field name="NUM">123</field>
</shadow>
</value>
<next>
<block type="device_set_tempo">
<value name="value">
<shadow type="math_number_minmax">
<mutation min="4" max="400" label="Bpm" precision="0" />
<field name="SLIDER">12312312</field>
</shadow>
</value>
<next>
<block type="serial_writeline">
<value name="text">
<shadow type="text">
<field name="TEXT" />
</shadow>
<block type="serial_read_line" />
</value>
<next>
<block type="serial_writenumber">
<value name="value">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="serial_writevalue">
<value name="name">
<shadow type="text">
<field name="TEXT">x</field>
</shadow>
</value>
<value name="value">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="serial_writestring">
<value name="text">
<shadow type="text">
<field name="TEXT" />
</shadow>
<block type="control_device_name" />
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="control_on_event" x="-701" y="1386">
<value name="src">
<shadow type="control_event_source_id">
<field name="id">EventBusSource.MICROBIT_ID_IO_P1</field>
</shadow>
</value>
<value name="value">
<shadow type="control_event_value_id">
<field name="id">EventBusValue.MES_ALERT_EVT_ALARM2</field>
</shadow>
</value>
</block>
</xml>
+3 -3
View File
@@ -323,9 +323,9 @@ namespace game {
}
function unplugEvents(): void {
input.onButtonPressed(Button.A, () => { });
input.onButtonPressed(Button.B, () => { });
input.onButtonPressed(Button.AB, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => { });
input.onButtonEvent(Button.B, ButtonEvent.Click, () => { });
input.onButtonEvent(Button.AB, ButtonEvent.Click, () => {
control.reset();
});
}
-53
View File
@@ -190,21 +190,6 @@ namespace input {
registerWithDal((int)button, eventType, body);
}
/**
* Do something when a button (A, B or both A+B) is pushed down and released again.
* @param button the button that needs to be pressed
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=16
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair"
//% deprecated=true
//% group="Events"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
}
/**
* Do something when when a gesture is done (like shaking the micro:bit).
* @param gesture the type of gesture to track, eg: Gesture.Shake
@@ -240,7 +225,6 @@ namespace input {
return uBit.accelerometer.getGesture() == gi;
}
/**
* Do something when a pin receives an touch event (while also touching the GND pin).
* @param name the pin, eg: TouchPin.P0
@@ -258,43 +242,6 @@ namespace input {
registerWithDal((int)name, eventType, body);
}
/**
* Do something when a pin is touched and released again (while also touching the GND pin).
* @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83 blockGap=16
//% blockId=device_pin_event block="on pin %name|pressed"
//% group="Events"
//% deprecated=true
void onPinPressed(TouchPin name, Action body) {
auto pin = getPin((int)name);
if (!pin) return;
// Forces the PIN to switch to makey-makey style detection.
pin->isTouched();
registerWithDal((int)name, MICROBIT_BUTTON_EVT_CLICK, body);
}
/**
* Do something when a pin is released.
* @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released
*/
//% help=input/on-pin-released weight=6 blockGap=16
//% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true
//% group="Events"
//% deprecated=true
void onPinReleased(TouchPin name, Action body) {
auto pin = getPin((int)name);
if (!pin) return;
// Forces the PIN to switch to makey-makey style detection.
pin->isTouched();
registerWithDal((int)name, MICROBIT_BUTTON_EVT_UP, body);
}
/**
* Get the button state (pressed or not) for ``A`` and ``B``.
* @param button the button to query the request, eg: Button.A
+17 -17
View File
@@ -2,26 +2,26 @@
* Events and data from sensors
*/
//% color=#C90072 weight=99
namespace input {
// namespace input {
/**
* gets the level of loudness from 0 (silent) to 255 (loud)
*/
//% blockId="loudness"
//% block="Loudness"
//% deprecated=true
export function loudness(): number {
let value = 0
let max = pins.analogReadPin(AnalogPin.MIC)
let min = max
for (let index = 0; index < 32; index++) {
value = pins.analogReadPin(AnalogPin.MIC)
if (value > max) {
max = value
} else if (value < min) {
min = value
}
}
value = Math.floor((max - min) / 4)
return value
}
}
// export function loudness(): number {
// let value = 0
// let max = pins.analogReadPin(AnalogPin.MIC)
// let min = max
// for (let index = 0; index < 32; index++) {
// value = pins.analogReadPin(AnalogPin.MIC)
// if (value > max) {
// max = value
// } else if (value < min) {
// min = value
// }
// }
// value = Math.floor((max - min) / 4)
// return value
// }
// }
+3 -37
View File
@@ -217,9 +217,10 @@ declare namespace basic {
*/
//% blockId=device_set_led_color
//% block="set led to %color=colorNumberPicker"
//%
//% weight=10
//% group="RGB LED" shim=basic::setLedColor
function setLedColor(color: int32): void;
//% group="RGB LED" color.defl=0xff0000 shim=basic::setLedColor
function setLedColor(color?: int32): void;
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
@@ -248,18 +249,6 @@ declare namespace input {
//% group="Events" shim=input::onButtonEvent
function onButtonEvent(button: Button, eventType: int32, body: () => void): void;
/**
* Do something when a button (A, B or both A+B) is pushed down and released again.
* @param button the button that needs to be pressed
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=16
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair"
//% deprecated=true
//% group="Events" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
/**
* Do something when when a gesture is done (like shaking the micro:bit).
* @param gesture the type of gesture to track, eg: Gesture.Shake
@@ -293,29 +282,6 @@ declare namespace input {
//% group="Events" shim=input::onPinTouchEvent
function onPinTouchEvent(name: TouchPin, eventType: int32, body: () => void): void;
/**
* Do something when a pin is touched and released again (while also touching the GND pin).
* @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83 blockGap=16
//% blockId=device_pin_event block="on pin %name|pressed"
//% group="Events"
//% deprecated=true shim=input::onPinPressed
function onPinPressed(name: TouchPin, body: () => void): void;
/**
* Do something when a pin is released.
* @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released
*/
//% help=input/on-pin-released weight=6 blockGap=16
//% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true
//% group="Events"
//% deprecated=true shim=input::onPinReleased
function onPinReleased(name: TouchPin, body: () => void): void;
/**
* Get the button state (pressed or not) for ``A`` and ``B``.
* @param button the button to query the request, eg: Button.A
+1 -1
View File
@@ -60,7 +60,7 @@ namespace storage {
//% block="Clear number %key"
//% blockId=storage_remove_key_int
//% group="Remove"
export function removeKeyInt(key: StorageSlots) : void {
export function removeNumber(key: StorageSlots) : void {
remove(storagesInt[key]);
}