Skip to content

Commit

Permalink
Merge pull request #10 from henriquesebastiao/main
Browse files Browse the repository at this point in the history
Sync with main
  • Loading branch information
henriquesebastiao authored Jun 29, 2024
2 parents ad62a61 + 6a5334a commit ca9563f
Show file tree
Hide file tree
Showing 14 changed files with 2,732 additions and 2,203 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build

on:
push:
branches:
- main
tags:
- "*"
pull_request:
branches:
- main

jobs:
compile_sketch:
name: Build Saturn Firmware
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- {
name: "M5Cardputer",
fqbn: "m5stack:esp32:m5stack_cardputer",
libraries: "M5Cardputer IRRemoteESP8266 M5Stack-SD-Updater M5Unified",
partitions: {
bootloader_addr: "0x0000",
},
}

steps:
- uses: actions/checkout@v4

- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v1

- name: Install platform
run: |
set -x
# arduino-cli core install esp32:esp32
arduino-cli core install m5stack:esp32 --additional-urls https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
arduino-cli core search m5stack
arduino-cli board listall
arduino-cli lib install ${{ matrix.board.libraries }} --log-level warn --verbose
- name: Install esptool
run: |
pip install -U esptool
- name: Setup platform.txt
run: |
baseFolder="$HOME/.arduino15/packages/m5stack/hardware/esp32"
# Find the latest version of the folder
latestVersion=$(find "$baseFolder" -maxdepth 1 -type d -exec basename {} \; | sort -V | head -n 1)
if [ -z "$latestVersion" ]; then
echo "No version found."
read -p "Press Enter to exit."
exit 1
fi
# Full path to the file to be edited
file="$baseFolder/$latestVersion/platform.txt"
backupFile="$baseFolder/$latestVersion/platform.txt.bkp"
prefix="build.extra_flags.esp32"
option=" -w "
prefix2="compiler.c.elf.libs.esp32"
option2=" -zmuldefs "
# Use awk to insert options after the first equals sign on lines with specified prefixes
awk -v prefix="$prefix" -v option="$option" -v prefix2="$prefix2" -v option2="$option2" '{
if ($0 ~ "^" prefix) {
sub(/=/, "=" option);
print;
} else if ($0 ~ "^" prefix2) {
sub(/=/, "=" option2);
print;
} else {
print;
}
}' "$file" > "$file.tmp" && mv "$file.tmp" "$file"

echo "Done."

- name: Compile ${{ matrix.board.name }} Sketch
run: |
set -x
arduino-cli compile --fqbn ${{ matrix.board.fqbn }} -e \
--build-property build.partitions=huge_app \
--build-property upload.maximum_size=3145728 \
./saturn.ino

- name: Create ${{ matrix.board.name }} Firmware Binary
run: |
set -x
fqbn=${{ matrix.board.fqbn }}
directory="${fqbn//:/.}"

esptool.py --chip esp32s3 merge_bin --output saturn.bin \
${{ matrix.board.partitions.bootloader_addr }} build/${directory}/saturn.ino.bootloader.bin \
0x8000 build/${directory}/saturn.ino.partitions.bin \
0x10000 build/${directory}/saturn.ino.bin

- name: List all files
if: always()
continue-on-error: true
run: |
set -x
pwd
ls -all
tree
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on: [push, pull_request]

