From 9208b087e2e1977d9ad0ab86e927780d971fc698 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 2 Nov 2025 23:38:16 +0100 Subject: [PATCH] feat: add matrixClear command to ArduinoBasics extension --- .../src/extensions/arduino_basics/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js index c45b3ce..5993281 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js @@ -19,8 +19,9 @@ const iconURI = ""; // eslint-disable-next-line max-len const menuIconURI = ""; -const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; +// const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; +const wsServerURL = `ws://192.168.1.39:7000`; class ArduinoBasics { constructor(runtime) { this.runtime = runtime; @@ -52,6 +53,13 @@ ArduinoBasics.prototype.getInfo = function() { }, }, }, + { + opcode: "matrixClear", + blockType: BlockType.COMMAND, + text: "clear matrix", + func: "matrixClear", + arguments: {}, + }, { opcode: "setLed3", blockType: BlockType.COMMAND, @@ -85,6 +93,11 @@ ArduinoBasics.prototype.matrixDraw = function(args) { this.io.emit("matrix_draw", { frame: args.FRAME }); }; +ArduinoBasics.prototype.matrixClear = function() { + console.log("Clearing matrix"); + this.io.emit("matrix_draw", { frame: "0000000000000000000000000" }); +}; + ArduinoBasics.prototype.setLed3 = function(args) { const hexColor = args.HEX; const rgb = this.hexToRgb(hexColor);