# 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 } }