jobs:
lint:
name: Lint
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck --error-exitcode=1 --force --language=c++ src/*.h
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ merge:
monitor:
arduino-cli monitor --port $(PORT)

format:
clang-format -i --style=google src/*.h

format-raw:
python scripts/format_raw.py -f dev/input.txt

Expand All @@ -27,12 +30,17 @@ format-ir:
black:
black .

lint:
cppcheck --error-exitcode=1 --force --language=c++ src/*.h

.PHONY: html-lint
.PHONY: upload
.PHONY: compile
.PHONY: merge
.PHONY: monitor
.PHONY: format
.PHONY: format-raw
.PHONY: format-pronto
.PHONY: format-ir
.PHONY: black
.PHONY: black
.PHONY: lint
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<a href="https://github.com/henriquesebastiao/saturn/" target="blank"><img src="img/logo.png" width="298" alt="Saturn Logo" /></a>
</h1>

[![CI](https://github.com/henriquesebastiao/saturn/actions/workflows/ci.yml/badge.svg)](https://github.com/henriquesebastiao/saturn/actions/workflows/ci.yml)
[![Build](https://github.com/henriquesebastiao/saturn/actions/workflows/build.yml/badge.svg)](https://github.com/henriquesebastiao/saturn/actions/workflows/build.yml)
[![Version](https://img.shields.io/badge/version-1.2.0-blue)](https://github.com/henriquesebastiao/saturn/tags)
[![License](https://img.shields.io/github/license/henriquesebastiao/saturn)](https://github.com/henriquesebastiao/saturn/blob/main/LICENSE)

Expand All @@ -13,6 +15,24 @@
<img src="img/boot-screen.jpg" alt="Typesense Demo" width="300" />
</p>

### Credits

If you read the source code you will see that it contains many things similar to the [Nemo](https://github.com/n0xa/m5stick-nemo) project, this is because many things are borrowed from there. I just added some irrelevant things, changed the color and added rounded corners.

Nemo project: https://github.com/n0xa/m5stick-nemo

Other sources were also borrowed:

#### IR codes

- https://www.remotecentral.com/cgi-bin/codes/
- https://github.com/probonopd/lirc-remotes

#### Sounds

- https://github.com/hibit-dev/buzzer/tree/master
- https://github.com/henriquesebastiao/RouterBOARD-Scripts

### An advance warning

This project is still in its initial phase and is being developed for my own learning, therefore, it may not generate the expected result at some point. The code is still under development and may contain bugs and flaws. If you find something that doesn't seem to be working correctly, don't hesitate to open an issue reporting the error you experienced. I will do my best to help you.
Expand Down Expand Up @@ -90,13 +110,23 @@ Record your voice and play it back.

Saturn has different compilation versions, versions with different languages ​​(pt-BR, en-US) and "silent" versions. The compiled silent versions present in GitHub releases are named with the suffix `silent`, they do not emit any sound during firmware execution.

### Install from M5Burner

This is the absolute easiest way to get Saturn

- Launch M5Burner.
- Select "Cardputer" from the menu on the left.
- Use the search at the top of the app to look for "Saturn". My official builds will be uploaded by "henriquesebastiao" and have photos.
- Click Download.
- Click Burn.

### Install `.bin` files manually with `esptool.py`

- Install ESP-IDF tools per the [Espressif Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/)
- Open the `esp-idf` CMD tool (on Windows) - on Mac or Linux, `esp-idf.py` and `esptool.py` should be in the system path.
- `esptool.py --port COMPORT -b 115200 write_flash -z 0x0 Saturn-VERSION.bin`
- port may be a COM port e.g. `COM4`, `COM11` on Windows. On Mac and Linux it will usually be in `/dev` such as `/dev/ttyUSB0`, `/dev/ttyACM0` or `/dev/cu.usbserial-3`
- `Saturn-VERSION.bin` should be a version you downloaded from a GitHub Release -- preferably the latest available.
- port may be a COM port e.g. `COM4`, `COM11` on Windows. On Mac and Linux it will usually be in `/dev` such as `/dev/ttyUSB0`, `/dev/ttyACM0` or `/dev/cu.usbserial-3`
- `Saturn-VERSION.bin` should be a version you downloaded from a GitHub Release -- preferably the latest available.

## Building from Source

Expand All @@ -106,12 +136,12 @@ If you want to customize Saturn or contribute to the project, you should be fami
- Install the M5Stack boards for Arduino IDE: In File -> Preferences, paste this URL into the "Boards Manager URLs" text box. Use commas between URLs if there are already URLs present. https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
- If M5Stack -> M5Cardputer doesn't show up under Tools -> Boards, then use Tools -> Boards -> Boards Manager and search for M5Stack. This will install support for most of the M5Stack boards including the Cardputer.
- Install necessary libraries. In Sketch -> Include Library -> Library Manager, search for and install the following libraries and any dependencies they require:
- M5Cardputer
- IRRemoteESP8266
- Switch partition schemes. `Tools` -> `Partition Scheme` -> `No OTA (Large APP)` - sometimes this option is labeled `Huge APP`
- M5Cardputer
- IRRemoteESP8266
- Switch partition schemes. `Tools` -> `Partition Scheme` -> `No OTA (Large APP)` - sometimes this option is labeled `Huge APP`
- Configuration
- The code should compile cleanly and work on an M5Stick C Plus out of the box from the main branch or a release tag.
- Uncomment only the one appropriate `#define` option or compiler errors will occur.
- The code should compile cleanly and work on an M5Stick C Plus out of the box from the main branch or a release tag.
- Uncomment only the one appropriate `#define` option or compiler errors will occur.
- Compile and upload the project


Expand Down Expand Up @@ -166,7 +196,7 @@ Things I'd like help on:

- Testing on different devices and reporting your feedback.
- Infrared
- Add support for new manufacturers and also new device types, such as air conditioners, sound systems, etc.
- Add support for new manufacturers and also new device types, such as air conditioners, sound systems, etc.

### How the project is organized?

Expand Down
Loading

0 comments on commit ca9563f

Please sign in to comment.