-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6ec2fcc
Showing
10 changed files
with
433 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: PlatformIO CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.platformio/.cache | ||
key: ${{ runner.os }}-pio | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
- name: Install PlatformIO Core | ||
run: pip install --upgrade platformio | ||
|
||
- name: Build PlatformIO Project | ||
run: pio run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
.pio | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
|
||
// Build all | ||
{ | ||
"label": "Build all", | ||
"type": "shell", | ||
"command": "pio run", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
|
||
// Make compiledb to allow LSP to work | ||
{ | ||
"label": "Build compiledb database for LSP / clangd", | ||
"type": "shell", | ||
"command": "pio run -t compiledb", | ||
}, | ||
|
||
// Upload raspberrypi-pico | ||
{ | ||
"label": "upload raspberrypi-pico", | ||
"type": "shell", | ||
"command": "pio run -t upload -e raspberrypi-pico", | ||
}, | ||
// Build raspberrypi-pico | ||
{ | ||
"label": "build raspberrypi-pico", | ||
"type": "shell", | ||
"command": "pio run -e raspberrypi-pico", | ||
}, | ||
|
||
// Upload teensy40 | ||
{ | ||
"label": "upload teensy40", | ||
"type": "shell", | ||
"command": "pio run -t upload -e teensy40", | ||
}, | ||
// Build teensy40 | ||
{ | ||
"label": "build teensy40", | ||
"type": "shell", | ||
"command": "pio run -e teensy40", | ||
}, | ||
|
||
// Upload teensy41 | ||
{ | ||
"label": "upload teensy41", | ||
"type": "shell", | ||
"command": "pio run -t upload -e teensy41", | ||
}, | ||
// Build teensy41 | ||
{ | ||
"label": "build teensy41", | ||
"type": "shell", | ||
"command": "pio run -e teensy41", | ||
}, | ||
|
||
// Upload raspberrypi-picow | ||
{ | ||
"label": "upload raspberrypi-picow", | ||
"type": "shell", | ||
"command": "pio run -t upload -e raspberrypi-picow", | ||
}, | ||
// Build raspberrypi-picow | ||
{ | ||
"label": "build raspberrypi-picow", | ||
"type": "shell", | ||
"command": "pio run -e raspberrypi-picow", | ||
}, | ||
|
||
// Upload nodemcuv2-esp8266 | ||
{ | ||
"label": "upload nodemcuv2-esp8266", | ||
"type": "shell", | ||
"command": "pio run -t upload -e nodemcuv2-esp8266", | ||
}, | ||
// Build nodemcuv2-esp8266 | ||
{ | ||
"label": "build nodemcuv2-esp8266", | ||
"type": "shell", | ||
"command": "pio run -e nodemcuv2-esp8266", | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Mads Kjeldgaard | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[![PlatformIO CI](https://github.com/madskjeldgaard/platformio-arduino-template/actions/workflows/build.yml/badge.svg)](https://github.com/madskjeldgaard/platformio-arduino-template/actions/workflows/build.yml) | ||
|
||
# Arduino starter template for Platformio | ||
|
||
This template sets up a nice skeleton to create a project for an arduino-supported microcontroller board using [platformio](https://platformio.org/). | ||
|
||
It has a lot of common things set up for most common boards used in the art/music/maker world, including a few optimizations and weird fixes. | ||
|
||
It includes suggestions for libraries to use so you don't have to dig around too much for the common stuff. Just uncomment in the platformio.ini file and recompile. | ||
|
||
## Features | ||
|
||
- Platformio-based – easy to compile and upload, gets dependencies automatically, also easy to extend with new boards | ||
- Includes a lot of common libraries. Just comment/uncomment in [platformio.ini](platformio.ini) to your project's liking. | ||
- C++17, allowing a lot of modern C++ tricks. | ||
- VSCode tasks are included making building easy in VSCode and in NeoVim (using the Overseer plugin) | ||
- A Github Action which runs every time you push code to test if your firmware still compiles. | ||
|
||
## Dependencies | ||
|
||
You need to have platformio installed to make use of this. | ||
|
||
Install it on MacOS by running homebrew: | ||
|
||
```bash | ||
brew install platformio | ||
``` | ||
|
||
## Compiling and uploading | ||
|
||
To compile and upload your sketch, simply run this command, adjusted to one of the supported boards, eg for Teensy 4.0: | ||
|
||
```bash | ||
pio run -t upload -e teensy40 | ||
``` | ||
|
||
You can also run it without the specified environment, then platformio will try to find the correct one (this is slow) | ||
|
||
```bash | ||
pio run -t upload | ||
``` | ||
|
||
Finally, the project includes vscode tasks, which are the recommended way of running these commands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
This directory is intended for project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link into executable file. | ||
|
||
The source code of each library should be placed in an own separate directory | ||
("lib/your_library_name/[here are source files]"). | ||
|
||
For example, see a structure of the following two libraries `Foo` and `Bar`: | ||
|
||
|--lib | ||
| | | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | ||
| | | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| | | ||
| |- README --> THIS FILE | ||
| | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
and a contents of `src/main.c`: | ||
``` | ||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
|
||
``` | ||
|
||
PlatformIO Library Dependency Finder will find automatically dependent | ||
libraries scanning project source files. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- https://docs.platformio.org/page/librarymanager/ldf.html |
Oops, something went wrong.