From dacf92ca52cf05086b3ef42067bc00213e756bb0 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Sat, 30 Mar 2024 18:22:56 +0100 Subject: [PATCH] Moved examples to module folder; minor adjustment to install script. --- arduino/arduino.py | 1 - {examples => arduino/examples}/00_basic.py | 0 {examples => arduino/examples}/01_arduino_blink.py | 0 .../examples}/02_nano_esp32_advanced.py | 0 install.sh | 12 +++++++++++- package.json | 5 ++++- 6 files changed, 15 insertions(+), 3 deletions(-) rename {examples => arduino/examples}/00_basic.py (100%) rename {examples => arduino/examples}/01_arduino_blink.py (100%) rename {examples => arduino/examples}/02_nano_esp32_advanced.py (100%) diff --git a/arduino/arduino.py b/arduino/arduino.py index 68c7067..890131a 100644 --- a/arduino/arduino.py +++ b/arduino/arduino.py @@ -82,7 +82,6 @@ def get_template_path(): return '/'.join(__file__.split('/')[:-1]) + '/template.tpl' def create_sketch(sketch_name = None, destination_path = '.', overwrite = False, source_path = None): - if sketch_name is None: sketch_name = 'main' new_sketch_path = f'{destination_path}/{sketch_name}.py' diff --git a/examples/00_basic.py b/arduino/examples/00_basic.py similarity index 100% rename from examples/00_basic.py rename to arduino/examples/00_basic.py diff --git a/examples/01_arduino_blink.py b/arduino/examples/01_arduino_blink.py similarity index 100% rename from examples/01_arduino_blink.py rename to arduino/examples/01_arduino_blink.py diff --git a/examples/02_nano_esp32_advanced.py b/arduino/examples/02_nano_esp32_advanced.py similarity index 100% rename from examples/02_nano_esp32_advanced.py rename to arduino/examples/02_nano_esp32_advanced.py diff --git a/install.sh b/install.sh index 499b29b..ed783be 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,22 @@ #!/bin/bash # -# Install Arduino Runtime to a MicroPython board using mpremote. +# MicroPython Package Installer +# Created by: Ubi de Feo and Sebastian Romero +# +# Installs a MicroPython Package to a board using mpremote. +# # This script accepts an optional argument to compile .py files to .mpy. # Simply run the script with the optional argument: # # ./install.sh mpy +# Name to display during installation PKGNAME="Arduino Runtime for MicroPython" +# Destination directory for the package on the board PKGDIR="arduino" +# Source directory for the package on the host SRCDIR=$PKGDIR +# Board library directory LIBDIR="lib" # File system operations such as "mpremote mkdir" or "mpremote rm" @@ -86,6 +94,8 @@ for filename in $SRCDIR/*; do source_extension="${f_name##*.}" destination_extension=$source_extension + # If examples are distributed within the package + # ensures they are copied but not compiled to .mpy if [[ -d $filename && "$f_name" == "examples" ]]; then if ! directory_exists "/${LIBDIR}/${PKGDIR}/examples"; then echo "Creating $LIBDIR/$PKGDIR/examples on board" diff --git a/package.json b/package.json index c997eaf..7f2b016 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,10 @@ "urls": [ ["arduino/__init__.py", "github:arduino/arduino-runtime-mpy/arduino/__init__.py"], ["arduino/arduino.py", "github:arduino/arduino-runtime-mpy/arduino/arduino.py"], - ["arduino/template.tpl", "github:arduino/arduino-runtime-mpy/arduino/template.tpl"] + ["arduino/template.tpl", "github:arduino/arduino-runtime-mpy/arduino/template.tpl"], + ["arduino/examples/00_basic.py", "github:arduino/arduino-runtime-mpy/arduino/examples/00_basic.py"], + ["arduino/examples/01_arduino_blink.py", "github:arduino/arduino-runtime-mpy/arduino/examples/01_arduino_blink.py"], + ["arduino/examples/02_nano_esp32_advanced.py", "github:arduino/arduino-runtime-mpy/arduino/examples/02_nano_esp32_advanced.py"] ], "deps": [], "version": "0.1.0"