V4 updates for beta testing (#147)

* change simulator svg

* change radio image

* Remove google fonts cdn

* change color of 'advanced' button

* font fix

* font fix 2

* display fix

* change fullsceen simulator bg

* Continuous servo

* handle continuous state

* adding shims

* update rendering for continuous servos

* fixing sim

* fix sig

* typo

* fix sim

* bump pxt

* bump pxt

* rerun travis

* Input blocks revision

- add Button and Pin event types
- merge onPinPressed & onPinReleased in new onPinEvent function
- create new onButtonEvent function

* update input blocks in docs and tests

* remove device_pin_release block

* Hide DAL.x behind Enum

* bring back deprecated blocks, but hide them

* shims and locales files

* fix input.input. typing

* remove buildpr

* bump V3

* update simulator aspect ratio

* add Loudness Block

* revoke loudness block

* Adds soundLevel

To be replaced by pxt-common-packages when DAL is updated.

* Remove P0 & P3 from AnalogPin

* Fix Sound and replace AnalogPin.P0

* remove approved extensions

* V4 Updates from remote Repo

* locales

* add storage functions

* fix storage functions

* fix int/float values

* decrease decimal precision

* reorder blocks

* Update BLE Settings and Storage Blocks

* Fetch MicroBit changes up to v4.0.18

* Update timing for LED Matrix usage

* use 32kb ram (mini v2)

* resize gatt table

* Revert "use 32kb ram (mini v2)"

This reverts commit 4b15592f0f.

* fix missleading indentation

* add support for 32kb and 16kb ram

* only MIT extensions in preferredRepos

* remove extensions without MIT License file

* add updated extensions

* add extensions with MIT license

Co-authored-by: Juri <gitkraken@juriwolf.de>
Co-authored-by: Juri <info@juriwolf.de>
This commit is contained in:
Amerlander
2022-03-22 17:36:19 +01:00
committed by GitHub
parent d0a85fd0d2
commit 3e0c9b43a2
115 changed files with 16788 additions and 7690 deletions

View File

@ -4,6 +4,7 @@
"AcceleratorRange.OneG": "The accelerator measures forces up to 1 gravity",
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
"Array": "Add, remove, and replace items in lists.",
"Array._pickRandom": "Return a random value from the array",
"Array._popStatement": "Remove the last element from an array and return it.",
"Array._removeAtStatement": "Remove the element at a certain index.",
"Array._shiftStatement": "Remove the first element from an array and return it. This method changes the length of the array.",
@ -41,6 +42,7 @@
"Array.reverse": "Reverse the elements in an array. The first array element becomes the last, and the last array element becomes the first.",
"Array.set": "Store a value at a particular index",
"Array.set|param|index": "the zero-based position in the list to store the value, eg: 0",
"Array.set|param|value": "the value to insert, eg: 0",
"Array.shift": "Remove the first element from an array and return it. This method changes the length of the array.",
"Array.slice": "Return a section of an array.",
"Array.slice|param|end": "The end of the specified portion of the array. eg: 0",
@ -124,9 +126,15 @@
"Image.showFrame": "Show a particular frame of the image strip.",
"Image.showFrame|param|frame": "image frame to show",
"Image.showImage": "Shows an frame from the image at offset ``x offset``.",
"Image.showImage|param|interval": "time in milliseconds to pause after drawing",
"Image.showImage|param|xOffset": "column index to start displaying the image",
"Image.width": "Gets the width in columns",
"Infinity": "Constant representing positive infinity.",
"JSON.parse": "Converts a JavaScript Object Notation (JSON) string into an object.",
"JSON.stringify": "Converts a JavaScript value to a JavaScript Object Notation (JSON) string.",
"JSON.stringify|param|indent": "Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.",
"JSON.stringify|param|replacer": "Not supported; use null.",
"JSON.stringify|param|value": "A JavaScript value, usually an object or array, to be converted.",
"Math": "More complex operations with numbers.",
"Math.abs": "Returns the absolute value of a number (the value without regard to whether it is positive or negative).\nFor example, the absolute value of -5 is the same as the absolute value of 5.",
"Math.abs|param|x": "A numeric expression for which the absolute value is needed.",
@ -225,7 +233,7 @@
"String.split": "Splits the string according to the separators",
"String.split|param|separator": "@param limit",
"String.substr": "Return a substring of the current string.",
"String.substr|param|length": "number of characters to extract",
"String.substr|param|length": "number of characters to extract, eg: 10",
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
"String.toLowerCase": "Converts the string to lower case characters.",
"String.trim": "Return a substring of the current string with whitespace removed from both ends",
@ -245,30 +253,31 @@
"basic.pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
"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",
"basic.setLedColor": "Sets the color on the build-in LED. Set to 0 to turn off.",
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
"basic.showArrow": "Draws an arrow on the LED screen",
"basic.showArrow|param|direction": "the direction of the arrow",
"basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
"basic.showCompass": "Draws needle on the screen which always points to north",
"basic.showCompass|param|interval": "the amount of time (milliseconds) to show the needle. Default is 600.",
"basic.showIcon": "Draws the selected icon on the LED screen",
"basic.showIcon|param|icon": "the predefined icon id",
"basic.showIcon|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
"basic.showIcon|param|interval": "the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 200.",
"basic.showLeds": "Draws an image on the LED screen.",
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
"basic.showNumber|param|interval": "speed of scroll; eg: 150, 100, 200, -100",
"basic.showNumber|param|interval": "speed of scroll; eg: 50, 100, 150, 200",
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
"basic.showString|param|interval": "how fast to shift characters; eg: 150, 100, 200, -100",
"basic.showString|param|interval": "how fast to shift characters; eg: 50, 100, 150, 200",
"basic.showString|param|text": "the text to scroll on the screen, eg: \"hi!\"",
"basic.turnRgbLedOff": "Sets the color on the build-in LED. Set to 0 to turn off.",
"console": "Reading and writing data to the console output.",
@ -280,31 +289,48 @@
"console.logValue": "Write a name:value pair as a line of text to the console output.",
"console.logValue|param|name": "name of the value stream, eg: \"x\"",
"console.logValue|param|value": "to write",
"console.log|param|value": "to send",
"console.minPriority": "Minimum priority to send messages to listeners",
"console.removeListener": "Removes a listener",
"control": "Runtime and event utilities.",
"control.allocateNotifyEvent": "Allocates the next user notification event",
"control.assert": "If the condition is false, display msg on serial console, and panic with code 098.",
"control.benchmark": "Runs the function and returns run time in microseconds.",
"control.createBuffer": "Create a new zero-initialized buffer.",
"control.createBufferFromUTF8": "Create a new buffer with UTF8-encoded string",
"control.createBufferFromUTF8|param|str": "the string to put in the buffer",
"control.createBuffer|param|size": "number of bytes in the buffer",
"control.deviceLongSerialNumber": "Derive a unique, consistent 64-bit serial number of this device from internal data.",
"control.deviceName": "Make a friendly name for the device based on its serial number",
"control.deviceSerialNumber": "Derive a unique, consistent serial number of this device from internal data.",
"control.dmesg": "Write a message to DMESG debugging buffer.",
"control.dmesgPerfCounters": "Dump values of profiling performance counters.",
"control.dmesgPtr": "Write a message and value (pointer) to DMESG debugging buffer.",
"control.enablePerfCounter": "Enable profiling for current function.",
"control.eventSourceId": "Returns the value of a C++ runtime constant",
"control.eventTimestamp": "Gets the timestamp of the last event executed on the bus",
"control.eventValue": "Gets the value of the last event executed on the bus",
"control.eventValueId": "Returns the value of a C++ runtime constant",
"control.gc": "Force GC and dump basic information about heap.",
"control.gcStats": "Get various statistics about the garbage collector (GC)",
"control.heapDump": "Force GC and halt waiting for debugger to do a full heap dump.",
"control.heapSnapshot": "Record a heap snapshot to debug memory leaks.",
"control.inBackground": "Schedules code that run in the background.",
"control.micros": "Gets current time in microseconds. Overflows every ~18 minutes.",
"control.millis": "Gets the number of milliseconds elapsed since power on.",
"control.onEvent": "Registers an event handler.",
"control.panic": "Display specified error code and stop the program.",
"control.profilingEnabled": "Return true if profiling is enabled in the current build.",
"control.raiseEvent": "Raises an event in the event bus.",
"control.raiseEvent|param|mode": "optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).",
"control.raiseEvent|param|src": "ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.",
"control.raiseEvent|param|value": "Component specific code indicating the cause of the event.",
"control.ramSize": "Returns estimated size of memory in bytes.",
"control.reset": "Resets the BBC micro:bit.",
"control.runInParallel": "Run other code in the parallel.",
"control.runtimeWarning": "Display warning in the simulator.",
"control.setDebugFlags": "Set flags used when connecting an external debugger.",
"control.simmessages.onReceived": "Registers the handler for a message on a given channel",
"control.waitForEvent": "Blocks the calling thread until the specified event is raised.",
"control.waitMicros": "Blocks the current fiber for the given microseconds",
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
@ -401,38 +427,39 @@
"input": "Events and data from sensors",
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
"input.acceleration|param|dimension": "x, y, or z dimension, eg: Dimension.X",
"input.assumeCalibrationCompass": "Obsolete, compass calibration is automatic.",
"input.buttonEventValueId": "Returns the value of a C++ runtime constant",
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
"input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
"input.calibrate": "Obsolete, use input.calibrateCompass instead.",
"input.calibrateCompass": "Obsolete, compass calibration is automatic.",
"input.clearCalibrationCompass": "Obsolete, compass calibration is automatic.",
"input.compassHeading": "Get the current compass heading in degrees.",
"input.isCalibratedCompass": "Returns 'true' when the compass is calibrated. Otherwise returns 'false'.",
"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.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
"input.onLogoDown|param|body": "TODO",
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
"input.onLogoUp|param|body": "TODO",
"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.onScreenDown": "Attaches code to run when the screen is facing down.",
"input.onScreenDown|param|body": "TODO",
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
"input.onScreenUp|param|body": "TODO",
"input.onShake": "Attaches code to run when the device is shaken.",
"input.onShake|param|body": "TODO",
"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",
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
"input.pinIsPressed|param|name": "pin used to detect the touch, eg: TouchPin.P0",
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
@ -441,7 +468,7 @@
"input.runningTimeMicros": "Gets the number of microseconds elapsed since power on.",
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
"input.soundLevel": "gets the level of loudness in 0-100%",
"input.soundLevel": "gets the level of loudness from 0 (silent) to 255 (loud)",
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
"led": "Control of the LED screen.",
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
@ -482,7 +509,10 @@
"led.unplot|param|x": "the horizontal coordinate of the LED",
"led.unplot|param|y": "the vertical coordinate of the LED",
"light.sendWS2812Buffer": "Sends a color buffer to a light strip",
"light.sendWS2812BufferWithBrightness": "Sends a color buffer to a light strip",
"light.setMode": "Sets the light mode of a pin",
"loops.everyInterval": "Repeats the code forever in the background.\nAfter each iteration, allows other codes to run for a set duration\nso that it runs on a timer",
"loops.everyInterval|param|interval": "time (in ms) to wait between each iteration of the action.",
"motors": "Blocks to control the onboard motors",
"motors.dualMotorPower": "Controls two motors attached to the board. Switches to dual-motor mode!",
"motors.motorCommand": "Send break, coast or sleep commands to the motor. Has no effect in dual-motor mode.",
@ -522,6 +552,7 @@
"music.startMelody": "Starts playing a melody.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
"music.startMelody|param|melodyArray": "the melody array to play",
"music.startMelody|param|options": "melody options, once / forever, in the foreground / background",
"music.stopAllSounds": "Stop all sounds and melodies currently playing.",
"music.stopMelody": "Stops the melodies",
"music.stopMelody|param|options": "which melody to stop",
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
@ -531,6 +562,9 @@
"parseInt|param|radix": "optional A value between 2 and 36 that specifies the base of the number in text.",
"parseInt|param|text": "A string to convert into an integral number. eg: \"123\"",
"pause": "Pause for the specified time in milliseconds",
"pauseUntil": "Busy wait for a condition to be true",
"pauseUntil|param|condition": "condition to test for",
"pauseUntil|param|timeOut": "if positive, maximum duration to wait for in milliseconds",
"pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
"pins.C10": "Pin C10",
@ -597,9 +631,12 @@
"pins.servoWritePin": "Write a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
"pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P1",
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
"pins.setAudioPin": "Set the pin used when producing sounds and melodies. Default is P0.",
"pins.setAudioPin|param|name": "pin to modulate pitch from",
"pins.setEvents": "Configure the events emitted by this pin. Events can be subscribed to\nusing ``control.onEvent()``.",
"pins.setEvents|param|name": "pin to set the event mode on, eg: DigitalPin.P0",
"pins.setEvents|param|type": "the type of events for this pin to emit, eg: PinEventType.Edge",
"pins.setMatrixWidth": "Set the matrix width for Neopixel strip (already assigned to a pin).\nShould be used in conjunction with `set matrix width` from Neopixel package.",
"pins.setPull": "Configure the pull directiion of of a pin.",
"pins.setPull|param|name": "pin to set the pull mode on, eg: DigitalPin.P0",
"pins.setPull|param|pull": "one of the mbed pull configurations, eg: PinPullMode.PullUp",
@ -622,8 +659,8 @@
"serial.delimiters": "Return the corresponding delimiter string",
"serial.onDataReceived": "Register an event to be fired when one of the delimiter is matched.",
"serial.onDataReceived|param|delimiters": "the characters to match received characters against.",
"serial.readBuffer": "Read multiple characters from the receive buffer. Pause until enough characters are present.",
"serial.readBuffer|param|length": "default buffer length, eg: 64",
"serial.readBuffer": "Read multiple characters from the receive buffer. \nIf length is positive, pauses until enough characters are present.",
"serial.readBuffer|param|length": "default buffer length",
"serial.readLine": "Read a line of text from the serial port.",
"serial.readString": "Read the buffered received data as a string",
"serial.readUntil": "Read a line of text from the serial port and return the buffer when the delimiter is met.",
@ -647,5 +684,20 @@
"serial.writeString": "Send a piece of text through the serial connection.",
"serial.writeValue": "Write a name:value pair as a line to the serial port.",
"serial.writeValue|param|name": "name of the value stream, eg: x",
"serial.writeValue|param|value": "to write"
"serial.writeValue|param|value": "to write",
"storage": "Provides access to persistent storage functionality.\n\nProvides access to persistent storage functionality.",
"storage.getNumber": "Reads a key value pair from the non volatile storage as a number",
"storage.getNumber|param|key": "the key for accesing the value",
"storage.getValueInt": "Reads a key value pair from the non volatile storage",
"storage.getValueInt|param|key": "the key for accesing the value",
"storage.putNumber": "Saves a key value pair in the non volatile storage",
"storage.putNumber|param|key": "the key for accesing the value",
"storage.putNumber|param|value": "value to store",
"storage.putValueInt": "Saves a key value pair in the non volatile storage",
"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.remove|param|key": "the key for accesing the value"
}

View File

@ -7,6 +7,7 @@
"AcceleratorRange.OneG|block": "1g",
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
"AcceleratorRange.TwoG|block": "2g",
"Array._pickRandom|block": "get random value from %list",
"Array._popStatement|block": "remove last value from %list",
"Array._removeAtStatement|block": "%list| remove value at %index",
"Array._shiftStatement|block": "remove first value from %list",
@ -21,14 +22,6 @@
"Array.shift|block": "get and remove first value from %list",
"Array.unshift|block": "%list| insert %value| at beginning",
"Array|block": "Array",
"ArrowNames.East|block": "East",
"ArrowNames.NorthEast|block": "North East",
"ArrowNames.NorthWest|block": "North West",
"ArrowNames.North|block": "North",
"ArrowNames.SouthEast|block": "South East",
"ArrowNames.SouthWest|block": "South West",
"ArrowNames.South|block": "South",
"ArrowNames.West|block": "West",
"BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate1200|block": "1200",
"BaudRate.BaudRate14400|block": "14400",
@ -49,6 +42,10 @@
"BeatFraction.Whole|block": "1",
"Buffer|block": "Buffer",
"Button.AB|block": "A+B",
"ButtonEvent.Click|block": "clicked",
"ButtonEvent.Down|block": "pressed down",
"ButtonEvent.LongClick|block": "long clicked",
"ButtonEvent.Up|block": "released up",
"Colors.Blue|block": "blue",
"Colors.Green|block": "green",
"Colors.Indigo|block": "indigo",
@ -112,46 +109,20 @@
"IconNames.ArrowSouth|block": "arrow south",
"IconNames.ArrowWest|block": "arrow west",
"IconNames.Asleep|block": "asleep",
"IconNames.Butterfly|block": "butterfly",
"IconNames.Chessboard|block": "chess board",
"IconNames.Confused|block": "confused",
"IconNames.Cow|block": "cow",
"IconNames.Diamond|block": "diamond",
"IconNames.Duck|block": "duck",
"IconNames.EigthNote|block": "eigth note",
"IconNames.Fabulous|block": "fabulous",
"IconNames.Ghost|block": "ghost",
"IconNames.Giraffe|block": "giraffe",
"IconNames.Happy|block": "happy",
"IconNames.Heart|block": "heart",
"IconNames.House|block": "house",
"IconNames.LeftTriangle|block": "left triangle",
"IconNames.Meh|block": "meh",
"IconNames.No|block": "no",
"IconNames.Pitchfork|block": "pitchfork",
"IconNames.QuarterNote|block": "quarter note",
"IconNames.Rabbit|block": "rabbit",
"IconNames.Rollerskate|block": "roller skate",
"IconNames.Sad|block": "sad",
"IconNames.Scissors|block": "scissors",
"IconNames.Silly|block": "silly",
"IconNames.Skull|block": "skull",
"IconNames.SmallDiamond|block": "small diamond",
"IconNames.SmallHeart|block": "small heart",
"IconNames.SmallSquare|block": "small square",
"IconNames.Snake|block": "snake",
"IconNames.Square|block": "square",
"IconNames.StickFigure|block": "stick figure",
"IconNames.Surprised|block": "surprised",
"IconNames.Sword|block": "sword",
"IconNames.TShirt|block": "t-shirt",
"IconNames.Target|block": "target",
"IconNames.Tortoise|block": "tortoise",
"IconNames.Triangle|block": "triangle",
"IconNames.Umbrella|block": "umbrella",
"IconNames.Yes|block": "yes",
"Image.scrollImage|block": "scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %delay",
"Image.showImage|block": "show image %sprite(myImage)|at offset %offset",
"Image.scrollImage|block": "scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %interval",
"Image.showImage|block": "show image %sprite(myImage)|at offset %offset ||and interval (ms) %interval",
"JSON|block": "JSON",
"LedSpriteProperty.Blink|block": "blink",
"LedSpriteProperty.Brightness|block": "brightness",
"LedSpriteProperty.Direction|block": "direction",
@ -248,6 +219,13 @@
"PulseValue.Low|block": "low",
"Rotation.Pitch|block": "pitch",
"Rotation.Roll|block": "roll",
"StorageSlots.s1|block": "Slot 1",
"StorageSlots.s2|block": "Slot 2",
"StorageSlots.s3|block": "Slot 3",
"StorageSlots.s4|block": "Slot 4",
"StorageSlots.s5|block": "Slot 5",
"StorageSlots.s6|block": "Slot 6",
"StorageSlots.s7|block": "Slot 7",
"String.charAt|block": "char from %this=text|at %pos",
"String.compare|block": "compare %this=text| to %that",
"String.fromCharCode|block": "text from char code %code",
@ -264,13 +242,13 @@
"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",
"basic.showCompass|block": "show compass needle for $interval|ms",
"basic.showIcon|block": "show icon %i",
"basic.showIcon|block": "show icon %i || for %interval ms",
"basic.showLeds|block": "show leds",
"basic.showNumber|block": "show|number %number",
"basic.showString|block": "show|string %text",
"basic.showNumber|block": "show|number %number || in an interval of %interval ms",
"basic.showString|block": "show|string %text || in an interval of %interval ms",
"basic.turnRgbLedOff|block": "turn build-in LED off",
"basic|block": "basic",
"console|block": "console",
@ -314,29 +292,34 @@
"game.setScore|block": "set score %points",
"game.startCountdown|block": "start countdown|(ms) %duration",
"game|block": "game",
"images.arrowImage|block": "arrow image %i",
"images.arrowNumber|block": "%arrow",
"images.createBigImage|block": "create big image",
"images.createImage|block": "create image",
"images.iconImage|block": "icon image %i",
"images|block": "images",
"input.acceleration|block": "acceleration (mg)|%NAME",
"input.assumeCalibrationCompass|block": "assume calibration compass",
"input.buttonEventValueId|block": "%id",
"input.buttonIsPressed|block": "button|%NAME|is pressed",
"input.calibrateCompass|block": "calibrate compass",
"input.clearCalibrationCompass|block": "clear calibration compass",
"input.compassHeading|block": "compass heading (°)",
"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",
"input.runningTimeMicros|block": "running time (micros)",
"input.runningTime|block": "running time (ms)",
"input.setAccelerometerRange|block": "set accelerometer|range %range",
"input.soundLevel|block": "Loudness",
"input.soundLevel|block": "soundLevel",
"input.temperature|block": "temperature (°C)",
"input|block": "input",
"led.brightness|block": "brightness",
@ -353,6 +336,8 @@
"led.unplot|block": "unplot|x %x|y %y",
"led|block": "led",
"light|block": "light",
"loops.everyInterval|block": "every $interval ms",
"loops|block": "loops",
"motors.dualMotorPower|block": "motor %motor|at %percent \\%",
"motors.motorCommand|block": "motor %command",
"motors.motorPower|block": "motor on at %percent \\%",
@ -371,6 +356,7 @@
"music.setTempo|block": "set tempo to (bpm)|%value",
"music.setVolume|block": "set volume %volume",
"music.startMelody|block": "start melody %melody=device_builtin_melody| repeating %options",
"music.stopAllSounds|block": "stop all sounds",
"music.stopMelody|block": "stop melody $options",
"music.tempo|block": "tempo (bpm)",
"music.volume|block": "volume",
@ -394,7 +380,9 @@
"pins.pulseIn|block": "pulse in (µs)|pin %name|pulsed %value",
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
"pins.servoWritePin|block": "servo write|pin %name|to %value",
"pins.setAudioPin|block": "set audio pin $name",
"pins.setEvents|block": "set pin %pin|to emit %type|events",
"pins.setMatrixWidth|block": "neopixel matrix width|pin %pin %width",
"pins.setPull|block": "set pull|pin %pin|to %pull",
"pins.spiFormat|block": "spi format|bits %bits|mode %mode",
"pins.spiFrequency|block": "spi frequency %frequency",
@ -421,6 +409,13 @@
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial",
"storage.getNumber|block": "read from number %key",
"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.remove|block": "remove %key",
"storage|block": "storage",
"{id:category}AnalogInPin": "AnalogInPin",
"{id:category}AnalogOutPin": "AnalogOutPin",
"{id:category}Array": "Array",
@ -438,8 +433,10 @@
"{id:category}Image": "Image",
"{id:category}Images": "Images",
"{id:category}Input": "Input",
"{id:category}JSON": "JSON",
"{id:category}Led": "Led",
"{id:category}Light": "Light",
"{id:category}Loops": "Loops",
"{id:category}Math": "Math",
"{id:category}MicrobitPin": "MicrobitPin",
"{id:category}Motors": "Motors",
@ -450,15 +447,27 @@
"{id:category}Pins": "Pins",
"{id:category}PwmOnlyPin": "PwmOnlyPin",
"{id:category}Serial": "Serial",
"{id:category}Storage": "Storage",
"{id:category}String": "String",
"{id:category}Text": "Text",
"{id:category}_py": "_py",
"{id:group}Configuration": "Configuration",
"{id:group}Control": "Control",
"{id:group}Events": "Events",
"{id:group}Get": "Get",
"{id:group}LED matrix": "LED matrix",
"{id:group}Melody": "Melody",
"{id:group}Melody Advanced": "Melody Advanced",
"{id:group}Modify": "Modify",
"{id:group}Operations": "Operations",
"{id:group}Put": "Put",
"{id:group}RGB LED": "RGB LED",
"{id:group}Read": "Read",
"{id:group}Remove": "Remove",
"{id:group}Sensors": "Sensors",
"{id:group}Silence": "Silence",
"{id:group}States": "States",
"{id:group}System": "System",
"{id:group}Tempo": "Tempo",
"{id:group}Tone": "Tone",
"{id:group}Volume": "Volume"

