diff --git a/src/playground/blocks/hardwareLite/block_microbit2_lite.js b/src/playground/blocks/hardwareLite/block_microbit2_lite.js index a22a7ccd53..8135c352f6 100644 --- a/src/playground/blocks/hardwareLite/block_microbit2_lite.js +++ b/src/playground/blocks/hardwareLite/block_microbit2_lite.js @@ -1487,6 +1487,13 @@ const EVENT_INTERVAL = 150; params: [ { type: 'Led2', + value: [ + [0, 0, 0, 0, 0], + [0, 9, 0, 9, 0], + [0, 0, 0, 0, 0], + [9, 0, 0, 0, 9], + [0, 9, 9, 9, 0], + ], }, { type: 'Indicator', diff --git a/src/playground/field/led2.js b/src/playground/field/led2.js index 0357be457c..959c2971ec 100644 --- a/src/playground/field/led2.js +++ b/src/playground/field/led2.js @@ -7,6 +7,8 @@ import { LedPicker } from '@entrylabs/tool'; /* * */ +const DEFAULT_LED_SIZE = 5; + Entry.FieldLed2 = class FieldLed2 extends Entry.Field { constructor(content, blockView, index) { super(content, blockView, index); @@ -35,6 +37,7 @@ Entry.FieldLed2 = class FieldLed2 extends Entry.Field { [0, 9, 9, 9, 0], ] ); + this.ledSize = this.getValue().length || DEFAULT_LED_SIZE; /* */ @@ -46,8 +49,8 @@ Entry.FieldLed2 = class FieldLed2 extends Entry.Field { renderLed() { const ledStatus = this.getValue(); - const ledDist = 3; - const ledOffset = 0.5; + const ledDist = 3 * (DEFAULT_LED_SIZE / this.ledSize); + const ledOffset = 0.5 * (DEFAULT_LED_SIZE / this.ledSize); const currentStatus = ledStatus.params || ledStatus; currentStatus.map((leds, x_pos) => { return leds.map((led, y_pos) => { @@ -107,7 +110,7 @@ Entry.FieldLed2 = class FieldLed2 extends Entry.Field { fill: '#008380', }); - this._rect = [[], [], [], [], []]; + this._rect = Array.from({ length: this.ledSize }, () => []); this.renderLed(); this._arrow = this.svgGroup.elem('path', { d: `M 30.79 -1.182