Compare commits
2 Commits
2727dfb0ef
...
bf2b794421
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf2b794421 | ||
|
|
f0e8a7f05f |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -4,7 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
- 'arduino_pong.ini'
|
- 'arduino_pong.ino'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
- '.github/workflows/ci.yml'
|
- '.github/workflows/ci.yml'
|
||||||
|
|
||||||
@@ -34,4 +34,4 @@ jobs:
|
|||||||
|
|
||||||
- name: Compile Sketch (via Makefile)
|
- name: Compile Sketch (via Makefile)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: make compile
|
run: make prepare_and_compile
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
.secrets
|
.secrets
|
||||||
|
.arduino_cache/
|
||||||
|
bin/
|
||||||
|
|||||||
52
Makefile
52
Makefile
@@ -1,20 +1,58 @@
|
|||||||
PORT ?= /dev/ttyACM0
|
PORT ?= /dev/ttyACM0
|
||||||
BOARD = arduino:renesas_uno:unor4wifi
|
BOARD = arduino:renesas_uno:unor4wifi
|
||||||
SKETCH = arduino_pong.ino
|
SKETCH = arduino_pong.ino
|
||||||
|
CACHE_DIR = $(shell pwd)/.arduino_cache
|
||||||
|
BIN_DIR = $(shell pwd)/bin
|
||||||
|
CLI = $(BIN_DIR)/arduino-cli --config-file $(CACHE_DIR)/arduino-cli.yaml
|
||||||
|
|
||||||
|
YELLOW := \033[0;33m
|
||||||
|
GREEN := \033[0;32m
|
||||||
|
CLEAR := \033[0m
|
||||||
|
|
||||||
|
prepare:
|
||||||
|
@mkdir -p $(BIN_DIR)
|
||||||
|
@mkdir -p $(CACHE_DIR)
|
||||||
|
@if [ ! -f $(BIN_DIR)/arduino-cli ]; then \
|
||||||
|
echo -e "📥 $(YELLOW)Downloading arduino-cli...$(CLEAR)"; \
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=$(BIN_DIR) sh; \
|
||||||
|
fi
|
||||||
|
@if [ ! -f $(CACHE_DIR)/arduino-cli.yaml ]; then \
|
||||||
|
echo -e "⚙️ $(YELLOW)Initializing local config...$(CLEAR)"; \
|
||||||
|
$(CLI) config init --dest-dir $(CACHE_DIR); \
|
||||||
|
$(CLI) config set directories.data $(CACHE_DIR)/data; \
|
||||||
|
$(CLI) config set directories.downloads $(CACHE_DIR)/downloads; \
|
||||||
|
$(CLI) config set directories.user $(CACHE_DIR)/user; \
|
||||||
|
fi
|
||||||
|
@if ! $(CLI) core list | grep -q "arduino:renesas_uno"; then \
|
||||||
|
echo -e "$(YELLOW)📥 Installing board core...$(CLEAR)"; \
|
||||||
|
$(CLI) core update-index; \
|
||||||
|
$(CLI) core install arduino:renesas_uno; \
|
||||||
|
fi
|
||||||
|
|
||||||
compile:
|
compile:
|
||||||
arduino-cli compile -b $(BOARD) $(SKETCH)
|
@echo -e "$(GREEN)🛠️ Compiling $(SKETCH)...$(CLEAR)"
|
||||||
|
@$(CLI) compile -b $(BOARD) $(SKETCH)
|
||||||
|
|
||||||
|
prepare_and_compile:
|
||||||
|
make prepare --no-print-directory
|
||||||
|
make compile --no-print-directory
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
arduino-cli upload -b $(BOARD) -p $(PORT)
|
@echo -e "$(GREEN)🚀 Uploading $(SKETCH)...$(CLEAR)"
|
||||||
|
@$(CLI) upload -b $(BOARD) -p $(PORT)
|
||||||
|
|
||||||
upload_verbose:
|
upload_verbose:
|
||||||
arduino-cli upload -b $(BOARD) -p $(PORT) -v
|
@echo -e "$(GREEN)🚀 Uploading (Verbose) $(SKETCH)...$(CLEAR)"
|
||||||
|
@$(CLI) upload -b $(BOARD) -p $(PORT) -v
|
||||||
|
|
||||||
monitor:
|
monitor:
|
||||||
arduino-cli monitor -p $(PORT)
|
@$(CLI) monitor -p $(PORT)
|
||||||
|
|
||||||
run:
|
run:
|
||||||
make compile
|
make compile --no-print-directory
|
||||||
make upload
|
make upload --no-print-directory
|
||||||
make monitor
|
make monitor --no-print-directory
|
||||||
|
|
||||||
|
run_init:
|
||||||
|
make prepare --no-print-directory
|
||||||
|
make run --no-print-directory
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ This project includes a `Makefile` to automate the workflow using `arduino-cli`.
|
|||||||
### Commands
|
### Commands
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| :--- | :--- |
|
| :--- | :--- |
|
||||||
|
| `make prepare` | Downloads arduino-cli locally and installs the UNO R4 core. |
|
||||||
| `make compile` | Compiles the sketch without uploading. |
|
| `make compile` | Compiles the sketch without uploading. |
|
||||||
| `make upload` | Uploads the compiled binary to `/dev/ttyACM0`. |
|
| `make upload` | Uploads the compiled binary to `/dev/ttyACM0`. |
|
||||||
| `make monitor` | Opens the Serial Monitor. |
|
| `make monitor` | Opens the Serial Monitor. |
|
||||||
| `make run` | Full cycle: Compile + Upload + Monitor. |
|
| `make run` | Full cycle: Compile + Upload + Monitor. |
|
||||||
|
| `make run_init` | Full first-time setup: Prepare env + Compile + Upload + Monitor. |
|
||||||
|
|
||||||
> **Note:** If your board is on a different port, edit the `Makefile` or override it: `make upload PORT=/dev/ttyUSB0`.
|
> **Note:** If your board is on a different port, edit the `Makefile` or override it: `make upload PORT=/dev/ttyUSB0`.
|
||||||
|
|||||||
Reference in New Issue
Block a user