From 91c6fdee3d144fceba398c66e5b25e166a21363f Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 07:50:32 +0100 Subject: [PATCH 1/8] feat: implement ArduinoUnoQ class for enhanced LED and matrix control --- .../scratch-vm/src/extensions/ArduinoUnoQ.js | 104 ++++++++++++++++++ .../src/extensions/arduino_basics/index.js | 37 ++----- 2 files changed, 112 insertions(+), 29 deletions(-) create mode 100644 scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js new file mode 100644 index 0000000..30ff94a --- /dev/null +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js @@ -0,0 +1,104 @@ +const io = require("./socket.io.min.js"); + +class ArduinoUnoQ { + constructor(host, port) { + this.serverURL = `wss://${host}:${port}`; + + this.io = io(this.serverURL, { + path: "/socket.io", + transports: ["polling", "websocket"], + autoConnect: true, + }); + this.isConnected = false; + + this._setupConnectionHandlers(); + } + + _setupConnectionHandlers() { + this.io.on("connect", () => { + this.isConnected = true; + console.log(`Connected to Arduino UNO Q at ${this.serverURL}`); + }); + + this.io.on("disconnect", (reason) => { + this.isConnected = false; + console.log(`Disconnected from Arduino UNO Q: ${reason}`); + }); + + this.io.on("connect_error", (error) => { + console.error(`Connection error:`, error.message); + }); + + this.io.on("reconnect", (attemptNumber) => { + console.log(`Reconnected to Arduino UNO Q after ${attemptNumber} attempts`); + }); + } + + connect() { + if (!this.io.connected) { + console.log("Attempting to connect to Arduino UNO Q..."); + this.io.connect(); + } + } + + disconnect() { + if (this.io.connected) { + console.log("Disconnecting from Arduino UNO Q..."); + this.io.disconnect(); + } + } + + // ===== LED CONTROL METHODS ===== + /** + * Set RGB LED color + * @param {string} led - LED identifier ("LED3" or "LED4") + * @param {number} r - Red value (0-255) + * @param {number} g - Green value (0-255) + * @param {number} b - Blue value (0-255) + */ + setLedRGB(led, r, g, b) { + this.io.emit("set_led_rgb", { + led: led, + r: Math.max(0, Math.min(255, r)), + g: Math.max(0, Math.min(255, g)), + b: Math.max(0, Math.min(255, b)), + }); + console.log(`Setting ${led} to RGB(${r}, ${g}, ${b})`); + } + + /** + * Turn off LED + * @param {string} led - LED identifier ("LED3" or "LED4") + */ + turnOffLed(led) { + this.setLedRGB(led, 0, 0, 0); + } + + // ===== MATRIX CONTROL METHODS ===== + + /** + * Draw frame on LED matrix + * @param {string} frame - 25-character string representing 5x5 matrix (0s and 1s) + */ + matrixDraw(frame) { + if (typeof frame !== "string" || frame.length !== 25) { + console.error("Invalid frame format. Expected 25-character string of 0s and 1s"); + return; + } + // Validate frame contains only 0s and 1s + if (!/^[01]+$/.test(frame)) { + console.error("Frame must contain only 0s and 1s"); + return; + } + + this.io.emit("matrix_draw", { frame: frame }); + console.log(`Drawing matrix frame: ${frame}`); + } + + matrixClear() { + const clearFrame = "0".repeat(25); + this.matrixDraw(clearFrame); + } +} + +module.exports = ArduinoUnoQ; 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 d6431a5..c1957b7 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 @@ -1,35 +1,18 @@ -// const formatMessage = require('../../../../../../scratch-editor/node_modules/format-message'); const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/block-type"); const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const io = require("../socket.io.min.js"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); -/** - * Url of icon to be displayed at the left edge of each extension block. - * @type {string} - */ -// eslint-disable-next-line max-len +// TODO: add icons const iconURI = ""; - -/** - * Url of icon to be displayed in the toolbox menu for the extension category. - * @type {string} - */ -// eslint-disable-next-line max-len const menuIconURI = ""; -const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; - class ArduinoBasics { constructor(runtime) { this.runtime = runtime; - - this.io = io(wsServerURL, { - path: "/socket.io", - transports: ["polling", "websocket"], - autoConnect: true, - }); + this.unoq = new ArduinoUnoQ("192.168.1.39", 7000); + this.unoq.connect(); } } @@ -88,27 +71,23 @@ ArduinoBasics.prototype.getInfo = function() { }; ArduinoBasics.prototype.matrixDraw = function(args) { - console.log(`Drawing frame on matrix: ${args}`); - this.io.emit("matrix_draw", { frame: args.FRAME }); + this.unoq.matrixDraw(args.FRAME); }; ArduinoBasics.prototype.matrixClear = function() { - console.log("Clearing matrix"); - this.io.emit("matrix_draw", { frame: "0000000000000000000000000" }); + this.unoq.matrixClear(); }; ArduinoBasics.prototype.setLed3 = function(args) { const hexColor = args.HEX; const rgb = this.hexToRgb(hexColor); - console.log(`Setting led 3 to: r:${rgb.r}, g:${rgb.g}, b:${rgb.b} (HEX: ${hexColor})`); - this.io.emit("set_led_rgb", { led: "LED3", r: rgb.r, g: rgb.g, b: rgb.b }); + this.unoq.setLedRGB("LED3", rgb.r, rgb.g, rgb.b); }; ArduinoBasics.prototype.setLed4 = function(args) { const hexColor = args.HEX; const rgb = this.hexToRgb(hexColor); - console.log(`Setting led 4 to: r:${rgb.r}, g:${rgb.g}, b:${rgb.b} (HEX: ${hexColor})`); - this.io.emit("set_led_rgb", { led: "LED4", r: rgb.r, g: rgb.g, b: rgb.b }); + this.unoq.setLedRGB("LED4", rgb.r, rgb.g, rgb.b); }; ArduinoBasics.prototype.hexToRgb = function(hex) { From c26c435042620bf23711323d7486a76e7a596a12 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 21:28:30 +0100 Subject: [PATCH 2/8] fix: update ArduinoUnoQ connection to use dynamic hostname --- .../packages/scratch-vm/src/extensions/arduino_basics/index.js | 2 +- 1 file changed, 1 insertion(+), 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 c1957b7..d918825 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 @@ -11,7 +11,7 @@ const menuIconURI = ""; class ArduinoBasics { constructor(runtime) { this.runtime = runtime; - this.unoq = new ArduinoUnoQ("192.168.1.39", 7000); + this.unoq = new ArduinoUnoQ(`${window.location.hostname}`, 7000); this.unoq.connect(); } } From 42ef451c51dc4d193bc1348cf11ac32c241ee50e Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 21:54:51 +0100 Subject: [PATCH 3/8] refactor: update ArduinoUnoQ integration to use default host and enhance object detection methods --- .../scratch-vm/src/extensions/ArduinoUnoQ.js | 35 +++++++++++++++++-- .../src/extensions/arduino_basics/index.js | 2 +- .../src/extensions/arduino_modulino/index.js | 23 +++--------- .../arduino_object_detection/index.js | 29 ++++----------- 4 files changed, 46 insertions(+), 43 deletions(-) diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js index 30ff94a..a294aaf 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js @@ -1,8 +1,11 @@ const io = require("./socket.io.min.js"); +// const DEFAULT_HOST = window.location.hostname; +const DEFAULT_HOST = "192.168.1.39"; + class ArduinoUnoQ { - constructor(host, port) { - this.serverURL = `wss://${host}:${port}`; + constructor() { + this.serverURL = `wss://${DEFAULT_HOST}:7000`; this.io = io(this.serverURL, { path: "/socket.io", @@ -99,6 +102,34 @@ class ArduinoUnoQ { const clearFrame = "0".repeat(25); this.matrixDraw(clearFrame); } + + // AI object detection + + detectObjects(imageData) { + this.io.emit("detect_objects", { image: imageData }); + console.log("Emitted detect_objects event"); + } + + // ===== EVENT HANDLING METHODS ===== + + on(event, callback) { + if (this.io) { + this.io.on(event, callback); + console.log(`Registered event listener for: ${event}`); + } else { + console.error("Socket.io not initialized"); + } + } + + emit(event, data) { + if (this.io && this.isConnected) { + this.io.emit(event, data); + console.log(`Emitted event: ${event}`, data); + } else { + console.warn(`Cannot emit ${event}: Not connected to Arduino UNO Q`); + } + } + } module.exports = ArduinoUnoQ; 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 d918825..8f95ab3 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 @@ -11,7 +11,7 @@ const menuIconURI = ""; class ArduinoBasics { constructor(runtime) { this.runtime = runtime; - this.unoq = new ArduinoUnoQ(`${window.location.hostname}`, 7000); + this.unoq = new ArduinoUnoQ(); this.unoq.connect(); } } diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js index 4b3fb5a..b0cb6b4 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js @@ -2,20 +2,10 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const io = require("../socket.io.min.js"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); -/** - * Url of icon to be displayed at the left edge of each extension block. - * @type {string} - */ -// eslint-disable-next-line max-len +// TODO: add icons const iconURI = ""; - -/** - * Url of icon to be displayed in the toolbox menu for the extension category. - * @type {string} - */ -// eslint-disable-next-line max-len const menuIconURI = ""; const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; @@ -23,15 +13,12 @@ const wsServerURL = `${window.location.protocol}//${window.location.hostname}:70 class ArduinoModulino { constructor(runtime) { this.runtime = runtime; - this.io = io(wsServerURL, { - path: "/socket.io", - transports: ["polling", "websocket"], - autoConnect: true, - }); + this.unoq = new ArduinoUnoQ(); + this.unoq.connect(); // TODO: move to ModulinoPeripheral this._button_pressed = ""; - this.io.on("modulino_buttons_pressed", (data) => { + this.unoq.on("modulino_buttons_pressed", (data) => { console.log(`Modulino button pressed event received: ${data.btn}`); this._button_pressed = data.btn.toUpperCase(); }); diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js index 29dac29..64e62af 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js @@ -2,27 +2,16 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const io = require("../socket.io.min.js"); const Video = require("../../../../../../scratch-editor/packages/scratch-vm/src/io/video"); const Rectangle = require("../../../../../../scratch-editor/packages/scratch-render/src/Rectangle.js"); const StageLayering = require("../../../../../../scratch-editor/packages/scratch-vm/src/engine/stage-layering.js"); const { Detection, MODEL_LABELS } = require("./object_detection"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); -/** - * Url of icon to be displayed at the left edge of each extension block. - * @type {string} - */ -// eslint-disable-next-line max-len +//TODO add icons const iconURI = ""; - -/** - * Url of icon to be displayed in the toolbox menu for the extension category. - * @type {string} - */ -// eslint-disable-next-line max-len const menuIconURI = ""; -const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; /** * RGB color constants for confidence visualization @@ -37,6 +26,9 @@ class ArduinoObjectDetection { constructor(runtime) { this.runtime = runtime; + this.unoq = new ArduinoUnoQ(); + this.unoq.connect(); + /** @type {Array} */ this.detectedObjects = []; @@ -66,15 +58,8 @@ class ArduinoObjectDetection { } }); - this.io = io(wsServerURL, { - path: "/socket.io", - transports: ["polling", "websocket"], - autoConnect: true, - }); - - this.io.on("detection_result", (data) => { + this.unoq.on("detection_result", (data) => { this.detectedObjects = []; - this._clearBoundingBoxes(); data.detection.forEach((detection) => { @@ -264,7 +249,7 @@ ArduinoObjectDetection.prototype._detectObjects = function(args) { } const dataUrl = canvas.toDataURL("image/png"); const base64Frame = dataUrl.split(",")[1]; - this.io.emit("detect_objects", { image: base64Frame }); + this.unoq.detectObjects(base64Frame); }; ArduinoObjectDetection.prototype._clearBoundingBoxes = function(args) { From 6b1e4c0d17b643bd6dcf8c45544d4213148e6022 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 22:06:39 +0100 Subject: [PATCH 4/8] refactor: update ArduinoUnoQ import statements for consistency --- README.md | 6 ++++-- .../scratch-vm/src/extensions/arduino_basics/index.js | 2 +- .../scratch-vm/src/extensions/arduino_modulino/index.js | 4 +--- .../src/extensions/arduino_object_detection/index.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a025a5e..125e015 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,14 @@ Accessible from any device via a browser, it makes coding, electronics, and AI h curl -sSL https://raw.githubusercontent.com/dido18/scratch-arduino-app/main/install.sh | bash ``` -- Open the Scratch interface at the `:7000` address +- Open the Scratch interface at the `https://:7000` address. + +NOTE: the `https` is needed by the `getUserMedia()` method for security reason. ### Local development - `task scratch:init` - `task scratch:local:start` - `ŧask board:upload` -- change the `const wsServerURL =`ws://:7000`;` in the `index.js` +- change the `const DEFAULT_HOST =``;` in the `scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js` - Open local scratch on http://localhost:8601/ 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 8f95ab3..b1486d4 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 @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const ArduinoUnoQ = require("../ArduinoUnoQ"); +const {ArduinoUnoQ} = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js index b0cb6b4..1c1899f 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js @@ -2,14 +2,12 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const ArduinoUnoQ = require("../ArduinoUnoQ"); +const {ArduinoUnoQ} = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; const menuIconURI = ""; -const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`; - class ArduinoModulino { constructor(runtime) { this.runtime = runtime; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js index 64e62af..deabb35 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js @@ -6,7 +6,7 @@ const Video = require("../../../../../../scratch-editor/packages/scratch-vm/src/ const Rectangle = require("../../../../../../scratch-editor/packages/scratch-render/src/Rectangle.js"); const StageLayering = require("../../../../../../scratch-editor/packages/scratch-vm/src/engine/stage-layering.js"); const { Detection, MODEL_LABELS } = require("./object_detection"); -const ArduinoUnoQ = require("../ArduinoUnoQ"); +const {ArduinoUnoQ} = require("../ArduinoUnoQ"); //TODO add icons const iconURI = ""; From 9400b197b8daee4a6973f51b0d61de9260806baa Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 22:06:56 +0100 Subject: [PATCH 5/8] fix: revert DEFAULT_HOST to use dynamic hostname for improved flexibility --- .../packages/scratch-vm/src/extensions/ArduinoUnoQ.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js index a294aaf..98df440 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js @@ -1,7 +1,6 @@ const io = require("./socket.io.min.js"); -// const DEFAULT_HOST = window.location.hostname; -const DEFAULT_HOST = "192.168.1.39"; +const DEFAULT_HOST = window.location.hostname; class ArduinoUnoQ { constructor() { From 428d5699d83b2b3b505ac6870aae92491bd995c8 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 22:07:42 +0100 Subject: [PATCH 6/8] refactor: standardize import statement formatting for ArduinoUnoQ across multiple files --- .../scratch-vm/src/extensions/ArduinoUnoQ.js | 37 +++++++++---------- .../src/extensions/arduino_basics/index.js | 2 +- .../src/extensions/arduino_modulino/index.js | 2 +- .../arduino_object_detection/index.js | 5 +-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js index 98df440..734401c 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/ArduinoUnoQ.js @@ -16,6 +16,24 @@ class ArduinoUnoQ { this._setupConnectionHandlers(); } + on(event, callback) { + if (this.io) { + this.io.on(event, callback); + console.log(`Registered event listener for: ${event}`); + } else { + console.error("Socket.io not initialized"); + } + } + + emit(event, data) { + if (this.io && this.isConnected) { + this.io.emit(event, data); + console.log(`Emitted event: ${event}`, data); + } else { + console.warn(`Cannot emit ${event}: Not connected to Arduino UNO Q`); + } + } + _setupConnectionHandlers() { this.io.on("connect", () => { this.isConnected = true; @@ -110,25 +128,6 @@ class ArduinoUnoQ { } // ===== EVENT HANDLING METHODS ===== - - on(event, callback) { - if (this.io) { - this.io.on(event, callback); - console.log(`Registered event listener for: ${event}`); - } else { - console.error("Socket.io not initialized"); - } - } - - emit(event, data) { - if (this.io && this.isConnected) { - this.io.emit(event, data); - console.log(`Emitted event: ${event}`, data); - } else { - console.warn(`Cannot emit ${event}: Not connected to Arduino UNO Q`); - } - } - } module.exports = ArduinoUnoQ; 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 b1486d4..83ad482 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 @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const {ArduinoUnoQ} = require("../ArduinoUnoQ"); +const { ArduinoUnoQ } = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js index 1c1899f..bd2eeb8 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const {ArduinoUnoQ} = require("../ArduinoUnoQ"); +const { ArduinoUnoQ } = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js index deabb35..7a3df06 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js @@ -6,13 +6,12 @@ const Video = require("../../../../../../scratch-editor/packages/scratch-vm/src/ const Rectangle = require("../../../../../../scratch-editor/packages/scratch-render/src/Rectangle.js"); const StageLayering = require("../../../../../../scratch-editor/packages/scratch-vm/src/engine/stage-layering.js"); const { Detection, MODEL_LABELS } = require("./object_detection"); -const {ArduinoUnoQ} = require("../ArduinoUnoQ"); +const { ArduinoUnoQ } = require("../ArduinoUnoQ"); -//TODO add icons +// TODO add icons const iconURI = ""; const menuIconURI = ""; - /** * RGB color constants for confidence visualization */ From e4a872887caa6f8d761918994474a3dda46af857 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 22:11:14 +0100 Subject: [PATCH 7/8] refactor: update ArduinoUnoQ import statements for consistency across multiple files --- .../packages/scratch-vm/src/extensions/arduino_basics/index.js | 2 +- .../scratch-vm/src/extensions/arduino_modulino/index.js | 2 +- .../scratch-vm/src/extensions/arduino_object_detection/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 83ad482..8f95ab3 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 @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const { ArduinoUnoQ } = require("../ArduinoUnoQ"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js index bd2eeb8..572a0c0 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/ const ArgumentType = require( "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type", ); -const { ArduinoUnoQ } = require("../ArduinoUnoQ"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); // TODO: add icons const iconURI = ""; diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js index 7a3df06..66d1897 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_object_detection/index.js @@ -6,7 +6,7 @@ const Video = require("../../../../../../scratch-editor/packages/scratch-vm/src/ const Rectangle = require("../../../../../../scratch-editor/packages/scratch-render/src/Rectangle.js"); const StageLayering = require("../../../../../../scratch-editor/packages/scratch-vm/src/engine/stage-layering.js"); const { Detection, MODEL_LABELS } = require("./object_detection"); -const { ArduinoUnoQ } = require("../ArduinoUnoQ"); +const ArduinoUnoQ = require("../ArduinoUnoQ"); // TODO add icons const iconURI = ""; From 4c7793b27dbec62905ab34413f0928e527281cf1 Mon Sep 17 00:00:00 2001 From: dido18 Date: Sun, 9 Nov 2025 22:23:10 +0100 Subject: [PATCH 8/8] docs: update installation instructions for clarity and formatting consistency --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 125e015..17f42a0 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,8 @@ Accessible from any device via a browser, it makes coding, electronics, and AI h ## Installation -- Connect the Arduino Uno Q board via USB -- Open an `adb shell` into the board using [adb](https://docs.arduino.cc/software/app-lab/tutorials/cli/) -- Copy and paste the following command into the terminal to install the latest `scratch-arduino-app` into the board: +- Open a terminal inside the UNO Q board (you can also use the [adb](https://docs.arduino.cc/software/app-lab/tutorials/cli/) tool) +- Copy and paste the following command into the terminal to install the latest `scratch-arduino-app`: ``` curl -sSL https://raw.githubusercontent.com/dido18/scratch-arduino-app/main/install.sh | bash @@ -23,7 +22,7 @@ curl -sSL https://raw.githubusercontent.com/dido18/scratch-arduino-app/main/inst NOTE: the `https` is needed by the `getUserMedia()` method for security reason. -### Local development +## Local development - `task scratch:init` - `task scratch:local:start`