make and build
This commit is contained in:
parent
e6ab6ef45f
commit
a6ee45727b
55
Makefile
Normal file
55
Makefile
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Makefile for Arduino project
|
||||
|
||||
# Detect OS
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ARDUINO_CLI := arduino-cli.exe
|
||||
RM := del /Q
|
||||
PORT ?= COM20
|
||||
else
|
||||
ARDUINO_CLI := arduino-cli
|
||||
RM := rm -f
|
||||
PORT ?= /dev/ttyACM0
|
||||
endif
|
||||
|
||||
# Arduino CLI configuration
|
||||
BOARD ?= arduino:avr:nano:cpu=atmega328old
|
||||
SKETCH := apply_stimulation/apply_stimulation.ino
|
||||
|
||||
# Python configuration
|
||||
PYTHON := python
|
||||
|
||||
# Targets
|
||||
.PHONY: all generate compile upload clean
|
||||
|
||||
all: generate compile upload
|
||||
|
||||
generate:
|
||||
$(PYTHON) gen_stimulat.py
|
||||
|
||||
compile:
|
||||
$(ARDUINO_CLI) compile --fqbn $(BOARD) $(SKETCH)
|
||||
|
||||
upload:
|
||||
$(ARDUINO_CLI) upload -p $(PORT) --fqbn $(BOARD) $(SKETCH)
|
||||
|
||||
clean:
|
||||
$(RM) apply_stimulation/build
|
||||
$(RM) stimulation_pattern.h
|
||||
|
||||
# Help target
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo " all - Generate pattern, compile and upload the sketch"
|
||||
@echo " generate - Generate the stimulation pattern"
|
||||
@echo " compile - Compile the sketch"
|
||||
@echo " upload - Upload the compiled sketch to the Arduino"
|
||||
@echo " clean - Remove build files and generated pattern"
|
||||
@echo " help - Display this help message"
|
||||
@echo ""
|
||||
@echo "You can specify the Arduino port and board using the PORT and BOARD variables:"
|
||||
@echo " make upload PORT=COM20 BOARD=arduino:avr:nano:cpu=atmega328old"
|
||||
@echo ""
|
||||
@echo "Default board is set to Arduino Nano with old bootloader (atmega328old)"
|
||||
|
||||
# Default target
|
||||
.DEFAULT_GOAL := help
|
86
README.md
86
README.md
|
@ -15,7 +15,89 @@ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.
|
|||
```
|
||||
|
||||
## Usage
|
||||
After installation, you can use Arduino CLI to compile and upload sketches to your Arduino board. For example:
|
||||
|
||||
### Using Make (Linux and Windows with Make installed)
|
||||
We've provided a Makefile to simplify the process of compiling and uploading sketches to your Arduino board. Here's how to use it:
|
||||
|
||||
1. Generate the stimulation pattern, compile, and upload the sketch:
|
||||
```
|
||||
make all
|
||||
```
|
||||
|
||||
2. Only generate the stimulation pattern:
|
||||
```
|
||||
make generate
|
||||
```
|
||||
|
||||
3. Only compile the sketch:
|
||||
```
|
||||
make compile
|
||||
```
|
||||
|
||||
4. Only upload the compiled sketch:
|
||||
```
|
||||
make upload
|
||||
```
|
||||
|
||||
5. Clean the build files and generated pattern:
|
||||
```
|
||||
make clean
|
||||
```
|
||||
|
||||
You can specify a different port or board by using the PORT and BOARD variables:
|
||||
|
||||
```
|
||||
make upload PORT=COM3 BOARD=arduino:avr:uno
|
||||
```
|
||||
|
||||
The default board is set to Arduino Nano with old bootloader (atmega328old). To see all available options, run:
|
||||
|
||||
```
|
||||
make help
|
||||
```
|
||||
|
||||
### Using PowerShell Script (Windows without Make)
|
||||
For Windows users who don't have Make installed, we've provided a PowerShell script (build.ps1) that mimics the Makefile functionality. Here's how to use it:
|
||||
|
||||
1. Generate the stimulation pattern, compile, and upload the sketch:
|
||||
```
|
||||
.\build.ps1 all
|
||||
```
|
||||
|
||||
2. Only generate the stimulation pattern:
|
||||
```
|
||||
.\build.ps1 generate
|
||||
```
|
||||
|
||||
3. Only compile the sketch:
|
||||
```
|
||||
.\build.ps1 compile
|
||||
```
|
||||
|
||||
4. Only upload the compiled sketch:
|
||||
```
|
||||
.\build.ps1 upload
|
||||
```
|
||||
|
||||
5. Clean the build files and generated pattern:
|
||||
```
|
||||
.\build.ps1 clean
|
||||
```
|
||||
|
||||
You can specify a different port or board by using the -PORT and -BOARD parameters:
|
||||
|
||||
```
|
||||
.\build.ps1 upload -PORT COM3 -BOARD arduino:avr:uno
|
||||
```
|
||||
|
||||
To see all available options, run:
|
||||
|
||||
```
|
||||
.\build.ps1 help
|
||||
```
|
||||
|
||||
## Manual Arduino CLI Usage
|
||||
If you prefer to use Arduino CLI directly, you can still use the following commands:
|
||||
|
||||
```
|
||||
arduino-cli compile --fqbn arduino:avr:nano:cpu=atmega328old your_sketch.ino
|
||||
|
@ -31,7 +113,7 @@ The goal of this project is to create a system that generates and applies stimul
|
|||
The project workflow is as follows:
|
||||
|
||||
1. Generate a stimulation pattern from MNIST data (gen_stimulat.py)
|
||||
2. Upload this pattern to an Arduino board (using Arduino CLI)
|
||||
2. Upload this pattern to an Arduino board (using Arduino CLI, Makefile, or PowerShell script)
|
||||
3. The Arduino applies the stimulation pattern to the nano fiber sample (apply_stimulation.ino)
|
||||
4. Receive and decode the response data from the nano fiber reservoir (decode_serial_digit.py)
|
||||
5. Visualize the received data to interpret the reservoir's response (visualize_digit.py)
|
||||
|
|
51
build.ps1
Normal file
51
build.ps1
Normal file
|
@ -0,0 +1,51 @@
|
|||
# PowerShell script to mimic Makefile functionality
|
||||
|
||||
# Default values
|
||||
$ARDUINO_CLI = "arduino-cli.exe"
|
||||
$PYTHON = "python"
|
||||
$PORT = "COM20"
|
||||
$BOARD = "arduino:avr:nano:cpu=atmega328old"
|
||||
$SKETCH = "apply_stimulation/apply_stimulation.ino"
|
||||
|
||||
function Generate {
|
||||
& $PYTHON gen_stimulat.py
|
||||
}
|
||||
|
||||
function Compile {
|
||||
& $ARDUINO_CLI compile --fqbn $BOARD $SKETCH
|
||||
}
|
||||
|
||||
function Upload {
|
||||
& $ARDUINO_CLI upload -p $PORT --fqbn $BOARD $SKETCH
|
||||
}
|
||||
|
||||
function Clean {
|
||||
Remove-Item -Path "apply_stimulation/build" -Recurse -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "stimulation_pattern.h" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
function Help {
|
||||
Write-Host "Available commands:"
|
||||
Write-Host " .\build.ps1 all - Generate pattern, compile and upload the sketch"
|
||||
Write-Host " .\build.ps1 generate - Generate the stimulation pattern"
|
||||
Write-Host " .\build.ps1 compile - Compile the sketch"
|
||||
Write-Host " .\build.ps1 upload - Upload the compiled sketch to the Arduino"
|
||||
Write-Host " .\build.ps1 clean - Remove build files and generated pattern"
|
||||
Write-Host " .\build.ps1 help - Display this help message"
|
||||
Write-Host ""
|
||||
Write-Host "You can specify the Arduino port and board using the -PORT and -BOARD parameters:"
|
||||
Write-Host " .\build.ps1 upload -PORT COM3 -BOARD arduino:avr:uno"
|
||||
Write-Host ""
|
||||
Write-Host "Default board is set to Arduino Nano with old bootloader (atmega328old)"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
switch ($args[0]) {
|
||||
"all" { Generate; Compile; Upload }
|
||||
"generate" { Generate }
|
||||
"compile" { Compile }
|
||||
"upload" { Upload }
|
||||
"clean" { Clean }
|
||||
"help" { Help }
|
||||
default { Help }
|
||||
}
|
Loading…
Reference in New Issue
Block a user