Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
madskjeldgaard committed Jul 16, 2024
0 parents commit 99ebbde
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
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
35 changes: 35 additions & 0 deletions .gitignore
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
102 changes: 102 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
// 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 esp32dev
{
"label": "upload esp32dev",
"type": "shell",
"command": "pio run -t upload -e esp32dev",
},
// Build esp32dev
{
"label": "build esp32dev",
"type": "shell",
"command": "pio run -e esp32dev",
},
// 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",
},
]
}
21 changes: 21 additions & 0 deletions LICENSE
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.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[![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.

## Supported boards

- ✅ Raspberry Pi Pico
- ✅ Raspberry Pi PicoW
- ✅ Teensy 4.1
- ✅ Teensy 4.0
- ✅ NodeMCU ESP8266
- ✅ ESP32 dev boards

... And it's very easy to add more boards, feel free to open a PR. I just added the ones I commonly use.

## 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.
39 changes: 39 additions & 0 deletions include/README
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
46 changes: 46 additions & 0 deletions lib/README
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
Loading

0 comments on commit 99ebbde

Please sign in to comment.