diff --git a/libs/core/dal.d.ts b/libs/core/dal.d.ts index 06c8867c..4658e0d9 100644 --- a/libs/core/dal.d.ts +++ b/libs/core/dal.d.ts @@ -153,6 +153,9 @@ declare const enum DAL { CALLIOPE_ID_IO_P14 = 38, CALLIOPE_ID_IO_P15 = 39, CALLIOPE_ID_IO_P22 = 40, + CALLIOPE_ID_IO_P28 = 41, + CALLIOPE_ID_IO_P29 = 42, + CALLIOPE_ID_IO_P30 = 43, MICROBIT_ID_MESSAGE_BUS_LISTENER = 1021, MICROBIT_ID_NOTIFY_ONE = 1022, MICROBIT_ID_NOTIFY = 1023, diff --git a/libs/core/enums.d.ts b/libs/core/enums.d.ts index c546d312..8def741a 100644 --- a/libs/core/enums.d.ts +++ b/libs/core/enums.d.ts @@ -37,7 +37,7 @@ declare namespace basic { P0 = 7, // MICROBIT_ID_IO_P0 P1 = 8, // MICROBIT_ID_IO_P1 P2 = 9, // MICROBIT_ID_IO_P2 - P3 = 33, // CALLIOPE_ID_IO_P3 + P3 = 40, // CALLIOPE_ID_IO_P22 } @@ -282,6 +282,9 @@ declare namespace motors { //P16 = MICROBIT_ID_IO_P16, P19 = 24, // MICROBIT_ID_IO_P19 P20 = 25, // MICROBIT_ID_IO_P20 + P28 = 41, // CALLIOPE_ID_IO_P28 + P29 = 42, // CALLIOPE_ID_IO_P29 + P30 = 43, // CALLIOPE_ID_IO_P30 } @@ -292,6 +295,8 @@ declare namespace motors { P3 = 10, // MICROBIT_ID_IO_P3 P4 = 11, // MICROBIT_ID_IO_P4 P10 = 17, // MICROBIT_ID_IO_P10 + P29 = 42, // CALLIOPE_ID_IO_P29 + P30 = 43, // CALLIOPE_ID_IO_P30 } diff --git a/libs/core/input.cpp b/libs/core/input.cpp index 4424e4c8..3e0fc943 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -29,7 +29,7 @@ enum class TouchPin { P0 = MICROBIT_ID_IO_P0, P1 = MICROBIT_ID_IO_P1, P2 = MICROBIT_ID_IO_P2, - P3 = CALLIOPE_ID_IO_P3 + P3 = CALLIOPE_ID_IO_P22 }; enum class AcceleratorRange { diff --git a/libs/core/motors.cpp b/libs/core/motors.cpp index d04a6837..864e0eef 100644 --- a/libs/core/motors.cpp +++ b/libs/core/motors.cpp @@ -51,17 +51,17 @@ namespace motors { //% weight=80 void dualMotorPower(Motor motor, int duty_percent) { switch(motor) { - case Motor::A: if (duty_percent <= 0) uBit.soundmotor.MotorA_Off(); + case Motor::A: if (duty_percent <= 0) uBit.soundmotor.MotorA_Off(); else uBit.soundmotor.MotorA_On(duty_percent); break; - case Motor::B: if (duty_percent <= 0) uBit.soundmotor.MotorB_Off(); + case Motor::B: if (duty_percent <= 0) uBit.soundmotor.MotorB_Off(); else uBit.soundmotor.MotorB_On(duty_percent); break; case Motor::AB: if (duty_percent <= 0) { uBit.soundmotor.MotorA_Off(); uBit.soundmotor.MotorB_Off(); } else { - uBit.soundmotor.MotorA_On(duty_percent); - uBit.soundmotor.MotorB_On(duty_percent); - } + uBit.soundmotor.MotorA_On(duty_percent); + uBit.soundmotor.MotorB_On(duty_percent); + } break; } } diff --git a/libs/core/music.cpp b/libs/core/music.cpp index f7292d78..3311cc19 100644 --- a/libs/core/music.cpp +++ b/libs/core/music.cpp @@ -8,11 +8,11 @@ namespace music { */ //% help=music/play-tone weight=90 //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 - //% parts="speaker" async - void playTone(int frequency, int ms) { - uBit.soundmotor.Sound_On(frequency); + //% parts="speaker" + void playTone(int freqency, int ms) { + uBit.soundmotor.soundOn(freqency); if(ms > 0) uBit.sleep(ms); - uBit.soundmotor.Sound_Off(); + uBit.soundmotor.soundOff(); } /** diff --git a/libs/core/music.ts b/libs/core/music.ts index 50882332..9ad9b3a3 100644 --- a/libs/core/music.ts +++ b/libs/core/music.ts @@ -167,7 +167,7 @@ namespace music { let beat = 60000 / beatsPerMinute; if (fraction == BeatFraction.Whole) return beat; else if (fraction == BeatFraction.Half) return beat / 2; - else if (fraction == BeatFraction.Quarter) return beat / 4 + else if (fraction == BeatFraction.Quarter) return beat / 4; else if (fraction == BeatFraction.Eighth) return beat / 8; else return beat / 16; } diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index 47e30ba4..4b8b2461 100644 --- a/libs/core/pins.cpp +++ b/libs/core/pins.cpp @@ -20,6 +20,9 @@ enum class DigitalPin { //P16 = MICROBIT_ID_IO_P16, P19 = MICROBIT_ID_IO_P19, P20 = MICROBIT_ID_IO_P20, + P28 = CALLIOPE_ID_IO_P28, + P29 = CALLIOPE_ID_IO_P29, + P30 = CALLIOPE_ID_IO_P30 }; enum class AnalogPin { @@ -29,6 +32,8 @@ enum class AnalogPin { P3 = MICROBIT_ID_IO_P3, P4 = MICROBIT_ID_IO_P4, P10 = MICROBIT_ID_IO_P10, + P29 = CALLIOPE_ID_IO_P29, + P30 = CALLIOPE_ID_IO_P30 }; enum class PulseValue { @@ -74,6 +79,9 @@ MicroBitPin *getPin(int id) { case CALLIOPE_ID_IO_P14: return &uBit.io.CAL_P14; case CALLIOPE_ID_IO_P15: return &uBit.io.CAL_P15; case CALLIOPE_ID_IO_P22: return &uBit.io.CAL_P22; + case CALLIOPE_ID_IO_P28: return &uBit.io.CAL_P28; + case CALLIOPE_ID_IO_P29: return &uBit.io.CAL_P29; + case CALLIOPE_ID_IO_P30: return &uBit.io.CAL_P30; default: return NULL; } } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 3a11cfa0..63f135f9 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -559,6 +559,18 @@ declare namespace music { //% parts="speaker" shim=music::ringTone function ringTone(frequency: number): void; } +declare namespace music { + + /** + * Plays a tone through ``speaker`` for the given duration. + * @param frequency pitch of the tone to play in Hertz (Hz) + * @param ms tone duration in milliseconds (ms) + */ + //% help=music/play-tone weight=90 + //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8 + //% parts="speaker" shim=music::playTone + function playTone(freqency: number, ms: number): void; +} declare namespace pins { /**