View File

@ -1,210 +1,214 @@
{
"Math.abs": "Gibt den absoluten Wert einer Zahl aus (den Wert unabhängig davon, ob er positiv oder negativ ist).\nDer absolute Wert von -5 ist zum Beispiel der gleiche wie der von 5.",
"Math.abs|param|x": "Ein numerischer Ausdruck, für den der absolute Wert benötigt wird.",
"Math.max": "Gibt den größeren von zwei vorhandenen numerischen Ausdrücken aus.",
"Math.min": "Gibt den niedrigeren von zwei vorhandenen numerischen Ausdrücken aus.",
"Math.pow": "Gibt den Wert eines grundlegenden Ausdrucks bis zu einer bestimmten Stärke aus.",
"Math.pow|param|x": "Der Basiswert des Ausdrucks.",
"Math.pow|param|y": "Der exponentielle Wert des Ausdrucks.",
"Math.random": "Gibt eine pseudozufüllige Zahl zwischen 0 und `max`aus.",
"Math.randomBoolean": "Erzeugt zufällig einen \"wahr\" oder \"falsch\"-Wert, wie bei einem Münzwurf.",
"Math.sign": "Gibt das Vorzeichen von x aus und zeigt an, ob dieses positiv, negativ oder null ist.",
"Math.sign|param|x": "Der numerische Ausdruck, der getestet werden soll",
"Math.sqrt": "Gibt die Quadratwurzel einer Zahl aus.",
"Math.sqrt|param|x": "Ein numerischer Ausdruck.",
"String.charAt": "Gibt den Buchstaben beim angegebenen Index aus.",
"String.charAt|param|index": "Der null-basierte index des gewünschten Zeichens.",
"String.charCodeAt": "Gibt den Unicode-Wert des Zeichens am vorgegebenen Ort aus.",
"String.charCodeAt|param|index": "Der null-basierte Index des gewünschten Zeichens. Wenn kein Zeichen am angegeben Index vorhanden ist, wird NaN ausgegeben.",
"String.compare": "Bestimmt die relative Reihenfolge zweier Strings (in ASCII).",
"String.compare|param|that": "Zeichenfolge, die mit der Zielzeichenfolge verglichen werden soll",
"String.concat": "Gibt eine Zeichenfolge aus, die die Verkettung von zwei oder mehr Zeichenfolgen ist.",
"String.concat|param|other": "Die Zeichenfolge, die an das Ende einer Zeichenfolge angehängt werden soll.",
"String.fromCharCode": "Erstelle Sie eine Zeichenfolge aus dem angegebenen ASCII-Zeichencode.",
"String.isEmpty": "Gibt einen Wert aus, der anzeigt, ob die Zeichenfolge leer ist",
"String.length": "Gibt die Länge einer Zeichenfolge aus.",
"String.substr": "Gibt eine Teilzeichenfolge der aktuellen Zeichenfolge aus.",
"String.substr|param|length": "Anzahl der zu extrahierenden Zeichen",
"String.substr|param|start": "Erster Zeichenindex, kann beim zählen vom Ende negativ sein, zum Beispiel: 0",
"basic": "Bietet Zugriff auf grundlegende mini-Funktionalität.",
"basic.clearScreen": "Schalte alle LEDs aus",
"basic.color": "Konvertiert den Farbnamen in eine Nummer",
"basic.forever": "Wiederholt immer wieder den Code im Hintergrund. Bei jeder Iteration ist es möglich, anderen Code auszuführen.",
"basic.pause": "Pausiere für die angegebene Zeit in Millisekunden",
"basic.pause|param|ms": "wie lange pausieren, z.B.: 100, 200, 500, 1000, 2000",
"basic.plotLeds": "Zeichnet ein Bild auf dem LED-Bildschirm.",
"basic.plotLeds|param|leds": "Muster der LEDs, die ein-/ und ausgeschaltet werden",
"basic.rgbw": "Konvertiert Rot-, Grün- und Blau-Kanäle in eine RGB-Farbe",
"basic.rgbw|param|blue": "Blauwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|green": "Grünwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|red": "Rotwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|white": "Weißwert zwischen 0 und 255, z.B. 0",
"basic.setLedColor": "Legt die Farbe der eingebauten LED fest. Setze auf 0, um diese abzuschalten.",
"basic.showAnimation": "Zeigt eine Abfolge von LED-Anzeigen als Animation.",
"basic.showAnimation|param|interval": "Zeit in Millisekunden zwischen jedem Neuzeichnen",
"basic.showAnimation|param|leds": "Muster der LEDs, die ein-/ und ausgeschaltet werden",
"basic.showLeds": "Zeichnet ein Bild auf dem LED-Bildschirm.",
"basic.showLeds|param|interval": "Zeit in Millisekunden, die nach der Zeichnung gewartet wird",
"basic.showLeds|param|leds": "Muster der LEDs, die ein- und ausgeschaltet werden",
"basic.showNumber": "Zeige eine Nummer auf dem Display. Wenn die Nummer auf das Display passt (es sich also um eine einstellige Zahl handelt), scrolle nicht weiter.",
"basic.showNumber|param|interval": "Scroll-Geschwindigkeit; z.B. 150, 100, 200,-100",
"basic.showString": "Zeige Text auf dem Display an, Buchstabe für Buchstabe. Wenn die Zeichenfolge in das Display passt (also wenn es sich um einen einzelnen Buchstaben handelt), scrolle nicht weiter.",
"basic.showString|param|interval": "Wie schnell die Zeichen geändert werden; z.B. 150, 100, 200,-100",
"basic.showString|param|text": "Text auf dem Bildschirm dargestellt werden soll, z.B.: \"Hallo!\"",
"control": "Laufzeit- und Event-Dienstprogramme.",
"control.assert": "Wenn die Bedingung falsch ist, zeige eine Nachricht auf der seriellen Konsole und gebe Panic-Code 098 aus",
"control.deviceName": "Erzeugt einen Namen für das Gerät, basierend auf der Seriennummer",
"control.eventSourceId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
"control.eventTimestamp": "Holt den Zeitstempel des letzten Events auf dem Bus",
"control.eventValue": "Holt den Wert des letzten ausgeführten Events auf dem Bus",
"control.eventValueId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
"control.inBackground": "Plant Code, der im Hintergrund wiedergegeben wird.",
"control.onEvent": "Startet ein Event auf dem Event-Bus.",
"control.panic": "Zeigt einen spezifizierten Fehlercode und hält das Programm an.",
"control.raiseEvent": "Startet ein Event auf dem Event-Bus.",
"control.raiseEvent|param|mode": "optionale Definition davon, wie ein Event nach dem Erstellen ausgeführt wird (Standard ist \"CREATE_AND_FIRE).",
"control.raiseEvent|param|src": "ID der Calliope mini-Komponente, die das Event generiert hat, zum Beispiel CALLIOPE_ID_BUTTON_A.",
"control.raiseEvent|param|value": "Komponentenspezifischer Code, der den Grund des Events angibt.",
"control.reset": "Seit den mini zurück.",
"control.runtimeWarning": "Zeige Warnmeldung im Simulator.",
"control.waitMicros": "Sperrt die aktuelle Leitung für die Dauer der angegebenen Mikrosekunden",
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
"game": "Eine Einzel-LED-Sprite-Spielumgebung",
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu",
"game.addScore": "Fügt zum aktuellen Spielstand Punkte hinzu",
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.",
"game.createSprite|param|x": "horizontale Koordinate des Sprites, z.B. 2",
"game.createSprite|param|y": "vertikale Koordinate des Sprites, z.B. 2",
"game.currentTime": "Ruft die verbliebene Zeit (seit `starte Countdown`) oder die aktuelle Zeit (seit das Gerät gestartet wurde oder eine Stoppuhr aktiviert wurde) an.",
"game.gameOver": "Gibt über eine Animation ein Spiel wieder.",
"game.invalidSprite": "Ruft einen invaliden Sprite ab; wird genutzt, um Locale zu initialisieren.",
"game.isGameOver": "Zeigt an, ob das Spil die \"Game Over\"-Sequenz angezeigt hat.",
"game.isRunning": "Holt einen Wert, der anzeigt, ob das Spiel noch läuft. Gibt `falsch`aus, wenn das Spiel zu Ende ist.",
"game.level": "Ruft das aktuelle Level ab",
"game.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
"game.life": "Ruft das aktuelle Leben ab",
"game.removeLife": "Entfernt ein Leben",
"game.score": "Ruft den aktuellen Punktestand ab",
"game.setLife": "Setzt den aktuellen Wert der Leben",
"game.setScore": "Setzt den aktuellen Wert des Spielstands",
"game.showScore": "Zeigt den Spielstand auf dem Display.",
"game.startCountdown": "Startet einen Spiel-Countdown",
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000",
"game.startStopwatch": "Startet eine Stoppuhr.`aktuelle Zeit`gibt die vergangene Zeit an.",
"images": "Erstellung, Bearbeitung und Anzeige von LED-Bildern.",
"images.createBigImage": "Erstellt ein Bild mit zwei Einzelbildern.",
"images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
"input": "Ereignisse und Daten der Sensoren",
"input.acceleration": "Holt den Beschleunigungswert in Milli-Erdanziehung (wenn das Board flach mit dem Display nach oben liegt, X = 0, y = 0 und Z =-1024)",
"input.buttonIsPressed": "Erhalte den Sie den Tastenstatus (gepresst oder nicht) für ``A`` und ``B``.",
"input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.",
"input.compassHeading": "Holt die aktuelle Kompassrichtung in Grad.",
"input.lightLevel": "Liest die Lichtintensität auf dem LED-Bildschirm im Bereich von ``0`` (dunkel) und `` 255`` (hell).",
"input.magneticForce": "Ruft den Wert der Magnetkraft in ``Mikro-Tesla`` (``µT``) ab. Diese Funktion wird im Simulator nicht unterstützt.",
"input.onButtonPressed": "Tue etwas, wenn eine Taste (``A``, ``B`` oder ``A + B``) gedrückt wird",
"input.onGesture": "Mache etwas, wenn eine Geste gemacht wird (wie den mini zu schütteln).",
"input.onLogoDown": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach unten zeigt und das Board vertikal ausgerichtet ist.",
"input.onLogoUp": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach oben zeigt und das Board vertikal ausgerichtet ist.",
"input.onPinPressed": "Mache etwas, wenn eine Pin gehalten wird.",
"input.onPinPressed|param|body": "Code, der ausführt wird, wenn ein Pin gehalten wird",
"input.onPinReleased": "Mache etwas, wenn der Pin losgelassen wird.",
"input.onPinReleased|param|body": "Code, der ausgeführt werden soll, wenn der Pin losgelassen wird",
"input.onScreenDown": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach unten zeigt.",
"input.onScreenUp": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach oben zeigt.",
"input.onShake": "Hängt Code an, der ausgeführt wird, wenn der mini geschüttelt wird.",
"input.pinIsPressed": "Ruft den Pin-Zustand (gehalten oder nicht) ab. Die Erdung muss gehalten werden, um den Stromkreis zu schließen.",
"input.rotation": "Die Neigung und Drehung des mini Drehung auf ``X-Achse``oder ``Y-Achse``, in Grad.",
"input.runningTime": "Ruft die Anzahl der Millisekunden auf, die seit dem Einschalten vergangen sind.",
"input.setAccelerometerRange": "Legt die Stichprobenbereich des Beschleunigungssensors in Schwerkraft fest.",
"input.setAccelerometerRange|param|range": "Ein Wert, der die maximale Stärke der gemessenen Beschleunigung beschreibt",
"input.temperature": "Ruft die aktuelle Temperatur in Grad Celsius (°C) ab.",
"led": "Steuerung des LED-Bildschirms.",
"led.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
"led.enable": "Schaltet das Display an und aus",
"led.fadeIn": "Blendet die Bildschirmanzeige ein.",
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.",
"led.plot": "Schalte die angegebene LED mit Hilfe von X- und Y-Koordinaten ein (X ist horizontal, Y ist vertikal). (0,0) ist die obere linke Ecke.",
"led.plotAll": "Schaltet alle LEDs an",
"led.plotBarGraph": "Zeigt ein vertikales Balkendiagramm an, basierend auf dem `Wert`und dem `Hoch`-Wert. Wenn `Hoch`0 ist, wird das Diagramm automatisch angepasst.",
"led.plotBarGraph|param|high": "maximalen Wert. Wenn dieser 0 ist, wird der Maximalwert automatisch angepasst, z.B.: 0",
"led.plotBarGraph|param|value": "aktueller Wert zum Darstellen",
"led.point": "Ruft den An/Aus-Status einer vorgegebenen LED mittels X-/Y-Koordinaten ab. (0,0) ist oben links.",
"led.screenshot": "Macht einen Screenshot vom LED-Bildschirm und gibt ein Bild aus.",
"led.setBrightness": "Lege die Helligkeit des Bildschirms fest, von 0 (aus) bis 255 (volle Helligkeit).",
"led.setBrightness|param|value": "Helligkeitswert, z.B.: 255, 127, 0",
"led.setDisplayMode": "Legt den Anzeigemodus von Wiedergabe-LEDs zwischen Schwarz und Weiß und Graustufen fest.",
"led.setDisplayMode|param|mode": "TODO",
"led.stopAnimation": "Bricht die aktuelle Animation ab und löscht andere ausstehende Animationen.",
"led.toggle": "Schaltet ein bestimmtes Pixel ein",
"led.toggleAll": "Invertiert die aktuelle LED-Anzeige",
"led.unplot": "Schalte die angegebene LED mit x-und y-Koordinaten ab (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
"motors": "Blöcke, die genutzt werden, um Onboard-Motoren zu steuern",
"motors.dualMotorPower": "Steuert zwei an das Board angeschlossene Motoren. Schaltet auf Dual-Motor-Modus um!",
"motors.motorCommand": "Schicke Anhalten, Ausrollen oder Anhalten-Befehle an den Motor. Hat im Dual-Motor-Modus keinen Effekt.",
"motors.motorPower": "Schaltet den Motor bei einer bestimmten Prozentzahl der Kraft an. Schaltet um auf den Single-Motor-Modus!",
"motors.motorPower|param|power": "%percent der Kraft, die an den Motor geschickt wird. Negative Werte laufen rückwärts, z.B. 50",
"music": "Generierung von von Musik durch Pin ``P0``.",
"music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus",
"music.changeTempoBy": "Ändere die Geschwindigkeit um den angegebenen Betrag",
"music.changeTempoBy|param|bpm": "Die Änderung in Schlägen pro Minute auf das Tempo, z.B.: 20",
"music.noteFrequency": "Ruft die Frequenz einer Note ab.",
"music.playTone": "Spielt einen Ton für den angegebenen Zeitraum auf dem Lautsprecher ab.",
"music.playTone|param|ms": "Tondauer in Millisekunden (ms)",
"music.rest": "Ruht (spielt nichts) für eine bestimmte Zeit auf Pin ``P0``.",
"music.rest|param|ms": "Restdauer in Millisekunden (ms)",
"music.ringTone": "Spielt einen Ton durch den Lautsprecher ab.",
"music.ringTone|param|frequency": "Tonhöhe des abzuspielenden Tones in Hertz (Hz)",
"music.setTempo": "Legt die Geschwindigkeit auf den angegebenen Wert fest.",
"music.setTempo|param|bpm": "Die neue Geschwindigkeit in Schlägen pro Minute, z.B.: 120",
"music.tempo": "Gibt die Geschwindigkeit in Schlägen pro Minute aus. Die Geschwindigkeit ist Schnelligkeit (Bpm = Beats pro Minute), in der Töne abgespielt werden. Je größer der Wert, desto schneller werden die Töne abgespielt.",
"pins": "Steuere die Stromstärke über die Pins für analoge/digitale Signale, Servos, I2C,...",
"pins.analogPitch": "Gibt ein Pulsweiten Modulation (PWM)-Signal über den aktuellen Pitch-Pin. Benutze `analog set pitch pin`, um den Pitch-Pin festzulegen.",
"pins.analogReadPin": "Lese den Anschlusswert als Analog aus, d. h. als einen Wert zwischen 0 und 1023.",
"pins.analogSetPeriod": "Stellt die Pulsweite Modulation (PWM) des Analogausganges auf den angegebenen Wert in ** Mikrosekunden ** oder `1/1000` Millisekunden ein.\nWenn dieser Pin nicht als einen Analogausgang (mit `analog write pin`) konfiguriert ist, hat der Vorgang keine Auswirkungen.",
"pins.analogSetPeriod|param|micros": "Zeit in Mikrosekunden. z.B.: 20000",
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.",
"pins.analogWritePin|param|value": "Wert, der auf den Pin geschrieben werden soll, zwischen ``0`` und ``1023`` z.B.: 1023,0",
"pins.createBuffer": "Erstellt einen Null-initialisierten Zwischenspeicher.",
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1",
"pins.digitalWritePin": "Setzt einen Pin- oder Verbinder-Wert auf 0 oder 1.",
"pins.digitalWritePin|param|value": "Wert, der auf dem Pin 1 gesetzt werden soll, z.B. 0",
"pins.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
"pins.i2cReadNumber": "Lese eine Nummer aus einer 7-bit I2C-Adresse.",
"pins.i2cWriteBuffer": "Schreibt Bytes in eine 7-bit I2C-Adresse.",
"pins.i2cWriteNumber": "Schreibe eine Nummer in eine 7-bit I2C-Adresse.",
"pins.map": "Definiert eine Nummer von einer Auswahl zu einer anderen um. Ein Wert ``von niedrig``wird so auf ``zu niedrig``umgeändert, ein Wert ``von hoch`` zu ``zu hoch`` etc.",
"pins.map|param|fromHigh": "die obere Grenze des aktuellen Wertebereichs, z.B.: 1023",
"pins.map|param|fromLow": "die untere Grenze des aktuellen Wertebereichs",
"pins.map|param|toHigh": "die Obergrenze des Wertezielbereichs, z.B.: 4",
"pins.map|param|toLow": "die Untergrenze des Wertezielbereichs",
"pins.map|param|value": "Wert in Bereichen zuordnen",
"pins.onPulsed": "Stellt diesen Pin als einen Digitaleingang ein und generiert Ereignisse, deren Zeitstempel die Dauer darstellt, in der der Pin entweder ``hoch``oder ``niedrig``war.",
"pins.pulseDuration": "Ruft die Dauer des letzten Impulses in Mikrosendungen ab. Diese Funktion soll von einem `onPulsed`-Handler aufgerufen werden.",
"pins.pulseIn": "Gibt die Dauer eines Pulses in Mikrosekunden an",
"pins.pulseIn|param|name": "der Pin, der den Puls misst",
"pins.pulseIn|param|value": "der Wert des Pulses (Standard hoch)",
"pins.servoSetPulse": "Konfiguriert diesen IO-Pin als einen analogen/PWM-Ausgang, stellt den Zeitraum auf 20 ms ein und setzt die Pulsweite fest, basieren auf dem angegeben Wert **Mikrosekunden** oder `1/1000`Millisekunden.",
"pins.servoSetPulse|param|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
"pins.servoSetPulse|param|name": "PIN-Name",
"pins.servoWritePin": "Schreibt einen Wert in den Servo, der die Welle entsprechend kontroliert. Auf einem Standard-Servo wird so der Winkel der Welle (in Grad) eingestellt, sodass sich die Welle entsprechend anpasst. Auf einem kontinuierlich drehenden Servo wird dadurch die Geschwindigkeit des Servos festgelegt, wobei ``0``die volle Geschwindigkeit in eine Richtung darstellt, ``180``die volle Geschwindigkeit in die andere, und ein Wert von ``90`` einen Stillstand erzeugt.",
"pins.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.",
"pins.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus",
"pins.spiWrite|param|value": "Daten, die an den SPI-Slave geschickt werden sollen",
"serial": "Lesen und Schreiben von Daten über eine serielle Verbindung.",
"serial.delimiters": "Gibt die mit dem Begrenzer korrespondierende Zeichenfolge aus.",
"serial.onLineReceived": "Registriert ein Event, das ausgeführt wird, wenn eine Zeile empfangen wurde",
"serial.readLine": "Liest eine Textzeile aus der seriellen Schnittstelle.",
"serial.readUntil": "Liest aus eine Textzeile aus dem seriellen Anschluss und gibt den Puffer aus, wenn die Begrenzung erreicht wurde.",
"serial.readUntil|param|delimiter": "Text-Begrenzung, die die Textblöcke voneinander trennt",
"serial.redirect": "Konfiguriert dynamisch die serielle Instanz, damit sie andere Pins als USBTX und USBRX benutzt.",
"serial.writeLine": "Gibt eine Zeile des Textes an die serielle",
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",
"serial.writeValue": "Schreibt ein ``Namen: Wert`` Wertepaar auf die serielle Schnittstelle.",
"serial.writeValue|param|name": "Name des Wertestreams, z.B.: x",
"serial.writeValue|param|value": "Schreiben"
"Math.abs": "Gibt den absoluten Wert einer Zahl aus (den Wert unabhängig davon, ob er positiv oder negativ ist).\nDer absolute Wert von -5 ist zum Beispiel der gleiche wie der von 5.",
"Math.abs|param|x": "Ein numerischer Ausdruck, für den der absolute Wert benötigt wird.",
"Math.max": "Gibt den größeren von zwei vorhandenen numerischen Ausdrücken aus.",
"Math.min": "Gibt den niedrigeren von zwei vorhandenen numerischen Ausdrücken aus.",
"Math.pow": "Gibt den Wert eines grundlegenden Ausdrucks bis zu einer bestimmten Stärke aus.",
"Math.pow|param|x": "Der Basiswert des Ausdrucks.",
"Math.pow|param|y": "Der exponentielle Wert des Ausdrucks.",
"Math.random": "Gibt eine pseudozufüllige Zahl zwischen 0 und `max`aus.",
"Math.randomBoolean": "Erzeugt zufällig einen \"wahr\" oder \"falsch\"-Wert, wie bei einem Münzwurf.",
"Math.sign": "Gibt das Vorzeichen von x aus und zeigt an, ob dieses positiv, negativ oder null ist.",
"Math.sign|param|x": "Der numerische Ausdruck, der getestet werden soll",
"Math.sqrt": "Gibt die Quadratwurzel einer Zahl aus.",
"Math.sqrt|param|x": "Ein numerischer Ausdruck.",
"String.charAt": "Gibt den Buchstaben beim angegebenen Index aus.",
"String.charAt|param|index": "Der null-basierte index des gewünschten Zeichens.",
"String.charCodeAt": "Gibt den Unicode-Wert des Zeichens am vorgegebenen Ort aus.",
"String.charCodeAt|param|index": "Der null-basierte Index des gewünschten Zeichens. Wenn kein Zeichen am angegeben Index vorhanden ist, wird NaN ausgegeben.",
"String.compare": "Bestimmt die relative Reihenfolge zweier Strings (in ASCII).",
"String.compare|param|that": "Zeichenfolge, die mit der Zielzeichenfolge verglichen werden soll",
"String.concat": "Gibt eine Zeichenfolge aus, die die Verkettung von zwei oder mehr Zeichenfolgen ist.",
"String.concat|param|other": "Die Zeichenfolge, die an das Ende einer Zeichenfolge angehängt werden soll.",
"String.fromCharCode": "Erstelle Sie eine Zeichenfolge aus dem angegebenen ASCII-Zeichencode.",
"String.isEmpty": "Gibt einen Wert aus, der anzeigt, ob die Zeichenfolge leer ist",
"String.length": "Gibt die Länge einer Zeichenfolge aus.",
"String.substr": "Gibt eine Teilzeichenfolge der aktuellen Zeichenfolge aus.",
"String.substr|param|length": "Anzahl der zu extrahierenden Zeichen",
"String.substr|param|start": "Erster Zeichenindex, kann beim zählen vom Ende negativ sein, zum Beispiel: 0",
"basic": "Bietet Zugriff auf grundlegende mini-Funktionalität.",
"basic.clearScreen": "Schalte alle LEDs aus",
"basic.color": "Konvertiert den Farbnamen in eine Nummer",
"basic.forever": "Wiederholt immer wieder den Code im Hintergrund. Bei jeder Iteration ist es möglich, anderen Code auszuführen.",
"basic.pause": "Pausiere für die angegebene Zeit in Millisekunden",
"basic.pause|param|ms": "wie lange pausieren, z.B.: 100, 200, 500, 1000, 2000",
"basic.plotLeds": "Zeichnet ein Bild auf dem LED-Bildschirm.",
"basic.plotLeds|param|leds": "Muster der LEDs, die ein-/ und ausgeschaltet werden",
"basic.rgbw": "Konvertiert Rot-, Grün- und Blau-Kanäle in eine RGB-Farbe",
"basic.rgbw|param|blue": "Blauwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|green": "Grünwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|red": "Rotwert zwischen 0 und 255, z.B. 255",
"basic.rgbw|param|white": "Weißwert zwischen 0 und 255, z.B. 0",
"basic.rgb": "Konvertiert Rot-, Grün- und Blau-Kanäle in eine RGB-Farbe",
"basic.rgb|param|blue": "Blauwert zwischen 0 und 255, z.B. 255",
"basic.rgb|param|green": "Grünwert zwischen 0 und 255, z.B. 255",
"basic.rgb|param|red": "Rotwert zwischen 0 und 255, z.B. 255",
"basic.setLedColor": "Legt die Farbe der eingebauten LED fest. Setze auf 0, um diese abzuschalten.",
"basic.showAnimation": "Zeigt eine Abfolge von LED-Anzeigen als Animation.",
"basic.showAnimation|param|interval": "Zeit in Millisekunden zwischen jedem Neuzeichnen",
"basic.showAnimation|param|leds": "Muster der LEDs, die ein-/ und ausgeschaltet werden",
"basic.showLeds": "Zeichnet ein Bild auf dem LED-Bildschirm.",
"basic.showLeds|param|interval": "Zeit in Millisekunden, die nach der Zeichnung gewartet wird",
"basic.showLeds|param|leds": "Muster der LEDs, die ein- und ausgeschaltet werden",
"basic.showNumber": "Zeige eine Nummer auf dem Display. Wenn die Nummer auf das Display passt (es sich also um eine einstellige Zahl handelt), scrolle nicht weiter.",
"basic.showNumber|param|interval": "Scroll-Geschwindigkeit; z.B. 150, 100, 200,-100",
"basic.showString": "Zeige Text auf dem Display an, Buchstabe für Buchstabe. Wenn die Zeichenfolge in das Display passt (also wenn es sich um einen einzelnen Buchstaben handelt), scrolle nicht weiter.",
"basic.showString|param|interval": "Wie schnell die Zeichen geändert werden; z.B. 150, 100, 200,-100",
"basic.showString|param|text": "Text auf dem Bildschirm dargestellt werden soll, z.B.: \"Hallo!\"",
"control": "Laufzeit- und Event-Dienstprogramme.",
"control.assert": "Wenn die Bedingung falsch ist, zeige eine Nachricht auf der seriellen Konsole und gebe Panic-Code 098 aus",
"control.deviceName": "Erzeugt einen Namen für das Gerät, basierend auf der Seriennummer",
"control.eventSourceId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
"control.eventTimestamp": "Holt den Zeitstempel des letzten Events auf dem Bus",
"control.eventValue": "Holt den Wert des letzten ausgeführten Events auf dem Bus",
"control.eventValueId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
"control.inBackground": "Plant Code, der im Hintergrund wiedergegeben wird.",
"control.onEvent": "Startet ein Event auf dem Event-Bus.",
"control.panic": "Zeigt einen spezifizierten Fehlercode und hält das Programm an.",
"control.raiseEvent": "Startet ein Event auf dem Event-Bus.",
"control.raiseEvent|param|mode": "optionale Definition davon, wie ein Event nach dem Erstellen ausgeführt wird (Standard ist \"CREATE_AND_FIRE).",
"control.raiseEvent|param|src": "ID der Calliope mini-Komponente, die das Event generiert hat, zum Beispiel CALLIOPE_ID_BUTTON_A.",
"control.raiseEvent|param|value": "Komponentenspezifischer Code, der den Grund des Events angibt.",
"control.reset": "Seit den mini zurück.",
"control.runtimeWarning": "Zeige Warnmeldung im Simulator.",
"control.waitMicros": "Sperrt die aktuelle Leitung für die Dauer der angegebenen Mikrosekunden",
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
"game": "Eine Einzel-LED-Sprite-Spielumgebung",
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu",
"game.addScore": "Fügt zum aktuellen Spielstand Punkte hinzu",
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.",
"game.createSprite|param|x": "horizontale Koordinate des Sprites, z.B. 2",
"game.createSprite|param|y": "vertikale Koordinate des Sprites, z.B. 2",
"game.currentTime": "Ruft die verbliebene Zeit (seit `starte Countdown`) oder die aktuelle Zeit (seit das Gerät gestartet wurde oder eine Stoppuhr aktiviert wurde) an.",
"game.gameOver": "Gibt über eine Animation ein Spiel wieder.",
"game.invalidSprite": "Ruft einen invaliden Sprite ab; wird genutzt, um Locale zu initialisieren.",
"game.isGameOver": "Zeigt an, ob das Spil die \"Game Over\"-Sequenz angezeigt hat.",
"game.isRunning": "Holt einen Wert, der anzeigt, ob das Spiel noch läuft. Gibt `falsch`aus, wenn das Spiel zu Ende ist.",
"game.level": "Ruft das aktuelle Level ab",
"game.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
"game.life": "Ruft das aktuelle Leben ab",
"game.removeLife": "Entfernt ein Leben",
"game.score": "Ruft den aktuellen Punktestand ab",
"game.setLife": "Setzt den aktuellen Wert der Leben",
"game.setScore": "Setzt den aktuellen Wert des Spielstands",
"game.showScore": "Zeigt den Spielstand auf dem Display.",
"game.startCountdown": "Startet einen Spiel-Countdown",
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000",
"game.startStopwatch": "Startet eine Stoppuhr.`aktuelle Zeit`gibt die vergangene Zeit an.",
"images": "Erstellung, Bearbeitung und Anzeige von LED-Bildern.",
"images.createBigImage": "Erstellt ein Bild mit zwei Einzelbildern.",
"images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
"input": "Ereignisse und Daten der Sensoren",
"input.acceleration": "Holt den Beschleunigungswert in Milli-Erdanziehung (wenn das Board flach mit dem Display nach oben liegt, X = 0, y = 0 und Z =-1024)",
"input.buttonIsPressed": "Erhalte den Sie den Tastenstatus (gepresst oder nicht) für ``A`` und ``B``.",
"input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.",
"input.compassHeading": "Holt die aktuelle Kompassrichtung in Grad.",
"input.lightLevel": "Liest die Lichtintensität auf dem LED-Bildschirm im Bereich von ``0`` (dunkel) und `` 255`` (hell).",
"input.magneticForce": "Ruft den Wert der Magnetkraft in ``Mikro-Tesla`` (``µT``) ab. Diese Funktion wird im Simulator nicht unterstützt.",
"input.onButtonPressed": "Tue etwas, wenn eine Taste (``A``, ``B`` oder ``A + B``) gedrückt wird",
"input.onGesture": "Mache etwas, wenn eine Geste gemacht wird (wie den mini zu schütteln).",
"input.onLogoDown": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach unten zeigt und das Board vertikal ausgerichtet ist.",
"input.onLogoUp": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach oben zeigt und das Board vertikal ausgerichtet ist.",
"input.onPinPressed": "Mache etwas, wenn eine Pin gehalten wird.",
"input.onPinPressed|param|body": "Code, der ausführt wird, wenn ein Pin gehalten wird",
"input.onPinReleased": "Mache etwas, wenn der Pin losgelassen wird.",
"input.onPinReleased|param|body": "Code, der ausgeführt werden soll, wenn der Pin losgelassen wird",
"input.onScreenDown": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach unten zeigt.",
"input.onScreenUp": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach oben zeigt.",
"input.onShake": "Hängt Code an, der ausgeführt wird, wenn der mini geschüttelt wird.",
"input.pinIsPressed": "Ruft den Pin-Zustand (gehalten oder nicht) ab. Die Erdung muss gehalten werden, um den Stromkreis zu schließen.",
"input.rotation": "Die Neigung und Drehung des mini Drehung auf ``X-Achse``oder ``Y-Achse``, in Grad.",
"input.runningTime": "Ruft die Anzahl der Millisekunden auf, die seit dem Einschalten vergangen sind.",
"input.setAccelerometerRange": "Legt die Stichprobenbereich des Beschleunigungssensors in Schwerkraft fest.",
"input.setAccelerometerRange|param|range": "Ein Wert, der die maximale Stärke der gemessenen Beschleunigung beschreibt",
"input.temperature": "Ruft die aktuelle Temperatur in Grad Celsius (°C) ab.",
"led": "Steuerung des LED-Bildschirms.",
"led.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
"led.enable": "Schaltet das Display an und aus",
"led.fadeIn": "Blendet die Bildschirmanzeige ein.",
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.",
"led.plot": "Schalte die angegebene LED mit Hilfe von X- und Y-Koordinaten ein (X ist horizontal, Y ist vertikal). (0,0) ist die obere linke Ecke.",
"led.plotAll": "Schaltet alle LEDs an",
"led.plotBarGraph": "Zeigt ein vertikales Balkendiagramm an, basierend auf dem `Wert`und dem `Hoch`-Wert. Wenn `Hoch`0 ist, wird das Diagramm automatisch angepasst.",
"led.plotBarGraph|param|high": "maximalen Wert. Wenn dieser 0 ist, wird der Maximalwert automatisch angepasst, z.B.: 0",
"led.plotBarGraph|param|value": "aktueller Wert zum Darstellen",
"led.point": "Ruft den An/Aus-Status einer vorgegebenen LED mittels X-/Y-Koordinaten ab. (0,0) ist oben links.",
"led.screenshot": "Macht einen Screenshot vom LED-Bildschirm und gibt ein Bild aus.",
"led.setBrightness": "Lege die Helligkeit des Bildschirms fest, von 0 (aus) bis 255 (volle Helligkeit).",
"led.setBrightness|param|value": "Helligkeitswert, z.B.: 255, 127, 0",
"led.setDisplayMode": "Legt den Anzeigemodus von Wiedergabe-LEDs zwischen Schwarz und Weiß und Graustufen fest.",
"led.setDisplayMode|param|mode": "TODO",
"led.stopAnimation": "Bricht die aktuelle Animation ab und löscht andere ausstehende Animationen.",
"led.toggle": "Schaltet ein bestimmtes Pixel ein",
"led.toggleAll": "Invertiert die aktuelle LED-Anzeige",
"led.unplot": "Schalte die angegebene LED mit x-und y-Koordinaten ab (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
"motors": "Blöcke, die genutzt werden, um Onboard-Motoren zu steuern",
"motors.dualMotorPower": "Steuert zwei an das Board angeschlossene Motoren. Schaltet auf Dual-Motor-Modus um!",
"motors.motorCommand": "Schicke Anhalten, Ausrollen oder Anhalten-Befehle an den Motor. Hat im Dual-Motor-Modus keinen Effekt.",
"motors.motorPower": "Schaltet den Motor bei einer bestimmten Prozentzahl der Kraft an. Schaltet um auf den Single-Motor-Modus!",
"motors.motorPower|param|power": "%percent der Kraft, die an den Motor geschickt wird. Negative Werte laufen rückwärts, z.B. 50",
"music": "Generierung von von Musik durch Pin ``P0``.",
"music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus",
"music.changeTempoBy": "Ändere die Geschwindigkeit um den angegebenen Betrag",
"music.changeTempoBy|param|bpm": "Die Änderung in Schlägen pro Minute auf das Tempo, z.B.: 20",
"music.noteFrequency": "Ruft die Frequenz einer Note ab.",
"music.playTone": "Spielt einen Ton für den angegebenen Zeitraum auf dem Lautsprecher ab.",
"music.playTone|param|ms": "Tondauer in Millisekunden (ms)",
"music.rest": "Ruht (spielt nichts) für eine bestimmte Zeit auf Pin ``P0``.",
"music.rest|param|ms": "Restdauer in Millisekunden (ms)",
"music.ringTone": "Spielt einen Ton durch den Lautsprecher ab.",
"music.ringTone|param|frequency": "Tonhöhe des abzuspielenden Tones in Hertz (Hz)",
"music.setTempo": "Legt die Geschwindigkeit auf den angegebenen Wert fest.",
"music.setTempo|param|bpm": "Die neue Geschwindigkeit in Schlägen pro Minute, z.B.: 120",
"music.tempo": "Gibt die Geschwindigkeit in Schlägen pro Minute aus. Die Geschwindigkeit ist Schnelligkeit (Bpm = Beats pro Minute), in der Töne abgespielt werden. Je größer der Wert, desto schneller werden die Töne abgespielt.",
"pins": "Steuere die Stromstärke über die Pins für analoge/digitale Signale, Servos, I2C,...",
"pins.analogPitch": "Gibt ein Pulsweiten Modulation (PWM)-Signal über den aktuellen Pitch-Pin. Benutze `analog set pitch pin`, um den Pitch-Pin festzulegen.",
"pins.analogReadPin": "Lese den Anschlusswert als Analog aus, d. h. als einen Wert zwischen 0 und 1023.",
"pins.analogSetPeriod": "Stellt die Pulsweite Modulation (PWM) des Analogausganges auf den angegebenen Wert in ** Mikrosekunden ** oder `1/1000` Millisekunden ein.\nWenn dieser Pin nicht als einen Analogausgang (mit `analog write pin`) konfiguriert ist, hat der Vorgang keine Auswirkungen.",
"pins.analogSetPeriod|param|micros": "Zeit in Mikrosekunden. z.B.: 20000",
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.",
"pins.analogWritePin|param|value": "Wert, der auf den Pin geschrieben werden soll, zwischen ``0`` und ``1023`` z.B.: 1023,0",
"pins.createBuffer": "Erstellt einen Null-initialisierten Zwischenspeicher.",
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1",
"pins.digitalWritePin": "Setzt einen Pin- oder Verbinder-Wert auf 0 oder 1.",
"pins.digitalWritePin|param|value": "Wert, der auf dem Pin 1 gesetzt werden soll, z.B. 0",
"pins.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
"pins.i2cReadNumber": "Lese eine Nummer aus einer 7-bit I2C-Adresse.",
"pins.i2cWriteBuffer": "Schreibt Bytes in eine 7-bit I2C-Adresse.",
"pins.i2cWriteNumber": "Schreibe eine Nummer in eine 7-bit I2C-Adresse.",
"pins.map": "Definiert eine Nummer von einer Auswahl zu einer anderen um. Ein Wert ``von niedrig``wird so auf ``zu niedrig``umgeändert, ein Wert ``von hoch`` zu ``zu hoch`` etc.",
"pins.map|param|fromHigh": "die obere Grenze des aktuellen Wertebereichs, z.B.: 1023",
"pins.map|param|fromLow": "die untere Grenze des aktuellen Wertebereichs",
"pins.map|param|toHigh": "die Obergrenze des Wertezielbereichs, z.B.: 4",
"pins.map|param|toLow": "die Untergrenze des Wertezielbereichs",
"pins.map|param|value": "Wert in Bereichen zuordnen",
"pins.onPulsed": "Stellt diesen Pin als einen Digitaleingang ein und generiert Ereignisse, deren Zeitstempel die Dauer darstellt, in der der Pin entweder ``hoch``oder ``niedrig``war.",
"pins.pulseDuration": "Ruft die Dauer des letzten Impulses in Mikrosendungen ab. Diese Funktion soll von einem `onPulsed`-Handler aufgerufen werden.",
"pins.pulseIn": "Gibt die Dauer eines Pulses in Mikrosekunden an",
"pins.pulseIn|param|name": "der Pin, der den Puls misst",
"pins.pulseIn|param|value": "der Wert des Pulses (Standard hoch)",
"pins.servoSetPulse": "Konfiguriert diesen IO-Pin als einen analogen/PWM-Ausgang, stellt den Zeitraum auf 20 ms ein und setzt die Pulsweite fest, basieren auf dem angegeben Wert **Mikrosekunden** oder `1/1000`Millisekunden.",
"pins.servoSetPulse|param|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
"pins.servoSetPulse|param|name": "PIN-Name",
"pins.servoWritePin": "Schreibt einen Wert in den Servo, der die Welle entsprechend kontroliert. Auf einem Standard-Servo wird so der Winkel der Welle (in Grad) eingestellt, sodass sich die Welle entsprechend anpasst. Auf einem kontinuierlich drehenden Servo wird dadurch die Geschwindigkeit des Servos festgelegt, wobei ``0``die volle Geschwindigkeit in eine Richtung darstellt, ``180``die volle Geschwindigkeit in die andere, und ein Wert von ``90`` einen Stillstand erzeugt.",
"pins.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.",
"pins.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus",
"pins.spiWrite|param|value": "Daten, die an den SPI-Slave geschickt werden sollen",
"serial": "Lesen und Schreiben von Daten über eine serielle Verbindung.",
"serial.delimiters": "Gibt die mit dem Begrenzer korrespondierende Zeichenfolge aus.",
"serial.onLineReceived": "Registriert ein Event, das ausgeführt wird, wenn eine Zeile empfangen wurde",
"serial.readLine": "Liest eine Textzeile aus der seriellen Schnittstelle.",
"serial.readUntil": "Liest aus eine Textzeile aus dem seriellen Anschluss und gibt den Puffer aus, wenn die Begrenzung erreicht wurde.",
"serial.readUntil|param|delimiter": "Text-Begrenzung, die die Textblöcke voneinander trennt",
"serial.redirect": "Konfiguriert dynamisch die serielle Instanz, damit sie andere Pins als USBTX und USBRX benutzt.",
"serial.writeLine": "Gibt eine Zeile des Textes an die serielle",
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",
"serial.writeValue": "Schreibt ein ``Namen: Wert`` Wertepaar auf die serielle Schnittstelle.",
"serial.writeValue|param|name": "Name des Wertestreams, z.B.: x",
"serial.writeValue|param|value": "Schreiben"
}

