From 13076ab736538485d292b3624299fae31c228c0c Mon Sep 17 00:00:00 2001 From: Bryan Honof Date: Wed, 16 Oct 2024 11:41:23 -0600 Subject: [PATCH] feat: add platformio --- platformio/.flox/.gitignore | 4 + platformio/.flox/env.json | 4 + platformio/.flox/env/manifest.lock | 397 +++++++++++++++++++++++++++++ platformio/.flox/env/manifest.toml | 30 +++ platformio/.gitignore | 5 + platformio/include/README | 39 +++ platformio/lib/README | 46 ++++ platformio/platformio.ini | 27 ++ platformio/src/main.cc | 34 +++ platformio/test/README | 11 + 10 files changed, 597 insertions(+) create mode 100644 platformio/.flox/.gitignore create mode 100644 platformio/.flox/env.json create mode 100644 platformio/.flox/env/manifest.lock create mode 100644 platformio/.flox/env/manifest.toml create mode 100644 platformio/.gitignore create mode 100644 platformio/include/README create mode 100644 platformio/lib/README create mode 100644 platformio/platformio.ini create mode 100644 platformio/src/main.cc create mode 100644 platformio/test/README diff --git a/platformio/.flox/.gitignore b/platformio/.flox/.gitignore new file mode 100644 index 0000000..15d71a1 --- /dev/null +++ b/platformio/.flox/.gitignore @@ -0,0 +1,4 @@ +run/ +cache/ +lib/ +log/ diff --git a/platformio/.flox/env.json b/platformio/.flox/env.json new file mode 100644 index 0000000..fb0ecd4 --- /dev/null +++ b/platformio/.flox/env.json @@ -0,0 +1,4 @@ +{ + "name": "platformio", + "version": 1 +} \ No newline at end of file diff --git a/platformio/.flox/env/manifest.lock b/platformio/.flox/env/manifest.lock new file mode 100644 index 0000000..94fd3c3 --- /dev/null +++ b/platformio/.flox/env/manifest.lock @@ -0,0 +1,397 @@ +{ + "lockfile-version": 1, + "manifest": { + "version": 1, + "install": { + "clang-tools": { + "pkg-path": "clang-tools" + }, + "cppcheck": { + "pkg-path": "cppcheck" + }, + "platformio-core": { + "pkg-path": "platformio-core" + } + }, + "hook": {}, + "profile": {}, + "options": { + "systems": [ + "aarch64-darwin", + "aarch64-linux", + "x86_64-darwin", + "x86_64-linux" + ], + "allow": { + "licenses": [] + }, + "semver": {} + } + }, + "packages": [ + { + "attr_path": "clang-tools", + "broken": false, + "derivation": "/nix/store/bkk1mpqc0kqwi1mxg6csg6y5s8nxxsjs-clang-tools-16.0.6.drv", + "description": "Standalone command line tools for C++ development", + "install_id": "clang-tools", + "license": "NCSA", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "clang-tools-16.0.6", + "pname": "clang-tools", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "16.0.6", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/rq9c536ivh2lxa9ang4s8c1c7p8i9lcf-clang-tools-16.0.6" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "clang-tools", + "broken": false, + "derivation": "/nix/store/1r7amp6kpzdqjhl1bakgc7sgyjbrqv4b-clang-tools-18.1.8.drv", + "description": "Standalone command line tools for C++ development", + "install_id": "clang-tools", + "license": "NCSA", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "clang-tools-18.1.8", + "pname": "clang-tools", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "18.1.8", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/7yl57mfwh307jzhj0j7j2f99c5g1mwqf-clang-tools-18.1.8" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "clang-tools", + "broken": false, + "derivation": "/nix/store/855acicq5rsil87qj76igq8vqgrpivdv-clang-tools-16.0.6.drv", + "description": "Standalone command line tools for C++ development", + "install_id": "clang-tools", + "license": "NCSA", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "clang-tools-16.0.6", + "pname": "clang-tools", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "16.0.6", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/gra2dg123ib2iq8k7makyf7j98lv5hkq-clang-tools-16.0.6" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "clang-tools", + "broken": false, + "derivation": "/nix/store/c9q4qz1564spw7al9bgp2nfkmm3x2b62-clang-tools-18.1.8.drv", + "description": "Standalone command line tools for C++ development", + "install_id": "clang-tools", + "license": "NCSA", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "clang-tools-18.1.8", + "pname": "clang-tools", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "18.1.8", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/sx4hsylfqdr03sgy4p0d0mqw9fx81a05-clang-tools-18.1.8" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "cppcheck", + "broken": false, + "derivation": "/nix/store/lp9zkj8j35sqak926ji5zn5zq4mxwy9i-cppcheck-2.15.0.drv", + "description": "Static analysis tool for C/C++ code", + "install_id": "cppcheck", + "license": "GPL-3.0-or-later", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "cppcheck-2.15.0", + "pname": "cppcheck", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "2.15.0", + "outputs_to_install": [ + "out", + "man" + ], + "outputs": { + "man": "/nix/store/wj7j57lrpz40w09vigiabr9w4c69in7g-cppcheck-2.15.0-man", + "out": "/nix/store/ap7hkqxz3sbgqlp9jrcy4km0a3xrw1cw-cppcheck-2.15.0" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "cppcheck", + "broken": false, + "derivation": "/nix/store/pd61ny9a0cn02zh1dql1fnvwy027xa4w-cppcheck-2.15.0.drv", + "description": "Static analysis tool for C/C++ code", + "install_id": "cppcheck", + "license": "GPL-3.0-or-later", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "cppcheck-2.15.0", + "pname": "cppcheck", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "2.15.0", + "outputs_to_install": [ + "out", + "man" + ], + "outputs": { + "man": "/nix/store/l7nsxz6gslavahcnnk9hsj5xhw340lvh-cppcheck-2.15.0-man", + "out": "/nix/store/k4cxnadq3mpaxfl9vcmvy38rb8wf4i53-cppcheck-2.15.0" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "cppcheck", + "broken": false, + "derivation": "/nix/store/llbfdn8n9m0kvfwv79bmqlvhghw0rgbn-cppcheck-2.15.0.drv", + "description": "Static analysis tool for C/C++ code", + "install_id": "cppcheck", + "license": "GPL-3.0-or-later", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "cppcheck-2.15.0", + "pname": "cppcheck", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "2.15.0", + "outputs_to_install": [ + "out", + "man" + ], + "outputs": { + "man": "/nix/store/s50w9qicbybxxycpx7lbailhhf2lqhwx-cppcheck-2.15.0-man", + "out": "/nix/store/4rfbf01qf4nxps7d8378rikhk371rzg8-cppcheck-2.15.0" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "cppcheck", + "broken": false, + "derivation": "/nix/store/9y2wq61gx5gq9wxl874bps1vkh1aahra-cppcheck-2.15.0.drv", + "description": "Static analysis tool for C/C++ code", + "install_id": "cppcheck", + "license": "GPL-3.0-or-later", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "cppcheck-2.15.0", + "pname": "cppcheck", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "2.15.0", + "outputs_to_install": [ + "out", + "man" + ], + "outputs": { + "man": "/nix/store/rb58ypjb600v1904s6vvw4mc3vnd4i7n-cppcheck-2.15.0-man", + "out": "/nix/store/z4d5lq0jlgq5p06zk6a00j0l95k0sxa4-cppcheck-2.15.0" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "platformio-core", + "broken": false, + "derivation": "/nix/store/348gqvlf6wg0d7k87ixd9s88n0mjc8yr-platformio-6.1.15.drv", + "description": "Open source ecosystem for IoT development", + "install_id": "platformio-core", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "platformio-6.1.15", + "pname": "platformio-core", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "platformio-6.1.15", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dist": "/nix/store/k6kjm71ykpja5lpzyrhvpk44kfq1lass-platformio-6.1.15-dist", + "out": "/nix/store/lwiv1vrccxdjps2ax6702nixdibj4c1i-platformio-6.1.15", + "udev": "/nix/store/5xmv999hkc0nhnv2skk9qn22slk6nzx4-platformio-6.1.15-udev" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "platformio-core", + "broken": false, + "derivation": "/nix/store/5s5ir7y42vyax5sz2x6q85mxbm8mh5v4-platformio-6.1.15.drv", + "description": "Open source ecosystem for IoT development", + "install_id": "platformio-core", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "platformio-6.1.15", + "pname": "platformio-core", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "platformio-6.1.15", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dist": "/nix/store/xb463wv69hzv914074k7pgblfnknk448-platformio-6.1.15-dist", + "out": "/nix/store/jwgvgxz27cf2fxwvxnnq48z3i39r8z06-platformio-6.1.15", + "udev": "/nix/store/mk3cjxawgm2x6q137sz5hn0fcrgzd6mj-platformio-6.1.15-udev" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "platformio-core", + "broken": false, + "derivation": "/nix/store/pibq1ds8xh1z0a1yfwgl88k8a7dd0j0h-platformio-6.1.15.drv", + "description": "Open source ecosystem for IoT development", + "install_id": "platformio-core", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "platformio-6.1.15", + "pname": "platformio-core", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "platformio-6.1.15", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dist": "/nix/store/vwcx87fj64b0c56mipdf0xndp2jl06fl-platformio-6.1.15-dist", + "out": "/nix/store/p06zbvshll1svalx3j0s0j3r38algg9s-platformio-6.1.15", + "udev": "/nix/store/4z6dr0rngzy1lrrvbzr6vhpnd8ilkffc-platformio-6.1.15-udev" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "platformio-core", + "broken": false, + "derivation": "/nix/store/d6hp8qf1irhhlc7m4jq2iardqjmaq4qi-platformio-6.1.15.drv", + "description": "Open source ecosystem for IoT development", + "install_id": "platformio-core", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "platformio-6.1.15", + "pname": "platformio-core", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "platformio-6.1.15", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dist": "/nix/store/v5hf371szpdwmrmaj4vg4j72kcrkvyfa-platformio-6.1.15-dist", + "out": "/nix/store/risy72538q40qfx8pn87p65zf4x3pkba-platformio-6.1.15", + "udev": "/nix/store/v368d5g0ig17dhq5mgd6n2yazr1x05gr-platformio-6.1.15-udev" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + } + ] +} \ No newline at end of file diff --git a/platformio/.flox/env/manifest.toml b/platformio/.flox/env/manifest.toml new file mode 100644 index 0000000..358619c --- /dev/null +++ b/platformio/.flox/env/manifest.toml @@ -0,0 +1,30 @@ +version = 1 + +[install] +platformio-core.pkg-path = "platformio-core" +cppcheck.pkg-path = "cppcheck" +clang-tools.pkg-path = "clang-tools" + +[vars] +# message = "Howdy" + +[hook] +# on-activate = ''' +# # Set variables, create files and directories +# venv_dir="$(mktemp -d)" +# export venv_dir +# +# # Perform initialization steps, e.g. create a python venv +# python -m venv "$venv_dir" +# ''' + +[profile] +# common = ''' +# echo "it's gettin' flox in here" +# ''' + +[services] +# postgres.command = "postgres --config-file=pg.conf" + +[options] +systems = ["aarch64-darwin", "aarch64-linux", "x86_64-darwin", "x86_64-linux"] diff --git a/platformio/.gitignore b/platformio/.gitignore new file mode 100644 index 0000000..16a4d8b --- /dev/null +++ b/platformio/.gitignore @@ -0,0 +1,5 @@ +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json +.pio diff --git a/platformio/include/README b/platformio/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/platformio/include/README @@ -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 diff --git a/platformio/lib/README b/platformio/lib/README new file mode 100644 index 0000000..2593a33 --- /dev/null +++ b/platformio/lib/README @@ -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 +#include + +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 diff --git a/platformio/platformio.ini b/platformio/platformio.ini new file mode 100644 index 0000000..d8af912 --- /dev/null +++ b/platformio/platformio.ini @@ -0,0 +1,27 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:uno] +platform = atmelavr +board = uno +framework = arduino +check_tool = cppcheck, clangtidy + +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +check_tool = cppcheck, clangtidy + +[env:teensy31] +platform = teensy +board = teensy31 +framework = arduino +check_tool = cppcheck, clangtidy diff --git a/platformio/src/main.cc b/platformio/src/main.cc new file mode 100644 index 0000000..0ac7a14 --- /dev/null +++ b/platformio/src/main.cc @@ -0,0 +1,34 @@ +/** + * Blink + * + * Turns on an LED on for one second, + * then off for one second, repeatedly. + */ +#include "Arduino.h" + +#ifndef LED_BUILTIN +#define LED_BUILTIN 13 +#endif + +constexpr auto DELAY_TIME = 1000u; + +void setup() +{ + // initialize LED digital pin as an output. + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop() +{ + // turn the LED on (HIGH is the voltage level) + digitalWrite(LED_BUILTIN, HIGH); + + // wait for a second + delay(DELAY_TIME); + + // turn the LED off by making the voltage LOW + digitalWrite(LED_BUILTIN, LOW); + + // wait for a second + delay(DELAY_TIME); +} diff --git a/platformio/test/README b/platformio/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/platformio/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html