From 9cfba7504a7dda19cde04aba2d19a06dbad217fa Mon Sep 17 00:00:00 2001 From: Amerlander Date: Fri, 11 Sep 2020 11:19:33 +0200 Subject: [PATCH] Changes to the Beta (#115) * fixes for beta - hide blocks without function - digital Pin selection bring P0 in first position - add compass block to end confusion about "basic.showArrow(ArrowNames.North)" - add approved repos - add and sort preffered repos - add prefferedPackages - disable webUSB - disable parts - remove mobileSafariDownloadProtocol - update socialOptions * remove `preferredPackages` from `pxtarget` Co-authored-by: Juri --- libs/core/_locales/core-jsdoc-strings.json | 10 +- libs/core/_locales/core-strings.json | 1 + libs/core/compass.ts | 273 +++++++++++++++++++++ libs/core/music.ts | 2 + libs/core/pins.cpp | 12 +- libs/core/pxt.json | 1 + libs/core/shims.d.ts | 8 +- package-lock.json | 6 +- pxtarget.json | 16 +- targetconfig.json | 26 +- 10 files changed, 322 insertions(+), 33 deletions(-) create mode 100644 libs/core/compass.ts diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 98d947e3..d51a8d1b 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -396,6 +396,8 @@ "images": "Creation, manipulation and display of LED images.", "images.createBigImage": "Creates an image with 2 frames.", "images.createImage": "Creates an image that fits on the LED screen.", + "images.showCompass": "Draws needle on the screen which always points to north", + "images.showCompass|param|interval": "the amount of time (milliseconds) to show the needle. Default is 600.", "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", @@ -553,16 +555,16 @@ "pins.analogPitch|param|frequency": "frequency to modulate in Hz.", "pins.analogPitch|param|ms": "duration of the pitch in milli seconds.", "pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.", - "pins.analogReadPin|param|name": "pin to write to, eg: AnalogPin.P0", + "pins.analogReadPin|param|name": "pin to write to, eg: AnalogPin.P1", "pins.analogSetPeriod": "Configure the pulse-width modulation (PWM) period of the analog output in microseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.", "pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000", - "pins.analogSetPeriod|param|name": "analog pin to set period to, eg: AnalogPin.P0", + "pins.analogSetPeriod|param|name": "analog pin to set period to, eg: AnalogPin.P1", "pins.analogSetPitchPin": "Set the pin used when using analog pitch or music.", "pins.analogSetPitchPin|param|name": "pin to modulate pitch from", "pins.analogSetPitchVolume": "Sets the volume on the pitch pin", "pins.analogSetPitchVolume|param|volume": "the intensity of the sound from 0..255", "pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.", - "pins.analogWritePin|param|name": "pin name to write to, eg: AnalogPin.P0", + "pins.analogWritePin|param|name": "pin name to write to, eg: AnalogPin.P1", "pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0", "pins.createBuffer": "Create a new zero-initialized buffer.", "pins.createBuffer|param|size": "number of bytes in the buffer", @@ -594,7 +596,7 @@ "pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500", "pins.servoSetPulse|param|name": "pin name", "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.P0", + "pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P1", "pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0", "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", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 7e6c79c8..a1c31820 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -310,6 +310,7 @@ "images.createBigImage|block": "create big image", "images.createImage|block": "create image", "images.iconImage|block": "icon image %i", + "images.showCompass|block": "show compass needle for $interval|ms", "images|block": "images", "input.acceleration|block": "acceleration (mg)|%NAME", "input.buttonIsPressed|block": "button|%NAME|is pressed", diff --git a/libs/core/compass.ts b/libs/core/compass.ts new file mode 100644 index 00000000..255fc8d1 --- /dev/null +++ b/libs/core/compass.ts @@ -0,0 +1,273 @@ +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(` + . . . # . + . . . . . + . . # . . + . . . . . + . . . . . + `), + images.createImage(` + . . # . . + . . . . . + . . # . . + . . . . . + . . . . . + `), + images.createImage(` + . # . . . + . . . . . + . . # . . + . . . . . + . . . . . + `), + images.createImage(` + # . . . . + . . . . . + . . # . . + . . . . . + . . . . . + `), + images.createImage(` + . . . . . + # . . . . + . . # . . + . . . . . + . . . . . + `), + images.createImage(` + . . . . . + . . . . . + # . # . . + . . . . . + . . . . . + `), + images.createImage(` + . . . . . + . . . . . + . . # . . + # . . . . + . . . . . + `), + images.createImage(` + . . . . . + . . . . . + . . # . . + . . . . . + # . . . . + `), + images.createImage(` + . . . . . + . . . . . + . . # . . + . . . . . + . # . . . + `)]; + + + + +namespace images { + /** + * Draws needle on the screen which always points to north + * @param interval the amount of time (milliseconds) to show the needle. Default is 600. + */ + //% weight=50 blockGap=8 + //% blockId=basic_show_compass + //% block="show compass needle for $interval|ms" + //% interval.shadow=timePicker + //% interval.min=1 + //% interval.defl=600 + //% parts="ledmatrix" + //% advanced=true + export function showCompass(interval = 600) { + let i = 0 + let startTime = input.runningTime() + let endTime = startTime + interval + let refreshRate = 100 + let rest = 0 + + 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) + } + } + + 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) + } + + } + } + +} \ No newline at end of file diff --git a/libs/core/music.ts b/libs/core/music.ts index 1580e7ec..fb4adffa 100644 --- a/libs/core/music.ts +++ b/libs/core/music.ts @@ -482,6 +482,7 @@ namespace music { //% help=music/set-volume //% weight=70 //% group="Volume" + //% deprecated=true export function setVolume(volume: number): void { pins.analogSetPitchVolume(volume); } @@ -494,6 +495,7 @@ namespace music { //% help=music/volume //% weight=69 //% group="Volume" + //% deprecated=true export function volume(): number { return pins.analogPitchVolume(); } diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index 436024fa..5b4021da 100644 --- a/libs/core/pins.cpp +++ b/libs/core/pins.cpp @@ -112,7 +112,7 @@ namespace pins { /** * Read the specified pin or connector as either 0 or 1 - * @param name pin to read from, eg: DigitalPin.P1 + * @param name pin to read from, eg: DigitalPin.P0 */ //% help=pins/digital-read-pin weight=30 //% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 @@ -124,7 +124,7 @@ namespace pins { /** * Set a pin or connector value to either 0 or 1. - * @param name pin to write to, eg: DigitalPin.P1 + * @param name pin to write to, eg: DigitalPin.P0 * @param value value to set on the pin, 1 eg,0 */ //% help=pins/digital-write-pin weight=29 @@ -178,7 +178,7 @@ namespace pins { /** * Configure the pin as a digital input and generate an event when the pin is pulsed either high or low. - * @param name digital pin to register to, eg: DigitalPin.P1 + * @param name digital pin to register to, eg: DigitalPin.P0 * @param pulse the value of the pulse, eg: PulseValue.High */ //% help=pins/on-pulsed weight=22 blockGap=16 advanced=true @@ -205,7 +205,7 @@ namespace pins { /** * Return the duration of a pulse at a pin in microseconds. - * @param name the pin which measures the pulse, eg: DigitalPin.P1 + * @param name the pin which measures the pulse, eg: DigitalPin.P0 * @param value the value of the pulse, eg: PulseValue.High * @param maximum duration in microseconds */ @@ -366,7 +366,7 @@ namespace pins { /** * Configure the pull directiion of of a pin. - * @param name pin to set the pull mode on, eg: DigitalPin.P1 + * @param name pin to set the pull mode on, eg: DigitalPin.P0 * @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp */ //% help=pins/set-pull weight=3 advanced=true @@ -392,7 +392,7 @@ namespace pins { /** * Configure the events emitted by this pin. Events can be subscribed to * using ``control.onEvent()``. - * @param name pin to set the event mode on, eg: DigitalPin.P1 + * @param name pin to set the event mode on, eg: DigitalPin.P0 * @param type the type of events for this pin to emit, eg: PinEventType.Edge */ //% help=pins/set-events weight=4 advanced=true diff --git a/libs/core/pxt.json b/libs/core/pxt.json index fd1e9439..1ccbcbc7 100644 --- a/libs/core/pxt.json +++ b/libs/core/pxt.json @@ -56,6 +56,7 @@ "templates.ts", "sendbuffer.s", "light.cpp", + "compass.ts", "parts/speaker.svg", "parts/headphone.svg", "parts/dcmotor.svg", diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 4c30e6c1..afd83068 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -662,7 +662,7 @@ declare namespace pins { /** * Read the connector value as analog, that is, as a value comprised between 0 and 1023. - * @param name pin to write to, eg: AnalogPin.P0 + * @param name pin to write to, eg: AnalogPin.P1 */ //% help=pins/analog-read-pin weight=25 //% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" @@ -672,7 +672,7 @@ declare namespace pins { /** * Set the connector value as analog. Value must be comprised between 0 and 1023. - * @param name pin name to write to, eg: AnalogPin.P0 + * @param name pin name to write to, eg: AnalogPin.P1 * @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0 */ //% help=pins/analog-write-pin weight=24 @@ -685,7 +685,7 @@ declare namespace pins { /** * Configure the pulse-width modulation (PWM) period of the analog output in microseconds. * If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect. - * @param name analog pin to set period to, eg: AnalogPin.P0 + * @param name analog pin to set period to, eg: AnalogPin.P1 * @param micros period in micro seconds. eg:20000 */ //% help=pins/analog-set-period weight=23 blockGap=8 @@ -728,7 +728,7 @@ declare namespace pins { /** * 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). - * @param name pin to write to, eg: AnalogPin.P0 + * @param name pin to write to, eg: AnalogPin.P1 * @param value angle or rotation speed, eg:180,90,0 */ //% help=pins/servo-write-pin weight=20 diff --git a/package-lock.json b/package-lock.json index 281cb785..b26980cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4322,9 +4322,9 @@ } }, "pxt-core": { - "version": "6.0.20", - "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-6.0.20.tgz", - "integrity": "sha512-dugQC1/10P72exsR3Ed3vGuK8rLkP3+NjrWE+NrLqSH9064Fl20d1fGe8yHGjlbPYyKACDjJeX3fZy1Y12GzEA==", + "version": "6.0.23", + "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-6.0.23.tgz", + "integrity": "sha512-3RYVuojjcN3AkFxivFnjRkghknXGbfVGYwkzdx6UGLlr4c+AtZqKJf9SNV0eJBDpQEukpe4DXEct7ADWHtXwoA==", "requires": { "applicationinsights-js": "^1.0.20", "bluebird": "3.5.1", diff --git a/pxtarget.json b/pxtarget.json index a19b2d0a..4bc23bd8 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -21,9 +21,6 @@ "thumbnails": true, "publishing": true, "importing": true, - "preferredPackages": [ - "Microsoft/pxt-neopixel" - ], "githubPackages": true, "cloudProviders": { "github": {} @@ -113,7 +110,7 @@ "pid": "0x1025" } ], - "webUSB": true, + "webUSB": false, "useNewFunctions": true }, "compileService": { @@ -159,7 +156,7 @@ "autoRun": true, "streams": false, "aspectRatio": 1.13, - "parts": true, + "parts": false, "partsAspectRatio": 0.69, "boardDefinition": { "visual": "calliope", @@ -313,7 +310,6 @@ "boardName": "Calliope mini", "driveDisplayName": "MINI", "appStoreID": "1309545545", - "mobileSafariDownloadProtocol": "microbithex://?data", "crowdinProject": "kindscript", "extendEditor": true, "extendFieldEditors": true, @@ -357,10 +353,10 @@ "monacoToolbox": true, "hasAudio": true, "socialOptions": { - "orgTwitterHandle": "MSMakeCode", - "hashtags": "MakeCode", - "discourse": "https://forum.makecode.com/", - "discourseCategory": "micro:bit" + "orgTwitterHandle": "calliopemini", + "hashtags": "calliopemini", + "discourse": "https://forum.calliope.cc", + "discourseCategory": "Probleme-Software" }, "blocklyOptions": { "grid": { diff --git a/targetconfig.json b/targetconfig.json index 4b55f7ed..e6381c5f 100644 --- a/targetconfig.json +++ b/targetconfig.json @@ -196,18 +196,32 @@ "daferdur/pxt-myHX711", "CytronTechnologies/pxt-edubit", "MakeAndLearn/pxt-microshield", - "elecfreaks/pxt-TPBot" - ], - "preferredRepos": [ - "Microsoft/pxt-neopixel", + "elecfreaks/pxt-TPBot", "calliope-edu/pxt-grove", "tinysuperlab/motionkit", "tinysuperlab/touchkit", + "MKleinSB/pxt-seeed-temperature", + "MKleinSB/pxt-iot-lora-node-calliope", + "MKleinSB/pxt-dht11", + "MKleinSB/pxt-esp-thingspeak", + "MKleinSB/pxt-neopixel-calliope", + "MKleinSB/pxt-OLED-SSD1306" + ], + "preferredRepos": [ + "tinysuperlab/motionkit", + "tinysuperlab/touchkit", + "calliope-edu/pxt-grove", + "Microsoft/pxt-neopixel", "Microsoft/pxt-microturtle", "MKleinSB/pxt-OLED-SSD1306", "MKleinSB/pxt-iot-lora-node", - "kittenbot/pxt-robotbit", - "MKleinSB/pxt-foldio" + "MKleinSB/pxt-foldio", + "MKleinSB/pxt-seeed-temperature", + "MKleinSB/pxt-iot-lora-node-calliope", + "MKleinSB/pxt-dht11", + "MKleinSB/pxt-esp-thingspeak", + "MKleinSB/pxt-neopixel-calliope", + "kittenbot/pxt-robotbit" ] }, "galleries": {