View File

@ -1,201 +1,202 @@
{
"AcceleratorRange.EightG": "Der Bewegungssensor misst Kräfte bis 8g",
"AcceleratorRange.EightG|block": "8g",
"AcceleratorRange.FourG": "Der Bewegungssensor misst Kräfte bis 4g",
"AcceleratorRange.FourG|block": "4g",
"AcceleratorRange.OneG": "Der Bewegungssensor misst Kräfte bis 1g",
"AcceleratorRange.OneG|block": "1g",
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
"AcceleratorRange.TwoG|block": "2g",
"BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",
"BeatFraction.Sixteenth|block": "1/16",
"BeatFraction.Whole|block": "1",
"Button.AB|block": "A+B",
"Colors.Blue|block": "Blau",
"Colors.Green|block": "Grün",
"Colors.Indigo|block": "Indigo",
"Colors.Orange|block": "Orange",
"Colors.Purple|block": "Violett",
"Colors.Red|block": "Rot",
"Colors.Violet|block": "Veilchenblau",
"Colors.White|block": "Weiß",
"Colors.Yellow|block": "Gelb",
"Delimiters.Dollar|block": "$",
"Delimiters.Hash|block": "#",
"Delimiters.NewLine|block": "Neue Zeile",
"Dimension.Strength|block": "Stärke",
"Dimension.X|block": "x",
"Dimension.Y|block": "y",
"Dimension.Z|block": "z",
"Direction.Left|block": "links",
"Direction.Right|block": "rechts",
"DisplayMode.BackAndWhite|block": "Schwarz-Weiß",
"DisplayMode.Greyscale|block": "Graustufen",
"EventCreationMode.CreateAndFire": "Calliope mini-Event wurde initialisiert, seine Event-Handler werden unverzüglich ausgeführt (nicht geeignet für die Nutzung bei Unterbrechungen!).",
"EventCreationMode.CreateOnly": "Calliope mini-Event wurde initialisiert, es wird keine weitere Verarbeitung vorgenommen.",
"Gesture.FreeFall": "Wird ausgeführt, wenn das Board fällt!",
"Gesture.FreeFall|block": "freier Fall",
"Gesture.LogoDown": "Wird ausgeführt, wenn das Logo nach unten zeigt und das Display vertikal ist.",
"Gesture.LogoDown|block": "Logo nach unten",
"Gesture.LogoUp": "Wird ausgeführt, wenn das Logo nach oben zeigt und das Display vertikal ist.",
"Gesture.LogoUp|block": "Logo oben",
"Gesture.ScreenDown": "Wird ausgeführt, wenn das Display nach oben zeigt und das Board horizontal ist.",
"Gesture.ScreenDown|block": "Display nach unten",
"Gesture.ScreenUp": "Wird ausgeführt, wenn das Display nach unten zeigt und das Board horizontal ist.",
"Gesture.ScreenUp|block": "Display nach oben",
"Gesture.Shake": "Wird erhöht, wenn geschüttelt",
"Gesture.Shake|block": "geschüttelt",
"Gesture.SixG": "Wird ausgeführt, ein 6g starker Stoß erkannt wird",
"Gesture.SixG|block": "6g",
"Gesture.ThreeG": "Wird ausgeführt, ein 3g starker Stoß erkannt wird",
"Gesture.ThreeG|block": "3g",
"Gesture.TiltLeft": "Wird ausgeführt, wenn das Display nach links zeigt",
"Gesture.TiltLeft|block": "nach links neigen",
"Gesture.TiltRight": "Wird ausgeführt, wenn das Display nach rechts zeigt",
"Gesture.TiltRight|block": "nach rechts neigen",
"LedSpriteProperty.Blink|block": "blinken",
"LedSpriteProperty.Brightness|block": "Helligkeit",
"LedSpriteProperty.Direction|block": "Richtung",
"LedSpriteProperty.X|block": "x",
"LedSpriteProperty.Y|block": "y",
"Math.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
"Math|block": "Mathematik",
"Motor.AB|block": "A und B",
"MotorCommand.Break|block": "Pause",
"MotorCommand.Coast|block": "auslaufen",
"MotorCommand.Sleep|block": "schlafen",
"Note.CSharp3|block": "C#3",
"Note.CSharp4|block": "C#4",
"Note.CSharp5|block": "C#5",
"Note.CSharp|block": "C#",
"Note.FSharp3|block": "F#3",
"Note.FSharp4|block": "F#4",
"Note.FSharp5|block": "F#5",
"Note.FSharp|block": "F#",
"Note.GSharp3|block": "G#3",
"Note.GSharp4|block": "G#4",
"Note.GSharp5|block": "G#5",
"Note.GSharp|block": "G#",
"PinPullMode.PullDown|block": "nach unten",
"PinPullMode.PullUp|block": "nach oben",
"Rotation.Pitch|block": "Winkel",
"Rotation.Roll|block": "rollen",
"String.charAt|block": "Zeichen an Position %pos aus|%this",
"String.compare|block": "vergleiche %this| mit %that",
"String.concat|block": "hänge %this| mit %other aneinander",
"String.fromCharCode|block": "Text aus ASCII-Code %code",
"String.isEmpty|block": "%this| ist leer",
"String.length|block": "Länge von %VALUE",
"String.substr|block": "extrahiere aus %this|beginnend mit %start|%length Zeichen",
"String|block": "Zeichenfolge",
"basic.clearScreen|block": "Bildschirminhalt löschen",
"basic.color|block": "%c",
"basic.forever|block": "dauerhaft",
"basic.pause|block": "pausiere (ms) %pause",
"basic.rgbw|block": "Rot %red|Grün %green|Blau %blue|Weiß %white",
"basic.setLedColor|block": "setze LED-Farbe auf %color=color_id",
"basic.showLeds|block": "zeige LEDs",
"basic.showNumber|block": "zeige|Nummer %number",
"basic.showString|block": "zeige|Zeichenfolge %text",
"basic|block": "Grundlagen",
"control.deviceName|block": "Gerätename",
"control.deviceSerialNumber|block": "Seriennnummer",
"control.eventSourceId|block": "%id",
"control.eventTimestamp|block": "Ereigniszeitstempel",
"control.eventValueId|block": "%id",
"control.eventValue|block": "Ereigniswert",
"control.inBackground|block": "im Hintergrund ausführen",
"control.onEvent|block": "wenn Ereignis|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
"control.raiseEvent|block": "Ereignis auslösen|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
"control.reset|block": "zurücksetzen",
"control.waitMicros|block": "Warte (µs)%micros",
"control|block": "Steuerung",
"game.addScore|block": "Ändere Spielstand um|%points",
"game.createSprite|block": "erzeuge Sprite an Position|x: %x|y:%y",
"game.gameOver|block": "Spiel beendet",
"game.score|block": "Spielstand",
"game.startCountdown|block": "Countdown| starten (ms) %duration",
"game|block": "Spiel",
"images.createBigImage|block": "erstelle großes Bild",
"images.createImage|block": "erstelle Bild",
"images|block": "Bilder",
"input.acceleration|block": "Beschleunigung (mg) |%NAME",
"input.buttonIsPressed|block": "Button|%NAME|ist gedrückt",
"input.compassHeading|block": "Kompassausrichtung (°)",
"input.lightLevel|block": "Lichtstärke",
"input.magneticForce|block": "Magnetkraft (µT) |%NAME",
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
"input.onGesture|block": "wenn |%NAME",
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
"input.rotation|block": "Rotation (°)|%NAME",
"input.runningTime|block": "Laufzeit (ms)",
"input.setAccelerometerRange|block": "setze Bewegungsmesser auf|%range",
"input.temperature|block": "Temperatur (°C)",
"input|block": "Eingabe",
"led.brightness|block": "Helligkeit",
"led.plotBarGraph|block": "zeichne Balkendiagramm von %value|bis %high",
"led.plot|block": "Zeichne|x %x|y %y",
"led.point|block": "Punkt|x %x|y %y",
"led.setBrightness|block": "setze Helligkeit auf %value",
"led.stopAnimation|block": "halte Animation an",
"led.toggle|block": "Schalte zwischen|x %x|y %y",
"led.unplot|block": "schalte Pixel|x %x|y %y aus",
"led|block": "LED",
"motors.dualMotorPower|block": "Motor %motor an|mit %percent",
"motors.motorCommand|block": "Motor %command",
"motors.motorPower|block": "Motor an mit %percent",
"motors|block": "Motoren",
"music.beat|block": "%fraction|Takt",
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value",
"music.noteFrequency|block": "%note",
"music.playTone|block": "spiele|Note %note=device_note|für %duration=device_beat",
"music.rest|block": "pausiere (ms)|%duration=device_beat",
"music.ringTone|block": "Klingelton (Hz) |%note = Device_note",
"music.setTempo|block": "ändere Geschwindigkeit auf (bpm)|%value",
"music.tempo|block": "Geschwindkeit (bpm)",
"music|block": "Musik",
"pins.analogReadPin|block": "lese analoge Werte von|Pin %name",
"pins.analogSetPeriod|block": "setze Zeitraum für analogen|Pin %pin|auf (µs)%micros",
"pins.analogWritePin|block": "schreibe analogen|Pin %name|auf %value",
"pins.digitalReadPin|block": "lese digitale Werte von|Pin %name",
"pins.digitalWritePin|block": "schreibe digitalen Wert von|pin %name|auf %value",
"pins.i2cReadNumber|block": "lese Nummer aus I2C|auf Adresse %address|im Format %format=i2c_sizeof",
"pins.i2cWriteNumber|block": "schreibe Nummer aus I2C|auf Adresse %address|mit Wert %value|im Format %format=i2c_sizeof",
"pins.map|block": "verteile %value|von niedrig %fromLow|von hoch %fromHigh| bis niedrig %toLow|bis hoch %toHigh",
"pins.onPulsed|block": "wenn|Pin %pin|gepulst %pulse",
"pins.pulseDuration|block": "Impulsdauer (µs)",
"pins.pulseIn|block": "Impuls in (µs)|Pin %name|mit %value",
"pins.servoSetPulse|block": "setze den Puls von Servo an|Pin %value|auf (µs) %micros",
"pins.servoWritePin|block": "schreibe Servo an|Pin %name|auf %value",
"pins.setPull|block": "setze Anziehungskraft von|Pin %pin|auf %pull",
"pins.spiWrite|block": "schreibe %value in SPI",
"pins|block": "Pins",
"serial.delimiters|block": "%del",
"serial.readLine|block": "serial|read line",
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "Konsole",
"{id:category}Basic": "Grundlagen",
"{id:category}Control": "Steuerung",
"{id:category}Game": "Spiel",
"{id:category}Images": "Bilder",
"{id:category}Input": "Eingabe",
"{id:category}Led": "LED",
"{id:category}Math": "Mathematik",
"{id:category}Motors": "Motoren",
"{id:category}Music": "Musik",
"{id:category}Pins": "Pins",
"{id:category}Serial": "Konsole",
"{id:category}String": "Zeichenfolge",
"{id:category}Text": "Text"
"AcceleratorRange.EightG": "Der Bewegungssensor misst Kräfte bis 8g",
"AcceleratorRange.EightG|block": "8g",
"AcceleratorRange.FourG": "Der Bewegungssensor misst Kräfte bis 4g",
"AcceleratorRange.FourG|block": "4g",
"AcceleratorRange.OneG": "Der Bewegungssensor misst Kräfte bis 1g",
"AcceleratorRange.OneG|block": "1g",
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
"AcceleratorRange.TwoG|block": "2g",
"BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",
"BeatFraction.Sixteenth|block": "1/16",
"BeatFraction.Whole|block": "1",
"Button.AB|block": "A+B",
"Colors.Blue|block": "Blau",
"Colors.Green|block": "Grün",
"Colors.Indigo|block": "Indigo",
"Colors.Orange|block": "Orange",
"Colors.Purple|block": "Violett",
"Colors.Red|block": "Rot",
"Colors.Violet|block": "Veilchenblau",
"Colors.White|block": "Weiß",
"Colors.Yellow|block": "Gelb",
"Delimiters.Dollar|block": "$",
"Delimiters.Hash|block": "#",
"Delimiters.NewLine|block": "Neue Zeile",
"Dimension.Strength|block": "Stärke",
"Dimension.X|block": "x",
"Dimension.Y|block": "y",
"Dimension.Z|block": "z",
"Direction.Left|block": "links",
"Direction.Right|block": "rechts",
"DisplayMode.BackAndWhite|block": "Schwarz-Weiß",
"DisplayMode.Greyscale|block": "Graustufen",
"EventCreationMode.CreateAndFire": "Calliope mini-Event wurde initialisiert, seine Event-Handler werden unverzüglich ausgeführt (nicht geeignet für die Nutzung bei Unterbrechungen!).",
"EventCreationMode.CreateOnly": "Calliope mini-Event wurde initialisiert, es wird keine weitere Verarbeitung vorgenommen.",
"Gesture.FreeFall": "Wird ausgeführt, wenn das Board fällt!",
"Gesture.FreeFall|block": "freier Fall",
"Gesture.LogoDown": "Wird ausgeführt, wenn das Logo nach unten zeigt und das Display vertikal ist.",
"Gesture.LogoDown|block": "Logo nach unten",
"Gesture.LogoUp": "Wird ausgeführt, wenn das Logo nach oben zeigt und das Display vertikal ist.",
"Gesture.LogoUp|block": "Logo oben",
"Gesture.ScreenDown": "Wird ausgeführt, wenn das Display nach oben zeigt und das Board horizontal ist.",
"Gesture.ScreenDown|block": "Display nach unten",
"Gesture.ScreenUp": "Wird ausgeführt, wenn das Display nach unten zeigt und das Board horizontal ist.",
"Gesture.ScreenUp|block": "Display nach oben",
"Gesture.Shake": "Wird erhöht, wenn geschüttelt",
"Gesture.Shake|block": "geschüttelt",
"Gesture.SixG": "Wird ausgeführt, ein 6g starker Stoß erkannt wird",
"Gesture.SixG|block": "6g",
"Gesture.ThreeG": "Wird ausgeführt, ein 3g starker Stoß erkannt wird",
"Gesture.ThreeG|block": "3g",
"Gesture.TiltLeft": "Wird ausgeführt, wenn das Display nach links zeigt",
"Gesture.TiltLeft|block": "nach links neigen",
"Gesture.TiltRight": "Wird ausgeführt, wenn das Display nach rechts zeigt",
"Gesture.TiltRight|block": "nach rechts neigen",
"LedSpriteProperty.Blink|block": "blinken",
"LedSpriteProperty.Brightness|block": "Helligkeit",
"LedSpriteProperty.Direction|block": "Richtung",
"LedSpriteProperty.X|block": "x",
"LedSpriteProperty.Y|block": "y",
"Math.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
"Math|block": "Mathematik",
"Motor.AB|block": "A und B",
"MotorCommand.Break|block": "Pause",
"MotorCommand.Coast|block": "auslaufen",
"MotorCommand.Sleep|block": "schlafen",
"Note.CSharp3|block": "C#3",
"Note.CSharp4|block": "C#4",
"Note.CSharp5|block": "C#5",
"Note.CSharp|block": "C#",
"Note.FSharp3|block": "F#3",
"Note.FSharp4|block": "F#4",
"Note.FSharp5|block": "F#5",
"Note.FSharp|block": "F#",
"Note.GSharp3|block": "G#3",
"Note.GSharp4|block": "G#4",
"Note.GSharp5|block": "G#5",
"Note.GSharp|block": "G#",
"PinPullMode.PullDown|block": "nach unten",
"PinPullMode.PullUp|block": "nach oben",
"Rotation.Pitch|block": "Winkel",
"Rotation.Roll|block": "rollen",
"String.charAt|block": "Zeichen an Position %pos aus|%this",
"String.compare|block": "vergleiche %this| mit %that",
"String.concat|block": "hänge %this| mit %other aneinander",
"String.fromCharCode|block": "Text aus ASCII-Code %code",
"String.isEmpty|block": "%this| ist leer",
"String.length|block": "Länge von %VALUE",
"String.substr|block": "extrahiere aus %this|beginnend mit %start|%length Zeichen",
"String|block": "Zeichenfolge",
"basic.clearScreen|block": "Bildschirminhalt löschen",
"basic.color|block": "%c",
"basic.forever|block": "dauerhaft",
"basic.pause|block": "pausiere (ms) %pause",
"basic.rgbw|block": "Rot %red|Grün %green|Blau %blue|Weiß %white",
"basic.rgb|block": "Rot %red|Grün %green|Blau %blue",
"basic.setLedColor|block": "setze LED-Farbe auf %color=color_id",
"basic.showLeds|block": "zeige LEDs",
"basic.showNumber|block": "zeige|Nummer %number",
"basic.showString|block": "zeige|Zeichenfolge %text",
"basic|block": "Grundlagen",
"control.deviceName|block": "Gerätename",
"control.deviceSerialNumber|block": "Seriennnummer",
"control.eventSourceId|block": "%id",
"control.eventTimestamp|block": "Ereigniszeitstempel",
"control.eventValueId|block": "%id",
"control.eventValue|block": "Ereigniswert",
"control.inBackground|block": "im Hintergrund ausführen",
"control.onEvent|block": "wenn Ereignis|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
"control.raiseEvent|block": "Ereignis auslösen|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
"control.reset|block": "zurücksetzen",
"control.waitMicros|block": "Warte (µs)%micros",
"control|block": "Steuerung",
"game.addScore|block": "Ändere Spielstand um|%points",
"game.createSprite|block": "erzeuge Sprite an Position|x: %x|y:%y",
"game.gameOver|block": "Spiel beendet",
"game.score|block": "Spielstand",
"game.startCountdown|block": "Countdown| starten (ms) %duration",
"game|block": "Spiel",
"images.createBigImage|block": "erstelle großes Bild",
"images.createImage|block": "erstelle Bild",
"images|block": "Bilder",
"input.acceleration|block": "Beschleunigung (mg) |%NAME",
"input.buttonIsPressed|block": "Button|%NAME|ist gedrückt",
"input.compassHeading|block": "Kompassausrichtung (°)",
"input.lightLevel|block": "Lichtstärke",
"input.magneticForce|block": "Magnetkraft (µT) |%NAME",
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
"input.onGesture|block": "wenn |%NAME",
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
"input.rotation|block": "Rotation (°)|%NAME",
"input.runningTime|block": "Laufzeit (ms)",
"input.setAccelerometerRange|block": "setze Bewegungsmesser auf|%range",
"input.temperature|block": "Temperatur (°C)",
"input|block": "Eingabe",
"led.brightness|block": "Helligkeit",
"led.plotBarGraph|block": "zeichne Balkendiagramm von %value|bis %high",
"led.plot|block": "Zeichne|x %x|y %y",
"led.point|block": "Punkt|x %x|y %y",
"led.setBrightness|block": "setze Helligkeit auf %value",
"led.stopAnimation|block": "halte Animation an",
"led.toggle|block": "Schalte zwischen|x %x|y %y",
"led.unplot|block": "schalte Pixel|x %x|y %y aus",
"led|block": "LED",
"motors.dualMotorPower|block": "Motor %motor an|mit %percent",
"motors.motorCommand|block": "Motor %command",
"motors.motorPower|block": "Motor an mit %percent",
"motors|block": "Motoren",
"music.beat|block": "%fraction|Takt",
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value",
"music.noteFrequency|block": "%note",
"music.playTone|block": "spiele|Note %note=device_note|für %duration=device_beat",
"music.rest|block": "pausiere (ms)|%duration=device_beat",
"music.ringTone|block": "Klingelton (Hz) |%note = Device_note",
"music.setTempo|block": "ändere Geschwindigkeit auf (bpm)|%value",
"music.tempo|block": "Geschwindkeit (bpm)",
"music|block": "Musik",
"pins.analogReadPin|block": "lese analoge Werte von|Pin %name",
"pins.analogSetPeriod|block": "setze Zeitraum für analogen|Pin %pin|auf (µs)%micros",
"pins.analogWritePin|block": "schreibe analogen|Pin %name|auf %value",
"pins.digitalReadPin|block": "lese digitale Werte von|Pin %name",
"pins.digitalWritePin|block": "schreibe digitalen Wert von|pin %name|auf %value",
"pins.i2cReadNumber|block": "lese Nummer aus I2C|auf Adresse %address|im Format %format=i2c_sizeof",
"pins.i2cWriteNumber|block": "schreibe Nummer aus I2C|auf Adresse %address|mit Wert %value|im Format %format=i2c_sizeof",
"pins.map|block": "verteile %value|von niedrig %fromLow|von hoch %fromHigh| bis niedrig %toLow|bis hoch %toHigh",
"pins.onPulsed|block": "wenn|Pin %pin|gepulst %pulse",
"pins.pulseDuration|block": "Impulsdauer (µs)",
"pins.pulseIn|block": "Impuls in (µs)|Pin %name|mit %value",
"pins.servoSetPulse|block": "setze den Puls von Servo an|Pin %value|auf (µs) %micros",
"pins.servoWritePin|block": "schreibe Servo an|Pin %name|auf %value",
"pins.setPull|block": "setze Anziehungskraft von|Pin %pin|auf %pull",
"pins.spiWrite|block": "schreibe %value in SPI",
"pins|block": "Pins",
"serial.delimiters|block": "%del",
"serial.readLine|block": "serial|read line",
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "Konsole",
"{id:category}Basic": "Grundlagen",
"{id:category}Control": "Steuerung",
"{id:category}Game": "Spiel",
"{id:category}Images": "Bilder",
"{id:category}Input": "Eingabe",
"{id:category}Led": "LED",
"{id:category}Math": "Mathematik",
"{id:category}Motors": "Motoren",
"{id:category}Music": "Musik",
"{id:category}Pins": "Pins",
"{id:category}Serial": "Konsole",
"{id:category}String": "Zeichenfolge",
"{id:category}Text": "Text"
}

