mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-09 12:01:21 -04:00
Microbit display commands yield for a tick (#1331)
* Microbit display commands yield for a tick * JSDOC fixes
This commit is contained in:
parent
0c21f739ec
commit
ea1bb602f9
1 changed files with 9 additions and 5 deletions
|
@ -507,7 +507,7 @@ class Scratch3MicroBitBlocks {
|
|||
/**
|
||||
* Display a predefined symbol on the 5x5 LED matrix.
|
||||
* @param {object} args - the block's arguments.
|
||||
* @return {Promise} - a Promise that resolves when writing to device.
|
||||
* @return {Promise} - a Promise that resolves after a tick.
|
||||
*/
|
||||
displaySymbol (args) {
|
||||
const symbol = cast.toString(args.MATRIX);
|
||||
|
@ -522,29 +522,33 @@ class Scratch3MicroBitBlocks {
|
|||
this._device.ledMatrixState[2] = (hex >> 10) & 0x1F;
|
||||
this._device.ledMatrixState[3] = (hex >> 15) & 0x1F;
|
||||
this._device.ledMatrixState[4] = (hex >> 20) & 0x1F;
|
||||
return this._device.displayMatrix(this._device.ledMatrixState);
|
||||
this._device.displayMatrix(this._device.ledMatrixState);
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display text on the 5x5 LED matrix.
|
||||
* @param {object} args - the block's arguments.
|
||||
* @return {Promise} - a Promise that resolves when writing to device.
|
||||
* @return {Promise} - a Promise that resolves after a tick.
|
||||
* Note the limit is 19 characters
|
||||
*/
|
||||
displayText (args) {
|
||||
const text = String(args.TEXT).substring(0, 19);
|
||||
return this._device.displayText(text);
|
||||
this._device.displayText(text);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn all 5x5 matrix LEDs off.
|
||||
* @return {Promise} - a Promise that resolves after a tick.
|
||||
*/
|
||||
displayClear () {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
this._device.ledMatrixState[i] = 0;
|
||||
}
|
||||
this._device.displayMatrix(this._device.ledMatrixState);
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue