From e369512be22fea388fc41b660e4a07d6124d4a93 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 14 Nov 2025 08:46:51 +0100 Subject: [PATCH 1/5] feat: enhance watch tasks with improved messaging and structure --- Taskfile.yaml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 6b840bd..25c675c 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -58,6 +58,7 @@ tasks: cmds: - npm run build:dev --workspace @scratch/scratch-gui + board:app:upload: desc: "Upload zip file to Arduino board, unzip and deploy to /home/arduino/ArduinoApps" cmds: @@ -87,31 +88,38 @@ tasks: - echo "Creating zip with version {{.APP_VERSION}}" - cd build && zip -r scratch-arduino-app-{{.APP_VERSION}}.zip scratch-arduino-app && cd .. + watch: + desc: "wath cfile changes for both python and sketch, and upload the changes to the board and restart" + deps: + - python:watch + - sketch:watch + + python:watch: desc: "Watch Python folder for changes and auto-upload/restart" + silent: true cmds: - - echo "Press Ctrl+C to stop watching" - | while true; do - echo "Waiting for changes in python/ folder..." + echo "🐍 Waiting for changes in python folder..." inotifywait -r -e modify,create,delete,move python/ 2>/dev/null || { echo "inotifywait failed, retrying..." sleep 2 continue } - sleep 1 #W aiting 1 second for file writes to complete..." - + sleep 1 # Waiting 1 second for file writes to complete..." + echo "🐍 Change detected: uploading and restarting service..." task python:upload-and-restart || { echo "Upload/restart failed, continuing to watch..." continue } - echo "[ok] Upload and restart completed!" done python:upload-and-restart: desc: "Upload Python files and restart container" + silent: true cmds: - | adb push ./python/ /home/arduino/ArduinoApps/scratch-arduino-app/ @@ -127,11 +135,11 @@ tasks: sketch:watch: desc: "Watch sketch folder for changes and auto-compile/upload" + silent: true cmds: - | - echo "Press Ctrl+C to stop watching" while true; do - echo "Waiting for changes in sketch folder..." + echo "♾️ Waiting for changes in sketch folder..." inotifywait -r -e modify,create,delete sketch/ --include '\.(ino|cpp|h|c)$' 2>/dev/null || { echo "inotifywait failed, retrying..." sleep 2 @@ -139,29 +147,33 @@ tasks: } sleep 1 # Waiting 1 second for file writes to complete - + echo "♾️ Change detected: compiling and uploading..." task sketch:compile-and-upload|| { echo "Compile/upload failed, continuing to watch..." continue } + echo done sketch:compile-and-upload: desc: "Compile and upload Arduino sketch" + silent: true cmds: - arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ - arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ sketch:monitor: desc: "Open serial monitor for Arduino debugging" + silent: true cmds: - - echo "Opening serial monitor (Press Ctrl+C to exit)..." + - echo " ♾️ Opening serial monitor (Press Ctrl+C to exit)..." - arduino-cli monitor -p /dev/ttyACM0 python:monitor: desc: "Watch sketch folder for changes and auto-compile/upload" cmds: - | + echo "🐍 Python container logs" while true; do CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'") if [ -n "$CONTAINER_ID" ]; then From aeb34a67edfe9de7357ab28f3d88d31f72fbcd47 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 14 Nov 2025 09:02:31 +0100 Subject: [PATCH 2/5] feat: enhance python upload messages with emojis for better visibility --- Taskfile.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 25c675c..13e286a 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -58,7 +58,6 @@ tasks: cmds: - npm run build:dev --workspace @scratch/scratch-gui - board:app:upload: desc: "Upload zip file to Arduino board, unzip and deploy to /home/arduino/ArduinoApps" cmds: @@ -94,7 +93,6 @@ tasks: - python:watch - sketch:watch - python:watch: desc: "Watch Python folder for changes and auto-upload/restart" silent: true @@ -123,12 +121,12 @@ tasks: cmds: - | adb push ./python/ /home/arduino/ArduinoApps/scratch-arduino-app/ - echo "Python files uploaded successfully" + echo "🐍 files uploaded successfully" CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'") if [ -n "$CONTAINER_ID" ]; then adb shell "docker restart $CONTAINER_ID" - echo "[ok] Container restarted successfully" + echo "🐍 Container restarted successfully" else echo "[warning] No running container found with image ghcr.io/arduino/app-bricks/python-apps-base" fi From 29dde8c608c8b1452d956f985f4f50698673f394 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 14 Nov 2025 09:17:42 +0100 Subject: [PATCH 3/5] feat: enhance upload and compile tasks with timing messages for better performance tracking --- Taskfile.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 13e286a..83e1cca 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -121,12 +121,13 @@ tasks: cmds: - | adb push ./python/ /home/arduino/ArduinoApps/scratch-arduino-app/ - echo "🐍 files uploaded successfully" CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'") if [ -n "$CONTAINER_ID" ]; then + RESTART_START=$(date +%s) adb shell "docker restart $CONTAINER_ID" - echo "🐍 Container restarted successfully" + RESTART_END=$(date +%s) + echo "🐍 Container restarted in $((RESTART_END - RESTART_START))s" else echo "[warning] No running container found with image ghcr.io/arduino/app-bricks/python-apps-base" fi @@ -157,8 +158,17 @@ tasks: desc: "Compile and upload Arduino sketch" silent: true cmds: - - arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ - - arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ + - | + C_START=$(date +%s) + arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ + C_END=$(date +%s) + + U_START=$(date +%s) + arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ + U_END=$(date +%s) + echo "♾️ Compiled in $((C_END - C_START))s, Uploaded in $((U_END - U_START))s" + # even if not necessary: the sketch folder is sync into the board to have the updated version + - adb push ./sketch/ /home/arduino/ArduinoApps/scratch-arduino-app/ sketch:monitor: desc: "Open serial monitor for Arduino debugging" From 04f2e54cd83737c89e7edd7e7800937fa1cbf7a3 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 14 Nov 2025 09:25:22 +0100 Subject: [PATCH 4/5] feat: enhance restart and compile/upload tasks with timing messages for better performance tracking --- Taskfile.yaml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 83e1cca..3a77b88 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -124,10 +124,7 @@ tasks: CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'") if [ -n "$CONTAINER_ID" ]; then - RESTART_START=$(date +%s) - adb shell "docker restart $CONTAINER_ID" - RESTART_END=$(date +%s) - echo "🐍 Container restarted in $((RESTART_END - RESTART_START))s" + /usr/bin/time -f "🐍 Restarted in %es" adb shell "docker restart $CONTAINER_ID" else echo "[warning] No running container found with image ghcr.io/arduino/app-bricks/python-apps-base" fi @@ -159,14 +156,9 @@ tasks: silent: true cmds: - | - C_START=$(date +%s) - arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ - C_END=$(date +%s) - - U_START=$(date +%s) - arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ - U_END=$(date +%s) - echo "♾️ Compiled in $((C_END - C_START))s, Uploaded in $((U_END - U_START))s" + /usr/bin/time -f "♾️ Compiled in %es" arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ + /usr/bin/time -f "♾️ Uploaded in %es" arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ + echo "♾️ Compiled and uploaded successfully" # even if not necessary: the sketch folder is sync into the board to have the updated version - adb push ./sketch/ /home/arduino/ArduinoApps/scratch-arduino-app/ From c7f0f2c37c8126ac31897914fd349ca510711cb3 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 14 Nov 2025 09:27:46 +0100 Subject: [PATCH 5/5] feat: add timing messages for sketch compile and upload tasks to track performance --- Taskfile.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 3a77b88..3645624 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -156,9 +156,11 @@ tasks: silent: true cmds: - | + TOTAL_START=$(date +%s) /usr/bin/time -f "♾️ Compiled in %es" arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/ /usr/bin/time -f "♾️ Uploaded in %es" arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/ - echo "♾️ Compiled and uploaded successfully" + TOTAL_END=$(date +%s) + echo "♾️ Total time: $((TOTAL_END - TOTAL_START))s" # even if not necessary: the sketch folder is sync into the board to have the updated version - adb push ./sketch/ /home/arduino/ArduinoApps/scratch-arduino-app/