@@ -86,3 +86,87 @@ tasks:
8686 fi
8787 - echo "Creating zip with version {{.APP_VERSION}}"
8888 - cd build && zip -r scratch-arduino-app-{{.APP_VERSION}}.zip scratch-arduino-app && cd ..
89+
90+ python:watch :
91+ desc : " Watch Python folder for changes and auto-upload/restart"
92+ cmds :
93+ - echo "Press Ctrl+C to stop watching"
94+ - |
95+ while true; do
96+ echo "Waiting for changes in python/ folder..."
97+ inotifywait -r -e modify,create,delete,move python/ 2>/dev/null || {
98+ echo "inotifywait failed, retrying..."
99+ sleep 2
100+ continue
101+ }
102+
103+ sleep 1 #W aiting 1 second for file writes to complete..."
104+
105+ task python:upload-and-restart || {
106+ echo "Upload/restart failed, continuing to watch..."
107+ continue
108+ }
109+
110+ echo "[ok] Upload and restart completed!"
111+ done
112+
113+ python:upload-and-restart :
114+ desc : " Upload Python files and restart container"
115+ cmds :
116+ - |
117+ adb push ./python/ /home/arduino/ArduinoApps/scratch-arduino-app/
118+ echo "Python files uploaded successfully"
119+
120+ CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'")
121+ if [ -n "$CONTAINER_ID" ]; then
122+ adb shell "docker restart $CONTAINER_ID"
123+ echo "[ok] Container restarted successfully"
124+ else
125+ echo "[warning] No running container found with image ghcr.io/arduino/app-bricks/python-apps-base"
126+ fi
127+
128+ sketch:watch :
129+ desc : " Watch sketch folder for changes and auto-compile/upload"
130+ cmds :
131+ - |
132+ echo "Press Ctrl+C to stop watching"
133+ while true; do
134+ echo "Waiting for changes in sketch folder..."
135+ inotifywait -r -e modify,create,delete sketch/ --include '\.(ino|cpp|h|c)$' 2>/dev/null || {
136+ echo "inotifywait failed, retrying..."
137+ sleep 2
138+ continue
139+ }
140+
141+ sleep 1 # Waiting 1 second for file writes to complete
142+
143+ task sketch:compile-and-upload|| {
144+ echo "Compile/upload failed, continuing to watch..."
145+ continue
146+ }
147+ done
148+
149+ sketch:compile-and-upload :
150+ desc : " Compile and upload Arduino sketch"
151+ cmds :
152+ - arduino-cli compile --build-path .cache -b arduino:zephyr:unoq sketch/
153+ - arduino-cli upload -p /dev/ttyACM0 -b arduino:zephyr:unoq:flash_mode=ram --input-dir .cache sketch/
154+
155+ sketch:monitor :
156+ desc : " Open serial monitor for Arduino debugging"
157+ cmds :
158+ - echo "Opening serial monitor (Press Ctrl+C to exit)..."
159+ - arduino-cli monitor -p /dev/ttyACM0
160+
161+ python:monitor :
162+ desc : " Watch sketch folder for changes and auto-compile/upload"
163+ cmds :
164+ - |
165+ while true; do
166+ CONTAINER_ID=$(adb shell "docker ps -q --filter 'ancestor=ghcr.io/arduino/app-bricks/python-apps-base:0.5.0'")
167+ if [ -n "$CONTAINER_ID" ]; then
168+ adb shell "docker logs -f $CONTAINER_ID"
169+ else
170+ echo "[warning] No running container found with image ghcr.io/arduino/app-bricks/python-apps-base"
171+ fi
172+ done
0 commit comments