View File

@ -4,14 +4,122 @@
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#1E90FF weight=116 icon="\uf00a"
namespace basic {
/**
/**
* Draws an image on the LED screen.
* @param leds the pattern of LED to turn on/off
* @param interval time in milliseconds to pause after drawing
*/
//% help=basic/show-leds
//% weight=85 blockGap=8
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds" icon="\uf00a"
//% parts="ledmatrix"
//% group="LED matrix"
void showLeds(ImageLiteral_ leds, int interval = 400) {
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
}
/**
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
* @param text the text to scroll on the screen, eg: "hi!"
* @param interval how fast to shift characters; eg: 50, 100, 150, 200
*/
//% help=basic/show-string
//% weight=100 blockGap=16
//% block="show|string %text || in an interval of %interval ms"
//% async
//% blockId=device_print_message
//% parts="ledmatrix"
//% text.shadowOptions.toString=true
//% expandableArgumentMode="toggle"
//% interval.defl=80
//% group="LED matrix"
void showString(String text, int interval = 80) {
if (interval <= 0)
interval = 1;
int l = text ? text->getUTF8Size() : 0;
if (l == 0) {
uBit.display.clear();
fiber_sleep(interval * 5);
} else if (l > 1) {
uBit.display.scroll(MSTR(text), interval);
} else {
uBit.display.printChar(text->getUTF8Data()[0], interval * 5);
}
}
/**
* Shows a sequence of LED screens as an animation.
* @param leds pattern of LEDs to turn on/off
* @param interval time in milliseconds between each redraw
*/
//% help=basic/show-animation weight=83 imageLiteral=1 async
//% parts="ledmatrix"
//% group="LED matrix"
void showAnimation(ImageLiteral_ leds, int interval = 400) {
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0, 0);
}
/**
* Draws an image on the LED screen.
* @param leds pattern of LEDs to turn on/off
*/
//% help=basic/plot-leds weight=80
//% parts="ledmatrix"
//% group="LED matrix"
void plotLeds(ImageLiteral_ leds) {
MicroBitImage i(imageBytes(leds));
uBit.display.print(i, 0, 0, 0, 0);
}
/**
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=75
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix"
//% group="LED matrix"
//% advanced=true
void clearScreen() {
uBit.display.image.clear();
}
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=basic/forever weight=55 blockGap=16 blockAllowMultiple=1 afterOnStart=true
//% blockId=device_forever block="forever" icon="\uf01e"
//% group="Control"
void forever(Action a) {
runForever(a);
}
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
//% help=basic/pause weight=50
//% async block="pause (ms) %pause" blockGap=16
//% blockId=device_pause icon="\uf110"
//% pause.shadow=timePicker
//% group="Control"
void pause(int ms) {
fiber_sleep(ms);
}
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_set_led_color
//% block="set led to %color=colorNumberPicker"
//% weight=50
//% weight=10
//% group="RGB LED"
void setLedColor(int color) {
if (!color) {
uBit.rgb.off();
@ -31,104 +139,12 @@ namespace basic {
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_turn_rgb_led_off block="turn build-in LED off"
//% weight=50
//% weight=10
//% group="RGB LED"
//% advanced=true
void turnRgbLedOff() {
uBit.rgb.off();
}
/**
* Draws an image on the LED screen.
* @param leds the pattern of LED to turn on/off
* @param interval time in milliseconds to pause after drawing
*/
//% help=basic/show-leds
//% weight=95 blockGap=8
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds" icon="\uf00a"
//% parts="ledmatrix"
void showLeds(ImageLiteral_ leds, int interval = 400) {
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
}
/**
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
* @param text the text to scroll on the screen, eg: "hi!"
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
*/
//% help=basic/show-string
//% weight=87 blockGap=16
//% block="show|string %text"
//% async
//% blockId=device_print_message
//% parts="ledmatrix"
//% text.shadowOptions.toString=true
void showString(String text, int interval = 150) {
if (interval <= 0)
interval = 1;
int l = text ? text->getUTF8Size() : 0;
if (l == 0) {
uBit.display.clear();
fiber_sleep(interval * 5);
} else if (l > 1) {
uBit.display.scroll(MSTR(text), interval);
} else {
uBit.display.printChar(text->getUTF8Data()[0], interval * 5);
}
}
/**
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=79
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix"
//% advanced=true
void clearScreen() {
uBit.display.image.clear();
}
/**
* Shows a sequence of LED screens as an animation.
* @param leds pattern of LEDs to turn on/off
* @param interval time in milliseconds between each redraw
*/
//% help=basic/show-animation imageLiteral=1 async
//% parts="ledmatrix"
void showAnimation(ImageLiteral_ leds, int interval = 400) {
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0, 0);
}
/**
* Draws an image on the LED screen.
* @param leds pattern of LEDs to turn on/off
*/
//% help=basic/plot-leds weight=80
//% parts="ledmatrix"
void plotLeds(ImageLiteral_ leds) {
MicroBitImage i(imageBytes(leds));
uBit.display.print(i, 0, 0, 0, 0);
}
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=basic/forever weight=55 blockGap=16 blockAllowMultiple=1 afterOnStart=true
//% blockId=device_forever block="forever" icon="\uf01e"
void forever(Action a) {
runForever(a);
}
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
//% help=basic/pause weight=54
//% async block="pause (ms) %pause" blockGap=16
//% blockId=device_pause icon="\uf110"
//% pause.shadow=timePicker
void pause(int ms) {
fiber_sleep(ms);
}
}

