Skip to content

Commit

Permalink
Arduino IDE compatibility (#3)
Browse files Browse the repository at this point in the history
make project easiliy usable with the arduino ide
change image formatting; add a changelog
separate build files for carl and calibrate tool
  • Loading branch information
jandelgado authored Jun 20, 2021
1 parent a144e31 commit d4a6aae
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 16 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: linter
run: |
pip install cpplint
make lint
for project in carl calibrate; do
make -C "$project" lint
done
build:
runs-on: ubuntu-latest
Expand All @@ -27,16 +29,21 @@ jobs:

- name: install platformio
run: |
pip install platformio==5.0.3
pip install platformio==5.1.1
- name: build firmware
- name: build calibrate firmware
run: |
export PLATFORMIO_BUILD_DIR=$HOME/build
make ci
mkdir firmware
export PLATFORMIO_BUILD_DIR=$HOME/build-calibrate
make -C calibrate ci
- name: build carl firmware
run: |
export PLATFORMIO_BUILD_DIR=$HOME/build-carl
make -C carl ci
mkdir -p firmware
cp $PLATFORMIO_BUILD_DIR/pro16MHzatmega328/firmware.hex firmware/
- name: upload artifacts
- name: upload carl artifacts
uses: actions/upload-artifact@master
with:
name: firmware
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.pio
**/.pio
.pioenvs
.piolibdeps
.clang_complete
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# changelog for carl music player

# 1.1.0 [19.06.2021]

* add keypad calibration script `calibrate/calibrate.ino`
* rename folders to be compatible with Arduino IDE: just open the file
`carl/carl.ino` or `calibrate/calibrate.ino` to open the corresponding
projects in the Arduino IDE.
* update documentation

# 1.0.0 [01.04.2021]

* initial release

43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,48 @@
This is the firmware repository for the Carl music box. Details will follow
shortly.

![carl music box](.images/carl.jpg)
<img src=".images/carl.jpg" width=400 alt="carl music box">

<!-- vim-markdown-toc GFM -->

* [Build the firmware](#build-the-firmware)
* [Arduino IDE](#arduino-ide)
* [PlatformIO](#platformio)
* [Author](#author)

<!-- vim-markdown-toc -->

## Build the firmware

The firmware can be built using the Arduino IDE or PlatformIO.

### Arduino IDE

Check out the repository on your computer. In the Arduino IDE select `Open ...`
under the `File` menu and select the file `carl/carl.ino`.

Select `Arduino Pro or Pro Mini` as the target board under `Tools` > `Board` >
`Arduino AVR Boards`. The processor used is an `Atmega328P 5V 16MHz`.

Install the needed libraries using `Sketch` > `Include Library` > `Manage Libraries...`:
* AnalogMultiButton (1.0.0)
* DFPlayerMini (1.0.5)
* JLed (4.7.0)
* log4arduino (1.0.0)

Alternatively, install the libraries with this command:
```
arduino --install-library JLed:4.7.0,log4arduino:1.0.0,AnalogMultiButton:1.0.0,DFRobotDFPlayerMini:1.0.5
```

Compile and upload the sketch using the corresponding commands in the Arduino
IDE.

### PlatformIO

Check out the repository on your computer. Run `cd carl && make upload` to build and
upload the firmware.

## Author

(C) Copyright 2021 by Jan Delgado.

28 changes: 28 additions & 0 deletions calibrate/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Carl Music Box - keypad calibration tool
# use this makefile to build Carl with platformio
.PHONY: phony

all: phony
pio run

lint: phony
cpplint --root=calibrate --extensions=cpp,h,ino --filter=-build/include_subdir \
$(shell find . \( ! -regex '.*/\..*' \) \
-type f -a \( -name "*\.cpp" -o -name "*\.h" -o -name "*\.ino" \) )

ci: phony
pio ci --project-conf platformio.ini .

clean: phony
pio run --target clean

upload: phony
pio run --target upload

monitor: phony
pio device monitor

tags: phony
ctags -R

phony:
17 changes: 17 additions & 0 deletions calibrate/calibrate.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2021 Jan Delgado <jdelgado[at]gmx.net>
// https://github.com/jandelgado/carl
//
// Kalibriersketch für das Tastenfeld
// Calibration sketch for the key pad
//
constexpr auto PIN_BUTTONS = A2;

void setup() {
pinMode(PIN_BUTTONS, INPUT);
Serial.begin(9600);
}

void loop() {
Serial.println(analogRead(PIN_BUTTONS));
delay(50);
}
9 changes: 9 additions & 0 deletions calibrate/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Carl music box PlatformIO project file - calibration tool

[platformio]
src_dir = .

[env:pro16MHzatmega328]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
9 changes: 4 additions & 5 deletions Makefile → carl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
# use this makefile to build Carl with platformio
.PHONY: phony


all: phony
pio run

lint: phony
cpplint --root=src --extensions=cpp,h,ino --filter=-build/include_subdir \
$(shell find src \( ! -regex '.*/\..*' \) \
cpplint --root=carl --extensions=cpp,h,ino --filter=-build/include_subdir \
$(shell find . \( ! -regex '.*/\..*' \) \
-type f -a \( -name "*\.cpp" -o -name "*\.h" -o -name "*\.ino" \) )

ci: phony
pio ci --project-conf platformio.ini src
pio ci --project-conf platformio.ini .

clean: phony
pio run --target clean

upload: phony
pio run --target upload
pio run --target upload

monitor: phony
pio device monitor
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion platformio.ini → carl/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Carl music box PlatformIO project file

[platformio]
src_dir = src
src_dir = .

[env:pro16MHzatmega328]
platform = atmelavr
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d4a6aae

Please sign in to comment.