diff --git a/README.md b/README.md index fdbde24c..4bffc829 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Calliope target for PXT +# Calliope target for Microsoft MakeCode + +This target is hosted at https://makecode.calliope.cc. -This target allow to program a [Calliope](http://calliope.cc/) using -PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)). ### BUILD COMMENTS diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 7bbd1f39..bc0c14f7 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -1,31 +1,126 @@ { - "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.", + "AcceleratorRange.EightG": "The accelerator measures forces up to 8 gravity", + "AcceleratorRange.FourG": "The accelerator measures forces up to 4 gravity", + "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.\n\nAdd, remove, and replace items in lists.", + "Array.filter": "Return the elements of an array that meet the condition specified in a callback function.", + "Array.filter|param|callbackfn": "A function that accepts up to two arguments. The filter method calls the callbackfn function one time for each element in the array.", + "Array.get": "Get the value at a particular index.", + "Array.get|param|index": "the zero-based position in the list of the item, eg: 0", + "Array.indexOf": "Return the index of the first occurrence of a value in an array.", + "Array.indexOf|param|fromIndex": "The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.", + "Array.indexOf|param|item": "The value to locate in the array.", + "Array.insertAt": "Insert the value at a particular index, increase the array length by 1.", + "Array.insertAt|param|index": "the zero-based position in the list to insert the value, eg: 0", + "Array.insertAt|param|value": "to insert, eg: 0", + "Array.length": "Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.", + "Array.map": "Call a defined callback function on each element of an array, and return an array containing the results.", + "Array.map|param|callbackfn": "A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the array.", + "Array.pop": "Remove the last element from an array and return it.", + "Array.push": "Append a new elements to an array.", + "Array.push|param|item": "to append to the Array.", + "Array.reduce": "Call the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.", + "Array.reduce|param|callbackfn": "A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the array.", + "Array.reduce|param|initialValue": "Initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.", + "Array.removeAt": "Remove the element at a certain index.", + "Array.removeAt|param|index": "the zero-based position in the list to remove the value from, eg: 0", + "Array.removeElement": "Remove the first occurence of an object. Return true if removed.", + "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.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", + "Array.slice|param|start": "The beginning of the specified portion of the array. eg: 0", + "Array.sort": "Sort the elements of an array in place and returns the array. The sort is not necessarily stable.", + "Array.splice": "Remove elements from an array.", + "Array.splice|param|deleteCount": "The number of elements to remove. eg: 0", + "Array.splice|param|start": "The zero-based location in the array from which to start removing elements. eg: 0", + "Array.unshift": "Add one element to the beginning of an array and return the new length of the array.", + "Array.unshift|param|value": "to insert at the start of the Array.", + "Boolean.toString": "Returns a string representation of an object.", + "Buffer.fill": "Fill (a fragment) of the buffer with given value.", + "Buffer.getNumber": "Read a number in specified format from the buffer.", + "Buffer.length": "Returns the length of a Buffer object.", + "Buffer.rotate": "Rotate buffer left in place.", + "Buffer.rotate|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1", + "Buffer.rotate|param|offset": "number of bytes to shift; use negative value to shift right", + "Buffer.rotate|param|start": "start offset in buffer. Default is 0.", + "Buffer.setNumber": "Write a number in specified format in the buffer.", + "Buffer.shift": "Shift buffer left in place, with zero padding.", + "Buffer.shift|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1", + "Buffer.shift|param|offset": "number of bytes to shift; use negative value to shift right", + "Buffer.shift|param|start": "start offset in buffer. Default is 0.", + "Buffer.slice": "Return a copy of a fragment of a buffer.", + "Buffer.write": "Write contents of `src` at `dstOffset` in current buffer.", + "Colors": "Well known colors", + "EventCreationMode": "How to create the event.", + "EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).", + "EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.", + "Gesture.FreeFall": "Raised when the board is falling!", + "Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical", + "Gesture.LogoUp": "Raised when the logo is upward and the screen is vertical", + "Gesture.ScreenDown": "Raised when the screen is pointing up and the board is horizontal", + "Gesture.ScreenUp": "Raised when the screen is pointing down and the board is horizontal", + "Gesture.Shake": "Raised when shaken", + "Gesture.SixG": "Raised when a 6G shock is detected", + "Gesture.ThreeG": "Raised when a 3G shock is detected", + "Gesture.TiltLeft": "Raised when the screen is pointing left", + "Gesture.TiltRight": "Raised when the screen is pointing right", + "Image.clear": "Sets all pixels off.", + "Image.height": "Gets the height in rows (always 5)", + "Image.pixel": "Get the pixel state at position ``(x,y)``", + "Image.pixelBrightness": "Gets the pixel brightness ([0..255]) at a given position", + "Image.pixel|param|x": "TODO", + "Image.pixel|param|y": "TODO", + "Image.plotFrame": "Draws the ``index``-th frame of the image on the screen.", + "Image.plotFrame|param|xOffset": "column index to start displaying the image", + "Image.plotImage": "Plots the image at a given column to the screen", + "Image.scrollImage": "Scrolls an image .", + "Image.scrollImage|param|frameOffset": "x offset moved on each animation step, eg: 1, 2, 5", + "Image.scrollImage|param|interval": "time between each animation step in milli seconds, eg: 200", + "Image.setPixel": "Set a pixel state at position ``(x,y)``", + "Image.setPixelBrightness": "Sets a specific pixel brightness at a given position", + "Image.setPixel|param|value": "TODO", + "Image.setPixel|param|x": "TODO", + "Image.setPixel|param|y": "TODO", + "Image.showFrame": "Shows a particular frame of the image strip.", + "Image.showFrame|param|frame": "TODO", + "Image.showImage": "Shows an frame from the image at offset ``x offset``.", + "Image.showImage|param|xOffset": "column index to start displaying the image", + "Image.width": "Gets the width in columns", + "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.", "Math.max": "Returns the larger of two supplied numeric expressions.", "Math.min": "Returns the smaller of two supplied numeric expressions.", - "Math.pow": "Returns the value of a base expression taken to a specified power.", + "Math.pow": "Return the value of a base expression taken to a specified power.", "Math.pow|param|x": "The base value of the expression.", "Math.pow|param|y": "The exponent value of the expression.", - "Math.random": "Returns a pseudorandom number between 0 and `max`.", + "Math.random": "Return a pseudorandom number between 0 and `limit`.", "Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.", + "Math.random|param|limit": "the upper bound of the number generated, eg: 4", "Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.", "Math.sign|param|x": "The numeric expression to test", - "Math.sqrt": "Returns the square root of a number.", + "Math.sqrt": "Return the square root of a number.", "Math.sqrt|param|x": "A numeric expression.", - "String.charAt": "Returns the character at the specified index.", - "String.charAt|param|index": "The zero-based index of the desired character.", - "String.charCodeAt": "Returns the Unicode value of the character at the specified location.", + "Number.toString": "Return a string representation of a number.", + "String": "Combine, split, and search text strings.\n\nCombine, split, and search text strings.", + "String.charAt": "Return the character at the specified index.", + "String.charAt|param|index": "The zero-based index of the desired character, eg: 0", + "String.charCodeAt": "Return the Unicode value of the character at the specified location.", "String.charCodeAt|param|index": "The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.", - "String.compare": "Determines whether relative order of two strings (in ASCII encoding).", + "String.compare": "See how the order of characters in two strings is different (in ASCII encoding).", "String.compare|param|that": "String to compare to target string", "String.concat": "Returns a string that contains the concatenation of two or more strings.", - "String.concat|param|other": "The string to append to the end of the string.", + "String.concat|param|other": "The string to append to the end of the string, eg: \"add me!\"", "String.fromCharCode": "Make a string from the given ASCII character code.", "String.isEmpty": "Returns a value indicating if the string is empty", - "String.length": "Returns the length of a String object.", - "String.substr": "Return substring of the current string.", - "String.substr|param|length": "number of characters to extract", - "String.substr|param|start": "first character index; can be negative from counting from the end, eg:0", + "String.length": "Return the length of a String object.", + "String.substr": "Return a substring of the current string.", + "String.substr|param|length": "number of characters to extract, eg: 3", + "String.substr|param|start": "first character index; can be negative from counting from the end, eg: 0", "basic": "Provides access to basic micro:bit functionality.\n\nProvides access to basic micro:bit functionality.", "basic.clearScreen": "Turn off all LEDs", "basic.color": "Converts the color name to a number", @@ -72,6 +167,58 @@ "control.waitMicros": "Blocks the current fiber for the given microseconds", "control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4", "game": "A single-LED sprite game engine", + "game.LedSprite.blink": "Reports the ``blink`` duration of a sprite", + "game.LedSprite.brightness": "Reports the ``brightness` of a sprite on the LED screen", + "game.LedSprite.change": "Changes a property of the sprite", + "game.LedSprite.changeBlinkBy": "Changes the ``blink`` duration by the given amount of millisecons", + "game.LedSprite.changeBlinkBy|param|ms": "TODO", + "game.LedSprite.changeBrightnessBy": "Changes the ``y`` position by the given amount", + "game.LedSprite.changeBrightnessBy|param|value": "TODO", + "game.LedSprite.changeDirectionBy": "Changes the ``direction`` position by the given amount by turning right", + "game.LedSprite.changeDirectionBy|param|angle": "TODO", + "game.LedSprite.changeXBy": "Changes the ``x`` position by the given amount", + "game.LedSprite.changeXBy|param|x": "TODO", + "game.LedSprite.changeYBy": "Changes the ``y`` position by the given amount", + "game.LedSprite.changeYBy|param|y": "TODO", + "game.LedSprite.change|param|property": "the name of the property to change", + "game.LedSprite.change|param|value": "amount of change, eg: 1", + "game.LedSprite.delete": "Deletes the sprite from the game engine. All further operation of the sprite will not have any effect.", + "game.LedSprite.delete|param|sprite": "TODO", + "game.LedSprite.direction": "Reports the current direction of a sprite", + "game.LedSprite.get": "Gets a property of the sprite", + "game.LedSprite.get|param|property": "the name of the property to change", + "game.LedSprite.goTo": "Go to this position on the screen", + "game.LedSprite.goTo|param|x": "TODO", + "game.LedSprite.goTo|param|y": "TODO", + "game.LedSprite.ifOnEdgeBounce": "If touching the edge of the stage, then bounce away.", + "game.LedSprite.isTouching": "Reports true if sprite is touching specified sprite", + "game.LedSprite.isTouchingEdge": "Reports true if sprite is touching an edge", + "game.LedSprite.isTouching|param|other": "TODO", + "game.LedSprite.move": "Move a certain number of LEDs", + "game.LedSprite.move|param|leds": "number of leds to move, eg: 1, -1", + "game.LedSprite.off": "Turns off the sprite (on by default)", + "game.LedSprite.on": "Turns on the sprite (on by default)", + "game.LedSprite.set": "Sets a property of the sprite", + "game.LedSprite.setBlink": "Sets the blink duration interval in millisecond.", + "game.LedSprite.setBlink|param|ms": "TODO", + "game.LedSprite.setBrightness": "Set the ``brightness`` of a sprite", + "game.LedSprite.setBrightness|param|brightness": "TODO", + "game.LedSprite.setDirection": "Set the direction of the current sprite, rounded to the nearest multiple of 45", + "game.LedSprite.setDirection|param|degrees": "TODO", + "game.LedSprite.setX": "Set the ``x`` position of a sprite", + "game.LedSprite.setX|param|x": "TODO", + "game.LedSprite.setY": "Set the ``y`` position of a sprite", + "game.LedSprite.setY|param|y": "TODO", + "game.LedSprite.set|param|property": "the name of the property to change", + "game.LedSprite.turn": "Turn the sprite", + "game.LedSprite.turnLeft": "Turn to the left (counter-clockwise)", + "game.LedSprite.turnLeft|param|degrees": "TODO", + "game.LedSprite.turnRight": "Turn to the right (clockwise)", + "game.LedSprite.turnRight|param|degrees": "TODO", + "game.LedSprite.turn|param|degrees": "angle in degrees to turn, eg: 45, 90, 180, 135", + "game.LedSprite.turn|param|direction": "left or right", + "game.LedSprite.x": "Reports the ``x`` position of a sprite on the LED screen", + "game.LedSprite.y": "Reports the ``y`` position of a sprite on the LED screen", "game.addLife": "Adds life points to the current life", "game.addLife|param|lives": "TODO", "game.addScore": "Adds points to the current score", @@ -190,6 +337,7 @@ "music.setTempo": "Sets the tempo to the specified amount", "music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120", "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.", + "parseInt": "Convert A string to an integer.", "pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...", "pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.", "pins.analogPitch|param|frequency": "TODO", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 87793130..a56084e3 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -7,6 +7,16 @@ "AcceleratorRange.OneG|block": "1g", "AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity", "AcceleratorRange.TwoG|block": "2g", + "Array.indexOf|block": "%list| find index of %value", + "Array.insertAt|block": "%list| insert at %index| value %value", + "Array.length|block": "length of %VALUE", + "Array.pop|block": "get and remove last value from %list", + "Array.push|block": "%list| add value %value| to end", + "Array.removeAt|block": "%list| remove value at %index", + "Array.reverse|block": "reverse %list", + "Array.shift|block": "get and remove first value from %list", + "Array.unshift|block": "%list| insert %value| at beginning", + "Array|block": "Array", "BaudRate.BaudRate115200|block": "115200", "BaudRate.BaudRate56700|block": "57600", "BaudRate.BaudRate9600|block": "9600", @@ -101,12 +111,15 @@ "IconNames.Triangle|block": "triangle", "IconNames.Umbrella|block": "umbrella", "IconNames.Yes|block": "yes", + "Image.scrollImage|block": "scroll image %sprite|with offset %frameoffset|and interval (ms) %delay", + "Image.showImage|block": "show image %sprite|at offset %offset", "LedSpriteProperty.Blink|block": "blink", "LedSpriteProperty.Brightness|block": "brightness", "LedSpriteProperty.Direction|block": "direction", "LedSpriteProperty.X|block": "x", "LedSpriteProperty.Y|block": "y", "Math.randomBoolean|block": "pick random true or false", + "Math.random|block": "pick random 0 to %limit", "Math|block": "Math", "Motor.AB|block": "A and B", "MotorCommand.Break|block": "break", @@ -145,6 +158,7 @@ "basic.pause|block": "pause (ms) %pause", "basic.rgbw|block": "red %red|green %green|blue %blue|white %white", "basic.setLedColor|block": "set led to %color=color_id", + "basic.showArrow|block": "show arrow %i=device_arrow", "basic.showIcon|block": "show icon %i", "basic.showLeds|block": "show leds", "basic.showNumber|block": "show|number %number", @@ -162,14 +176,25 @@ "control.reset|block": "reset", "control.waitMicros|block": "wait (µs)%micros", "control|block": "control", + "game.LedSprite.change|block": "%sprite|change %property|by %value", + "game.LedSprite.get|block": "%sprite|%property", + "game.LedSprite.ifOnEdgeBounce|block": "%sprite|if on edge, bounce", + "game.LedSprite.isTouchingEdge|block": "%sprite|touching edge?", + "game.LedSprite.isTouching|block": "%sprite|touching %other|?", + "game.LedSprite.move|block": "%sprite|move by %leds", + "game.LedSprite.set|block": "%sprite|set %property|to %value", + "game.LedSprite.turn|block": "%sprite|turn %direction|by (°) %degrees", "game.addScore|block": "change score by|%points", "game.createSprite|block": "create sprite at|x: %x|y: %y", "game.gameOver|block": "game over", "game.score|block": "score", "game.startCountdown|block": "start countdown|(ms) %duration", "game|block": "game", + "images.arrowImage|block": "arrow image %i=device_arrow", + "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.buttonIsPressed|block": "button|%NAME|is pressed", @@ -208,6 +233,7 @@ "music.setTempo|block": "set tempo to (bpm)|%value", "music.tempo|block": "tempo (bpm)", "music|block": "music", + "parseInt|block": "parse to integer %text", "pins.analogPitch|block": "analog pitch %frequency|for (ms) %ms", "pins.analogReadPin|block": "analog read|pin %name", "pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros", @@ -238,15 +264,23 @@ "serial.writeString|block": "serial|write string %text", "serial.writeValue|block": "serial|write value %name|= %value", "serial|block": "serial", + "{id:category}Array": "Array", + "{id:category}Arrays": "Arrays", "{id:category}Basic": "Basic", + "{id:category}Boolean": "Boolean", + "{id:category}Buffer": "Buffer", + "{id:category}Console": "Console", "{id:category}Control": "Control", "{id:category}Game": "Game", + "{id:category}Helpers": "Helpers", + "{id:category}Image": "Image", "{id:category}Images": "Images", "{id:category}Input": "Input", "{id:category}Led": "Led", "{id:category}Math": "Math", "{id:category}Motors": "Motors", "{id:category}Music": "Music", + "{id:category}Number": "Number", "{id:category}Pins": "Pins", "{id:category}Serial": "Serial", "{id:category}String": "String", diff --git a/libs/core/enums.d.ts b/libs/core/enums.d.ts index 31633238..9a2ced3a 100644 --- a/libs/core/enums.d.ts +++ b/libs/core/enums.d.ts @@ -5,7 +5,7 @@ declare namespace basic { } - declare enum Button { + declare const enum Button { A = 1, // MICROBIT_ID_BUTTON_A B = 2, // MICROBIT_ID_BUTTON_B //% block="A+B" @@ -13,7 +13,7 @@ declare namespace basic { } - declare enum Dimension { + declare const enum Dimension { //% block=x X = 0, //% block=y @@ -25,7 +25,7 @@ declare namespace basic { } - declare enum Rotation { + declare const enum Rotation { //% block=pitch Pitch = 0, //% block=roll @@ -33,7 +33,7 @@ declare namespace basic { } - declare enum TouchPin { + declare const enum TouchPin { P0 = 19, // MICROBIT_ID_IO_P12 P1 = 7, // MICROBIT_ID_IO_P0 P2 = 8, // MICROBIT_ID_IO_P1 @@ -41,7 +41,7 @@ declare namespace basic { } - declare enum AcceleratorRange { + declare const enum AcceleratorRange { /** * The accelerator measures forces up to 1 gravity */ @@ -65,7 +65,7 @@ declare namespace basic { } - declare enum Gesture { + declare const enum Gesture { /** * Raised when shaken */ @@ -125,7 +125,7 @@ declare namespace input { * How to create the event. */ - declare enum EventCreationMode { + declare const enum EventCreationMode { /** * MicroBitEvent is initialised, and no further processing takes place. */ @@ -137,7 +137,7 @@ declare namespace input { } - declare enum EventBusSource { + declare const enum EventBusSource { MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB @@ -171,7 +171,7 @@ declare namespace input { } - declare enum EventBusValue { + declare const enum EventBusValue { MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM @@ -236,7 +236,7 @@ declare namespace control { } - declare enum DisplayMode { + declare const enum DisplayMode { //% block="black and white" BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE //% block="greyscale" @@ -247,7 +247,7 @@ declare namespace led { } - declare enum MotorCommand { + declare const enum MotorCommand { //% block=coast Coast = 0, //% block=break @@ -257,7 +257,7 @@ declare namespace led { } - declare enum Motor { + declare const enum Motor { A = 0, B = 1, //% block="A and B" @@ -267,7 +267,7 @@ declare namespace motors { } - declare enum DigitalPin { + declare const enum DigitalPin { P0 = 19, // MICROBIT_ID_IO_P12 P1 = 7, // MICROBIT_ID_IO_P0 P2 = 8, // MICROBIT_ID_IO_P1 @@ -288,7 +288,7 @@ declare namespace motors { } - declare enum AnalogPin { + declare const enum AnalogPin { P1 = 7, // MICROBIT_ID_IO_P0 P2 = 8, // MICROBIT_ID_IO_P1 C4 = 10, // MICROBIT_ID_IO_P3 @@ -300,13 +300,13 @@ declare namespace motors { } - declare enum PulseValue { + declare const enum PulseValue { High = 4, // MICROBIT_PIN_EVT_PULSE_HI Low = 5, // MICROBIT_PIN_EVT_PULSE_LO } - declare enum PinPullMode { + declare const enum PinPullMode { //% block="down" PullDown = 0, //% block="up" @@ -316,7 +316,7 @@ declare namespace motors { } - declare enum PinEventType { + declare const enum PinEventType { //% block="edge" Edge = 1, // MICROBIT_PIN_EVENT_ON_EDGE //% block="pulse" @@ -328,7 +328,7 @@ declare namespace motors { } - declare enum SerialPin { + declare const enum SerialPin { C16 = 9, // MICROBIT_ID_IO_P2 C17 = 15, // MICROBIT_ID_IO_P8 P0 = 19, // MICROBIT_ID_IO_P12 @@ -338,7 +338,7 @@ declare namespace motors { } - declare enum BaudRate { + declare const enum BaudRate { //% block=115200 BaudRate115200 = 115200, //% block=57600 @@ -348,7 +348,7 @@ declare namespace motors { } - declare enum Delimiters { + declare const enum Delimiters { //% block="new line" NewLine = 1, //% block="," @@ -366,7 +366,7 @@ declare namespace serial { } - declare enum NumberFormat { + declare const enum NumberFormat { Int8LE = 1, UInt8LE = 2, Int16LE = 3, diff --git a/libs/devices/enums.d.ts b/libs/devices/enums.d.ts index 57b6132e..d784422f 100644 --- a/libs/devices/enums.d.ts +++ b/libs/devices/enums.d.ts @@ -1,7 +1,7 @@ // Auto-generated. Do not edit. - declare enum MesCameraEvent { + declare const enum MesCameraEvent { //% block="take photo" TakePhoto = 3, // MES_CAMERA_EVT_TAKE_PHOTO //% block="start video capture" @@ -21,7 +21,7 @@ } - declare enum MesAlertEvent { + declare const enum MesAlertEvent { //% block="display toast" DisplayToast = 1, // MES_ALERT_EVT_DISPLAY_TOAST //% block="vibrate" @@ -47,7 +47,7 @@ } - declare enum MesDeviceInfo { + declare const enum MesDeviceInfo { //% block="incoming call" IncomingCall = 7, // MES_DEVICE_INCOMING_CALL //% block="incoming message" @@ -65,7 +65,7 @@ } - declare enum MesRemoteControlEvent { + declare const enum MesRemoteControlEvent { //% block="play" play = 1, // MES_REMOTE_CONTROL_EVT_PLAY //% block="pause" @@ -87,7 +87,7 @@ } - declare enum MesDpadButtonInfo { + declare const enum MesDpadButtonInfo { //% block="A down" ADown = 1, // MES_DPAD_BUTTON_A_DOWN //% block="A up" diff --git a/libs/radio/_locales/radio-jsdoc-strings.json b/libs/radio/_locales/radio-jsdoc-strings.json index f80bb225..5a1e3f8c 100644 --- a/libs/radio/_locales/radio-jsdoc-strings.json +++ b/libs/radio/_locales/radio-jsdoc-strings.json @@ -1,5 +1,10 @@ { "radio": "Communicate data using radio packets", + "radio.Packet.receivedNumber": "The number payload if a number was sent in this packet (via ``sendNumber()`` or ``sendValue()``)\nor 0 if this packet did not contain a number.", + "radio.Packet.receivedString": "The string payload if a string was sent in this packet (via ``sendString()`` or ``sendValue()``)\nor the empty string if this packet did not contain a string.", + "radio.Packet.serial": "The serial number of the sender of the packet or 0 if the sender did not sent their serial number.", + "radio.Packet.signal": "The received signal strength indicator (RSSI) of the packet.", + "radio.Packet.time": "The system time of the sender of the packet at the time the packet was sent.", "radio.onDataPacketReceived": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.", "radio.onDataReceived": "Registers code to run when a packet is received over radio.", "radio.receiveNumber": "Reads the next packet from the radio queue and returns the packet's number\npayload or 0 if the packet did not contain a number.", diff --git a/package.json b/package.json index f2a15d76..165cf675 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,12 @@ "devDependencies": { "typescript": "^1.8.7", "less": "^2.6.0", + "rtlcss": "^2.1.2", + "autoprefixer": "^6.7.6", "semantic-ui-less": "^2.2.4" }, "dependencies": { - "pxt-core": "1.0.20" + "pxt-core": "0.14.30" }, "scripts": { "test": "node node_modules/pxt-core/built/pxt.js travis" diff --git a/pxtarget.json b/pxtarget.json index 7e838010..6cec2142 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -1,31 +1,21 @@ { - "id": "calliope", - "name": " calliope", + "id": "calliopemini", + "name": " calliope mini", "nickname": "mini", - "title": "calliope mini - Blocks / Javascript editor", + "title": "Calliope mini - Blocks / Javascript editor", "description": "A Blocks / JavaScript code editor for the calliope mini.", "corepkg": "core", "bundleddirs": [ "libs/core", "libs/radio", "libs/devices", - "libs/bluetooth", - "libs/pxt-calliope-modem", - "libs/pxt-calliope-bc95", - "libs/pxt-calliope-esp", - "libs/pxt-calliope-bunt", - "libs/pxt-isl29125", - "libs/pxt-ubirch", - "libs/Grove", - "libs/pxt-ssd1306-microbit" + "libs/bluetooth" ], "cloud": { "workspace": false, "packages": true, - "sharing": false, + "sharing": true, "publishing": false, - "preferredPackages": [ - ], "githubPackages": true }, "compile": { @@ -197,8 +187,8 @@ "footerLogo": "./static/Calliopeminieditor.svg", "cardLogo": "./static/icons/apple-touch-icon.png", "appLogo": "./static/icons/apple-touch-icon.png", - "homeUrl": "https://calliope.cc/", - "embedUrl": "https://pxt.calliope.cc/", + "homeUrl": "https://makecode.calliope.cc/", + "embedUrl": "https://makecode.calliope.cc/", "privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839", "termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977", "githubUrl": "https://github.com/Microsoft/pxt-calliope", @@ -207,39 +197,14 @@ "organizationUrl": "https://makecode.com/", "organizationLogo": "./static/Microsoft-logo_rgb_c-gray-square.png", "organizationWideLogo": "./static/Microsoft-logo_rgb_c-white.png", - "browserSupport": [ - { - "name": "unsupported", - "os": "*", - "path": "/browsers" - }, - { - "name": "unsupported", - "os": "mac", - "path": "/browsers/mac" - }, - { - "name": "unsupported", - "os": "linux", - "path": "browsers/linux" - }, - { - "name": "unsupported", - "os": "rpi", - "path": "/raspberry-pi" - }, - { - "name": "unsupported", - "os": "windows", - "path": "/browsers/windows" - } - ], "boardName": "Calliope mini", + "driveDisplayName": "MINI", "hideSideDocs": true, "invertedMenu": true, "invertedToolbox": true, "monacoToolbox": false, - "hasAudio": true, + "hasAudio": true, + "highContrast": true, "simAnimationEnter": "rotate in", "simAnimationExit": "rotate out", "blocklyOptions": { @@ -250,6 +215,8 @@ "snap": false } }, - "docMenu": [] - } + "docMenu": [], + "hasReferenceDocs": false + }, + "ignoreDocsErrors": true } diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 0532122b..5ac586ec 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -98,7 +98,7 @@ namespace pxsim { break; case "radiopacket": let packet = msg; - this.radioState.recievePacket(packet); + this.radioState.receivePacket(packet); break; } } diff --git a/sim/state/neopixel.ts b/sim/state/neopixel.ts index c974fb16..c18d9588 100644 --- a/sim/state/neopixel.ts +++ b/sim/state/neopixel.ts @@ -4,7 +4,7 @@ namespace pxsim { if (b) { let np = b.neopixelState; if (np) { - let buf = (buffer).data; + let buf = (buffer).data; np.updateBuffer(buf, pin); runtime.queueDisplayUpdate(); } diff --git a/sim/state/radio.ts b/sim/state/radio.ts index fc1e3d28..2b13ab4a 100644 --- a/sim/state/radio.ts +++ b/sim/state/radio.ts @@ -21,11 +21,12 @@ namespace pxsim { } send(payload: SimulatorRadioPacketPayload) { + const b = board(); Runtime.postMessage({ type: "radiopacket", - rssi: 0, // Not yet supported - serial: board().radioState.bus.transmitSerialNumber ? board().radioState.bus.serial : 0, - time: 0, // Not yet supported + rssi: 70, // Not yet supported + serial: b.radioState.bus.transmitSerialNumber ? pxsim.control.deviceSerialNumber() : 0, + time: new Date().getTime(), payload }) } @@ -41,26 +42,19 @@ namespace pxsim { rssi: -1, serial: 0, time: 0, - payload: { type: -1 } + payload: { type: -1, groupId: 0 } }; } } export class RadioBus { // uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP; - groupId = 0; // todo power = 0; - serial = 0; transmitSerialNumber = false; datagram: RadioDatagram; constructor(private runtime: Runtime) { this.datagram = new RadioDatagram(runtime); - this.serial = Math.floor(Math.random() * Math.pow(2, 32)) - Math.pow(2, 31); // 32 bit signed integer - } - - setGroup(id: number) { - this.groupId = id & 0xff; // byte only } setTransmitPower(power: number) { @@ -71,26 +65,37 @@ namespace pxsim { this.transmitSerialNumber = !!sn; } - broadcast(msg: number) { + broadcast(msg: number, groupId: number) { Runtime.postMessage({ type: "eventbus", id: DAL.MES_BROADCAST_GENERAL_ID, eventid: msg, power: this.power, - group: this.groupId + group: groupId }) } } export class RadioState { bus: RadioBus; + groupId: number; constructor(runtime: Runtime) { this.bus = new RadioBus(runtime); + this.groupId = 0; } - public recievePacket(packet: SimulatorRadioPacketMessage) { - this.bus.datagram.queue(packet) + public setGroup(id: number) { + this.groupId = id & 0xff; // byte only + } + + public broadcast(msg: number) { + this.bus.broadcast(msg, this.groupId) + } + + public receivePacket(packet: SimulatorRadioPacketMessage) { + if (this.groupId == packet.payload.groupId) + this.bus.datagram.queue(packet) } } } @@ -103,7 +108,7 @@ namespace pxsim.radio { } export function broadcastMessage(msg: number): void { - board().radioState.bus.broadcast(msg); + board().radioState.broadcast(msg); } export function onBroadcastMessageReceived(msg: number, handler: RefAction): void { @@ -111,7 +116,7 @@ namespace pxsim.radio { } export function setGroup(id: number): void { - board().radioState.bus.setGroup(id); + board().radioState.setGroup(id); } export function setTransmitPower(power: number): void { @@ -125,7 +130,8 @@ namespace pxsim.radio { export function sendNumber(value: number): void { board().radioState.bus.datagram.send({ type: PacketPayloadType.NUMBER, - numberData: value + groupId: board().radioState.groupId, + numberData: value, }); } @@ -133,7 +139,8 @@ namespace pxsim.radio { msg = msg.substr(0, 19); board().radioState.bus.datagram.send({ type: PacketPayloadType.STRING, - stringData: msg + groupId: board().radioState.groupId, + stringData: msg, }); } @@ -153,6 +160,7 @@ namespace pxsim.radio { msg.push() board().radioState.bus.datagram.send({ type: PacketPayloadType.VALUE, + groupId: board().radioState.groupId, stringData: name, numberData: value }); @@ -186,7 +194,7 @@ namespace pxsim.radio { } export function receivedString(): string { - return board().radioState.bus.datagram.lastReceived.payload.stringData || ""; + return initString(board().radioState.bus.datagram.lastReceived.payload.stringData || ""); } export function receivedTime(): number { diff --git a/targetconfig.json b/targetconfig.json index 10dedd58..224c4604 100644 --- a/targetconfig.json +++ b/targetconfig.json @@ -7,7 +7,17 @@ "ubirch" ], "approvedRepos": [ - "CoderDojoOlney/pxt-olney" + "CoderDojoOlney/pxt-olney", + "Tinkertanker/pxt-ssd1306-microbit" + ], + "preferredRepos": [ + "calliope-mini/pxt-calliope-modem", + "calliope-mini/pxt-calliope-bc95", + "calliope-mini/pxt-calliope-esp", + "calliope-mini/pxt-calliope-bunt", + "calliope-mini/pxt-isl29125", + "ubirch/pxt-ubirch", + "Tinkertanker/pxt-ssd1306-microbit" ] } } \ No newline at end of file diff --git a/theme/blockly.less b/theme/blockly.less new file mode 100644 index 00000000..41e41113 --- /dev/null +++ b/theme/blockly.less @@ -0,0 +1,73 @@ +@import 'themes/default/globals/site.variables'; +@import 'themes/pxt/globals/site.variables'; +@import 'site/globals/site.variables'; + +@import 'blockly-core'; + +/* Reference import */ +@import (reference) "semantic.less"; + +/******************************* + Blockly +*******************************/ + +div.blocklyTreeRow { + box-shadow: inset 0 -1px 0 0 #ecf0f1; + + margin-bottom: 0px !important; + + -webkit-transition-property: background-color; /* Safari */ + -webkit-transition-duration: 1s; /* Safari */ + transition-property: background-color; + transition-duration: 1s; +} + +/* Blockly toolbox font size same as the page font */ +span.blocklyTreeLabel { + font-family: @pageFont !important; + font-weight: 200; +} + +.blocklyToolboxDiv, .monacoToolboxDiv { + background-color: white !important; + border-left: 1px solid #ecf0f1 !important; + box-shadow: 4px 0px 2px -4px rgba(0,0,0,0.12), 4px 0px 2px -4px rgba(0,0,0,0.24); +} + +.blocklyFlyoutBackground { + fill: #525A67 !important; +} + +/* Remove shadow around blockly blocks */ +.blocklyPathDark, .blocklyPathLight { + display: none; +} + +/* Blockly Field: Grid picker */ +.blocklyGridPickerTooltip { + padding: 3px 5px; + background-color: #fefefe; + border: black solid 3px; + color: black; + border-radius: 10px; +} + +/* Mobile */ +@media only screen and (max-width: @largestMobileScreen) { + .blocklyToolboxDiv, .monacoToolboxDiv { + border-left: 0 !important; + } + div.blocklyTreeRoot { + padding: 0; + } +} + +/* Tablet */ +@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) { + .blocklyToolboxDiv, .monacoToolboxDiv { + border-left: 0 !important; + } + div.blocklyTreeRoot { + padding: 0; + } +} \ No newline at end of file