From 79517f8a30522d913ee32729e00046656163a83b Mon Sep 17 00:00:00 2001 From: Amerlander Date: Thu, 10 Sep 2020 09:24:06 +0200 Subject: [PATCH] Fix Sound (#114) * 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 Co-authored-by: Juri --- calliope.code-workspace | 13 ------------- libs/core/music.ts | 2 +- libs/core/pins.cpp | 22 +++++++++++----------- package-lock.json | 4 +--- tests/wg-flood-monitor.ts | 2 +- 5 files changed, 14 insertions(+), 29 deletions(-) delete mode 100644 calliope.code-workspace diff --git a/calliope.code-workspace b/calliope.code-workspace deleted file mode 100644 index c925e61c..00000000 --- a/calliope.code-workspace +++ /dev/null @@ -1,13 +0,0 @@ -{ - "folders": [ - { - "path": "../pxt" - }, - { - "path": "../pxt-common-packages" - }, - { - "path": "." - } - ] -} \ No newline at end of file diff --git a/libs/core/music.ts b/libs/core/music.ts index 7a330b90..1580e7ec 100644 --- a/libs/core/music.ts +++ b/libs/core/music.ts @@ -200,7 +200,7 @@ namespace music { //% group="Tone" export function playTone(frequency: number, ms: number): void { if (_playTone) _playTone(frequency, ms); - else pins.analogPitch(frequency, ms); + else speakerPlayTone(frequency, ms); } /** diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index 47eef73a..436024fa 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.P0 + * @param name pin to read from, eg: DigitalPin.P1 */ //% 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.P0 + * @param name pin to write to, eg: DigitalPin.P1 * @param value value to set on the pin, 1 eg,0 */ //% help=pins/digital-write-pin weight=29 @@ -138,7 +138,7 @@ 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" @@ -150,7 +150,7 @@ 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 @@ -165,7 +165,7 @@ 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 @@ -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.P0 + * @param name digital pin to register to, eg: DigitalPin.P1 * @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.P0 + * @param name the pin which measures the pulse, eg: DigitalPin.P1 * @param value the value of the pulse, eg: PulseValue.High * @param maximum duration in microseconds */ @@ -248,7 +248,7 @@ 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 @@ -342,7 +342,7 @@ namespace pins { void analogPitch(int frequency, int ms) { // init pins if needed if (NULL == pitchPin) { - pitchPin = getPin((int)DigitalPin::P0); + pitchPin = getPin((int)DigitalPin::P1); #ifdef SOUND_MIRROR_EXTENSION pitchPin2 = &SOUND_MIRROR_EXTENSION; #endif @@ -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.P0 + * @param name pin to set the pull mode on, eg: DigitalPin.P1 * @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.P0 + * @param name pin to set the event mode on, eg: DigitalPin.P1 * @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/package-lock.json b/package-lock.json index 8a0996d0..f728b6d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -405,7 +405,6 @@ "version": "2.10.1", "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "optional": true, "requires": { "hoek": "2.x.x" } @@ -2096,8 +2095,7 @@ "hoek": { "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "optional": true + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" }, "hsl-regex": { "version": "1.0.0", diff --git a/tests/wg-flood-monitor.ts b/tests/wg-flood-monitor.ts index bf152d3a..35d2391c 100644 --- a/tests/wg-flood-monitor.ts +++ b/tests/wg-flood-monitor.ts @@ -130,7 +130,7 @@ function readSensor(): number { // Produce a sensor value in range 0..1023 if (sensorType == "ANALOG") { // Input range is 0..1023 - value = pins.analogReadPin(AnalogPin.P0) + value = pins.analogReadPin(AnalogPin.P1) } else if (sensorType == "TILT") { // Input range is -1024 (pads highest)..1023 (pads lowest) value = input.acceleration(Dimension.Y)