diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index c198899e..d9f29f2c 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -29,17 +29,12 @@ "brick.clearScreen": "Clears the screen", "brick.lightPattern": "Pattern block.", "brick.lightPattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green", - "brick.print": "Show text on the screen.", + "brick.printLine": "Show text on the screen at a specific line.", + "brick.printLine|param|line": "the line number to print the text at, eg: 0", + "brick.printLine|param|text": "the text to print on the screen, eg: \"Hello world\"", "brick.printPorts": "Prints the port states on the screen", - "brick.print|param|text": "the text to print on the screen, eg: \"Hello world\"", - "brick.print|param|x": "the starting position's x coordinate, eg: 0", - "brick.print|param|y": "the starting position's x coordinate, eg: 0", "brick.setLight": "Set lights.", "brick.setLight|param|pattern": "the lights pattern to use.", - "brick.setPixel": "Sets a pixel on or off", - "brick.setPixel|param|on": "a value indicating if the pixel should be on or off", - "brick.setPixel|param|x": "the starting position's x coordinate, eg: 0", - "brick.setPixel|param|y": "the starting position's x coordinate, eg: 0", "brick.showImage": "Shows an image on screen", "brick.showImage|param|image": "image to draw", "console": "Reading and writing data to the console output.\n\nReading and writing data to the console output.", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 95afbc34..628e7efe 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -35,10 +35,9 @@ "brick.buttonUp|block": "up", "brick.clearScreen|block": "clear screen", "brick.lightPattern|block": "%pattern", + "brick.printLine|block": "print %text| at line: %line", "brick.printPorts|block": "print ports", - "brick.print|block": "print %text| at x: %x| y: %y", "brick.setLight|block": "set light to %pattern=led_pattern", - "brick.setPixel|block": "set pixel %on| at x: %x| y: %y", "brick.showImage|block": "show image %image=screen_image_picker", "brick|block": "brick", "console.logValue|block": "console|log value %name|= %value", diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 0cf93b5a..854b395e 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -105,7 +105,7 @@ namespace brick { //% blockId=buttonWasPressed //% parts="brick" //% blockNamespace=brick - //% weight=80 blockGap=8 + //% weight=80 //% group="Buttons" wasPressed() { const r = this._wasPressed diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 7d5894c4..652d086d 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -80,15 +80,6 @@ namespace brick { } } - /** - * Sets a pixel on or off - * @param on a value indicating if the pixel should be on or off - * @param x the starting position's x coordinate, eg: 0 - * @param y the starting position's x coordinate, eg: 0 - */ - //% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y" - //% weight=98 group="Screen" - //% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff export function setPixel(on: boolean, x: number, y: number) { x |= 0 y |= 0 @@ -97,14 +88,20 @@ namespace brick { } /** - * Show text on the screen. + * Show text on the screen at a specific line. * @param text the text to print on the screen, eg: "Hello world" - * @param x the starting position's x coordinate, eg: 0 - * @param y the starting position's x coordinate, eg: 0 + * @param line the line number to print the text at, eg: 0 */ - //% blockId=screen_print block="print %text| at x: %x| y: %y" - //% weight=99 group="Screen" inlineInputMode="inline" blockGap=8 - //% x.min=0 x.max=178 y.min=0 y.max=128 + //% blockId=screen_print block="print %text| at line: %line" + //% weight=98 group="Screen" inlineInputMode="inline" blockGap=8 + //% line.min=0 line.max=9 + export function printLine(text: string, line: number) { + const NUM_LINES = 9; + const offset = 5; + const y = offset + (Math.clamp(0, NUM_LINES, line) / (NUM_LINES + 2)) * DAL.LCD_HEIGHT; + brick.print(text, offset, y); + } + export function print(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 y |= 0 @@ -140,7 +137,7 @@ namespace brick { * @param image image to draw */ //% blockId=screen_show_image block="show image %image=screen_image_picker" - //% weight=95 group="Screen" blockGap=8 + //% weight=100 group="Screen" blockGap=8 export function showImage(image: Image, delay: number = 400) { if (!image) return; image.draw(0, 0, Draw.Normal); @@ -166,7 +163,7 @@ namespace brick { * Clears the screen */ //% blockId=screen_clear_screen block="clear screen" - //% weight=94 group="Screen" blockGap=8 + //% weight=90 group="Screen" export function clearScreen() { screen.clear(); } diff --git a/libs/infrared-sensor/ir.ts b/libs/infrared-sensor/ir.ts index cebd135d..1fd9288b 100644 --- a/libs/infrared-sensor/ir.ts +++ b/libs/infrared-sensor/ir.ts @@ -112,7 +112,7 @@ namespace sensors { //% blockId=remotebuttonWasPressed //% parts="remote" //% blockNamespace=sensors - //% weight=80 blockGap=8 + //% weight=80 //% group="Remote Infrared Beacon" wasPressed() { return this.button.wasPressed(); @@ -238,7 +238,7 @@ namespace sensors { //% blockId=infraredGetRemoteCommand //% parts="infrared" //% blockNamespace=sensors - //% weight=65 blockGap=8 + //% weight=65 //% group="Infrared Sensor" remoteCommand(): number { this._setMode(IrSensorMode.RemoteControl) diff --git a/libs/music/_locales/music-jsdoc-strings.json b/libs/music/_locales/music-jsdoc-strings.json index e73f87ba..7123cd20 100644 --- a/libs/music/_locales/music-jsdoc-strings.json +++ b/libs/music/_locales/music-jsdoc-strings.json @@ -2,8 +2,6 @@ "Sound.buffer": "Returns the underlaying Buffer object.", "Sound.play": "Play sound.", "music": "Generation of music tones.", - "music._soundPicker": "A sound", - "music._soundPicker|param|sound": "the sound", "music.beat": "Return the duration of a beat in milliseconds (the beat fraction).", "music.beat|param|fraction": "the fraction of the current whole note, eg: BeatFraction.Half", "music.changeTempoBy": "Change the tempo up or down by some amount of beats per minute (bpm).", diff --git a/libs/music/_locales/music-strings.json b/libs/music/_locales/music-strings.json index 7cef7803..84820d72 100644 --- a/libs/music/_locales/music-strings.json +++ b/libs/music/_locales/music-strings.json @@ -20,7 +20,6 @@ "Note.GSharp|block": "G#", "SoundOutputDestination.Pin|block": "pin", "SoundOutputDestination.Speaker|block": "speaker", - "music._soundPicker|block": "%sound", "music.beat|block": "%fraction|beat", "music.changeTempoBy|block": "change tempo by %value|(bpm)", "music.noteFrequency|block": "%note", diff --git a/libs/music/music.cpp b/libs/music/music.cpp index e6b999ba..9939027a 100644 --- a/libs/music/music.cpp +++ b/libs/music/music.cpp @@ -170,7 +170,7 @@ void playTone(int frequency, int ms) { //% blockId=music_stop_all_sounds block="stop all sounds" //% parts="headphone" //% blockNamespace=music -//% weight=76 blockGap=8 +//% weight=97 void stopAllSounds() { if (currentSample) { samplePtr = currentSample->length; diff --git a/libs/music/shims.d.ts b/libs/music/shims.d.ts index 61f381a4..a70e58b7 100644 --- a/libs/music/shims.d.ts +++ b/libs/music/shims.d.ts @@ -32,7 +32,7 @@ declare namespace music { //% blockId=music_stop_all_sounds block="stop all sounds" //% parts="headphone" //% blockNamespace=music - //% weight=76 blockGap=8 shim=music::stopAllSounds + //% weight=97 shim=music::stopAllSounds function stopAllSounds(): void; /** Makes a sound bound to a buffer in WAV format. */ diff --git a/libs/music/sounds.ts b/libs/music/sounds.ts index 8fe1a906..c79caf18 100644 --- a/libs/music/sounds.ts +++ b/libs/music/sounds.ts @@ -264,7 +264,7 @@ namespace music { * @param sound the sound to play */ //% blockId=music_play_sound_effect_until_done block="play sound effect %sound|until done" - //% weight=98 + //% weight=98 blockGap=8 export function playSoundEffectUntilDone(sound: Sound) { if (!sound) return; sound.play(); @@ -276,7 +276,7 @@ namespace music { */ //% blockId=music_sound_picker block="%sound" shim=TD_ID //% weight=0 blockHidden=1 - export function _soundPicker(sound: Sound): Sound { + export function __soundPicker(sound: Sound): Sound { return sound; } @@ -285,7 +285,7 @@ namespace music { * @param sound the sound to play */ //% blockId=music_play_sound_effect block="play sound effect %sound" - //% weight=99 + //% weight=99 blockGap=8 export function playSoundEffect(sound: Sound) { if (!sound || numSoundsPlaying >= soundsLimit) return; numSoundsPlaying++; diff --git a/libs/touch-sensor/touch.ts b/libs/touch-sensor/touch.ts index 7d8b2540..86345f22 100644 --- a/libs/touch-sensor/touch.ts +++ b/libs/touch-sensor/touch.ts @@ -75,7 +75,7 @@ namespace sensors { //% blockId=touchIsPressed //% parts="touch" //% blockNamespace=sensors - //% weight=81 blockGap=8 + //% weight=81 //% group="Touch Sensor" isPressed() { return this.button.isPressed(); diff --git a/libs/ultrasonic-sensor/ultrasonic.ts b/libs/ultrasonic-sensor/ultrasonic.ts index 097749ca..0cf66ce4 100644 --- a/libs/ultrasonic-sensor/ultrasonic.ts +++ b/libs/ultrasonic-sensor/ultrasonic.ts @@ -75,7 +75,7 @@ namespace sensors { //% blockId=sonarGetDistance //% parts="ultrasonicsensor" //% blockNamespace=sensors - //% weight=65 blockGap=8 + //% weight=65 //% group="Ultrasonic Sensor" distance(): number { // it supposedly also has an inch mode, but we stick to cm