View File

@ -37,17 +37,52 @@ enum Colors {
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#54C9C9 weight=100
//% color=#54C9C9 weight=100 icon="\uf00a"
//% groups=['LED matrix', 'Control', 'RGB LED', 'others']
namespace basic {
/**
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
* @param interval speed of scroll; eg: 50, 100, 150, 200
*/
//% help=basic/show-number
//% weight=95
//% blockId=device_show_number
//% block="show|number %number || in an interval of %interval ms" blockGap=8
//% async
//% parts="ledmatrix"
//% expandableArgumentMode="toggle"
//% interval.defl=80
//% group="LED matrix"
export function showNumber(value: number, interval?: number) {
showString(Math.roundWithPrecision(value, 2).toString(), interval);
}
/**
* Converts the color name to a number
*/
//% blockId=color_id block="%c" shim=TD_ID
//% group="RGB LED"
//% weight=1
//% deprecated=true
export function color(c: Colors): number {
return c;
}
/**
* 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
*/
//% weight=3
//% blockId="core_rgb" block="red %red|green %green|blue %blue"
//% group="RGB LED"
export function rgb(red: number, green: number, blue: number): number {
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
@ -55,31 +90,21 @@ namespace basic {
* @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=1
//% blockId="core_rgb" block="red %red|green %green|blue %blue|white %white"
//% 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);
}
/**
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
* @param interval speed of scroll; eg: 150, 100, 200, -100
*/
//% help=basic/show-number
//% weight=96
//% blockId=device_show_number block="show|number %number" blockGap=8
//% async
//% parts="ledmatrix" interval.defl=150
export function showNumber(value: number, interval?: number) {
showString(Math.roundWithPrecision(value, 2).toString(), interval);
}
}
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
function pause(ms: number): void {
function pause(ms: number): void {
basic.pause(ms);
}
@ -89,4 +114,4 @@ function pause(ms: number): void {
*/
function forever(a: () => void): void {
basic.forever(a);
}
}

View File

@ -1,10 +1,10 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="pins_on_pulsed" x="-157" y="130">
<field name="pin">DigitalPin.C5</field>
<field name="pin">DigitalPin.P5</field>
<field name="pulse">PulseValue.Low</field>
<statement name="HANDLER">
<block type="device_set_analog_pin">
<field name="name">AnalogPin.C6</field>
<field name="name">AnalogPin.P9</field>
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
@ -12,7 +12,7 @@
</value>
<next>
<block type="device_set_analog_period">
<field name="pin">AnalogPin.C6</field>
<field name="pin">AnalogPin.P10</field>
<value name="micros">
<shadow type="math_number">
<field name="NUM">20000</field>
@ -20,7 +20,7 @@
</value>
<next>
<block type="device_set_digital_pin">
<field name="name">DigitalPin.C6</field>
<field name="name">DigitalPin.P6</field>
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
@ -28,7 +28,7 @@
</value>
<next>
<block type="device_set_servo_pin">
<field name="name">AnalogPin.C5</field>
<field name="name">AnalogPin.P13</field>
<value name="value">
<shadow type="math_number">
<field name="NUM">5</field>
@ -36,7 +36,7 @@
</value>
<next>
<block type="device_set_servo_pulse">
<field name="value">AnalogPin.C6</field>
<field name="value">AnalogPin.P8</field>
<value name="micros">
<shadow type="math_number" id="Hx4bpmg|8KSH=b_`+XtP">
<field name="NUM">1500</field>
@ -65,7 +65,7 @@
<field name="NUM">0</field>
</shadow>
<block type="pins_pulse_in">
<field name="name">DigitalPin.C9</field>
<field name="name">DigitalPin.P9</field>
<field name="value">PulseValue.Low</field>
</block>
</value>
@ -102,7 +102,7 @@
<field name="NUM">0</field>
</shadow>
<block type="device_get_digital_pin">
<field name="name">DigitalPin.C9</field>
<field name="name">DigitalPin.P9</field>
</block>
</value>
<value name="value">
@ -110,7 +110,7 @@
<field name="NUM">0</field>
</shadow>
<block type="device_get_analog_pin">
<field name="name">AnalogPin.C6</field>
<field name="name">AnalogPin.P9</field>
</block>
</value>
<value name="repeat">
@ -120,12 +120,12 @@
</value>
<next>
<block type="spi_pins">
<field name="mosi">DigitalPin.C11</field>
<field name="miso">DigitalPin.C9</field>
<field name="sck">DigitalPin.C10</field>
<field name="mosi">DigitalPin.P11</field>
<field name="miso">DigitalPin.P9</field>
<field name="sck">DigitalPin.P10</field>
<next>
<block type="device_set_pull">
<field name="pin">DigitalPin.C9</field>
<field name="pin">DigitalPin.P9</field>
<field name="pull">PinPullMode.PullDown</field>
<next>
<block type="device_analog_pitch">
@ -141,11 +141,11 @@
</value>
<next>
<block type="device_set_pin_events">
<field name="pin">DigitalPin.C8</field>
<field name="pin">DigitalPin.P8</field>
<field name="type">PinEventType.Touch</field>
<next>
<block type="device_analog_set_pitch_pin">
<field name="name">AnalogPin.C6</field>
<field name="name">AnalogPin.P9</field>
<next>
<block type="spi_format">
<value name="bits">

View File

@ -150,31 +150,31 @@
<field name="mode">DisplayMode.Greyscale</field>
<next>
<block type="device_set_analog_pin">
<field name="name">AnalogPin.C4</field>
<field name="name">AnalogPin.P4</field>
<value name="value">
<shadow type="math_number_minmax" id=",:%8N*FL3wa-zFQ[+^$9">
<mutation min="0" max="1023" label="Value"></mutation>
<field name="SLIDER">1023</field>
</shadow>
<block type="device_get_analog_pin">
<field name="name">AnalogPin.C5</field>
<field name="name">AnalogPin.P13</field>
</block>
</value>
<next>
<block type="device_set_digital_pin">
<field name="name">DigitalPin.C10</field>
<field name="name">DigitalPin.P10</field>
<value name="value">
<shadow type="math_number_minmax" id="W~pvdj%jFEj?EHmT{81Z">
<mutation min="0" max="1" label="Value"></mutation>
<field name="SLIDER">0</field>
</shadow>
<block type="device_get_digital_pin">
<field name="name">DigitalPin.C15</field>
<field name="name">DigitalPin.P15</field>
</block>
</value>
<next>
<block type="device_set_analog_period">
<field name="pin">AnalogPin.C6</field>
<field name="pin">AnalogPin.P9</field>
<value name="micros">
<shadow type="math_number" id="4a@.1MdG`n=p;34mQOpC">
<field name="NUM">1234</field>
@ -230,7 +230,7 @@
</value>
<next>
<block type="device_set_servo_pulse">
<field name="value">AnalogPin.C4</field>
<field name="value">AnalogPin.P14</field>
<value name="micros">
<shadow type="math_number" id="@*C3kzJkeeUQ@s$N5?K}">
<field name="NUM">1500</field>
@ -510,7 +510,7 @@
</statement>
</block>
<block type="pins_on_pulsed" x="1538" y="929">
<field name="pin">DigitalPin.C10</field>
<field name="pin">DigitalPin.P10</field>
<field name="pulse">PulseValue.Low</field>
<statement name="HANDLER">
<block type="i2c_writenumber">
@ -575,8 +575,8 @@
<next>
<block type="spi_pins">
<field name="mosi">DigitalPin.P9</field>
<field name="miso">DigitalPin.C14</field>
<field name="sck">DigitalPin.C16</field>
<field name="miso">DigitalPin.P14</field>
<field name="sck">DigitalPin.P16</field>
<next>
<block type="control_reset"></block>
</next>

View File

@ -8,6 +8,21 @@ PXT_ABI(__aeabi_dsub)
PXT_ABI(__aeabi_ddiv)
PXT_ABI(__aeabi_dmul)
#if MICROBIT_CODAL
namespace codal {
int list_fibers(Fiber **dest) {
int i = 0;
for (Fiber *fib = codal::get_fiber_list(); fib; fib = fib->next) {
if (dest)
dest[i] = fib;
i++;
}
return i;
}
} // namespace codal
#endif
extern "C" void target_panic(int error_code) {
#if !MICROBIT_CODAL
// wait for serial to flush
@ -28,6 +43,7 @@ namespace pxt {
MicroBit uBit;
MicroBitEvent lastEvent;
bool serialLoggingDisabled;
void platform_init() {
microbit_seed_random();
@ -152,7 +168,8 @@ int current_time_ms() {
}
static void logwriten(const char *msg, int l) {
uBit.serial.send((uint8_t *)msg, l);
if (!serialLoggingDisabled)
uBit.serial.send((uint8_t *)msg, l);
}
static void logwrite(const char *msg) {

View File

@ -1,174 +1,4 @@
let compassImages = [
images.createImage(`
. . # . .
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. # . . .
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
# . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
# . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
# . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
# . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
# . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. # . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . # . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . # .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . #
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . #
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . #
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . #
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . #
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . # .
. . . . .
. . # . .
. . . . .
. . . . .
`)];
let compassImagesDownside = [
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . # . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . # .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . #
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . #
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . #
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . #
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . #
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . # .
. . . . .
. . # . .
. . . . .
. . . . .
`),
const compassImagesLeft = [
images.createImage(`
. . # . .
. . . . .
@ -226,7 +56,66 @@ let compassImagesDownside = [
. # . . .
`)];
const compassImagesRight = [
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . # . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . # .
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . #
`),
images.createImage(`
. . . . .
. . . . .
. . # . .
. . . . #
. . . . .
`),
images.createImage(`
. . . . .
. . . . .
. . # . #
. . . . .
. . . . .
`),
images.createImage(`
. . . . .
. . . . #
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . . #
. . . . .
. . # . .
. . . . .
. . . . .
`),
images.createImage(`
. . . # .
. . . . .
. . # . .
. . . . .
. . . . .
`)];
const compassImages = compassImagesLeft.concat(compassImagesRight);
const compassImagesDownside = compassImagesRight.concat(compassImagesLeft);
namespace basic {
@ -242,6 +131,7 @@ namespace basic {
//% interval.defl=600
//% parts="ledmatrix"
//% advanced=true
//% group="LED matrix"
export function showCompass(interval = 600) {
let i = 0
let startTime = input.runningTime()
@ -251,22 +141,15 @@ namespace basic {
while ((endTime) > (input.runningTime() + refreshRate)) {
i = Math.round((input.compassHeading() - 11.25) / 22.5)
if (input.isGesture(Gesture.ScreenDown)) {
compassImagesDownside[i].showImage(0, refreshRate)
} else {
compassImages[i].showImage(0, refreshRate)
}
let images = (input.isGesture(Gesture.ScreenDown)) ? compassImagesDownside : compassImages;
images[i].showImage(0, refreshRate)
}
rest = (endTime - input.runningTime())
if(rest > 0) {
i = Math.round((input.compassHeading() - 11.25) / 22.5)
if (input.isGesture(Gesture.ScreenDown)) {
compassImagesDownside[i].showImage(0, rest)
} else {
compassImages[i].showImage(0, rest)
}
let images = (input.isGesture(Gesture.ScreenDown)) ? compassImagesDownside : compassImages;
images[i].showImage(0, rest)
}
}

View File

@ -1,15 +1,51 @@
/// <reference no-default-lib="true"/>
enum ConsolePriority {
Debug = 0,
Log = 1,
Warning = 2,
Error = 3,
Silent = 4
}
/**
* Reading and writing data to the console output.
*/
//% weight=12 color=#002050 icon="\uf120"
//% advanced=true
namespace console {
type Listener = (text: string) => void;
type Listener = (priority: ConsolePriority, text: string) => void;
//% whenUsed
let listeners: Listener[] = undefined;
/**
* Minimum priority to send messages to listeners
*/
export let minPriority = ConsolePriority.Log;
let listeners: Listener[]
export function add(priority: ConsolePriority, message: any) {
if (priority < minPriority) return;
let text = inspect(message);
// add new line
text += "\n";
control.__log(priority, text)
// send to listeners
if (listeners)
for (let i = 0; i < listeners.length; ++i)
listeners[i](priority, text);
}
export function debug(text: any) {
add(ConsolePriority.Debug, text);
}
export function warn(text: any) {
add(ConsolePriority.Warning, text);
}
export function error(text: any) {
add(ConsolePriority.Error, text);
}
/**
* Write a line of text to the console output.
@ -17,15 +53,8 @@ namespace console {
*/
//% weight=90
//% help=console/log blockGap=8
export function log(text: any): void {
let stringified = inspect(text);
// pad text on the 32byte boundar
stringified += "\r\n";
control.__log(stringified);
// send to listeners
if (listeners)
for (let i = 0; i < listeners.length; ++i)
listeners[i](stringified);
export function log(value: any): void {
add(ConsolePriority.Log, value);
}
/**
@ -35,21 +64,8 @@ namespace console {
*/
//% weight=88 blockGap=8
//% help=console/log-value
export function logValue(name: any, value: number): void {
const nameText = inspect(name);
log(nameText ? `${nameText}: ${value}` : `${value}`)
}
/**
* Adds a listener for the log messages
* @param listener
*/
//%
export function addListener(listener: (text: string) => void) {
if (!listener) return;
if (!listeners)
listeners = [];
listeners.push(listener);
export function logValue(name: any, value: any): void {
log(name ? `${inspect(name)}: ${inspect(value)}` : `${inspect(value)}`)
}
/**
@ -82,13 +98,35 @@ namespace console {
keys = keys.slice(0, maxElements);
}
return `{${
keys.reduce(
(prev, currKey) => prev + `\n ${currKey}: ${obj[currKey]}`,
""
) + (snipped ? "\n ..." : "")
}
return `{${keys.reduce(
(prev, currKey) => prev + `\n ${currKey}: ${obj[currKey]}`,
""
) + (snipped ? "\n ..." : "")
}
}`;
}
}
/**
* Adds a listener for the log messages
* @param listener
*/
//%
export function addListener(listener: (priority: ConsolePriority, text: string) => void) {
if (!listeners) listeners = []
if (!listener || listeners.indexOf(listener) > -1) return;
listeners.push(listener);
}
/**
* Removes a listener
* @param listener
*/
//%
export function removeListener(listener: (priority: ConsolePriority, text: string) => void) {
if (!listener || !listeners) return;
const i = listeners.indexOf(listener);
if (i > -1)
listeners.splice(i, 1);
}
}

View File

@ -1,5 +1,7 @@
#include "pxt.h"
extern uint32_t __StackTop;
/**
* How to create the event.
*/
@ -271,8 +273,9 @@ namespace control {
* Blocks the current fiber for the given microseconds
* @param micros number of micro-seconds to wait. eg: 4
*/
//% help=control/wait-micros weight=29
//% help=control/wait-micros weight=29 async
//% blockId="control_wait_us" block="wait (µs)%micros"
//% micros.min=0 micros.max=6000
void waitMicros(int micros) {
sleep_us(micros);
}
@ -341,6 +344,15 @@ namespace control {
return microbit_serial_number();
}
/**
* Derive a unique, consistent 64-bit serial number of this device from internal data.
*/
//% help=control/device-long-serial-number
//% advanced=true
Buffer deviceLongSerialNumber() {
return mkBuffer((uint8_t*)&NRF_FICR->DEVICEID[0], sizeof(uint64_t));
}
/**
* Informs simulator/runtime of a MIDI message
* Internal function to support the simulator.
@ -354,8 +366,44 @@ namespace control {
*
*/
//%
void __log(String text) {
void __log(int priority, String text) {
if (NULL == text) return;
pxt::sendSerial(text->getUTF8Data(), text->getUTF8Size());
}
/**
* Allocates the next user notification event
*/
//% help=control/allocate-notify-event
int allocateNotifyEvent() {
#if MICROBIT_CODAL
return ::allocateNotifyEvent();
#else
static int notifyEv = 1024;
return ++notifyEv;
#endif
}
/** Write a message to DMESG debugging buffer. */
//%
void dmesg(String s) {
// this is no-op on v1
DMESG("# %s", s->getUTF8Data());
}
/** Write a message and value (pointer) to DMESG debugging buffer. */
//%
void dmesgPtr(String str, Object_ ptr) {
// this is no-op on v1
DMESG("# %s: %p", str->getUTF8Data(), ptr);
}
//%
uint32_t _ramSize()
{
return (uint32_t)&__StackTop & 0x1fffffff;
}
}

View File

@ -12,6 +12,11 @@ namespace control {
control.inBackground(a);
}
//% hidden=1 deprecated=1
export function runInBackground(a: () => void) {
control.inBackground(a);
}
/**
* Returns the value of a C++ runtime constant
*/
@ -31,6 +36,50 @@ namespace control {
return id;
}
export const enum PXT_PANIC {
CODAL_OOM = 20,
GC_OOM = 21,
GC_TOO_BIG_ALLOCATION = 22,
CODAL_HEAP_ERROR = 30,
CODAL_NULL_DEREFERENCE = 40,
CODAL_USB_ERROR = 50,
CODAL_HARDWARE_CONFIGURATION_ERROR = 90,
INVALID_BINARY_HEADER = 901,
OUT_OF_BOUNDS = 902,
REF_DELETED = 903,
SIZE = 904,
INVALID_VTABLE = 905,
INTERNAL_ERROR = 906,
NO_SUCH_CONFIG = 907,
NO_SUCH_PIN = 908,
INVALID_ARGUMENT = 909,
MEMORY_LIMIT_EXCEEDED = 910,
SCREEN_ERROR = 911,
MISSING_PROPERTY = 912,
INVALID_IMAGE = 913,
CALLED_FROM_ISR = 914,
HEAP_DUMPED = 915,
STACK_OVERFLOW = 916,
BLOCKING_TO_STRING = 917,
VM_ERROR = 918,
SETTINGS_CLEARED = 920,
SETTINGS_OVERLOAD = 921,
SETTINGS_SECRET_MISSING = 922,
DELETE_ON_CLASS = 923,
CAST_FIRST = 980,
CAST_FROM_UNDEFINED = 980,
CAST_FROM_BOOLEAN = 981,
CAST_FROM_NUMBER = 982,
CAST_FROM_STRING = 983,
CAST_FROM_OBJECT = 984,
CAST_FROM_FUNCTION = 985,
CAST_FROM_NULL = 989,
UNHANDLED_EXCEPTION = 999,
}
/**
* Display specified error code and stop the program.
*/
@ -61,6 +110,28 @@ namespace control {
*/
//% shim=pxtrt::runtimeWarning
export function runtimeWarning(message: string) { }
//% shim=pxt::programHash
export declare function programHash(): number;
//% shim=pxt::programName
export declare function programName(): string;
/** Returns estimated size of memory in bytes. */
//% shim=control::_ramSize
export function ramSize() {
return 32 * 1024 * 1024;
}
/** Runs the function and returns run time in microseconds. */
export function benchmark(f: () => void) {
const t0 = micros()
f()
let t = micros() - t0
if (t < 0)
t += 0x3fffffff
return t
}
}
/**

18
libs/core/enums.d.ts vendored
View File

@ -39,6 +39,22 @@ declare namespace basic {
}
declare const enum ButtonEvent {
//% blockIdentity="input.buttonEventValueId"
//% block="pressed down"
Down = 1, // MICROBIT_BUTTON_EVT_DOWN
//% blockIdentity="input.buttonEventValueId"
//% block="released up"
Up = 2, // MICROBIT_BUTTON_EVT_UP
//% blockIdentity="input.buttonEventValueId"
//% block="clicked"
Click = 3, // MICROBIT_BUTTON_EVT_CLICK
//% blockIdentity="input.buttonEventValueId"
//% block="long clicked"
LongClick = 4, // MICROBIT_BUTTON_EVT_LONG_CLICK
}
declare const enum Dimension {
//% block=x
X = 0,
@ -548,5 +564,7 @@ declare namespace motors {
}
declare namespace serial {
}
declare namespace storage {
}
// Auto-generated. Do not edit. Really.

View File

@ -65,87 +65,6 @@ enum IconNames {
//% block="meh"
//% jres=icons.meh
Meh,
//% block="t-shirt"
//% jres=icons.tshirt
TShirt,
//% block="roller skate"
//% jres=icons.rollerskate
Rollerskate,
//% block="duck"
//% jres=icons.duck
Duck,
//% block="house"
//% jres=icons.house
House,
//% block="tortoise"
//% jres=icons.tortoise
Tortoise,
//% block="butterfly"
//% jres=icons.butterfly
Butterfly,
//% block="stick figure"
//% jres=icons.stickfigure
StickFigure,
//% block="ghost"
//% jres=icons.ghost
Ghost,
//% block="sword"
//% jres=icons.sword
Sword,
//% block="giraffe"
//% jres=icons.giraffe
Giraffe,
//% block="skull"
//% jres=icons.skull
Skull,
//% block="umbrella"
//% jres=icons.umbrella
Umbrella,
//% block="snake"
//% jres=icons.snake
Snake,
//% block="rabbit"
//% jres=icons.rabbit
Rabbit,
//% block="cow"
//% jres=icons.cow
Cow,
//% block="quarter note"
//% jres=icons.quarternote
QuarterNote,
//% block="eigth note"
//% jres=icons.eigthnote
EigthNote,
//% block="pitchfork"
//% jres=icons.pitchfork
Pitchfork,
//% block="target"
//% jres=icons.target
Target,
//% block="triangle"
//% jres=icons.triangle
Triangle,
//% block="left triangle"
//% jres=icons.lefttriangle
LeftTriangle,
//% block="chess board"
//% jres=icons.chessboard
Chessboard,
//% block="diamond"
//% jres=icons.diamond
Diamond,
//% block="small diamond"
//% jres=icons.smalldiamond
SmallDiamond,
//% block="square"
//% jres=icons.square
Square,
//% block="small square"
//% jres=icons.smallsquare
SmallSquare,
//% block="scissors"
//% jres=icons.scissors
Scissors,
//% block="arrow north"
//% jres=icons.arrownorth
ArrowNorth,
@ -172,132 +91,36 @@ enum IconNames {
ArrowNorthWest
}
enum ArrowNames {
//% blockIdentity=images.arrowNumber block="North"
North = 0,
//% blockIdentity=images.arrowNumber block="North East"
NorthEast,
//% blockIdentity=images.arrowNumber block="East"
East,
//% blockIdentity=images.arrowNumber block="South East"
SouthEast,
//% blockIdentity=images.arrowNumber block="South"
South,
//% blockIdentity=images.arrowNumber block="South West"
SouthWest,
//% blockIdentity=images.arrowNumber block="West"
West,
//% blockIdentity=images.arrowNumber block="North West"
NorthWest
}
namespace basic {
/**
* Draws the selected icon on the LED screen
* @param icon the predefined icon id
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
* @param interval the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 200.
*/
//% weight=90 blockGap=8
//% blockId=basic_show_icon
//% block="show icon %i" icon="\uf00a"
//% block="show icon %i || for %interval ms" icon="\uf00a"
//% parts="ledmatrix"
//% help=basic/show-icon
//% icon.fieldEditor="imagedropdown"
//% icon.fieldOptions.columns="5"
//% icon.fieldOptions.width="380"
//% icon.fieldOptions.maxRows=4
export function showIcon(icon: IconNames, interval = 600) {
//% expandableArgumentMode="toggle"
//% interval.defl=200
//% group="LED matrix"
export function showIcon(icon: IconNames, interval = 200) {
let res = images.iconImage(icon)
res.showImage(0, interval)
}
/**
* Draws an arrow on the LED screen
* @param direction the direction of the arrow
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
*/
//% weight=50 blockGap=8
//% blockId=basic_show_arrow
//% block="show arrow %i=device_arrow"
//% parts="ledmatrix"
//% advanced=true
//% help=basic/show-arrow
//% deprecated=true
export function showArrow(direction: number, interval = 600) {
let res = images.arrowImage(direction)
res.showImage(0, interval)
}
}
namespace images {
//% weight=50 blockGap=8
//% help=images/arrow-image
//% blockId=builtin_arrow_image block="arrow image %i"
//% deprecated=true
export function arrowImage(i: ArrowNames): Image {
switch (i) {
// compass directions
case ArrowNames.North: return images.createImage(`
. . # . .
. # # # .
# . # . #
. . # . .
. . # . .`);
case ArrowNames.NorthEast: return images.createImage(`
. . # # #
. . . # #
. . # . #
. # . . .
# . . . .`);
case ArrowNames.East: return images.createImage(`
. . # . .
. . . # .
# # # # #
. . . # .
. . # . .`);
case ArrowNames.SouthEast: return images.createImage(`
# . . . .
. # . . .
. . # . #
. . . # #
. . # # #`);
case ArrowNames.South: return images.createImage(`
. . # . .
. . # . .
# . # . #
. # # # .
. . # . .`);
case ArrowNames.SouthWest: return images.createImage(`
. . . . #
. . . # .
# . # . .
# # . . .
# # # . .`);
case ArrowNames.West: return images.createImage(`
. . # . .
. # . . .
# # # # #
. # . . .
. . # . .`);
case ArrowNames.NorthWest: return images.createImage(`
# # # . .
# # . . .
# . # . .
. . . # .
. . . . #`);
default: return images.createImage(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`);
}
}
//% weight=50 blockGap=8
//% help=images/icon-image
//% blockId=builtin_image block="icon image %i"
@ -387,173 +210,6 @@ namespace images {
. . # . .
. # . # .
# . . . #`);
case IconNames.Triangle: return images.createImage(`
. . . . .
. . # . .
. # . # .
# # # # #
. . . . .`);
case IconNames.LeftTriangle: return images.createImage(`
# . . . .
# # . . .
# . # . .
# . . # .
# # # # #`);
case IconNames.Chessboard: return images.createImage(`
. # . # .
# . # . #
. # . # .
# . # . #
. # . # .`);
case IconNames.Diamond: return images.createImage(`
. . # . .
. # . # .
# . . . #
. # . # .
. . # . .`);
case IconNames.SmallDiamond: return images.createImage(`
. . . . .
. . # . .
. # . # .
. . # . .
. . . . .`);
case IconNames.Square: return images.createImage(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #`);
case IconNames.SmallSquare: return images.createImage(`
. . . . .
. # # # .
. # . # .
. # # # .
. . . . .`);
case IconNames.Scissors: return images.createImage(`
# # . . #
# # . # .
. . # . .
# # . # .
# # . . #`);
// The following images were designed by Abbie Brooks.
case IconNames.TShirt: return images.createImage(`
# # . # #
# # # # #
. # # # .
. # # # .
. # # # .`);
case IconNames.Rollerskate: return images.createImage(`
. . . # #
. . . # #
# # # # #
# # # # #
. # . # .`);
case IconNames.Duck: return images.createImage(`
. # # . .
# # # . .
. # # # #
. # # # .
. . . . .`);
case IconNames.House: return images.createImage(`
. . # . .
. # # # .
# # # # #
. # # # .
. # . # .`);
case IconNames.Tortoise: return images.createImage(`
. . . . .
. # # # .
# # # # #
. # . # .
. . . . .`);
case IconNames.Butterfly: return images.createImage(`
# # . # #
# # # # #
. . # . .
# # # # #
# # . # #`);
case IconNames.StickFigure: return images.createImage(`
. . # . .
# # # # #
. . # . .
. # . # .
# . . . #`);
case IconNames.Ghost: return images.createImage(`
. # # # .
# . # . #
# # # # #
# # # # #
# . # . #`);
case IconNames.Sword: return images.createImage(`
. . # . .
. . # . .
. . # . .
. # # # .
. . # . .`);
case IconNames.Giraffe: return images.createImage(`
# # . . .
. # . . .
. # . . .
. # # # .
. # . # .`);
case IconNames.Skull: return images.createImage(`
. # # # .
# . # . #
# # # # #
. # # # .
. # # # .`);
case IconNames.Umbrella: return images.createImage(`
. # # # .
# # # # #
. . # . .
# . # . .
# # # . .`);
case IconNames.Snake: return images.createImage(`
# # . . .
# # . # #
. # . # .
. # # # .
. . . . .`);
// animals
case IconNames.Rabbit: return images.createImage(`
# . # . .
# . # . .
# # # # .
# # . # .
# # # # .`);
case IconNames.Cow: return images.createImage(`
# . . . #
# . . . #
# # # # #
. # # # .
. . # . .`);
// musical notes
case IconNames.QuarterNote: return images.createImage(`
. . # . .
. . # . .
. . # . .
# # # . .
# # # . .`);
case IconNames.EigthNote: return images.createImage(`
. . # . .
. . # # .
. . # . #
# # # . .
# # # . .`);
// other icons
case IconNames.Pitchfork: return images.createImage(`
# . # . #
# . # . #
# # # # #
. . # . .
. . # . .`);
case IconNames.Target: return images.createImage(`
. . # . .
. # # # .
# # . # #
. # # # .
. . # . .`);
// arrows
case IconNames.ArrowNorth: return images.createImage(`
. . # . .
@ -613,12 +269,4 @@ namespace images {
}
}
//% weight=50 blockGap=8
//% help=images/arrow-number
//% blockId=device_arrow block="%arrow"
//% shim=TD_ID
//% deprecated=true
export function arrowNumber(arrow: ArrowNames): number {
return arrow;
}
}

View File

@ -83,9 +83,11 @@ void plotImage(Image i, int xOffset = 0) {
/**
* Shows an frame from the image at offset ``x offset``.
* @param xOffset column index to start displaying the image
* @param interval time in milliseconds to pause after drawing
*/
//% help=images/show-image weight=80 blockNamespace=images
//% blockId=device_show_image_offset block="show image %sprite(myImage)|at offset %offset"
//% blockId=device_show_image_offset block="show image %sprite(myImage)|at offset %offset ||and interval (ms) %interval"
//% interval.defl=400
//% blockGap=8 parts="ledmatrix" async
void showImage(Image sprite, int xOffset, int interval = 400) {
uBit.display.print(MicroBitImage(sprite->img), -xOffset, 0, 0, interval);
@ -109,7 +111,7 @@ void plotFrame(Image i, int xOffset) {
*/
//% help=images/scroll-image weight=79 async blockNamespace=images
//% blockId=device_scroll_image
//% block="scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %delay"
//% block="scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %interval"
//% blockGap=8 parts="ledmatrix"
void scrollImage(Image id, int frameOffset, int interval) {
MicroBitImage i(id->img);

View File

@ -7,6 +7,21 @@ enum class Button {
AB = MICROBIT_ID_BUTTON_AB,
};
enum class ButtonEvent {
//% blockIdentity="input.buttonEventValueId"
//% block="pressed down"
Down = MICROBIT_BUTTON_EVT_DOWN,
//% blockIdentity="input.buttonEventValueId"
//% block="released up"
Up = MICROBIT_BUTTON_EVT_UP,
//% blockIdentity="input.buttonEventValueId"
//% block="clicked"
Click = MICROBIT_BUTTON_EVT_CLICK,
//% blockIdentity="input.buttonEventValueId"
//% block="long clicked"
LongClick = MICROBIT_BUTTON_EVT_LONG_CLICK,
};
enum class Dimension {
//% block=x
X = 0,
@ -161,6 +176,21 @@ enum class MesDpadButtonInfo {
//% color=#B4009E weight=99 icon="\uf192"
namespace input {
/**
* Do something when a button (A, B or both A+B) receives an event.
* @param button the button
* @param body code to run when event is raised
* @param eventType event Type
*/
//% help=input/on-button-event weight=100 blockGap=16
//% blockId=device_button_selected_event block="on button %NAME| %eventType=control_button_event_value_id"
//% parts="buttonpair"
//% group="Events"
void onButtonEvent(Button button, int eventType, Action body) {
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
@ -169,6 +199,8 @@ namespace input {
//% 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);
}
@ -178,10 +210,11 @@ namespace input {
* @param gesture the type of gesture to track, eg: Gesture.Shake
* @param body code to run when gesture is raised
*/
//% help=input/on-gesture weight=84 blockGap=16
//% help=input/on-gesture weight=98 blockGap=16
//% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer"
//% NAME.fieldEditor="gestures" NAME.fieldOptions.columns=4
//% group="Events"
void onGesture(Gesture gesture, Action body) {
int gi = (int)gesture;
if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
@ -195,10 +228,11 @@ namespace input {
* Tests if a gesture is currently detected.
* @param gesture the type of gesture to detect, eg: Gesture.Shake
*/
//% help=input/is-gesture weight=10 blockGap=8
//% help=input/is-gesture weight=86 blockGap=8
//% blockId=deviceisgesture block="is %gesture gesture"
//% parts="accelerometer"
//% gesture.fieldEditor="gestures" gesture.fieldOptions.columns=4
//% group="States"
bool isGesture(Gesture gesture) {
// turn on acceleration
uBit.accelerometer.getX();
@ -206,13 +240,33 @@ 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
* @param body the code to run when event is fired on pin
*/
//% help=input/on-pin-touch weight=99 blockGap=16
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
//% group="Events"
void onPinTouchEvent(TouchPin name, int eventType, 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, 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=32
//% 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;
@ -230,6 +284,8 @@ namespace input {
//% 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;
@ -243,11 +299,12 @@ namespace input {
* Get the button state (pressed or not) for ``A`` and ``B``.
* @param button the button to query the request, eg: Button.A
*/
//% help=input/button-is-pressed weight=60
//% help=input/button-is-pressed weight=89
//% block="button|%NAME|is pressed"
//% blockId=device_get_button2
//% icon="\uf192" blockGap=8
//% parts="buttonpair"
//% group="States"
bool buttonIsPressed(Button button) {
if (button == Button::A)
return uBit.buttonA.isPressed();
@ -262,9 +319,10 @@ namespace input {
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch, eg: TouchPin.P0
*/
//% help=input/pin-is-pressed weight=58
//% help=input/pin-is-pressed weight=87
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
//% blockGap=8
//% group="States"
bool pinIsPressed(TouchPin name) {
auto pin = getPin((int)name);
return pin && pin->isTouched();
@ -284,6 +342,7 @@ namespace input {
//% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer"
//% group="Sensors"
int acceleration(Dimension dimension) {
switch (dimension) {
case Dimension::X: return uBit.accelerometer.getX();
@ -297,13 +356,37 @@ namespace input {
/**
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
*/
//% help=input/light-level weight=57
//% help=input/light-level weight=59
//% blockId=device_get_light_level block="light level" blockGap=8
//% parts="ledmatrix"
//% group="Sensors"
int lightLevel() {
return uBit.display.readLightLevel();
}
/**
* gets the level of loudness from 0 (silent) to 255 (loud)
*/
//% blockId="soundLevel" weight=58
//% block="soundLevel" blockGap=8
//% group="Sensors"
int soundLevel() {
int level = uBit.io.P21.getAnalogValue();
int min = level;
int max = level;
for (int i = 0; i < 32; i++) {
level = uBit.io.P21.getAnalogValue();
if (level > max) {
max = level;
} else if (level < min) {
min = level;
}
}
level = floor((max - min + 0.5) / 4); //max can be up to 1023; + 0,5 to prevent division by 0, floor to get rid of decimals, divide by 4 to get a value between 0 and 255
return level;
}
/**
* Get the current compass heading in degrees.
*/
@ -311,6 +394,7 @@ namespace input {
//% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass"
//% group="Sensors"
int compassHeading() {
return uBit.compass.heading();
}
@ -319,10 +403,11 @@ namespace input {
/**
* Gets the temperature in Celsius degrees (°C).
*/
//% weight=55
//% weight=57
//% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer"
//% group="Sensors"
int temperature() {
return uBit.thermometer.getTemperature();
}
@ -334,6 +419,7 @@ namespace input {
//% help=input/rotation weight=52
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
//% parts="accelerometer" advanced=true
//% group="Sensors"
int rotation(Rotation kind) {
switch (kind) {
case Rotation::Pitch: return uBit.accelerometer.getPitch();
@ -346,10 +432,11 @@ namespace input {
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
* @param dimension the x, y, or z dimension, eg: Dimension.X
*/
//% help=input/magnetic-force weight=51
//% help=input/magnetic-force weight=49
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
//% parts="compass"
//% advanced=true
//% group="Sensors"
TNumber magneticForce(Dimension dimension) {
if (!uBit.compass.isCalibrated())
uBit.compass.calibrate();
@ -368,20 +455,58 @@ namespace input {
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_calibrate" block="calibrate compass"
//% weight=45
//% weight=20 gap=8
//% group="Configuration"
void calibrateCompass() {
uBit.compass.calibrate();
}
/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System"
bool isCalibratedCompass() {
return (uBit.compass.isCalibrated() == 1);
}
/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_clear_calibration" block="clear calibration compass"
//% weight=17
//% group="Configuration"
//% blockHidden=true
void clearCalibrationCompass() {
uBit.compass.clearCalibration();
}
/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_assume_calibration" block="assume calibration compass"
//% weight=16
//% group="Configuration"
//% blockHidden=true
void assumeCalibrationCompass() {
uBit.compass.assumeCalibration();
}
/**
* Sets the accelerometer sample range in gravities.
* @param range a value describe the maximum strengh of acceleration measured
*/
//% help=input/set-accelerometer-range
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
//% weight=5
//% weight=22 gap=8
//% parts="accelerometer"
//% advanced=true
//% group="Configuration"
void setAccelerometerRange(AcceleratorRange range) {
uBit.accelerometer.setRange((int)range);
}

View File

@ -1,69 +1,26 @@
/**
* Events and data from sensors
*/
//% color=#C90072 weight=99
//% color=#C90072 weight=99 icon="\uf192"
//% groups=['Events', 'States', 'Sensors', 'Configuration', 'System', 'others']
namespace input {
/**
* Attaches code to run when the screen is facing up.
* @param body TODO
* Returns the value of a C++ runtime constant
*/
//% help=input/on-screen-up
export function onScreenUp(body: () => void): void {
onGesture(Gesture.ScreenUp, body);
//% weight=1 weight=19 blockId="control_button_event_value_id" block="%id"
//% shim=TD_ID advanced=true
//% blockHidden=true
export function buttonEventValueId(id: ButtonEvent): number {
return id;
}
/**
* Attaches code to run when the screen is facing down.
* @param body TODO
*/
//% help=input/on-screen-down
export function onScreenDown(body: () => void): void {
onGesture(Gesture.ScreenDown, body);
}
/**
* Attaches code to run when the device is shaken.
* @param body TODO
*/
//% deprecated=true
//% help=input/on-shake
export function onShake(body: () => void): void {
onGesture(Gesture.Shake, body);
}
/**
* Attaches code to run when the logo is oriented upwards and the board is vertical.
* @param body TODO
*/
//% help=input/on-logo-up
export function onLogoUp(body: () => void): void {
onGesture(Gesture.LogoUp, body);
}
/**
* Attaches code to run when the logo is oriented downwards and the board is vertical.
* @param body TODO
*/
//% help=input/on-logo-down
export function onLogoDown(body: () => void): void {
onGesture(Gesture.LogoDown, body);
}
/**
* Obsolete, use input.calibrateCompass instead.
*/
//% weight=0 help=input/calibrate-compass
export function calibrate() {
input.calibrateCompass();
}
/**
* Gets the number of milliseconds elapsed since power on.
*/
//% help=input/running-time weight=50 blockGap=8
//% blockId=device_get_running_time block="running time (ms)"
//% advanced=true
//% group="System"
export function runningTime() {
return control.millis();
}
@ -71,33 +28,12 @@ namespace input {
/**
* Gets the number of microseconds elapsed since power on.
*/
//% help=input/running-time-micros weight=49
//% help=input/running-time-micros weight=49 blockGap=8
//% blockId=device_get_running_time_micros block="running time (micros)"
//% advanced=true
//% group="System"
export function runningTimeMicros() {
return control.micros();
}
/**
* gets the level of loudness in 0-100%
*/
//% blockId="loudness"
//% block="Loudness"
export function soundLevel(): number {
let value = 0
let max = 0
let min = 1023
for (let index = 0; index < 32; index++) {
value = pins.analogReadPin(AnalogPin.MIC)
if (value > max) {
max = value
} else if (value < min) {
min = value
}
}
value = (max - min) * 977 / 10000
return value
}
}

View File

@ -1,7 +1,41 @@
#include "pxt.h"
#if MICROBIT_CODAL
#include "neopixel.h"
// WS2812B timings, datasheet v1
// 0 - 0.25-0.55us hi 0.70-1.00us low
// 1 - 0.65-0.95us hi 0.30-0.60us low
// datasheet v5
// 0 - 0.22-0.38us hi 0.58-1.00us low
// 1 - 0.58-1.00us hi 0.58-1.00us low
// nrf52 asm timings:
// 0 0.34 - 0.78
// 1 0.80 - 0.59
extern "C" void __attribute__((long_call, section(".data")))
neopixel_send_buffer_nrf52(void *port500, uint32_t pinbr, const uint8_t *ptr, int numBytes);
__attribute__((noinline)) static void
neopixel_send_buffer_brightness(DevicePin &pin, const uint8_t *ptr, int numBytes, uint32_t br) {
if (br > 0x100)
br = 0x100;
pin.setDigitalValue(0);
target_wait_us(300); // initial reset
auto port = pin.name < 32 ? NRF_P0 : NRF_P1;
__disable_irq();
neopixel_send_buffer_nrf52((uint8_t *)(void *)port + 0x500, (pin.name & 31) | (br << 20), ptr,
numBytes);
__enable_irq();
}
static void neopixel_send_buffer(DevicePin &pin, const uint8_t *ptr, int numBytes) {
neopixel_send_buffer_brightness(pin, ptr, numBytes, 0x100);
}
#else
extern "C" void neopixel_send_buffer_core(DevicePin *pin, const uint8_t *ptr, int numBytes);
__attribute__((noinline)) static void neopixel_send_buffer(DevicePin &pin, const uint8_t *ptr,
@ -9,19 +43,32 @@ __attribute__((noinline)) static void neopixel_send_buffer(DevicePin &pin, const
// setup pin as digital
pin.setDigitalValue(0);
wait_us(300); // initial reset
__disable_irq();
neopixel_send_buffer_core(&pin, ptr, numBytes);
__enable_irq();
}
extern "C" void neopixel_send_buffer_brightness_core(DevicePin *pin, const uint8_t *ptr,
int numBytes, int br);
__attribute__((noinline)) static void
neopixel_send_buffer_brightness(DevicePin &pin, const uint8_t *ptr, int numBytes, int br) {
// setup pin as digital
pin.setDigitalValue(0);
wait_us(300); // initial reset
__disable_irq();
neopixel_send_buffer_brightness_core(&pin, ptr, numBytes, br);
__enable_irq();
}
#endif
namespace light {
/**
* Sends a color buffer to a light strip
**/
* Sends a color buffer to a light strip
**/
//% advanced=true
//%
void sendWS2812Buffer(Buffer buf, int pin) {
if (!buf || !buf->length)
return;
@ -29,12 +76,21 @@ void sendWS2812Buffer(Buffer buf, int pin) {
}
/**
* Sets the light mode of a pin
**/
* Sends a color buffer to a light strip
**/
//% advanced=true
//%
void setMode(int pin, int mode) {
void sendWS2812BufferWithBrightness(Buffer buf, int pin, int brightness) {
if (!buf || !buf->length)
return;
neopixel_send_buffer_brightness(*pxt::getPin(pin), buf->data, buf->length, brightness);
}
/**
* Sets the light mode of a pin
**/
//% advanced=true
//%
void setMode(int pin, int mode) {}
} // namespace light

38
libs/core/loops.ts Normal file
View File

@ -0,0 +1,38 @@
namespace loops {
/**
* Repeats the code forever in the background.
* After each iteration, allows other codes to run for a set duration
* so that it runs on a timer
* @param interval time (in ms) to wait between each iteration of the action.
* @param body code to execute
*/
//% weight=45 blockAllowMultiple=1
//% interval.shadow=longTimePicker
//% afterOnStart=true help=loops/every-interval
//% blockId=every_interval block="every $interval ms"
export function everyInterval(interval: number, a: () => void): void {
control.runInParallel(() => {
let start = 0;
let now = 0;
while (true) {
start = control.millis();
a();
now = control.millis();
pause(Math.max(0, interval - (now - start)));
}
});
}
/**
* Get the time field editor
* @param ms time duration in milliseconds, eg: 500, 1000
*/
//% blockId=longTimePicker block="%ms"
//% blockHidden=true shim=TD_ID
//% colorSecondary="#FFFFFF"
//% ms.fieldEditor="numberdropdown" ms.fieldOptions.decompileLiterals=true
//% ms.fieldOptions.data='[["100 ms", 100], ["200 ms", 200], ["500 ms", 500], ["1 second", 1000], ["1 minute", 60000], ["1 hour", 3600000]]'
export function __timePicker(ms: number): number {
return ms;
}
}

27
libs/core/microphone.ts Normal file
View File

@ -0,0 +1,27 @@
/**
* Events and data from sensors
*/
//% color=#C90072 weight=99
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
}
}

View File

@ -27,7 +27,8 @@ namespace motors {
*/
//% blockId=motor_on block="motor on at %percent \\%"
//% parts=dcmotor weight=90 blockGap=8
//% percent.shadow="speedPicker"
//% percent.shadow="speedPicker"
//% power.defl=100
void motorPower(int power) {
uBit.soundmotor.motorOn(power);
}
@ -51,20 +52,26 @@ namespace motors {
//% blockId=block_dual_motor block="motor %motor|at %percent \\%"
//% percent.shadow="speedPicker"
//% weight=80
//% duty_percent.defl=100
void dualMotorPower(Motor motor, int duty_percent) {
switch(motor) {
case Motor::A: if (duty_percent <= 0) uBit.soundmotor.motorAOff();
else uBit.soundmotor.motorAOn(duty_percent); break;
case Motor::B: if (duty_percent <= 0) uBit.soundmotor.motorBOff();
else uBit.soundmotor.motorBOn(duty_percent); break;
case Motor::AB: if (duty_percent <= 0) {
uBit.soundmotor.motorAOff();
uBit.soundmotor.motorBOff();
} else {
uBit.soundmotor.motorAOn(duty_percent);
uBit.soundmotor.motorBOn(duty_percent);
}
break;
case Motor::A:
if (duty_percent <= 0) uBit.soundmotor.motorAOff();
else uBit.soundmotor.motorAOn(duty_percent);
break;
case Motor::B:
if (duty_percent <= 0) uBit.soundmotor.motorBOff();
else uBit.soundmotor.motorBOn(duty_percent);
break;
case Motor::AB:
if (duty_percent <= 0) {
uBit.soundmotor.motorAOff();
uBit.soundmotor.motorBOff();
} else {
uBit.soundmotor.motorAOn(duty_percent);
uBit.soundmotor.motorBOn(duty_percent);
}
break;
}
}
}

View File

@ -1,5 +1,10 @@
#include "pxt.h"
namespace pins {
void analogSetPitchVolume(int volume);
int analogPitchVolume();
}
namespace music {
/**
* Plays a tone through ``speaker`` for the given duration.
@ -18,4 +23,41 @@ namespace music {
}
/**
* Set the default output volume of the sound synthesizer.
* @param volume the volume 0...255
*/
//% blockId=synth_set_volume block="set volume %volume"
//% volume.min=0 volume.max=255
//% volume.defl=127
//% help=music/set-volume
//% weight=70
//% group="Volume"
//% blockGap=8
//% blockHidden=true
void setVolume(int volume) {
#if MICROBIT_CODAL
uBit.audio.setVolume(max(0, min(255, volume)));
#else
pins::analogSetPitchVolume(volume);
#endif
}
/**
* Returns the current output volume of the sound synthesizer.
*/
//% blockId=synth_get_volume block="volume"
//% help=music/volume
//% weight=69
//% group="Volume"
//% blockGap=8
//% blockHidden=true
int volume() {
#if MICROBIT_CODAL
return uBit.audio.getVolume();
#else
return pins::analogPitchVolume();
#endif
}
}

View File

@ -223,7 +223,7 @@ namespace music {
//% help=music/rest weight=79
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
//% parts="speaker"
//% group="Tone"
//% group="Silence"
export function rest(ms: number): void {
playTone(0, ms);
}
@ -233,7 +233,7 @@ namespace music {
* Gets the frequency of a note.
* @param name the note name
*/
//% weight=50 help=music/note-frequency
//% weight=50
//% blockId=device_note block="%name"
//% shim=TD_ID color="#FFFFFF" colorSecondary="#FFFFFF"
//% name.fieldEditor="note" name.defl="262"
@ -241,6 +241,7 @@ namespace music {
//% useEnumVal=1
//% group="Tone"
//% blockGap=8
//% blockHidden=true
export function noteFrequency(name: Note): number {
return name;
}
@ -289,6 +290,7 @@ namespace music {
//% help=music/change-tempo-by weight=39
//% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8
//% group="Tempo"
//% weight=100
export function changeTempoBy(bpm: number): void {
init();
setTempo(beatsPerMinute + bpm);
@ -302,6 +304,7 @@ namespace music {
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
//% bpm.min=4 bpm.max=400
//% group="Tempo"
//% weight=99
export function setTempo(bpm: number): void {
init();
if (bpm > 0) {
@ -330,6 +333,7 @@ namespace music {
//% blockId=melody_on_event block="music on %value"
//% help=music/on-event weight=59 blockGap=32
//% group="Melody Advanced"
//% blockHidden=true
export function onEvent(value: MusicEvent, handler: () => void) {
control.onEvent(MICROBIT_MELODY_ID, value, handler);
}
@ -354,6 +358,7 @@ namespace music {
//% blockId=device_start_melody block="start melody %melody=device_builtin_melody| repeating %options"
//% parts="speaker"
//% group="Melody Advanced"
//% blockHidden=true
export function startMelody(melodyArray: string[], options: MelodyOptions = 1) {
init();
if (currentMelody != undefined) {
@ -453,7 +458,7 @@ namespace music {
//% help=music/stop-melody weight=59 blockGap=16
//% blockId=device_stop_melody block="stop melody $options"
//% parts="speaker"
//% group="Melody Advanced"
//% group="Silence"
export function stopMelody(options: MelodyStopOptions) {
if (options & MelodyStopOptions.Background)
startMelody([], MelodyOptions.OnceInBackground);
@ -461,6 +466,19 @@ namespace music {
startMelody([], MelodyOptions.Once);
}
/**
* Stop all sounds and melodies currently playing.
*/
//% help=music/stop-all-sounds
//% blockId=music_stop_all_sounds block="stop all sounds"
//% weight=10
//% group="Silence"
export function stopAllSounds() {
rest(0);
stopMelody(MelodyStopOptions.All);
}
/**
* Sets a custom playTone function for playing melodies
*/
@ -471,35 +489,6 @@ namespace music {
_playTone = f;
}
/**
* Set the default output volume of the sound synthesizer.
* @param volume the volume 0...255
*/
//% blockId=synth_set_volume block="set volume %volume"
//% parts="speaker"
//% volume.min=0 volume.max=255
//% volume.defl=127
//% help=music/set-volume
//% weight=70
//% group="Volume"
//% deprecated=true
export function setVolume(volume: number): void {
pins.analogSetPitchVolume(volume);
}
/**
* Returns the current output volume of the sound synthesizer.
*/
//% blockId=synth_get_volume block="volume"
//% parts="speaker"
//% help=music/volume
//% weight=69
//% group="Volume"
//% deprecated=true
export function volume(): number {
return pins.analogPitchVolume();
}
function playNextNote(melody: Melody): void {
// cache elements
let currNote = melody.nextNote();

View File

@ -1,5 +1,12 @@
#include "pxt.h"
#if MICROBIT_CODAL
#include "Pin.h"
#define PinCompat codal::Pin
#else
#define PinCompat MicroBitPin
#endif
enum class DigitalPin {
P0 = MICROBIT_ID_IO_P12, // edge connector 0
P1 = MICROBIT_ID_IO_P0, // edge connector 1
@ -217,6 +224,17 @@ namespace pins {
MicroBitPin* pin = getPin((int)name);
if (!pin) return 0;
#if MICROBIT_CODAL
// set polarity
pin->setPolarity(PulseValue::High == value ? 1 : 0);
// record pulse
int period = pin->getPulseUs(maxDuration);
// timeout
if (DEVICE_CANCELLED == period)
return 0;
// success!
return period;
#else
int pulse = value == PulseValue::High ? 1 : 0;
uint64_t tick = system_timer_current_time_us();
uint64_t maxd = (uint64_t)maxDuration;
@ -232,6 +250,7 @@ namespace pins {
}
uint64_t end = system_timer_current_time_us();
return end - start;
#endif
}
// TODO FIX THIS IN THE DAL!
@ -257,7 +276,6 @@ namespace pins {
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
void servoWritePin(AnalogPin name, int value) {
fixMotorIssue(name);
PINOP(setServoValue(value));
}
@ -284,9 +302,10 @@ namespace pins {
}
MicroBitPin* pitchPin = NULL;
MicroBitPin* pitchPin2 = NULL;
PinCompat* pitchPin = NULL;
PinCompat* pitchPin2 = NULL;
uint8_t pitchVolume = 0xff;
bool analogTonePlaying = false;
/**
* Set the pin used when using analog pitch or music.
@ -296,12 +315,13 @@ namespace pins {
//% help=pins/analog-set-pitch-pin weight=3 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% blockHidden=true
void analogSetPitchPin(AnalogPin name) {
pitchPin = getPin((int)name);
pitchPin2 = NULL;
}
void pinAnalogSetPitch(MicroBitPin* pin, int frequency, int ms) {
void pinAnalogSetPitch(PinCompat* pin, int frequency, int ms) {
if (frequency <= 0 || pitchVolume == 0) {
pin->setAnalogValue(0);
} else {
@ -318,8 +338,15 @@ namespace pins {
//% blockId=device_analog_set_pitch_volume block="analog set pitch volume $volume"
//% help=pins/analog-set-pitch-volume weight=3 advanced=true
//% volume.min=0 volume.max=255
//% blockHidden=true
void analogSetPitchVolume(int volume) {
pitchVolume = max(0, min(0xff, volume));
if (analogTonePlaying) {
int v = pitchVolume == 0 ? 0 : 1 << (pitchVolume >> 5);
if (NULL != pitchPin)
pitchPin->setAnalogValue(v);
}
}
/**
@ -327,6 +354,7 @@ namespace pins {
*/
//% blockId=device_analog_pitch_volume block="analog pitch volume"
//% help=pins/analog-pitch-volume weight=3 advanced=true
//% blockHidden=true
int analogPitchVolume() {
return pitchVolume;
}
@ -338,6 +366,7 @@ namespace pins {
*/
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
//% blockHidden=true
void analogPitch(int frequency, int ms) {
// init pins if needed
if (NULL == pitchPin) {
@ -347,6 +376,7 @@ namespace pins {
#endif
}
// set pitch
analogTonePlaying = true;
if (NULL != pitchPin)
pinAnalogSetPitch(pitchPin, frequency, ms);
if (NULL != pitchPin2)
@ -356,9 +386,9 @@ namespace pins {
fiber_sleep(ms);
if (NULL != pitchPin)
pitchPin->setAnalogValue(0);
if (NULL != pitchPin2)
pitchPin2->setAnalogValue(0);
fiber_sleep(5);
analogTonePlaying = false;
// causes issues with v2 DMA.
// fiber_sleep(5);
}
}
@ -373,7 +403,7 @@ namespace pins {
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
void setPull(DigitalPin name, PinPullMode pull) {
#if MICROBIT_CODAL
#if MICROBIT_CODAL
codal::PullMode m = pull == PinPullMode::PullDown
? codal::PullMode::Down
: pull == PinPullMode::PullUp ? codal::PullMode::Up
@ -412,6 +442,21 @@ namespace pins {
return mkBuffer(NULL, size);
}
/**
* Set the matrix width for Neopixel strip (already assigned to a pin).
* Should be used in conjunction with `set matrix width` from Neopixel package.
* @param name pin of Neopixel strip, eg: DigitalPin.P1
* @param value width of matrix (at least ``2``)
*/
//% help=pins/neopixel-matrix-width weight=3 advanced=true
//% blockId=pin_neopixel_matrix_width block="neopixel matrix width|pin %pin %width" blockGap=8
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% width.defl=5 width.min=2
//% blockHidden=true
void setMatrixWidth(DigitalPin pin, int width) {}
#if MICROBIT_CODAL
#define BUFFER_TYPE uint8_t*
#else
@ -500,7 +545,7 @@ namespace pins {
//% blockId=spi_format block="spi format|bits %bits|mode %mode"
void spiFormat(int bits, int mode) {
auto p = allocSPI();
p->format(bits, mode);
p->format(bits, mode);
}
#if MICROBIT_CODAL
@ -534,10 +579,26 @@ namespace pins {
*/
//% help=pins/push-button advanced=true
void pushButton(DigitalPin pin) {
new MicroBitButton((PinName)getPin((int)(pin))->name, (int)pin, MICROBIT_BUTTON_ALL_EVENTS, PinMode::PullUp);
}
/**
* Set the pin used when producing sounds and melodies. Default is P0.
* @param name pin to modulate pitch from
*/
//% blockId=pin_set_audio_pin block="set audio pin $name"
//% help=pins/set-audio-pin weight=3
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% weight=1
//% blockHidden=true
void setAudioPin(AnalogPin name) {
#if MICROBIT_CODAL
new MicroBitButton(PIN_ARG(pin), (int)pin, DEVICE_BUTTON_ALL_EVENTS, ACTIVE_LOW, codal::PullMode::Up);
uBit.audio.setPin(*getPin((int)name));
uBit.audio.setPinEnabled(true);
#else
new MicroBitButton(PIN_ARG(pin), PinMode::PullUp);
// v1 behavior
pins::analogSetPitchPin(name);
#endif
}
}
}

View File

@ -45,6 +45,7 @@ typedef RefMImage *Image;
extern MicroBit uBit;
extern MicroBitEvent lastEvent;
extern bool serialLoggingDisabled;
MicroBitPin *getPin(int id);

View File

@ -33,12 +33,16 @@
"gestures.jres",
"control.ts",
"control.cpp",
"controlgc.cpp",
"perfcounters.ts",
"interval.ts",
"gcstats.ts",
"console.ts",
"game.ts",
"led.cpp",
"led.ts",
"loops.ts",
"microphone.ts",
"motors.cpp",
"music.cpp",
"music.ts",
@ -49,12 +53,19 @@
"serial.ts",
"buffer.cpp",
"buffer.ts",
"json.ts",
"poll.ts",
"controlmessage.ts",
"pxtparts.json",
"advmath.cpp",
"trig.cpp",
"fixed.ts",
"templates.ts",
"sendbuffer.s",
"sendbuffernrf52.s",
"sendbufferbrightness.s",
"storage.cpp",
"storage.ts",
"light.cpp",
"compass.ts",
"parts/speaker.svg",
@ -94,65 +105,65 @@
"yotta": {
"config": {
"microbit-dal": {
"fiber_user_data": 1
"fiber_user_data": 1,
"pxt": 1
}
},
"optionalConfig": {
"microbit-dal": {
"bluetooth": {
"enabled": 1,
"pairing_mode": 1,
"private_addressing": 0,
"open": 1,
"security_level": null,
"whitelist": 1,
"advertising_timeout": 0,
"tx_power": 6,
"dfu_service": 1,
"event_service": 1,
"device_info_service": 1,
"eddystone_url": 1,
"eddystone_uid": 1,
"open": 0,
"pairing_mode": 1,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM",
"partial_flashing": 1
}
}
"event_service": 0,
"device_info_service": 0
},
"stack_size": 2048,
"gatt_table_size": "0x600",
"panic_on_heap_full": 0,
"debug": 0,
"heap_debug": 0,
"sram_end": "0x20008000"
},
"RAM_SIZE": "\"32K\""
},
"userConfigs": [
{
"description": "No Pairing Required: Anyone can connect via Bluetooth.",
"description": "Limit bluetooth access to BLE mode (A + B + Reset)",
"config": {
"microbit-dal": {
"bluetooth": {
"open": 1,
"whitelist": 0,
"security_level": null
"enabled": 0
}
}
}
},
{
"description": "JustWorks pairing (default): Pairing is automatic once the pairing is initiated.",
"description": "32K RAM (mini v2 and some v1.3)",
"config": {
"microbit-dal": {
"bluetooth": {
"open": 0,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
}
}
"stack_size": 2048,
"sram_end": "0x20008000"
},
"RAM_SIZE": "\"32K\""
}
},
{
"description": "Passkey pairing: Pairing requires 6 digit key to pair.",
"description": "16K RAM (mini v1.3 and below)",
"config": {
"microbit-dal": {
"bluetooth": {
"open": 0,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
}
}
"stack_size": 1280,
"sram_end": "0x20004000"
},
"RAM_SIZE": "\"16K\""
}
}
]
}
}
}

View File

@ -16,14 +16,13 @@ void debuglog(const char *format, ...);
#define GC_MAX_ALLOC_SIZE 9000
#define GC_BLOCK_SIZE 256
#define NON_GC_HEAP_RESERVATION 1024
#ifdef CODAL_CONFIG_H
#define MICROBIT_CODAL 1
#else
#define MICROBIT_CODAL 0
#define GC_BLOCK_SIZE 256
#endif
#if !MICROBIT_CODAL

View File

@ -0,0 +1,53 @@
.syntax unified
.section .text.neopixel_send_buffer_brightness_core
.global neopixel_send_buffer_brightness_core
neopixel_send_buffer_brightness_core:
push {r4,r5,r6,r7,lr}
mov r4, r1 // ptr
mov r5, r2 // len
mov r7, r3 // get the brightness figure
ldr r0, [r0, #8] // get mbed DigitalOut from MicroBitPin
ldr r1, [r0, #4] // r1-mask for this pin
ldr r2, [r0, #16] // r2-clraddr
ldr r3, [r0, #12] // r3-setaddr
b .start
.nextbit: // C0
str r1, [r3, #0] // pin := hi C2
tst r6, r0 // C3
bne .islate // C4
str r1, [r2, #0] // pin := lo C6
.islate:
lsrs r6, r6, #1 // r6 >>= 1 C7
bne .justbit // C8
// not just a bit - need new byte
adds r4, #1 // r4++ C9
subs r5, #1 // r5-- C10
bcc .stop // if (r5<0) goto .stop C11
.start:
movs r6, #0x80 // reset mask C12
ldrb r0, [r4, #0] // r0 := *r4
muls r0, r7 // hope we have single cycle multiplier...
lsrs r0, r0, #8 // r0 >>= 8 following multiplication
.common: // C13
str r1, [r2, #0] // pin := lo C15
nop // twiddle
nop // twaddle
b .nextbit // C20
.justbit: // C10
// no nops, branch taken is already 3 cycles
b .common // C13
.stop:
str r1, [r2, #0] // pin := lo
pop {r4,r5,r6,r7,pc}

View File

@ -0,0 +1,82 @@
.syntax unified
#ifndef NRF51
// put it in RAM
.section .data.neopixel_send_buffer_nrf52
.global neopixel_send_buffer_nrf52
.thumb
.type neopixel_send_buffer_nrf52, %function
neopixel_send_buffer_nrf52:
push {r4,r5,r6,r7,lr}
lsrs r7, r1, #20 // r7 - brightness
ands r1, #0xff
movs r4, #1
lsls r1, r4, r1 // r1 - mask
mov r4, r2 // ptr
mov r5, r3 // len
mov r3, r0 // port+0x500
b .start
.nextbit:
str r1, [r3, #0x8] // pin := hi
movs r2, #8
tst r6, r0
it eq
movseq r2, #3
.d1:
subs r2, #1
bne .d1
str r1, [r3, #0xC] // pin := lo
movs r2, #4
tst r6, r0
it eq
movseq r2, #6
lsrs r6, r6, #1 // r6 >>= 1
beq .reload
nop
nop
nop
.d0:
subs r2, #1
bne .d0
b .nextbit
.reload:
subs r2, #2 // offset following operations
.d2:
subs r2, #1
bne .d2
// not just a bit - need new byte
adds r4, #1 // r4++
subs r5, #1 // r5--
ble .stop // if (r5<=0) goto .stop
.start:
movs r6, #0x80 // reset mask
ldrb r0, [r4, #0] // r0 := *r4
muls r0, r7
lsrs r0, r0, #8 // r0 >>= 8
str r1, [r3, #0xC] // pin := lo
b .nextbit //
.stop:
str r1, [r3, #0xC] // pin := lo
pop {r4,r5,r6,r7,pc}
#endif

View File

@ -106,24 +106,29 @@ namespace serial {
}
/**
* Read multiple characters from the receive buffer. Pause until enough characters are present.
* @param length default buffer length, eg: 64
* Read multiple characters from the receive buffer.
* If length is positive, pauses until enough characters are present.
* @param length default buffer length
*/
//% blockId=serial_readbuffer block="serial|read buffer %length"
//% help=serial/read-buffer advanced=true weight=5
Buffer readBuffer(int length) {
if (length <= 0)
length = MICROBIT_SERIAL_READ_BUFFER_LENGTH;
auto buf = mkBuffer(NULL, length);
int read = uBit.serial.read(buf->data, buf->length);
if (read != length) {
auto prev = buf;
buf = mkBuffer(buf->data, read);
decrRC(prev);
auto mode = SYNC_SLEEP;
if (length <= 0) {
length = uBit.serial.getRxBufferSize();
mode = ASYNC;
}
return buf;
auto buf = mkBuffer(NULL, length);
auto res = buf;
registerGCObj(buf); // make sure buffer is pinned, while we wait for data
int read = uBit.serial.read(buf->data, buf->length, mode);
if (read != length) {
res = mkBuffer(buf->data, read);
}
unregisterGCObj(buf);
return res;
}
bool tryResolvePin(SerialPin p, PinName& name) {

407
libs/core/shims.d.ts vendored
View File

@ -37,9 +37,11 @@ declare interface Image {
/**
* Shows an frame from the image at offset ``x offset``.
* @param xOffset column index to start displaying the image
* @param interval time in milliseconds to pause after drawing
*/
//% help=images/show-image weight=80 blockNamespace=images
//% blockId=device_show_image_offset block="show image %sprite(myImage)|at offset %offset"
//% blockId=device_show_image_offset block="show image %sprite(myImage)|at offset %offset ||and interval (ms) %interval"
//%
//% blockGap=8 parts="ledmatrix" async interval.defl=400 shim=ImageMethods::showImage
showImage(xOffset: int32, interval?: int32): void;
@ -58,7 +60,7 @@ declare interface Image {
*/
//% help=images/scroll-image weight=79 async blockNamespace=images
//% blockId=device_scroll_image
//% block="scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %delay"
//% block="scroll image %sprite(myImage)|with offset %frameoffset|and interval (ms) %interval"
//% blockGap=8 parts="ledmatrix" shim=ImageMethods::scrollImage
scrollImage(frameOffset: int32, interval: int32): void;
@ -127,67 +129,48 @@ declare interface Image {
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#1E90FF weight=116 icon="\uf00a"
declare namespace basic {
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_set_led_color
//% block="set led to %color=colorNumberPicker"
//% weight=50 shim=basic::setLedColor
function setLedColor(color: int32): void;
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_turn_rgb_led_off block="turn build-in LED off"
//% weight=50 shim=basic::turnRgbLedOff
function turnRgbLedOff(): void;
/**
* Draws an image on the LED screen.
* @param leds the pattern of LED to turn on/off
* @param interval time in milliseconds to pause after drawing
*/
//% help=basic/show-leds
//% weight=95 blockGap=8
//% weight=85 blockGap=8
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds" icon="\uf00a"
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
//% parts="ledmatrix"
//% group="LED matrix" interval.defl=400 shim=basic::showLeds
function showLeds(leds: string, interval?: int32): void;
/**
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
* @param text the text to scroll on the screen, eg: "hi!"
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
* @param interval how fast to shift characters; eg: 50, 100, 150, 200
*/
//% help=basic/show-string
//% weight=87 blockGap=16
//% block="show|string %text"
//% weight=100 blockGap=16
//% block="show|string %text || in an interval of %interval ms"
//% async
//% blockId=device_print_message
//% parts="ledmatrix"
//% text.shadowOptions.toString=true interval.defl=150 shim=basic::showString
//% text.shadowOptions.toString=true
//% expandableArgumentMode="toggle"
//%
//% group="LED matrix" interval.defl=80 shim=basic::showString
function showString(text: string, interval?: int32): void;
/**
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=79
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix"
//% advanced=true shim=basic::clearScreen
function clearScreen(): void;
/**
* Shows a sequence of LED screens as an animation.
* @param leds pattern of LEDs to turn on/off
* @param interval time in milliseconds between each redraw
*/
//% help=basic/show-animation imageLiteral=1 async
//% parts="ledmatrix" interval.defl=400 shim=basic::showAnimation
//% help=basic/show-animation weight=83 imageLiteral=1 async
//% parts="ledmatrix"
//% group="LED matrix" interval.defl=400 shim=basic::showAnimation
function showAnimation(leds: string, interval?: int32): void;
/**
@ -195,26 +178,57 @@ declare namespace basic {
* @param leds pattern of LEDs to turn on/off
*/
//% help=basic/plot-leds weight=80
//% parts="ledmatrix" imageLiteral=1 shim=basic::plotLeds
//% parts="ledmatrix"
//% group="LED matrix" imageLiteral=1 shim=basic::plotLeds
function plotLeds(leds: string): void;
/**
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=75
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix"
//% group="LED matrix"
//% advanced=true shim=basic::clearScreen
function clearScreen(): void;
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=basic/forever weight=55 blockGap=16 blockAllowMultiple=1 afterOnStart=true
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
//% blockId=device_forever block="forever" icon="\uf01e"
//% group="Control" shim=basic::forever
function forever(a: () => void): void;
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
//% help=basic/pause weight=54
//% help=basic/pause weight=50
//% async block="pause (ms) %pause" blockGap=16
//% blockId=device_pause icon="\uf110"
//% pause.shadow=timePicker shim=basic::pause
//% pause.shadow=timePicker
//% group="Control" shim=basic::pause
function pause(ms: int32): void;
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_set_led_color
//% block="set led to %color=colorNumberPicker"
//% weight=10
//% group="RGB LED" shim=basic::setLedColor
function setLedColor(color: int32): void;
/**
* Sets the color on the build-in LED. Set to 0 to turn off.
*/
//% blockId=device_turn_rgb_led_off block="turn build-in LED off"
//% weight=10
//% group="RGB LED"
//% advanced=true shim=basic::turnRgbLedOff
function turnRgbLedOff(): void;
}
@ -222,6 +236,18 @@ declare namespace basic {
//% color=#B4009E weight=99 icon="\uf192"
declare namespace input {
/**
* Do something when a button (A, B or both A+B) receives an event.
* @param button the button
* @param body code to run when event is raised
* @param eventType event Type
*/
//% help=input/on-button-event weight=100 blockGap=16
//% blockId=device_button_selected_event block="on button %NAME| %eventType=control_button_event_value_id"
//% parts="buttonpair"
//% 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
@ -229,7 +255,9 @@ declare namespace input {
*/
//% help=input/on-button-pressed weight=85 blockGap=16
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair" shim=input::onButtonPressed
//% parts="buttonpair"
//% deprecated=true
//% group="Events" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
/**
@ -237,29 +265,43 @@ declare namespace input {
* @param gesture the type of gesture to track, eg: Gesture.Shake
* @param body code to run when gesture is raised
*/
//% help=input/on-gesture weight=84 blockGap=16
//% help=input/on-gesture weight=98 blockGap=16
//% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer"
//% NAME.fieldEditor="gestures" NAME.fieldOptions.columns=4 shim=input::onGesture
//% NAME.fieldEditor="gestures" NAME.fieldOptions.columns=4
//% group="Events" shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void;
/**
* Tests if a gesture is currently detected.
* @param gesture the type of gesture to detect, eg: Gesture.Shake
*/
//% help=input/is-gesture weight=10 blockGap=8
//% help=input/is-gesture weight=86 blockGap=8
//% blockId=deviceisgesture block="is %gesture gesture"
//% parts="accelerometer"
//% gesture.fieldEditor="gestures" gesture.fieldOptions.columns=4 shim=input::isGesture
//% gesture.fieldEditor="gestures" gesture.fieldOptions.columns=4
//% group="States" shim=input::isGesture
function isGesture(gesture: Gesture): boolean;
/**
* Do something when a pin receives an touch event (while also touching the GND pin).
* @param name the pin, eg: TouchPin.P0
* @param body the code to run when event is fired on pin
*/
//% help=input/on-pin-touch weight=99 blockGap=16
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
//% 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=32
//% blockId=device_pin_event block="on pin %name|pressed" shim=input::onPinPressed
//% 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;
/**
@ -269,27 +311,31 @@ declare namespace input {
*/
//% help=input/on-pin-released weight=6 blockGap=16
//% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true shim=input::onPinReleased
//% 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
*/
//% help=input/button-is-pressed weight=60
//% help=input/button-is-pressed weight=89
//% block="button|%NAME|is pressed"
//% blockId=device_get_button2
//% icon="\uf192" blockGap=8
//% parts="buttonpair" shim=input::buttonIsPressed
//% parts="buttonpair"
//% group="States" shim=input::buttonIsPressed
function buttonIsPressed(button: Button): boolean;
/**
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch, eg: TouchPin.P0
*/
//% help=input/pin-is-pressed weight=58
//% help=input/pin-is-pressed weight=87
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
//% blockGap=8 shim=input::pinIsPressed
//% blockGap=8
//% group="States" shim=input::pinIsPressed
function pinIsPressed(name: TouchPin): boolean;
/**
@ -298,33 +344,45 @@ declare namespace input {
*/
//% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer" shim=input::acceleration
//% parts="accelerometer"
//% group="Sensors" shim=input::acceleration
function acceleration(dimension: Dimension): int32;
/**
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
*/
//% help=input/light-level weight=57
//% help=input/light-level weight=59
//% blockId=device_get_light_level block="light level" blockGap=8
//% parts="ledmatrix" shim=input::lightLevel
//% parts="ledmatrix"
//% group="Sensors" shim=input::lightLevel
function lightLevel(): int32;
/**
* gets the level of loudness from 0 (silent) to 255 (loud)
*/
//% blockId="soundLevel" weight=58
//% block="soundLevel" blockGap=8
//% group="Sensors" shim=input::soundLevel
function soundLevel(): int32;
/**
* Get the current compass heading in degrees.
*/
//% help=input/compass-heading
//% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass" shim=input::compassHeading
//% parts="compass"
//% group="Sensors" shim=input::compassHeading
function compassHeading(): int32;
/**
* Gets the temperature in Celsius degrees (°C).
*/
//% weight=55
//% weight=57
//% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer" shim=input::temperature
//% parts="thermometer"
//% group="Sensors" shim=input::temperature
function temperature(): int32;
/**
@ -333,17 +391,19 @@ declare namespace input {
*/
//% help=input/rotation weight=52
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
//% parts="accelerometer" advanced=true shim=input::rotation
//% parts="accelerometer" advanced=true
//% group="Sensors" shim=input::rotation
function rotation(kind: Rotation): int32;
/**
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
* @param dimension the x, y, or z dimension, eg: Dimension.X
*/
//% help=input/magnetic-force weight=51
//% help=input/magnetic-force weight=49
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
//% parts="compass"
//% advanced=true shim=input::magneticForce
//% advanced=true
//% group="Sensors" shim=input::magneticForce
function magneticForce(dimension: Dimension): number;
/**
@ -351,18 +411,49 @@ declare namespace input {
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_calibrate" block="calibrate compass"
//% weight=45 shim=input::calibrateCompass
//% weight=20 gap=8
//% group="Configuration" shim=input::calibrateCompass
function calibrateCompass(): void;
/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System" shim=input::isCalibratedCompass
function isCalibratedCompass(): boolean;
/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_clear_calibration" block="clear calibration compass"
//% weight=17
//% group="Configuration"
//% blockHidden=true shim=input::clearCalibrationCompass
function clearCalibrationCompass(): void;
/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_assume_calibration" block="assume calibration compass"
//% weight=16
//% group="Configuration"
//% blockHidden=true shim=input::assumeCalibrationCompass
function assumeCalibrationCompass(): void;
/**
* Sets the accelerometer sample range in gravities.
* @param range a value describe the maximum strengh of acceleration measured
*/
//% help=input/set-accelerometer-range
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
//% weight=5
//% weight=22 gap=8
//% parts="accelerometer"
//% advanced=true shim=input::setAccelerometerRange
//% advanced=true
//% group="Configuration" shim=input::setAccelerometerRange
function setAccelerometerRange(range: AcceleratorRange): void;
}
@ -410,8 +501,9 @@ declare namespace control {
* Blocks the current fiber for the given microseconds
* @param micros number of micro-seconds to wait. eg: 4
*/
//% help=control/wait-micros weight=29
//% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros
//% help=control/wait-micros weight=29 async
//% blockId="control_wait_us" block="wait (µs)%micros"
//% micros.min=0 micros.max=6000 shim=control::waitMicros
function waitMicros(micros: int32): void;
/**
@ -465,6 +557,13 @@ declare namespace control {
//% advanced=true shim=control::deviceSerialNumber
function deviceSerialNumber(): int32;
/**
* Derive a unique, consistent 64-bit serial number of this device from internal data.
*/
//% help=control/device-long-serial-number
//% advanced=true shim=control::deviceLongSerialNumber
function deviceLongSerialNumber(): Buffer;
/**
* Informs simulator/runtime of a MIDI message
* Internal function to support the simulator.
@ -476,7 +575,53 @@ declare namespace control {
*
*/
//% shim=control::__log
function __log(text: string): void;
function __log(priority: int32, text: string): void;
/**
* Allocates the next user notification event
*/
//% help=control/allocate-notify-event shim=control::allocateNotifyEvent
function allocateNotifyEvent(): int32;
/** Write a message to DMESG debugging buffer. */
//% shim=control::dmesg
function dmesg(s: string): void;
/** Write a message and value (pointer) to DMESG debugging buffer. */
//% shim=control::dmesgPtr
function dmesgPtr(str: string, ptr: Object): void;
}
declare namespace control {
/**
* Force GC and dump basic information about heap.
*/
//% shim=control::gc
function gc(): void;
/**
* Force GC and halt waiting for debugger to do a full heap dump.
*/
//% shim=control::heapDump
function heapDump(): void;
/**
* Set flags used when connecting an external debugger.
*/
//% shim=control::setDebugFlags
function setDebugFlags(flags: int32): void;
/**
* Record a heap snapshot to debug memory leaks.
*/
//% shim=control::heapSnapshot
function heapSnapshot(): void;
/**
* Return true if profiling is enabled in the current build.
*/
//% shim=control::profilingEnabled
function profilingEnabled(): boolean;
}
@ -607,8 +752,9 @@ declare namespace motors {
*/
//% blockId=motor_on block="motor on at %percent \\%"
//% parts=dcmotor weight=90 blockGap=8
//% percent.shadow="speedPicker" shim=motors::motorPower
function motorPower(power: int32): void;
//% percent.shadow="speedPicker"
//% power.defl=100 shim=motors::motorPower
function motorPower(power?: int32): void;
/**
* Send break, coast or sleep commands to the motor. Has no effect in dual-motor mode.
@ -622,8 +768,9 @@ declare namespace motors {
*/
//% blockId=block_dual_motor block="motor %motor|at %percent \\%"
//% percent.shadow="speedPicker"
//% weight=80 shim=motors::dualMotorPower
function dualMotorPower(motor: Motor, duty_percent: int32): void;
//% weight=80
//% duty_percent.defl=100 shim=motors::dualMotorPower
function dualMotorPower(motor: Motor, duty_percent?: int32): void;
}
declare namespace music {
@ -635,6 +782,31 @@ declare namespace music {
//%
//% parts="speaker" async useEnumVal=1 shim=music::speakerPlayTone
function speakerPlayTone(frequency: int32, ms: int32): void;
/**
* Set the default output volume of the sound synthesizer.
* @param volume the volume 0...255
*/
//% blockId=synth_set_volume block="set volume %volume"
//% volume.min=0 volume.max=255
//%
//% help=music/set-volume
//% weight=70
//% group="Volume"
//% blockGap=8
//% blockHidden=true volume.defl=127 shim=music::setVolume
function setVolume(volume?: int32): void;
/**
* Returns the current output volume of the sound synthesizer.
*/
//% blockId=synth_get_volume block="volume"
//% help=music/volume
//% weight=69
//% group="Volume"
//% blockGap=8
//% blockHidden=true shim=music::volume
function volume(): int32;
}
declare namespace pins {
@ -763,7 +935,8 @@ declare namespace pins {
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
//% help=pins/analog-set-pitch-pin weight=3 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::analogSetPitchPin
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% blockHidden=true shim=pins::analogSetPitchPin
function analogSetPitchPin(name: AnalogPin): void;
/**
@ -772,14 +945,16 @@ declare namespace pins {
*/
//% blockId=device_analog_set_pitch_volume block="analog set pitch volume $volume"
//% help=pins/analog-set-pitch-volume weight=3 advanced=true
//% volume.min=0 volume.max=255 shim=pins::analogSetPitchVolume
//% volume.min=0 volume.max=255
//% blockHidden=true shim=pins::analogSetPitchVolume
function analogSetPitchVolume(volume: int32): void;
/**
* Gets the volume the pitch pin from 0..255
*/
//% blockId=device_analog_pitch_volume block="analog pitch volume"
//% help=pins/analog-pitch-volume weight=3 advanced=true shim=pins::analogPitchVolume
//% help=pins/analog-pitch-volume weight=3 advanced=true
//% blockHidden=true shim=pins::analogPitchVolume
function analogPitchVolume(): int32;
/**
@ -788,7 +963,8 @@ declare namespace pins {
* @param ms duration of the pitch in milli seconds.
*/
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 shim=pins::analogPitch
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
//% blockHidden=true shim=pins::analogPitch
function analogPitch(frequency: int32, ms: int32): void;
/**
@ -821,6 +997,20 @@ declare namespace pins {
//% shim=pins::createBuffer
function createBuffer(size: int32): Buffer;
/**
* Set the matrix width for Neopixel strip (already assigned to a pin).
* Should be used in conjunction with `set matrix width` from Neopixel package.
* @param name pin of Neopixel strip, eg: DigitalPin.P1
* @param value width of matrix (at least ``2``)
*/
//% help=pins/neopixel-matrix-width weight=3 advanced=true
//% blockId=pin_neopixel_matrix_width block="neopixel matrix width|pin %pin %width" blockGap=8
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% width.min=2
//% blockHidden=true width.defl=5 shim=pins::setMatrixWidth
function setMatrixWidth(pin: DigitalPin, width?: int32): void;
/**
* Read `size` bytes from a 7-bit I2C `address`.
*/
@ -885,6 +1075,18 @@ declare namespace pins {
*/
//% help=pins/push-button advanced=true shim=pins::pushButton
function pushButton(pin: DigitalPin): void;
/**
* Set the pin used when producing sounds and melodies. Default is P0.
* @param name pin to modulate pitch from
*/
//% blockId=pin_set_audio_pin block="set audio pin $name"
//% help=pins/set-audio-pin weight=3
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% weight=1
//% blockHidden=true shim=pins::setAudioPin
function setAudioPin(name: AnalogPin): void;
}
@ -935,8 +1137,9 @@ declare namespace serial {
function writeBuffer(buffer: Buffer): void;
/**
* Read multiple characters from the receive buffer. Pause until enough characters are present.
* @param length default buffer length, eg: 64
* Read multiple characters from the receive buffer.
* If length is positive, pauses until enough characters are present.
* @param length default buffer length
*/
//% blockId=serial_readbuffer block="serial|read buffer %length"
//% help=serial/read-buffer advanced=true weight=5 shim=serial::readBuffer
@ -1105,15 +1308,63 @@ declare namespace control {
//% deprecated=1 shim=control::createBufferFromUTF8
function createBufferFromUTF8(str: string): Buffer;
}
/**
* Provides access to persistent storage functionality.
*/
declare namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=100 blockGap=16
//% block="Put into %key a value of %value as Int"
//% blockId=storage_put_value_int
//%
//% group="Put"
//% blockHidden=true value.defl=0 shim=storage::putValueInt
function putValueInt(key: string, value?: int32): void;
/**
* Reads a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="get number from %key"
//% blockId=storage_get_value_int
//% group="Get"
//% blockHidden=true shim=storage::getValueInt
function getValueInt(key: string): int32;
/**
* Removes a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="remove %key"
//% blockId=storage_remove
//% group="Remove"
//% blockHidden=true shim=storage::remove
function remove(key: string): void;
}
declare namespace light {
/**
* Sends a color buffer to a light strip
**/
//% advanced=true
//% shim=light::sendWS2812Buffer
//% advanced=true shim=light::sendWS2812Buffer
function sendWS2812Buffer(buf: Buffer, pin: int32): void;
/**
* Sends a color buffer to a light strip
**/
//% advanced=true shim=light::sendWS2812BufferWithBrightness
function sendWS2812BufferWithBrightness(buf: Buffer, pin: int32, brightness: int32): void;
/**
* Sets the light mode of a pin
**/

View File

@ -0,0 +1,28 @@
#include "pxt.h"
namespace music {
/**
* Internal use only
**/
//% async
void __playSoundExpression(String nodes, bool waitTillDone) {
#if MICROBIT_CODAL
if (waitTillDone)
uBit.audio.soundExpressions.play(MSTR(nodes));
else
uBit.audio.soundExpressions.playAsync(MSTR(nodes));
#else
target_panic(PANIC_VARIANT_NOT_SUPPORTED);
#endif
}
/**
* Internal use only
*/
//%
void __stopSoundExpressions() {
#if MICROBIT_CODAL
uBit.audio.soundExpressions.stop();
#endif
}
}

View File

@ -0,0 +1,59 @@
/**
* A sound expression.
*/
//% fixedInstances
//% blockNamespace=music
//% group="micro:bit (V2)"
class SoundExpression {
constructor(private notes: string) {
}
/**
* Starts to play a sound expression.
*/
//% block="play sound $this"
//% weight=80
//% blockGap=8
//% help=music/play
//% group="micro:bit (V2)"
//% parts=builtinspeaker
play() {
music.__playSoundExpression(this.notes, false)
}
/**
* Plays a sound expression until finished
*/
//% block="play sound $this until done"
//% weight=81
//% blockGap=8
//% help=music/play-until-done
//% group="micro:bit (V2)"
//% parts=builtinspeaker
playUntilDone() {
music.__playSoundExpression(this.notes, true)
}
}
namespace soundExpression {
//% fixedInstance whenUsed block="{id:soundexpression}giggle"
export const giggle = new SoundExpression("giggle");
//% fixedInstance whenUsed block="{id:soundexpression}happy"
export const happy = new SoundExpression("happy");
//% fixedInstance whenUsed block="{id:soundexpression}hello"
export const hello = new SoundExpression("hello");
//% fixedInstance whenUsed block="{id:soundexpression}mysterious"
export const mysterious = new SoundExpression("mysterious");
//% fixedInstance whenUsed block="{id:soundexpression}sad"
export const sad = new SoundExpression("sad");
//% fixedInstance whenUsed block="{id:soundexpression}slide"
export const slide = new SoundExpression("slide");
//% fixedInstance whenUsed block="{id:soundexpression}soaring"
export const soaring = new SoundExpression("soaring");
//% fixedInstance whenUsed block="{id:soundexpression}spring"
export const spring = new SoundExpression("spring");
//% fixedInstance whenUsed block="{id:soundexpression}twinkle"
export const twinkle = new SoundExpression("twinkle");
//% fixedInstance whenUsed block="{id:soundexpression}yawn"
export const yawn = new SoundExpression("yawn");
}

57
libs/core/storage.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "pxt.h"
/**
* Provides access to persistent storage functionality.
*/
namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=100 blockGap=16
//% block="Put into %key a value of %value as Int"
//% blockId=storage_put_value_int
//% value.defl=0
//% group="Put"
//% blockHidden=true
void putValueInt(String key, int value) {
ManagedString managedKey = MSTR(key);
uBit.storage.put(managedKey, (uint8_t *)&value, sizeof(int));
}
/**
* Reads a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="get number from %key"
//% blockId=storage_get_value_int
//% group="Get"
//% blockHidden=true
int getValueInt(String key) {
KeyValuePair* data = uBit.storage.get(MSTR(key));
int stored;
if(data == NULL) {
return 0;
} else {
memcpy(&stored, data->value, sizeof(int));
delete data;
return stored;
}
}
/**
* Removes a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="remove %key"
//% blockId=storage_remove
//% group="Remove"
//% blockHidden=true
void remove(String key) {
uBit.storage.remove(MSTR(key));
}
}

68
libs/core/storage.ts Normal file
View File

@ -0,0 +1,68 @@
enum StorageSlots {
//% block="Slot 1"
s1 = 0,
//% block="Slot 2"
s2 = 1,
//% block="Slot 3"
s3 = 2,
//% block="Slot 4"
s4 = 3,
//% block="Slot 5"
s5 = 4,
//% block="Slot 6"
s6 = 5,
//% block="Slot 7"
s7 = 6,
}
// let storagesStr = ['s1', 's2', 's3', 's4', 's5', 's6', 's7'];
let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7'];
/**
* Provides access to persistent storage functionality.
*/
//% color=#FFBB00 weight=10 icon="\uf187"
//% advanced=true
namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=90 blockGap=16
//% block="Save into number %key a value of %value"
//% blockId=storage_put_number
//% group="Put"
export function putNumber(key: StorageSlots, value: number) : void {
let managedValue = Math.floor(value * 100);
putValueInt(storagesInt[key], managedValue);
}
/**
* Reads a key value pair from the non volatile storage as a number
* @param key the key for accesing the value
*/
//% weight=70 blockGap=16
//% block="read from number %key"
//% blockId=storage_get_number
//% group="Get"
export function getNumber(key: StorageSlots) : number {
let value = getValueInt(storagesInt[key]);
return value / 100;
}
/**
* Deletes the key from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=50 blockGap=16
//% block="Clear number %key"
//% blockId=storage_remove_key_int
//% group="Remove"
export function removeKeyInt(key: StorageSlots) : void {
remove(storagesInt[key]);
}
}

53
libs/core/touchmode.cpp Normal file
View File

@ -0,0 +1,53 @@
#include "pxt.h"
#if MICROBIT_CODAL
#else
#define MICROBIT_ID_LOGO 121
#endif
enum class TouchTargetMode {
//% block="capacitive"
Capacitive = 1,
//% block="resistive"
Resistive = 0
};
enum class TouchTarget {
//% block="P0"
P0 = MICROBIT_ID_IO_P0,
//% block="P1"
P1 = MICROBIT_ID_IO_P1,
//% block="P2"
P2 = MICROBIT_ID_IO_P2,
//% block="logo"
LOGO = MICROBIT_ID_LOGO
};
namespace pins {
/**
* Configure the touch detection for the pins and logo.
* P0, P1, P2 use resistive touch by default.
* The logo uses capacitative touch by default.
* @param name target to change the touch mode for
* @param mode the touch mode to use
*/
//% weight=60
//% blockId=device_touch_set_type block="set %name to touch mode %mode"
//% advanced=true
//% group="micro:bit (V2)"
//% help=pins/touch-set-mode
void touchSetMode(TouchTarget name, TouchTargetMode mode) {
#if MICROBIT_CODAL
const auto pin = name == TouchTarget::LOGO
? &uBit.io.logo : getPin((int)name);
if (pin) {
pin->isTouched(mode == TouchTargetMode::Capacitive
? codal::TouchMode::Capacitative : codal::TouchMode::Resistive);
}
#else
target_panic(PANIC_VARIANT_NOT_SUPPORTED);
#endif
}
}