From bdf8c4c6be6f0f380135791fccaabe8dffe25a7b Mon Sep 17 00:00:00 2001 From: Tnks2U Date: Wed, 18 Dec 2024 19:19:40 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20led=20=EC=82=AC=EC=9D=B4=EC=A6=88=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocks/hardwareLite/block_microbit2_lite.js | 7 +++++++ src/playground/field/led2.js | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) 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