├── .editorconfig ├── .gitattributes ├── .gitignore ├── .idea └── codeStyles │ └── codeStyleConfig.xml ├── .markdownlint.json ├── .travis-arch-build ├── Dockerfile └── run.sh ├── .travis-fedora-build ├── Dockerfile └── run.sh ├── .travis.yml ├── .vscode └── cmake-kits.json ├── AUTHORS.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── appveyor.yml ├── cmake ├── Arduino-Toolchain.cmake └── Platform │ ├── Arduino.cmake │ ├── Hardware │ └── Boards │ │ ├── BoardManager.cmake │ │ └── Boards.cmake │ ├── Libraries │ ├── Libraries.cmake │ ├── LibrariesFinder.cmake │ ├── LibraryArchitectureParser.cmake │ ├── LibraryFlagsManager.cmake │ └── LibrarySourcesArchitectureResolver.cmake │ ├── Other │ ├── ArchitectureSupportQuery.cmake │ ├── ArduinoSDKSeeker.cmake │ ├── FirmwareSizeCalculator.cmake │ ├── RecipeParser.cmake │ └── TargetFlagsManager.cmake │ ├── Project │ ├── BoardSetup.cmake │ ├── CoreLibSetup.cmake │ ├── Project.cmake │ └── ProjectSetup.cmake │ ├── Properties │ ├── BoardPropertiesReader.cmake │ ├── CMakeProperties.cmake │ ├── PropertiesReader.cmake │ ├── PropertyValueResolver.cmake │ └── RecipePropertyValueResolver.cmake │ ├── Sketches │ ├── SketchHeadersManager.cmake │ ├── SketchManager.cmake │ └── SketchSourceConverter.cmake │ ├── Sources │ ├── ArduinoLibrarySourcesSeeker.cmake │ ├── ExampleSourcesSeeker.cmake │ ├── SourceSeeker.cmake │ └── SourcesManager.cmake │ ├── System │ ├── AvrToolsFinder.cmake │ ├── BuildSystemInitializer.cmake │ ├── DefaultsManager.cmake │ ├── LinuxDistDetector.cmake │ ├── PlatformElementsManager.cmake │ ├── PlatformFlagsSetter.cmake │ ├── PlatformInitializer.cmake │ ├── SketchbookFinder.cmake │ └── VersionDetector.cmake │ ├── Targets │ ├── ArduinoCMakeLibraryTarget.cmake │ ├── ArduinoExampleTarget.cmake │ ├── ArduinoLibraryTarget.cmake │ ├── CoreLibTarget.cmake │ ├── ExecutableTarget.cmake │ ├── PlatformLibraryTarget.cmake │ └── UploadTarget.cmake │ └── Utilities │ ├── CMakeArgumentsUtils.cmake │ ├── LibraryUtils.cmake │ ├── ListUtils.cmake │ ├── MathUtils.cmake │ ├── PathUtils.cmake │ ├── PlatformLibraryUtils.cmake │ ├── PropertyUtils.cmake │ ├── StringUtils.cmake │ └── Utilities.cmake └── examples ├── 3rd-party-library ├── 3rd_party.cpp ├── CMakeLists.txt ├── GFXTest.cpp ├── LiquidCrystalTest.cpp ├── NeoPixelTest.cpp ├── include │ ├── GFXTest.h │ ├── LiquidCrystalTest.hpp │ └── NeoPixelTest.hpp └── libraries │ ├── Adafruit-GFX-Library │ ├── Adafruit_GFX.cpp │ ├── Adafruit_GFX.h │ ├── Adafruit_SPITFT.cpp │ ├── Adafruit_SPITFT.h │ ├── Adafruit_SPITFT_Macros.h │ ├── Fonts │ │ ├── FreeMono12pt7b.h │ │ ├── FreeMono18pt7b.h │ │ ├── FreeMono24pt7b.h │ │ ├── FreeMono9pt7b.h │ │ ├── FreeMonoBold12pt7b.h │ │ ├── FreeMonoBold18pt7b.h │ │ ├── FreeMonoBold24pt7b.h │ │ ├── FreeMonoBold9pt7b.h │ │ ├── FreeMonoBoldOblique12pt7b.h │ │ ├── FreeMonoBoldOblique18pt7b.h │ │ ├── FreeMonoBoldOblique24pt7b.h │ │ ├── FreeMonoBoldOblique9pt7b.h │ │ ├── FreeMonoOblique12pt7b.h │ │ ├── FreeMonoOblique18pt7b.h │ │ ├── FreeMonoOblique24pt7b.h │ │ ├── FreeMonoOblique9pt7b.h │ │ ├── FreeSans12pt7b.h │ │ ├── FreeSans18pt7b.h │ │ ├── FreeSans24pt7b.h │ │ ├── FreeSans9pt7b.h │ │ ├── FreeSansBold12pt7b.h │ │ ├── FreeSansBold18pt7b.h │ │ ├── FreeSansBold24pt7b.h │ │ ├── FreeSansBold9pt7b.h │ │ ├── FreeSansBoldOblique12pt7b.h │ │ ├── FreeSansBoldOblique18pt7b.h │ │ ├── FreeSansBoldOblique24pt7b.h │ │ ├── FreeSansBoldOblique9pt7b.h │ │ ├── FreeSansOblique12pt7b.h │ │ ├── FreeSansOblique18pt7b.h │ │ ├── FreeSansOblique24pt7b.h │ │ ├── FreeSansOblique9pt7b.h │ │ ├── FreeSerif12pt7b.h │ │ ├── FreeSerif18pt7b.h │ │ ├── FreeSerif24pt7b.h │ │ ├── FreeSerif9pt7b.h │ │ ├── FreeSerifBold12pt7b.h │ │ ├── FreeSerifBold18pt7b.h │ │ ├── FreeSerifBold24pt7b.h │ │ ├── FreeSerifBold9pt7b.h │ │ ├── FreeSerifBoldItalic12pt7b.h │ │ ├── FreeSerifBoldItalic18pt7b.h │ │ ├── FreeSerifBoldItalic24pt7b.h │ │ ├── FreeSerifBoldItalic9pt7b.h │ │ ├── FreeSerifItalic12pt7b.h │ │ ├── FreeSerifItalic18pt7b.h │ │ ├── FreeSerifItalic24pt7b.h │ │ ├── FreeSerifItalic9pt7b.h │ │ ├── Org_01.h │ │ ├── Picopixel.h │ │ ├── Tiny3x3a2pt7b │ │ └── TomThumb.h │ ├── examples │ │ └── mock_ili9341 │ │ │ └── mock_ili9341.ino │ ├── fontconvert │ │ ├── fontconvert.c │ │ ├── fontconvert_win.md │ │ └── makefonts.sh │ ├── gfxfont.h │ ├── glcdfont.c │ ├── library.properties │ └── license.txt │ ├── Adafruit_NeoPixel │ ├── Adafruit_NeoPixel.cpp │ ├── Adafruit_NeoPixel.h │ ├── esp8266.c │ ├── examples │ │ ├── RGBWstrandtest │ │ │ ├── .esp8266.test.skip │ │ │ ├── .trinket.test.skip │ │ │ └── RGBWstrandtest.ino │ │ ├── StrandtestBLE │ │ │ ├── .test.skip │ │ │ ├── BLESerial.cpp │ │ │ ├── BLESerial.h │ │ │ └── StrandtestBLE.ino │ │ ├── buttoncycler │ │ │ ├── .esp8266.test.skip │ │ │ └── buttoncycler.ino │ │ ├── simple │ │ │ ├── .esp8266.test.skip │ │ │ └── simple.ino │ │ ├── simple_new_operator │ │ │ ├── .esp8266.test.skip │ │ │ └── simple_new_operator.ino │ │ └── strandtest │ │ │ ├── .esp8266.test.skip │ │ │ └── strandtest.ino │ ├── keywords.txt │ └── library.properties │ ├── LiquidCrystal_I2C │ ├── LiquidCrystal_I2C.cpp │ ├── LiquidCrystal_I2C.h │ ├── examples │ │ ├── CustomChars │ │ │ └── CustomChars.pde │ │ ├── HelloWorld │ │ │ └── HelloWorld.pde │ │ └── SerialDisplay │ │ │ └── SerialDisplay.pde │ ├── keywords.txt │ ├── library.json │ └── library.properties │ └── Skywriter │ ├── examples │ ├── NeoPaint │ │ └── NeoPaint.ino │ ├── SkyPainter │ │ └── SkyPainter.ino │ └── SkywriterInterrupt │ │ └── SkywriterInterrupt.ino │ ├── keywords.txt │ ├── skywriter.cpp │ └── skywriter.h ├── CMakeLists.txt ├── arduino-library ├── CMakeLists.txt └── test.cpp ├── blink-example └── CMakeLists.txt ├── header-only-library ├── CMakeLists.txt ├── headerOnlyTest.cpp └── libraries │ └── test-lib │ ├── library.properties │ └── src │ └── TestLib.hpp ├── hello-world ├── CMakeLists.txt └── helloWorld.cpp ├── misc ├── CMakeLists.txt └── libraries │ ├── CMakeLists.txt │ └── late-sources-library │ ├── Adafruit_NeoPixel │ ├── Adafruit_NeoPixel.cpp │ ├── Adafruit_NeoPixel.h │ ├── esp8266.c │ ├── examples │ │ ├── RGBWstrandtest │ │ │ ├── .esp8266.test.skip │ │ │ ├── .trinket.test.skip │ │ │ └── RGBWstrandtest.ino │ │ ├── StrandtestBLE │ │ │ ├── .test.skip │ │ │ ├── BLESerial.cpp │ │ │ ├── BLESerial.h │ │ │ └── StrandtestBLE.ino │ │ ├── buttoncycler │ │ │ ├── .esp8266.test.skip │ │ │ └── buttoncycler.ino │ │ ├── simple │ │ │ ├── .esp8266.test.skip │ │ │ └── simple.ino │ │ ├── simple_new_operator │ │ │ ├── .esp8266.test.skip │ │ │ └── simple_new_operator.ino │ │ └── strandtest │ │ │ ├── .esp8266.test.skip │ │ │ └── strandtest.ino │ ├── keywords.txt │ └── library.properties │ ├── CMakeLists.txt │ └── late-sources-lib.cpp ├── platform-library ├── CMakeLists.txt └── platformLibrary.cpp ├── servo-knob-example └── CMakeLists.txt └── sketch ├── CMakeLists.txt ├── sketch1.ino └── sketch2.pde /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | 6 | end_of_line = lf 7 | insert_final_newline = true 8 | 9 | indent_style = space 10 | indent_size = 4 11 | # Editor support is limited. Make you align multi-line statements accordingly, 12 | # should your editor not honour this attribute 13 | continuation_indent_size = 8 14 | 15 | trim_trailing_whitespace = true 16 | 17 | [*.{md,rst}] 18 | trim_trailing_whitespace = false 19 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### CMake template 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Testing 6 | Makefile 7 | cmake_install.cmake 8 | install_manifest.txt 9 | compile_commands.json 10 | CTestTestfile.cmake 11 | 12 | ### C++ template 13 | # Prerequisites 14 | *.d 15 | 16 | # Compiled Object files 17 | *.slo 18 | *.lo 19 | *.o 20 | *.obj 21 | 22 | # Precompiled Headers 23 | *.gch 24 | *.pch 25 | 26 | # Compiled Dynamic libraries 27 | *.so 28 | *.dylib 29 | *.dll 30 | 31 | # Fortran module files 32 | *.mod 33 | *.smod 34 | 35 | # Compiled Static libraries 36 | *.lai 37 | *.la 38 | *.a 39 | *.lib 40 | 41 | # Executables 42 | *.exe 43 | *.out 44 | *.app 45 | 46 | ### C template 47 | # Prerequisites 48 | 49 | # Object files 50 | *.ko 51 | *.elf 52 | 53 | # Linker output 54 | *.ilk 55 | *.map 56 | *.exp 57 | 58 | # Precompiled Headers 59 | 60 | # Libraries 61 | 62 | # Shared objects (inc. Windows DLLs) 63 | *.so.* 64 | 65 | # Executables 66 | *.i*86 67 | *.x86_64 68 | *.hex 69 | 70 | # Debug files 71 | *.dSYM/ 72 | *.su 73 | *.idb 74 | *.pdb 75 | 76 | # Kernel Module Compile Results 77 | *.mod* 78 | *.cmd 79 | .tmp_versions/ 80 | modules.order 81 | Module.symvers 82 | Mkfile.old 83 | dkms.conf 84 | 85 | ### JetBrains (modified) 86 | .idea/* 87 | !.idea/codeStyleSettings.xml 88 | !.idea/codeStyles/ 89 | 90 | # CMake 91 | cmake-build-debug/ 92 | 93 | # Mongo Explorer plugin: 94 | .idea/**/mongoSettings.xml 95 | 96 | ## File-based project format: 97 | *.iws 98 | 99 | ## Plugin-specific files: 100 | 101 | # IntelliJ 102 | out/ 103 | 104 | # mpeltonen/sbt-idea plugin 105 | .idea_modules/ 106 | 107 | # JIRA plugin 108 | atlassian-ide-plugin.xml 109 | 110 | # Cursive Clojure plugin 111 | .idea/replstate.xml 112 | 113 | # Crashlytics plugin (for Android Studio and IntelliJ) 114 | com_crashlytics_export_strings.xml 115 | crashlytics.properties 116 | crashlytics-build.properties 117 | fabric.properties 118 | 119 | # Created by https://www.gitignore.io/api/clion 120 | # Edit at https://www.gitignore.io/?templates=clion 121 | 122 | ### CLion ### 123 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 124 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 125 | 126 | # User-specific stuff 127 | .idea/**/workspace.xml 128 | .idea/**/tasks.xml 129 | .idea/**/usage.statistics.xml 130 | .idea/**/dictionaries 131 | .idea/**/shelf 132 | 133 | # Generated files 134 | .idea/**/contentModel.xml 135 | 136 | # Sensitive or high-churn files 137 | .idea/**/dataSources/ 138 | .idea/**/dataSources.ids 139 | .idea/**/dataSources.local.xml 140 | .idea/**/sqlDataSources.xml 141 | .idea/**/dynamic.xml 142 | .idea/**/uiDesigner.xml 143 | .idea/**/dbnavigator.xml 144 | 145 | # Gradle 146 | .idea/**/gradle.xml 147 | .idea/**/libraries 148 | 149 | # Gradle and Maven with auto-import 150 | # When using Gradle or Maven with auto-import, you should exclude module files, 151 | # since they will be recreated, and may cause churn. Uncomment if using 152 | # auto-import. 153 | # .idea/modules.xml 154 | # .idea/*.iml 155 | # .idea/modules 156 | 157 | # CMake 158 | cmake-build-*/ 159 | 160 | # Mongo Explorer plugin 161 | .idea/**/mongoSettings.xml 162 | 163 | # File-based project format 164 | *.iws 165 | 166 | # IntelliJ 167 | out/ 168 | 169 | # mpeltonen/sbt-idea plugin 170 | .idea_modules/ 171 | 172 | # JIRA plugin 173 | atlassian-ide-plugin.xml 174 | 175 | # Cursive Clojure plugin 176 | .idea/replstate.xml 177 | 178 | # Crashlytics plugin (for Android Studio and IntelliJ) 179 | com_crashlytics_export_strings.xml 180 | crashlytics.properties 181 | crashlytics-build.properties 182 | fabric.properties 183 | 184 | # Editor-based Rest Client 185 | .idea/httpRequests 186 | 187 | # Android studio 3.1+ serialized cache file 188 | .idea/caches/build_file_checksums.ser 189 | 190 | # JetBrains templates 191 | **___jb_tmp___ 192 | 193 | ### CLion Patch ### 194 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 195 | 196 | # *.iml 197 | # modules.xml 198 | # .idea/misc.xml 199 | # *.ipr 200 | 201 | # Sonarlint plugin 202 | .idea/sonarlint 203 | 204 | # End of https://www.gitignore.io/api/clion 205 | 206 | ### VisualStudioCode ### 207 | .vscode/* 208 | !.vscode/tasks.json 209 | !.vscode/launch.json 210 | !.vscode/extensions.json 211 | !.vscode/cmake-kits.json 212 | 213 | ### VisualStudioCode Patch ### 214 | # Ignore all local history of files 215 | .history 216 | 217 | ### User-Defined 218 | [Aa]ssets/* 219 | [Bb]uild/* 220 | examples/blink-example/Blink.cpp 221 | examples/servo-knob-example/Knob.cpp 222 | examples/sketch/sketch1.cpp 223 | examples/sketch/sketch2.cpp 224 | docs/wiki 225 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "line_length": false, 4 | "no-duplicate-heading": false, 5 | "first-line-h1": false, 6 | "first-header-h1": false 7 | } 8 | -------------------------------------------------------------------------------- /.travis-arch-build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM archlinux/base 2 | RUN pacman --noconfirm -Sy 3 | RUN pacman --noconfirm -S arduino arduino-avr-core git cmake make lsb-release 4 | RUN mkdir -p /root/Arduino/libraries 5 | RUN git clone https://github.com/arduino-libraries/Servo.git /root/Arduino/libraries/Servo 6 | RUN git clone https://github.com/arduino-libraries/Stepper.git /root/Arduino/libraries/Stepper 7 | RUN git clone https://github.com/arduino-libraries/Ethernet.git /root/Arduino/libraries/Ethernet 8 | COPY run.sh /run.sh 9 | CMD /run.sh 10 | 11 | -------------------------------------------------------------------------------- /.travis-arch-build/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir build 3 | cd build 4 | cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Arduino-Toolchain.cmake -DARDUINO_CMAKE_SKETCHBOOK_PATH=/root/Arduino ../examples/ 5 | make 6 | 7 | -------------------------------------------------------------------------------- /.travis-fedora-build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:latest 2 | RUN dnf install -y arduino cmake make redhat-lsb-core git 3 | RUN mkdir -p /root/Arduino/libraries 4 | RUN git clone https://github.com/arduino-libraries/Servo.git /root/Arduino/libraries/Servo 5 | RUN git clone https://github.com/arduino-libraries/Stepper.git /root/Arduino/libraries/Stepper 6 | RUN git clone https://github.com/arduino-libraries/Ethernet.git /root/Arduino/libraries/Ethernet 7 | COPY run.sh /run.sh 8 | CMD /run.sh 9 | 10 | -------------------------------------------------------------------------------- /.travis-fedora-build/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir build 3 | cd build 4 | cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Arduino-Toolchain.cmake -DARDUINO_CMAKE_SKETCHBOOK_PATH=/root/Arduino ../examples/ 5 | make 6 | 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | os: 3 | - linux 4 | - osx 5 | env: 6 | global: 7 | - ARDUINO_SDK_BASE_PATH=arduino-sdk/arduino 8 | matrix: 9 | - ARDUINO_SDK_VERSION=1.6.10 10 | - ARDUINO_SDK_VERSION=1.8.9 11 | matrix: 12 | include: 13 | - os: linux 14 | service: docker 15 | env: TEST_FEDORA=TRUE 16 | addons: {} 17 | before_install: 18 | - docker build -t fedorabuild .travis-fedora-build 19 | install: [] 20 | script: 21 | - docker run -v "$TRAVIS_BUILD_DIR/cmake":/cmake -v "$TRAVIS_BUILD_DIR/examples":/examples fedorabuild 22 | - os: linux 23 | service: docker 24 | env: TEST_ARCH=TRUE 25 | addons: {} 26 | before_install: 27 | - docker build -t archbuild .travis-arch-build 28 | install: [] 29 | script: 30 | - docker run -v "$TRAVIS_BUILD_DIR/cmake":/cmake -v "$TRAVIS_BUILD_DIR/examples":/examples archbuild 31 | cache: 32 | directories: 33 | - $HOME/$ARDUINO_SDK_BASE_PATH-$ARDUINO_SDK_VERSION 34 | if: branch != feature/appveyor-ci 35 | addons: 36 | apt: 37 | packages: 38 | - binutils-avr 39 | - avr-libc 40 | - avrdude 41 | - cmake 42 | before_install: 43 | - sdk_path="$HOME/$ARDUINO_SDK_BASE_PATH-$ARDUINO_SDK_VERSION" 44 | - mkdir -p "$sdk_path" 45 | - cd "$sdk_path/../.." # Get one level above 'arduino-sdk' 46 | - | 47 | if [[ -z "$(ls -A "$sdk_path")" ]]; 48 | then 49 | if [[ $TRAVIS_OS_NAME == linux ]]; then 50 | sdk_file="arduino-$ARDUINO_SDK_VERSION-linux64.tar.xz" 51 | else 52 | sdk_file="arduino-$ARDUINO_SDK_VERSION-macosx.zip" 53 | fi 54 | wget "https://downloads.arduino.cc/$sdk_file" -O "$sdk_file" 55 | if [[ $TRAVIS_OS_NAME == linux ]]; then 56 | tar -xf "$sdk_file" -C arduino-sdk 57 | else 58 | unzip -q "$sdk_file" 59 | mv Arduino.app/* arduino-sdk/arduino-$ARDUINO_SDK_VERSION 60 | fi 61 | fi 62 | - | 63 | if [[ $TRAVIS_OS_NAME == osx ]]; then 64 | sdk_path="$sdk_path/Contents/Java" 65 | fi 66 | - export ARDUINO_SDK_PATH="$sdk_path" 67 | install: 68 | - cd "$TRAVIS_BUILD_DIR" 69 | - mkdir build 70 | - rm -rf build/* 71 | - cd build/ 72 | script: 73 | - cmake -D CMAKE_TOOLCHAIN_FILE="../cmake/Arduino-Toolchain.cmake" ../examples 74 | - make 75 | after_failure: 76 | - cat CMakeFiles/CMakeOutput.log 77 | -------------------------------------------------------------------------------- /.vscode/cmake-kits.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Arduino-CMake-Toolchain", 4 | "toolchainFile": "${workspaceRoot}/cmake/Arduino-Toolchain.cmake" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | This files lists all the authors of this project that helped it grow by adding code, fixing bugs, etc. 4 | 5 | - [Tomasz Bogdal](https://github.com/queezythegreat) - Original author of **Arduino-CMake** 6 | - [Timor Gruber](https://github.com/MrPointer) - Author of **Arduino-CMake-NG**, Current Maintainer 7 | - [Tao Yuan](https://github.com/taoyuan) 8 | - [Mike Machado](https://github.com/machadolab) 9 | - [ooxi](https://github.com/ooxi) 10 | - [tellowkrinkle](https://github.com/tellowkrinkle) - For archlinux & Fedora support 11 | 12 | There are many other authors who have contributed to the various forks and versions, work which couldn't be done without them. 13 | 14 | To all of you - Thank you very much! 15 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Arduino CMake 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | branches: 3 | except: 4 | - feature/travis-ci # Affects only 'Travis-CI' builds, shouldn't be built 5 | image: Visual Studio 2017 6 | environment: 7 | MINGW_PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin 8 | ARDUINO_SDK_BASE_PATH: C:\arduino-sdk\arduino 9 | matrix: 10 | - ARDUINO_SDK_VERSION: 1.8.2 11 | - ARDUINO_SDK_VERSION: 1.8.9 12 | cache: 13 | - '%ARDUINO_SDK_BASE_PATH%-%ARDUINO_SDK_VERSION% -> %ARDUINO_SDK_VERSION%' 14 | install: 15 | - ps: cinst unzip 16 | - ps: $sdk_file = "arduino-$env:ARDUINO_SDK_VERSION-windows.zip" 17 | # Append SDK's version to SDK's base path 18 | - ps: $env:ARDUINO_SDK_PATH = "$env:ARDUINO_SDK_BASE_PATH-$env:ARDUINO_SDK_VERSION" 19 | - ps: cd C:\ 20 | - ps: | 21 | if ( -Not (Test-Path -Path $env:ARDUINO_SDK_PATH) ) 22 | { 23 | $arduino_sdk_uri = "https://downloads.arduino.cc/$sdk_file" 24 | wget "$arduino_sdk_uri" -O "$sdk_file" 25 | unzip -q "$sdk_file" -d "arduino-sdk" 26 | } 27 | - ps: $env:ARDUINO_SDK_PATH = ($env:ARDUINO_SDK_PATH -replace "\\","/") 28 | - ps: $env:Path += ";$env:MINGW_PATH" 29 | build_script: 30 | # Add the MinGW Path to the system PATH temporarily for this session 31 | - ps: cd $env:APPVEYOR_BUILD_FOLDER 32 | - ps: mkdir build 33 | - ps: cd build 34 | - ps: echo "$env:ARDUINO_SDK_PATH" 35 | - ps: >- 36 | cmake -G "MinGW Makefiles" 37 | -D CMAKE_TOOLCHAIN_FILE="..\cmake\Arduino-Toolchain.cmake" 38 | -D CMAKE_SH="CMAKE_SH-NOTFOUND" 39 | --no-warn-unused-cli 40 | ..\examples 41 | - ps: | 42 | mingw32-make.exe 2>&1 3>&1 43 | if ($LastExitCode -eq 0) { $host.SetShouldExit(0) } 44 | artifacts: 45 | - path: cmake 46 | name: CMake-Framework 47 | type: zip 48 | deploy: 49 | - provider: GitHub 50 | description: 'ToDo' 51 | artifact: CMake-Framework 52 | auth_token: 53 | secure: HdFffeP0STWdHzMbRZtWPESj7B88CtHWrh1/eHTpq6DWavB2GYrc3HbAVRieAXQW 54 | draft: true 55 | on: 56 | appveyor_repo_tag: true 57 | on_failure: 58 | - ps: cat CMakeFiles/CMakeOutput.log 59 | -------------------------------------------------------------------------------- /cmake/Arduino-Toolchain.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/Platform/Other/ArduinoSDKSeeker.cmake) 2 | 3 | function(_find_required_programs) 4 | 5 | # Find ASM compiler 6 | find_program(CMAKE_ASM_COMPILER avr-gcc 7 | PATHS ${ARDUINO_SDK_BIN_PATH} 8 | NO_DEFAULT_PATH 9 | NO_CMAKE_FIND_ROOT_PATH) 10 | # Find C compiler 11 | find_program(CMAKE_C_COMPILER avr-gcc 12 | PATHS ${ARDUINO_SDK_BIN_PATH} 13 | NO_DEFAULT_PATH 14 | NO_CMAKE_FIND_ROOT_PATH) 15 | # Find C++ compiler 16 | find_program(CMAKE_CXX_COMPILER avr-g++ 17 | PATHS ${ARDUINO_SDK_BIN_PATH} 18 | NO_DEFAULT_PATH 19 | NO_CMAKE_FIND_ROOT_PATH) 20 | # Find AR required for linkage 21 | find_program(CMAKE_AR avr-gcc-ar 22 | PATHS ${ARDUINO_SDK_BIN_PATH} 23 | NO_DEFAULT_PATH 24 | NO_CMAKE_FIND_ROOT_PATH) 25 | # Find Ranlib required for linkage 26 | find_program(CMAKE_RANLIB avr-gcc-ranlib 27 | PATHS ${ARDUINO_SDK_BIN_PATH} 28 | NO_DEFAULT_PATH 29 | NO_CMAKE_FIND_ROOT_PATH) 30 | # Find NM 31 | find_program(CMAKE_NM avr-gcc-nm 32 | PATHS ${ARDUINO_SDK_BIN_PATH} 33 | NO_DEFAULT_PATH 34 | NO_CMAKE_FIND_ROOT_PATH) 35 | 36 | endfunction() 37 | 38 | function(_setup_sdk_internal_paths) 39 | 40 | find_arduino_sdk_bin(arduino_bin_path) 41 | set(ARDUINO_SDK_BIN_PATH "${arduino_bin_path}" CACHE PATH 42 | "Path to Arduino SDK's binaries folder") 43 | find_arduino_sdk_root(arduino_root_path) 44 | set(ARDUINO_SDK_ROOT_PATH "${arduino_root_path}" CACHE PATH 45 | "Path to Arduino SDK's sys-root folder") 46 | set(ARDUINO_SDK_LIBRARIES_PATH "${ARDUINO_SDK_PATH}/libraries" CACHE PATH 47 | "Path to SDK's libraries directory") 48 | set(ARDUINO_SDK_EXAMPLES_PATH "${ARDUINO_SDK_PATH}/examples" CACHE PATH 49 | "Path to SDK's examples directory") 50 | 51 | endfunction() 52 | 53 | set(CMAKE_SYSTEM_NAME Arduino) 54 | 55 | # Add current directory to CMake Module path automatically 56 | if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake) 57 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}) 58 | endif () 59 | 60 | set(ARDUINO_CMAKE_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH 61 | "Path to Arduino-CMake's toolchain directory") 62 | 63 | if (DEFINED ENV{ARDUINO_SDK_PATH}) 64 | string(REPLACE "\\" "/" unix_style_sdk_path $ENV{ARDUINO_SDK_PATH}) 65 | set(ARDUINO_SDK_PATH "${unix_style_sdk_path}" CACHE PATH "Arduino SDK Path") 66 | else () 67 | # Set default path if none is set 68 | find_arduino_sdk(arduino_sdk_path) 69 | set(ARDUINO_SDK_PATH "${arduino_sdk_path}" CACHE PATH "Arduino SDK Path") 70 | endif () 71 | 72 | _setup_sdk_internal_paths() 73 | _find_required_programs() 74 | 75 | # where is the target environment 76 | set(CMAKE_FIND_ROOT_PATH "${ARDUINO_SDK_ROOT_PATH}") 77 | 78 | # search for programs in the build host directories 79 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 80 | # for libraries and headers in the target directories 81 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 82 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 83 | -------------------------------------------------------------------------------- /cmake/Platform/Arduino.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Utilities) 4 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Hardware/Boards) 5 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/System) 6 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Other) 7 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Project) 8 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Properties) 9 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Sketches) 10 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Sources) 11 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Libraries) 12 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Targets) 13 | 14 | include(Utilities) 15 | 16 | include(Boards) 17 | 18 | include(RecipeParser) 19 | include(TargetFlagsManager) 20 | include(SourcesManager) 21 | include(SketchManager) 22 | include(DefaultsManager) 23 | include(ArchitectureSupportQuery) 24 | include(CMakeProperties) 25 | 26 | include(Libraries) 27 | 28 | include(BuildSystemInitializer) 29 | 30 | include(ExecutableTarget) 31 | include(UploadTarget) 32 | include(CoreLibTarget) 33 | include(ArduinoCMakeLibraryTarget) 34 | include(ArduinoLibraryTarget) 35 | include(PlatformLibraryTarget) 36 | include(ArduinoExampleTarget) 37 | 38 | include(Project) 39 | 40 | initialize_build_system() 41 | -------------------------------------------------------------------------------- /cmake/Platform/Hardware/Boards/Boards.cmake: -------------------------------------------------------------------------------- 1 | include(BoardManager) 2 | -------------------------------------------------------------------------------- /cmake/Platform/Libraries/Libraries.cmake: -------------------------------------------------------------------------------- 1 | include(LibraryArchitectureParser) 2 | include(LibrarySourcesArchitectureResolver) 3 | include(LibraryFlagsManager) 4 | include(LibrariesFinder) 5 | -------------------------------------------------------------------------------- /cmake/Platform/Libraries/LibrariesFinder.cmake: -------------------------------------------------------------------------------- 1 | macro(_clear_find_library_state) 2 | 3 | unset(library_path CACHE) 4 | 5 | endmacro() 6 | 7 | #=============================================================================# 8 | # Finds an Arduino library with the given library name and creates a library target from it 9 | # with the given target name. 10 | # The search process also resolves library's architecture to check if it even can be built 11 | # using the current platform architecture. 12 | # _target_name - Name of the library target to be created. Usually library's real name. 13 | # _library_name - Name of the Arduino library to find. 14 | # [3RD_PARTY] - Whether library should be treated as a 3rd Party library. 15 | # [HEADER_ONLY] - Whether library should be treated as header-only library. 16 | # [QUIET] - Whether function should "fail" safely without warnings/errors 17 | # in case of an actual error. 18 | #=============================================================================# 19 | function(find_arduino_library _target_name _library_name) 20 | 21 | 22 | _clear_find_library_state() 23 | 24 | 25 | set(argument_options "3RD_PARTY" "HEADER_ONLY" "QUIET") 26 | cmake_parse_arguments(parsed_args "${argument_options}" "" "" ${ARGN}) 27 | 28 | is_platform_library(${_library_name} is_plib) # Detect whether library is a platform library 29 | 30 | if (NOT parsed_args_3RD_PARTY AND NOT is_plib) 31 | convert_string_to_pascal_case(${_library_name} _library_name) 32 | endif () 33 | 34 | find_file(library_path 35 | NAMES "${_library_name}" 36 | PATHS ${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH} ${ARDUINO_SDK_LIBRARIES_PATH} 37 | ${ARDUINO_CMAKE_SKETCHBOOK_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR} 38 | PATH_SUFFIXES libraries dependencies 39 | NO_DEFAULT_PATH 40 | NO_CMAKE_FIND_ROOT_PATH) 41 | 42 | if ("${library_path}" MATCHES "NOTFOUND" AND NOT parsed_args_QUIET) 43 | message(SEND_ERROR "Couldn't find library named ${_library_name}") 44 | 45 | else () # Library is found 46 | find_library_header_files("${library_path}" library_headers) 47 | 48 | if (NOT library_headers) 49 | if (parsed_args_QUIET) 50 | _clear_find_library_state() 51 | return() 52 | else () 53 | message(SEND_ERROR "Couldn't find any header files for the " 54 | "${_library_name} library") 55 | endif () 56 | else () 57 | if (parsed_args_HEADER_ONLY) 58 | add_arduino_header_only_library(${_target_name} ${library_headers}) 59 | else () 60 | find_library_source_files("${library_path}" library_sources) 61 | 62 | if (NOT library_sources) 63 | if (parsed_args_QUIET) 64 | _clear_find_library_state() 65 | return() 66 | else () 67 | message(SEND_ERROR "Couldn't find any source files for the " 68 | "${_library_name} library - Is it a header-only library?" 69 | "If so, please pass the HEADER_ONLY option " 70 | "as an argument to the function") 71 | endif () 72 | else () 73 | set(sources ${library_headers} ${library_sources}) 74 | 75 | if (is_plib) 76 | add_arduino_library(${_target_name} PLATFORM ${sources}) 77 | else () 78 | add_arduino_library(${_target_name} ${sources}) 79 | endif () 80 | endif () 81 | endif () 82 | endif () 83 | endif () 84 | 85 | _clear_find_library_state() 86 | 87 | endfunction() 88 | -------------------------------------------------------------------------------- /cmake/Platform/Libraries/LibraryArchitectureParser.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Gets a list of architectures supported by a library. 3 | # The list is read from the given properties file, which includes metadata about the library. 4 | # _library_properties_file - Full path to a library's properties file 5 | # (usually named 'library,propertie'). 6 | # _return_var - Name of variable in parent-scope holding the return value. 7 | # Returns - List of architectures supported by the library or '*' 8 | # if it's architecture-agnostic (Supports all arhcitectures). 9 | #=============================================================================# 10 | function(get_arduino_library_supported_architectures _library_properties_file _return_var) 11 | 12 | file(STRINGS ${_library_properties_file} library_properties) 13 | 14 | list(FILTER library_properties INCLUDE REGEX "arch") 15 | 16 | _get_property_value("${library_properties}" _library_arch_list) 17 | 18 | string(REPLACE "," ";" _library_arch_list ${_library_arch_list}) # Turn into a valid list 19 | 20 | set(${_return_var} ${_library_arch_list} PARENT_SCOPE) 21 | 22 | endfunction() 23 | -------------------------------------------------------------------------------- /cmake/Platform/Libraries/LibraryFlagsManager.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Sets compiler and linker flags on the given library target. 3 | # Changes are kept even outside the scope of the function since they apply on a target. 4 | # _library_target - Name of the library target. 5 | #=============================================================================# 6 | function(set_library_flags _library_target) 7 | 8 | parse_scope_argument(scope "${ARGN}" 9 | DEFAULT_SCOPE PUBLIC) 10 | 11 | set_target_compile_flags(${_library_target} ${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD} ${scope}) 12 | 13 | # Set linker flags 14 | set_target_linker_flags(${_library_target} ${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD}) 15 | 16 | endfunction() 17 | -------------------------------------------------------------------------------- /cmake/Platform/Libraries/LibrarySourcesArchitectureResolver.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Filters sources that relate to an architecture from the given list of unsupported architectures. 3 | # _unsupported_archs_regex - List of unsupported architectures as a regex-pattern string. 4 | # _sources - List of sources to check and potentially filter. 5 | # _return_var - Name of variable in parent-scope holding the return value. 6 | # Returns - Filtered list of sources containing only those that don't relate to 7 | # any unsupported architecture. 8 | #=============================================================================# 9 | function(_filter_unsupported_arch_sources _unsupported_archs_regex _sources _return_var) 10 | 11 | if (NOT "${_unsupported_archs_regex}" STREQUAL "") # Not all architectures are supported 12 | # Filter sources dependant on unsupported architectures 13 | list(FILTER _sources EXCLUDE REGEX ${_unsupported_archs_regex}) 14 | endif () 15 | 16 | set(${_return_var} ${_sources} PARENT_SCOPE) 17 | 18 | endfunction() 19 | 20 | #=============================================================================# 21 | # Resolves library's architecture-related elements by doing several things: 22 | # 1. Checking whether the platform's architecture is supported by the library 23 | # 2. Filtering out any library sources that relate to unsupported architectures, i.e 24 | # architectures other than the platform's. 25 | # If the platform's architecture isn't supported by the library, CMake generates an error and stops. 26 | # _library_sources - List of library's sources to check and potentially filter. 27 | # [LIB_PROPS_FILE] - Full path to the library's properties file. Optional. 28 | # _return_var - Name of variable in parent-scope holding the return value. 29 | # Returns - Filtered list of sources containing only those that don't relate to 30 | # any unsupported architecture. 31 | #=============================================================================# 32 | function(resolve_library_architecture _library_sources _return_var) 33 | 34 | if(NOT _library_sources) 35 | return() 36 | endif() 37 | 38 | cmake_parse_arguments(parsed_args "" "LIB_PROPS_FILE" "" ${ARGN}) 39 | 40 | if (parsed_args_LIB_PROPS_FILE) # Library properties file is given 41 | set(lib_props_file ${parsed_args_LIB_PROPS_FILE}) 42 | else () 43 | 44 | set(${_return_var} "${_library_sources}" PARENT_SCOPE) 45 | return() 46 | 47 | endif () 48 | 49 | get_arduino_library_supported_architectures("${lib_props_file}" lib_archs) 50 | 51 | # Check if the platform's architecture is supported by the library 52 | is_platform_architecture_supported(${lib_archs} arch_supported_by_lib) 53 | 54 | if (NOT ${arch_supported_by_lib}) 55 | message(SEND_ERROR "The platform's architecture, ${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE}, " 56 | "isn't supported by the ${_library_name} library") 57 | endif () 58 | 59 | get_unsupported_architectures("${lib_archs}" unsupported_archs REGEX) 60 | 61 | # Filter any sources that aren't supported by the platform's architecture 62 | _filter_unsupported_arch_sources("${unsupported_archs}" "${_library_sources}" valid_sources) 63 | 64 | set(${_return_var} "${valid_sources}" PARENT_SCOPE) 65 | 66 | endfunction() 67 | -------------------------------------------------------------------------------- /cmake/Platform/Other/ArchitectureSupportQuery.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Checks whether the platform's architecture is supported in the context of the given list 3 | # of architectures, i.e If the list contains the platform's architecture. 4 | # _arch_list - List of architectures supported by the library, 5 | # inferred from its' 'library.properties' file. 6 | # _return_var - Name of variable in parent-scope holding the return value. 7 | # Returns - True if supported, false otherwise. 8 | #=============================================================================# 9 | function(is_platform_architecture_supported _arch_list _return_var) 10 | 11 | if ("${_arch_list}" MATCHES "\\*") # Any architecture is supported 12 | set(result TRUE) 13 | else () 14 | if (${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE} IN_LIST _arch_list) 15 | set(result TRUE) # Our platform's arch is supported 16 | else () 17 | set(result FALSE) # Our arch isn't supported 18 | endif () 19 | endif () 20 | 21 | set(${_return_var} ${result} PARENT_SCOPE) 22 | 23 | endfunction() 24 | 25 | #=============================================================================# 26 | # Gets a filtered list of architectures that aren't compliant with the platform's architecture. 27 | # e.g If a list contains 'avr' and 'nrf52', while our arch is 'avr', 'nrf52' will be returned. 28 | # _arch_list - List of all architectures probably read from a library's properties file 29 | # [REGEX] - Returns list in a regex-compatible mode, allowing caller to 30 | # use result in search patterns. This is currently the only supported mode. 31 | # _return_var - Name of variable in parent-scope holding the return value. 32 | # Returns - Filtered list of architectures. 33 | #=============================================================================# 34 | function(get_unsupported_architectures _arch_list _return_var) 35 | 36 | cmake_parse_arguments(parsed_args "REGEX" "" "" ${ARGN}) 37 | 38 | if ("${_arch_list}" MATCHES "\\*") # All architectures are supported, return nothing 39 | return() 40 | endif () 41 | 42 | list(FILTER _arch_list EXCLUDE REGEX ${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE}) 43 | set(unsupported_arch_list ${_arch_list}) # Just for better readability 44 | 45 | if (NOT unsupported_arch_list) # The only supported architecture is our platform's architecture 46 | return() # Return nothing as there are no uspported architectures 47 | endif () 48 | 49 | if (parsed_args_REGEX) # Return in regex format 50 | 51 | foreach (arch ${unsupported_arch_list}) 52 | # Append an "|" to every unsupported-architecture to represent "or" in regex-fomart 53 | string(APPEND unsupported_archs_regex "${arch}" "|") 54 | endforeach () 55 | 56 | # Remove last "|" as it's unnecessary - There's no element after it 57 | string(LENGTH ${unsupported_archs_regex} str_len) 58 | decrement_integer(str_len 1) # Decrement string's length by 1 to trim last char ('|') 59 | string(SUBSTRING ${unsupported_archs_regex} 0 ${str_len} unsupported_archs_regex) 60 | 61 | # prepare for generalized function return 62 | set(unsupported_arch_list ${unsupported_archs_regex}) 63 | 64 | endif () 65 | 66 | set(${_return_var} ${unsupported_arch_list} PARENT_SCOPE) 67 | 68 | endfunction() 69 | -------------------------------------------------------------------------------- /cmake/Platform/Other/FirmwareSizeCalculator.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | function(parse_list_entry _list _entry_pattern _entry_index _parsed_variables_prefix) 4 | 5 | set(temp_list "${_list}") 6 | list(FILTER temp_list INCLUDE REGEX "${_entry_pattern}") 7 | list(GET temp_list ${_entry_index} entry_to_parse) 8 | 9 | if ("${entry_to_parse}" MATCHES "([^:]+):[ \t]*([0-9]+)[ \t]*([^ \t]+)[ \t]*[(]([0-9.]+)%.*") 10 | set(${_parsed_variables_prefix}_name ${CMAKE_MATCH_1} PARENT_SCOPE) 11 | set(${_parsed_variables_prefix}_size ${CMAKE_MATCH_2} PARENT_SCOPE) 12 | set(${_parsed_variables_prefix}_size_type ${CMAKE_MATCH_3} PARENT_SCOPE) 13 | set(${_parsed_variables_prefix}_percent ${CMAKE_MATCH_4} PARENT_SCOPE) 14 | endif () 15 | 16 | endfunction() 17 | 18 | function(format_output_message _message_prefix _sections _inner_sections _message_suffix 19 | _return_var) 20 | 21 | set(options USE_CUSTOM_CHARACTERS) 22 | set(multi_args CUSTOM_CHARACTERS CUSTOM_CHAR_INDICES) 23 | cmake_parse_arguments(format_args "${options}" "" "${multi_args}" ${ARGN}) 24 | 25 | if (format_args_USE_CUSTOM_CHARACTERS) 26 | if (NOT format_args_CUSTOM_CHARACTERS OR NOT format_args_CUSTOM_CHAR_INDICES) 27 | set(valid_custom_chars FALSE) 28 | string(CONCAT message_str "If custom characters are to be used" 29 | "," "they must also be provided" "," "along with their indices") 30 | message(WARNING "${message_str}") 31 | else () 32 | set(valid_custom_chars TRUE) 33 | endif () 34 | endif () 35 | 36 | set(message "${_message_prefix}") 37 | 38 | # Exclude "name" inner-section as it's treated differently 39 | list(FILTER _inner_sections EXCLUDE REGEX "name") 40 | # Decrement all custom chars' indices if they should be used since the "name" has been removed 41 | if (valid_custom_chars) 42 | set(new_custom_char_indices "") 43 | foreach (char ${format_args_CUSTOM_CHAR_INDICES}) 44 | math(EXPR char "${char}-1") 45 | list(APPEND new_custom_char_indices ${char}) 46 | endforeach () 47 | set(format_args_CUSTOM_CHAR_INDICES "${new_custom_char_indices}") 48 | endif () 49 | 50 | foreach (section ${_sections}) 51 | set(index 0) 52 | string(APPEND message "[${${section}_name}: ") 53 | foreach (inner_section ${_inner_sections}) 54 | if (valid_custom_chars AND ${index} IN_LIST format_args_CUSTOM_CHAR_INDICES) 55 | string(APPEND message "${${section}_${inner_section}}") 56 | string(APPEND message "${format_args_CUSTOM_CHARACTERS} ") 57 | else () 58 | string(APPEND message "${${section}_${inner_section}} ") 59 | endif () 60 | math(EXPR index "${index}+1") 61 | endforeach () 62 | string(APPEND message "] ") 63 | endforeach () 64 | 65 | string(APPEND message "${_message_suffix}") 66 | 67 | set(${_return_var} "${message}" PARENT_SCOPE) 68 | 69 | endfunction() 70 | 71 | function(_get_image_type_parsing_index _image_type _return_var) 72 | 73 | string(TOLOWER "${_image_type}" image_type) 74 | 75 | if ("${image_type}" MATCHES "firmware") 76 | set(parsing_index 0) 77 | elseif ("${image_type}" MATCHES "eeprom") 78 | set(parsing_index 1) 79 | elseif ("${image_type}" MATCHES "flash") 80 | set(parsing_index 2) 81 | endif () 82 | 83 | set(${_return_var} ${parsing_index} PARENT_SCOPE) 84 | 85 | endfunction() 86 | 87 | function(format_image_size _original_size_list _image_type _return_var) 88 | 89 | _get_image_type_parsing_index("${_image_type}" image_index) 90 | 91 | parse_list_entry("${_original_size_list}" "Program:" ${image_index} program_entry) 92 | parse_list_entry("${_original_size_list}" "Data:" ${image_index} data_entry) 93 | 94 | set(sections "program_entry" "data_entry") 95 | format_output_message("${_image_type} Size: " "${sections}" "${inner_sections}" "on ${MCU}" 96 | formatted_message USE_CUSTOM_CHARACTERS CUSTOM_CHARACTERS "%" CUSTOM_CHAR_INDICES 3) 97 | 98 | set(${_return_var} "${formatted_message}" PARENT_SCOPE) 99 | 100 | endfunction() 101 | 102 | set(avrsize_flags -C --mcu=${MCU}) 103 | execute_process(COMMAND ${AVRSIZE_PROGRAM} ${avrsize_flags} ${FIRMWARE_IMAGE} ${EEPROM_IMAGE} 104 | OUTPUT_VARIABLE firmware_size) 105 | 106 | # Convert lines into a list 107 | string(REPLACE "\n" ";" firmware_size_as_list "${firmware_size}") 108 | list(FILTER firmware_size_as_list INCLUDE REGEX ".+") 109 | 110 | set(inner_sections name size size_type percent) 111 | 112 | # Process Firmware size 113 | format_image_size("${firmware_size_as_list}" Firmware firmware_formatted_message) 114 | # Process EEPROM size 115 | format_image_size("${firmware_size_as_list}" EEPROM eeprom_formatted_message) 116 | 117 | message("${firmware_formatted_message}") 118 | message("${eeprom_formatted_message}\n") 119 | -------------------------------------------------------------------------------- /cmake/Platform/Other/RecipeParser.cmake: -------------------------------------------------------------------------------- 1 | include(RecipePropertyValueResolver) 2 | 3 | function(_determine_compiler_language _language _return_var) 4 | 5 | if (NOT _language) # Use default language 6 | set(language cpp) 7 | else () 8 | # Convert language to expected recipe format 9 | get_arduino_compliant_language_name(${_language} language) 10 | endif () 11 | 12 | set(${_return_var} "${language}" PARENT_SCOPE) 13 | 14 | endfunction() 15 | 16 | function(parse_compiler_recipe_flags _board_id _return_var) 17 | 18 | set(single_args "LANGUAGE") 19 | cmake_parse_arguments(recipe_flags "" "${single_args}" "" ${ARGN}) 20 | 21 | _determine_compiler_language("${recipe_flags_LANGUAGE}" recipe_language) 22 | 23 | set(original_list "${recipe_${recipe_language}_o_pattern}") 24 | set(final_recipe "") 25 | 26 | # Filter unwanted patterns from the recipe, so that only wanted ones will be parsed 27 | list(FILTER original_list INCLUDE REGEX "(^[^\"].*[^\"]$)") 28 | list(FILTER original_list EXCLUDE REGEX "-o") 29 | 30 | foreach (recipe_element ${original_list}) 31 | _resolve_recipe_property("${recipe_element}" "${_board_id}" resolved_element) 32 | if (NOT "${resolved_element}" STREQUAL "") # Unresolved element, don't append 33 | string(STRIP ${resolved_element} element) 34 | list(APPEND final_recipe "${element}") 35 | endif () 36 | endforeach () 37 | 38 | set(${_return_var} "${final_recipe}" PARENT_SCOPE) 39 | 40 | endfunction() 41 | 42 | function(parse_linker_recpie_pattern _board_id _return_var) 43 | 44 | set(original_list "${recipe_c_combine_pattern}") 45 | set(final_recipe "") 46 | 47 | # Filter unwanted patterns from the recipe, so that only wanted ones will be parsed 48 | list(FILTER original_list INCLUDE REGEX "(^[^\"].*[^\"]$)") 49 | list(FILTER original_list EXCLUDE REGEX "-[ol]") 50 | 51 | foreach (recipe_element ${original_list}) 52 | _resolve_recipe_property("${recipe_element}" "${_board_id}" resolved_element) 53 | if (NOT "${resolved_element}" STREQUAL "") # Unresolved element, don't append 54 | list(APPEND final_recipe "${resolved_element}") 55 | endif () 56 | endforeach () 57 | 58 | set(${_return_var} "${final_recipe} " PARENT_SCOPE) 59 | 60 | endfunction() 61 | 62 | function(parse_upload_recipe_pattern _board_id _port _return_var) 63 | 64 | set(original_list "${tools_avrdude_upload_pattern}") 65 | set(final_recipe "") 66 | 67 | list(FILTER original_list EXCLUDE REGEX ":|cmd") 68 | 69 | # Upload recipe contains many elements which aren't named correctly 70 | # Setting a local variable here will keep it in the resolving function's scope 71 | # In other words, it makes the variable resolvable 72 | # So if a special elment is met, its' expected variable is locally set with correct value 73 | foreach (recipe_element ${original_list}) 74 | if ("${recipe_element}" MATCHES "config.path") 75 | set(config_path "${ARDUINO_CMAKE_AVRDUDE_CONFIG_PATH}") 76 | elseif ("${recipe_element}" MATCHES "upload.verbose") 77 | set(upload_verbose "${tools_avrdude_upload_params_verbose}") 78 | elseif ("${recipe_element}" MATCHES "upload.verify") 79 | set(upload_verify "${tools_avrdude_upload_verify}") 80 | elseif ("${recipe_element}" MATCHES "protocol") 81 | set(protocol "${${_board_id}_upload_protocol}") 82 | elseif ("${recipe_element}" MATCHES "serial.port") 83 | set(serial_port "${_port}") 84 | endif () 85 | 86 | _resolve_recipe_property("${recipe_element}" "${_board_id}" resolved_element) 87 | if (NOT "${resolved_element}" STREQUAL "") 88 | list(APPEND final_recipe "${resolved_element}") 89 | endif () 90 | endforeach () 91 | 92 | set(${_return_var} "${final_recipe}" PARENT_SCOPE) 93 | 94 | endfunction() 95 | -------------------------------------------------------------------------------- /cmake/Platform/Project/BoardSetup.cmake: -------------------------------------------------------------------------------- 1 | function(setup_project_board _project_name) 2 | 3 | cmake_parse_arguments(parsed_args "" "BOARD_NAME;BOARD_CPU" "" ${ARGV}) 4 | 5 | if (NOT parsed_args_BOARD_NAME) 6 | message(FATAL_ERROR "Expected board name in setup function") 7 | else () 8 | 9 | get_board_id(board_id ${parsed_args_BOARD_NAME} ${parsed_args_BOARD_CPU}) 10 | 11 | set(PROJECT_${_project_name}_BOARD ${board_id} CACHE STRING "Project-Global board ID") 12 | 13 | endif () 14 | 15 | endfunction() 16 | -------------------------------------------------------------------------------- /cmake/Platform/Project/CoreLibSetup.cmake: -------------------------------------------------------------------------------- 1 | function(setup_project_core_lib _project_name) 2 | 3 | # Guard against redefiniton of the Core Lib target 4 | if (NOT TARGET ${${PROJECT_${_project_name}_BOARD}_CORELIB_TARGET}) 5 | 6 | add_arduino_core_lib(${PROJECT_${_project_name}_BOARD} target_name) 7 | 8 | # Define a global way to access Core Lib's target name 9 | set(${PROJECT_${_project_name}_BOARD}_CORELIB_TARGET ${target_name} 10 | CACHE STRING "Project-Global CoreLib target name") 11 | 12 | endif () 13 | 14 | endfunction() 15 | -------------------------------------------------------------------------------- /cmake/Platform/Project/Project.cmake: -------------------------------------------------------------------------------- 1 | include(BoardSetup) 2 | include(CoreLibSetup) 3 | include(ProjectSetup) 4 | -------------------------------------------------------------------------------- /cmake/Platform/Project/ProjectSetup.cmake: -------------------------------------------------------------------------------- 1 | function(arduino_cmake_project _project_name) 2 | 3 | # Store the project's name in parent scope as if it were defined by the CMakeLists.txt file 4 | # that called this function. It helps ensure each "sub-project" can actually exists separately from the others, 5 | # as is the case with the examples of the framework. 6 | # This is done because CMake's `project()` function doesn't maintain scope properly, 7 | # thus a custom one is needed. 8 | set(ARDUINO_CMAKE_PROJECT_NAME ${_project_name} PARENT_SCOPE) 9 | 10 | setup_project_board(${_project_name} ${ARGN}) 11 | 12 | setup_project_core_lib(${_project_name}) 13 | 14 | endfunction() 15 | -------------------------------------------------------------------------------- /cmake/Platform/Properties/BoardPropertiesReader.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Gets valid board names from the given list of properties, which should be the properties read 3 | # from the boards properties file. 4 | # As the boards' names may contain spaces, their property name is returned instead of the value. 5 | # That way, it's easier to treat them later as Cache variables. 6 | # _properties - List of properties that contains boards names. 7 | # _return_var - Name of variable in parent-scope holding the return value. 8 | # Returns - List of valid board names found in the given property-list. 9 | #=============================================================================# 10 | function(_get_boards_names _properties _return_var) 11 | 12 | list(FILTER _properties INCLUDE REGEX "name") 13 | 14 | set(__board_list) 15 | foreach (name_property ${_properties}) 16 | string(REGEX MATCH "[^.]+" board_name "${name_property}") 17 | list(APPEND __board_list "${board_name}") 18 | endforeach () 19 | list(REMOVE_DUPLICATES __board_list) # Remove possible duplicates 20 | 21 | set(ARDUINO_CMAKE_BOARDS ${__board_list} CACHE STRING "List of platform boards") 22 | 23 | set(${_return_var} ${__board_list} PARENT_SCOPE) 24 | 25 | endfunction() 26 | 27 | #=============================================================================# 28 | # Finds CPUs of each existing board that defines explciit ones. 29 | # It means that boards such as 'nano' that define both the 'atmega168' and the 'atmega328' CPUs 30 | # will define an appropriate Cache variable that stores the list of those CPUs for the given board. 31 | # _properties - List of properties that should be read from the boards properties file. 32 | # _boards - List of existing boards' names, found earlier with '_get_boards_names' 33 | #=============================================================================# 34 | function(_find_boards_cpus _properties _boards) 35 | 36 | list(FILTER _properties INCLUDE REGEX "^.+\\.menu\\.cpu\\.[^.]+=") 37 | foreach (cpu_property ${_properties}) 38 | string(REGEX MATCH "^[^.]+" board_name "${cpu_property}") 39 | 40 | string(REGEX MATCH "[^.]+=" cpu_entry "${cpu_property}") 41 | string(LENGTH ${cpu_entry} cpu_entry_length) 42 | decrement_integer(cpu_entry_length 1) 43 | string(SUBSTRING ${cpu_entry} 0 ${cpu_entry_length} cpu) 44 | 45 | if (DEFINED __${board_name}_cpu_list) 46 | list(APPEND __${board_name}_cpu_list ${cpu}) 47 | else () 48 | set(__${board_name}_cpu_list ${cpu}) 49 | endif () 50 | endforeach () 51 | 52 | foreach (board ${_boards}) 53 | if (DEFINED __${board}_cpu_list) 54 | set(${board}_cpu_list ${__${board}_cpu_list} CACHE STRING "") 55 | endif () 56 | endforeach () 57 | 58 | endfunction() 59 | 60 | #=============================================================================# 61 | # Property-reader function designed exclusively for the boards properties file. 62 | # It's different since there are some processes which must be done in order to completely initialize 63 | # the boards' properties. 64 | # _boards_properties_file - Full path to the boards properties file, 65 | # usually located under the platform directory. 66 | #=============================================================================# 67 | function(read_boards_properties _boards_properties_file) 68 | 69 | file(STRINGS ${_boards_properties_file} properties) 70 | read_properties("${properties}") 71 | 72 | _get_boards_names("${properties}" board_list) 73 | _find_boards_cpus("${properties}" "${board_list}") 74 | 75 | endfunction() 76 | -------------------------------------------------------------------------------- /cmake/Platform/Properties/CMakeProperties.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Defines custom properties used internally by the framework. 3 | #=============================================================================# 4 | function(define_custom_properties) 5 | 6 | define_property(TARGET PROPERTY BOARD_ID 7 | BRIEF_DOCS "ID of the associated hardware board" 8 | FULL_DOCS 9 | "Framework-Internal ID of the hardware Arduino board associated with the target") 10 | 11 | endfunction() 12 | -------------------------------------------------------------------------------- /cmake/Platform/Properties/PropertiesReader.cmake: -------------------------------------------------------------------------------- 1 | function(read_properties _properties_list) 2 | 3 | list(FILTER _properties_list INCLUDE REGEX "^[^#]+=.*") 4 | 5 | foreach (property ${_properties_list}) 6 | _get_property_name(${property} property_name) 7 | if ("${property_name}" MATCHES "name") # Property contains 'name' string 8 | continue() # Don't process further - Unnecessary information 9 | endif () 10 | 11 | _get_property_value(${property} property_value) 12 | # Create a list if values are separated by spaces 13 | string(REPLACE " " ";" property_value "${property_value}") 14 | _resolve_value("${property_value}" resolved_property_value) 15 | 16 | string(REPLACE "." "_" property_cache_name ${property_name}) 17 | set(${property_cache_name} ${resolved_property_value} CACHE STRING "") 18 | 19 | endforeach () 20 | 21 | endfunction() 22 | 23 | function(read_properties_from_file _properties_file_path) 24 | 25 | file(STRINGS ${_properties_file_path} properties) 26 | read_properties("${properties}") 27 | 28 | endfunction() 29 | -------------------------------------------------------------------------------- /cmake/Platform/Properties/PropertyValueResolver.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Resolves the given value by trying to find a variable with the same name. 3 | # The variable can be a Cache variable or a board property. 4 | # The original, given value is then replaced with the resolved one. 5 | # _value - Value to resolve, enclosed in curly-brackets ('{}') 6 | # _return_var - Name of variable in parent-scope holding the return value. 7 | # Returns - Resolved value if one is found, nothing otherwise. 8 | #=============================================================================# 9 | function(_resolve_single_value _value _return_var) 10 | 11 | set(extra_args ${ARGN}) 12 | 13 | string(REGEX REPLACE "^{(.+)}$" "\\1" value "${_value}") # Get only the value 14 | string(REPLACE "." "_" value_as_var "${value}") 15 | if (DEFINED ${value_as_var}) # Value is a variable (Probably cache) 16 | set(${_return_var} "${${value_as_var}}" PARENT_SCOPE) 17 | else () 18 | # Get extra arguments 19 | list(LENGTH extra_args num_of_extra_args) 20 | if (${num_of_extra_args} EQUAL 0) # No extra arguments 21 | return() # Link simply not found, it's probably desired 22 | elseif (${num_of_extra_args} EQUAL 1) 23 | list(GET extra_args 0 board_id) 24 | endif () 25 | 26 | # Maybe value is a board property? 27 | try_get_board_property("${board_id}" "${value}" value_as_board_property) 28 | if (NOT "${value_as_board_property}" STREQUAL "") # Value is indeed a board property 29 | set(${_return_var} ${value_as_board_property} PARENT_SCOPE) 30 | endif () 31 | endif () 32 | 33 | endfunction() 34 | 35 | #=============================================================================# 36 | # Resolves the given value by trying to find a variable with the same name for each 'inner-value'. 37 | # _value - Value to resolve as a list of 'inner-values', enclosed in curly-brackets ('{}') 38 | # _return_var - Name of variable in parent-scope holding the return value. 39 | # Returns - Resolved list of values. If nothing is resolved, simply the original list. 40 | #=============================================================================# 41 | function(_resolve_list_value _value _return_var) 42 | 43 | set(index 0) 44 | set(temp_list "${_value}") 45 | 46 | foreach (value_entry ${_value}) 47 | set(index_inc 1) # Always reset incrementation to 1 48 | if ("${value_entry}" MATCHES "^{.+}$") # Wrapped with brackets - resolvable 49 | _resolve_single_value(${value_entry} resolved_entry "${ARGN}") 50 | if (DEFINED resolved_entry) # Entry has been resolved 51 | if ("${resolved_entry}" STREQUAL "") # Resolved entry is an empty string 52 | list(REMOVE_AT temp_list ${index}) # Remove the entry completely 53 | decrement_integer(index 1) 54 | else () 55 | # Replace old value with new resolved value 56 | list_replace(temp_list ${index} "${resolved_entry}") 57 | # Also enlrage the index incrementation if resolved entry is a list 58 | list(LENGTH resolved_entry num_of_inner_resolved_entries) 59 | if (${num_of_inner_resolved_entries} GREATER 1) 60 | set(index_inc ${num_of_inner_resolved_entries}) 61 | endif () 62 | endif () 63 | endif () 64 | endif () 65 | increment_integer(index ${index_inc}) 66 | endforeach () 67 | 68 | set(${_return_var} "${temp_list}" PARENT_SCOPE) 69 | 70 | endfunction() 71 | 72 | #=============================================================================# 73 | # Resolves the given value by trying to find a variable with the same name. 74 | # The value can be a single value or a list value, and is resolved accordingly. 75 | # _value - Value to resolve. 76 | # _return_var - Name of variable in parent-scope holding the return value. 77 | # Returns - Resolved value if one is found, original value otherwise. 78 | #=============================================================================# 79 | function(_resolve_value _value _return_var) 80 | 81 | # Don't resolve empty values - There's nothing to resolve 82 | if ("${_value}" STREQUAL "") 83 | set(${_return_var} "" PARENT_SCOPE) 84 | return() 85 | endif () 86 | 87 | # Treat value as if it were a list and get its length to know if it's actually a list or not 88 | list(LENGTH _value value_list_length) 89 | if (${value_list_length} GREATER 1) 90 | _resolve_list_value("${_value}" resolved_var "${ARGN}") 91 | else () 92 | if (NOT "${_value}" MATCHES "^{.+}$") # No wrapping brackets, shouldn't be resolved 93 | set(resolved_var "${_value}") 94 | else () 95 | _resolve_single_value("${_value}" resolved_var "${ARGN}") 96 | endif () 97 | endif () 98 | 99 | set(${_return_var} "${resolved_var}" PARENT_SCOPE) 100 | 101 | endfunction() 102 | -------------------------------------------------------------------------------- /cmake/Platform/Properties/RecipePropertyValueResolver.cmake: -------------------------------------------------------------------------------- 1 | function(_get_recipe_property_name _property _return_var) 2 | 3 | string(REGEX MATCH "^[^{]+" property_name "${_property}") 4 | set(${_return_var} "${property_name}" PARENT_SCOPE) 5 | 6 | endfunction() 7 | 8 | function(_get_recipe_property_value _property _return_var) 9 | 10 | string(STRIP "${_property}" stripped_property) 11 | string(REGEX MATCH "{.+}$" property_value "${stripped_property}") 12 | set(${_return_var} "${property_value}" PARENT_SCOPE) 13 | 14 | endfunction() 15 | 16 | function(_resolve_recipe_property _property _board_id _return_var) 17 | 18 | string(REGEX MATCH "=" normal_property "${_property}") 19 | if ("${normal_property}" STREQUAL "") # Recipe property, doesn't have '=' 20 | if ("${_property}" MATCHES "^\".+\"$") # Property enclosed with qutoes 21 | string(REPLACE "\"" "" _property "${_property}") # Omit quotes for now 22 | set(quoted_property TRUE) 23 | endif () 24 | _get_recipe_property_name("${_property}" property_name) 25 | _get_recipe_property_value("${_property}" property_value) 26 | 27 | # If property has no value and can't be resolved, it probably has been already resolved 28 | if ("${property_value}" STREQUAL "" AND "${property_name}" STREQUAL "${_property}") 29 | set(resolved_property_value 0) 30 | set(resolved_property "${_property}") 31 | else () 32 | _resolve_value("${property_value}" resolved_property_value "${_board_id}") 33 | if (quoted_property) 34 | set(resolved_property "\"${property_name}${resolved_property_value}\"") 35 | else () 36 | set(resolved_property "${property_name}${resolved_property_value}") 37 | endif () 38 | endif () 39 | else () 40 | _get_property_name("${_property}" property_name) 41 | _get_property_value("${_property}" property_value) 42 | _resolve_value("${property_value}" resolved_property_value "${_board_id}") 43 | set(resolved_property "${property_name}=${resolved_property_value}") 44 | endif () 45 | 46 | # If value couldn't been resolved, return empty string 47 | if ("${resolved_property_value}" STREQUAL "") 48 | set(${_return_var} "" PARENT_SCOPE) 49 | else () 50 | set(${_return_var} "${resolved_property}" PARENT_SCOPE) 51 | endif () 52 | 53 | endfunction() 54 | -------------------------------------------------------------------------------- /cmake/Platform/Sketches/SketchHeadersManager.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Resolves the header files included in a sketch by linking their appropriate library if necessary 3 | # or by validating they're included by the sketch target. 4 | # _target_name - Name of the target to add the sketch file to. 5 | # _sketch_file - Path to a sketch file to add to the target. 6 | #=============================================================================# 7 | function(resolve_sketch_headers _target_name _sketch_file) 8 | 9 | get_source_file_included_headers("${_sketch_file}" sketch_headers) 10 | 11 | foreach (header ${sketch_headers}) 12 | 13 | # Header name without extension (such as '.h') can represent an Arduino/Platform library 14 | # So first we should check whether it's a library 15 | get_name_without_file_extension("${header}" header_we) 16 | 17 | is_platform_library(${header_we} is_header_platform_lib) 18 | 19 | if (is_header_platform_lib) 20 | 21 | string(TOLOWER ${header_we} header_we_lower) 22 | 23 | link_platform_library(${_target_name} ${header_we_lower}) 24 | 25 | else () 26 | 27 | # Pass the '3RD_PARTY' option to avoid name-conversion 28 | find_arduino_library(${header_we}_sketch_lib ${header_we} 3RD_PARTY QUIET) 29 | 30 | # If library isn't found, display a status since it might be a user library 31 | if (NOT TARGET ${header_we}_sketch_lib OR 32 | "${${header_we}_sketch_lib}" MATCHES "NOTFOUND") 33 | 34 | message(STATUS "The header '${header_we}' is used by the '${_sketch_file}' sketch, " 35 | "but it isn't part of an Arduino nor a Platform library.\n\t" 36 | "However, it may be part of a user library but " 37 | "you'd have to check this manually!") 38 | 39 | else () 40 | link_arduino_library(${_target_name} ${header_we}_sketch_lib) 41 | endif () 42 | 43 | endif () 44 | 45 | endforeach () 46 | 47 | endfunction() 48 | -------------------------------------------------------------------------------- /cmake/Platform/Sketches/SketchManager.cmake: -------------------------------------------------------------------------------- 1 | include(SketchSourceConverter) 2 | include(SketchHeadersManager) 3 | 4 | #=============================================================================# 5 | # Returns a desired path for sources converted from sketches. 6 | # It can't be resolved just by a cache variable since sketches may belong each to a different project, 7 | # thus having different path to be returned. 8 | # _sketch_file - Path to a sketch file to find the desired path to its converted source. 9 | # _return_var - Name of variable in parent-scope holding the return value. 10 | # Returns - Desired path for the source file converted from the given sketch 11 | #=============================================================================# 12 | function(_get_converted_source_desired_path _sketch_file _return_var) 13 | 14 | get_filename_component(sketch_file_name "${_sketch_file}" NAME_WE) 15 | 16 | set(desired_source_path "${CMAKE_CURRENT_SOURCE_DIR}/${sketch_file_name}.cpp") 17 | 18 | set(${_return_var} ${desired_source_path} PARENT_SCOPE) 19 | 20 | endfunction() 21 | 22 | #=============================================================================# 23 | # Adds the sketch file to the given target with the given board ID. 24 | # Each sketch is converted to a valid '.cpp' source file under the project's source directory. 25 | # The function also finds and links any libraries the sketch uses to the target. 26 | # _target_name - Name of the target to add the sketch file to. 27 | # _sketch_file - Path to a sketch file to add to the target. 28 | #=============================================================================# 29 | function(add_sketch_to_target _target_name _sketch_file) 30 | 31 | _get_converted_source_desired_path(${_sketch_file} sketch_converted_source_path) 32 | 33 | # Only perform conversion if policy is set or if sketch hasn't been converted yet 34 | if (CONVERT_SKETCHES_IF_CONVERTED_SOURCES_EXISTS OR 35 | NOT EXISTS ${sketch_converted_source_path}) 36 | 37 | resolve_sketch_headers(${_target_name} ${_sketch_file}) 38 | 39 | convert_sketch_to_source(${_sketch_file} ${sketch_converted_source_path}) 40 | 41 | endif () 42 | 43 | target_sources(${_target_name} PRIVATE ${sketch_converted_source_path}) 44 | 45 | endfunction() 46 | 47 | #=============================================================================# 48 | # Adds a list of sketch files as converted sources to the given target. 49 | # _target_name - Name of the target to add the sketch file to. 50 | # [Sketches] - List of paths to sketch files to add to the target. 51 | #=============================================================================# 52 | function(target_sketches _target_name) 53 | 54 | parse_sources_arguments(parsed_sketches "" "" "" "${ARGN}") 55 | 56 | foreach (sketch_file ${parsed_sketches}) 57 | add_sketch_to_target(${_target_name} ${sketch_file}) 58 | endforeach () 59 | 60 | endfunction() 61 | -------------------------------------------------------------------------------- /cmake/Platform/Sources/ArduinoLibrarySourcesSeeker.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Recursively finds header files under the given path, excluding those that don't belong to a library, 3 | # such as files under the 'exmaples' directory (In case sources reside under lib's root directory). 4 | # _base_path - Top-Directory path to search source files in. 5 | # _return_var - Name of variable in parent-scope holding the return value. 6 | # Returns - List of source files in the given path 7 | #=============================================================================# 8 | function(find_library_header_files _base_path _return_var) 9 | 10 | if (EXISTS ${_base_path}/src) # 'src' sub-dir exists and should contain sources 11 | 12 | # Headers are always searched recursively under the 'src' sub-dir 13 | find_header_files(${_base_path}/src headers RECURSE) 14 | 15 | else () 16 | 17 | # Both root-dir and 'utility' sub-dir are searched when 'src' doesn't exist 18 | find_header_files(${_base_path} root_headers) 19 | find_header_files(${_base_path}/utility utility_headers) 20 | 21 | set(headers ${root_headers} ${utility_headers}) 22 | 23 | endif () 24 | 25 | set(${_return_var} "${headers}" PARENT_SCOPE) 26 | 27 | endfunction() 28 | 29 | #=============================================================================# 30 | # Recursively finds source files under the given path, excluding those that don't belong to a library, 31 | # such as files under the 'exmaples' directory (In case sources reside under lib's root directory). 32 | # _base_path - Top-Directory path to search source files in. 33 | # _return_var - Name of variable in parent-scope holding the return value. 34 | # Returns - List of source files in the given path 35 | #=============================================================================# 36 | function(find_library_source_files _base_path _return_var) 37 | 38 | if (EXISTS ${_base_path}/src) 39 | 40 | # Sources are always searched recursively under the 'src' sub-dir 41 | find_source_files(${_base_path}/src sources RECURSE) 42 | 43 | else () 44 | 45 | # Both root-dir and 'utility' sub-dir are searched when 'src' doesn't exist 46 | find_source_files(${_base_path} root_sources) 47 | find_source_files(${_base_path}/utility utility_sources) 48 | 49 | set(sources ${root_sources} ${utility_sources}) 50 | 51 | endif () 52 | 53 | set(${_return_var} "${sources}" PARENT_SCOPE) 54 | 55 | endfunction() 56 | -------------------------------------------------------------------------------- /cmake/Platform/Sources/ExampleSourcesSeeker.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Finds all sources under the given base path conforming to the given extension. 3 | # Found sources represent Arduino sketches, which in turn are also examples. 4 | # _base_path - Top-Directory path to search source files in. 5 | # _example_name - Name of the example to find its' sources. 6 | # _search_extension - File extension of the target example, marking an example as 'found'. 7 | # _return_var - Name of variable in parent-scope holding the return value. 8 | # Returns - List of sources representing the requested example. 9 | #=============================================================================# 10 | function(_find_example_sources _base_path _example_name _search_extension _return_var) 11 | 12 | if (example_CATEGORY) 13 | set(search_path "${_base_path}/${example_CATEGORY}/${_example_name}.${_search_extension}") 14 | else () 15 | set(search_path "${_base_path}/${_example_name}.${_search_extension}") 16 | endif () 17 | file(GLOB_RECURSE example_description_file "${search_path}") 18 | get_filename_component(example_dir "${example_description_file}" DIRECTORY) 19 | 20 | find_sketch_files("${example_dir}" example_sketches) 21 | 22 | set(${_return_var} ${example_sketches} PARENT_SCOPE) 23 | 24 | endfunction() 25 | 26 | #=============================================================================# 27 | # Finds all sources under the given base path conforming to the given extension. 28 | # Found sources represent Arduino sketches, which in turn are also examples. 29 | # _base_path - Top-Directory path to search source files in. 30 | # _example_name - Name of the example to find its' sources. 31 | # _return_var - Name of variable in parent-scope holding the return value. 32 | # Returns - List of sources representing the requested example. 33 | #=============================================================================# 34 | function(find_arduino_example_sources _base_path _example_name _return_var) 35 | 36 | # Example directories contain a '.txt' file along with all other sources 37 | _find_example_sources("${_base_path}" ${_example_name} "txt" sources) 38 | set(${_return_var} ${sources} PARENT_SCOPE) 39 | 40 | endfunction() 41 | 42 | #=============================================================================# 43 | # Finds all sources under the given base path conforming to the given extension. 44 | # Found sources represent Arduino sketches, which in turn are also examples. 45 | # _base_path - Top-Directory path to search source files in. 46 | # _example_name - Name of the example to find its' sources. 47 | # _return_var - Name of variable in parent-scope holding the return value. 48 | # Returns - List of sources representing the requested example. 49 | #=============================================================================# 50 | function(find_arduino_library_example_sources _base_path _example_name _return_var) 51 | 52 | # Library example directories contain only '.ino' files 53 | _find_example_sources("${_base_path}" ${_example_name} "ino" sources) 54 | set(${_return_var} ${sources} PARENT_SCOPE) 55 | 56 | endfunction() 57 | -------------------------------------------------------------------------------- /cmake/Platform/Sources/SourceSeeker.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Finds source files matching the given pattern under the given path. 3 | # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed. 4 | # _base_path - Top-Directory path to search source files in. 5 | # [RECURSE] - Whether search should be done recursively or not. 6 | # _return_var - Name of variable in parent-scope holding the return value. 7 | # Returns - List of sources in the given path 8 | #=============================================================================# 9 | function(_find_sources _base_path _pattern _return_var) 10 | 11 | cmake_parse_arguments(source_file_search "RECURSE" "" "" ${ARGN}) 12 | 13 | # Adapt the source files pattern to the given base dir 14 | set(current_pattern "") 15 | foreach (pattern_part ${_pattern}) 16 | list(APPEND current_pattern "${_base_path}/${pattern_part}") 17 | endforeach () 18 | 19 | if (${source_file_search_RECURSE}) 20 | file(GLOB_RECURSE source_files ${current_pattern}) 21 | else () 22 | file(GLOB source_files LIST_DIRECTORIES FALSE ${current_pattern}) 23 | endif () 24 | 25 | set(${_return_var} "${source_files}" PARENT_SCOPE) 26 | 27 | endfunction() 28 | 29 | #=============================================================================# 30 | # Finds header files matching the pre-defined header-file pattern under the given path. 31 | # This functions searchs explicitly for header-files such as '*.h'. 32 | # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed. 33 | # _base_path - Top-Directory path to search source files in. 34 | # [RECURSE] - Whether search should be done recursively or not. 35 | # _return_var - Name of variable in parent-scope holding the return value. 36 | # Returns - List of header files in the given path 37 | #=============================================================================# 38 | function(find_header_files _base_path _return_var) 39 | 40 | _find_sources("${_base_path}" "${ARDUINO_CMAKE_HEADER_FILES_PATTERN}" headers ${ARGN}) 41 | set(${_return_var} "${headers}" PARENT_SCOPE) 42 | 43 | endfunction() 44 | 45 | #=============================================================================# 46 | # Finds source files matching the pre-defined source-file pattern under the given path. 47 | # This functions searchs explicitly for source-files such as '*.c'. 48 | # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed. 49 | # _base_path - Top-Directory path to search source files in. 50 | # [RECURSE] - Whether search should be done recursively or not. 51 | # _return_var - Name of variable in parent-scope holding the return value. 52 | # Returns - List of source files in the given path 53 | #=============================================================================# 54 | function(find_source_files _base_path _return_var) 55 | 56 | _find_sources("${_base_path}" "${ARDUINO_CMAKE_SOURCE_FILES_PATTERN}" sources ${ARGN}) 57 | set(${_return_var} "${sources}" PARENT_SCOPE) 58 | 59 | endfunction() 60 | 61 | #=============================================================================# 62 | # Finds sketch files matching the pre-defined sketch-file pattern under the given path. 63 | # This functions searchs explicitly for sketch-files such as '*.ino'. 64 | # Search could also be recursive (With sub-directories) if the optional 'RECURSE' option is passed. 65 | # _base_path - Top-Directory path to search source files in. 66 | # [RECURSE] - Whether search should be done recursively or not. 67 | # _return_var - Name of variable in parent-scope holding the return value. 68 | # Returns - List of header files in the given path 69 | #=============================================================================# 70 | function(find_sketch_files _base_path _return_var) 71 | 72 | _find_sources("${_base_path}" "${ARDUINO_CMAKE_SKETCH_FILES_PATTERN}" sketches ${ARGN}) 73 | set(${_return_var} "${sketches}" PARENT_SCOPE) 74 | 75 | endfunction() 76 | -------------------------------------------------------------------------------- /cmake/Platform/System/AvrToolsFinder.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Finds 'avr-objcopy' tool in Arduino's SDK path. 3 | #=============================================================================# 4 | function(find_tool_avr_objcopy) 5 | 6 | find_program(ARDUINO_CMAKE_AVROBJCOPY_PROGRAM 7 | NAMES avr-objcopy 8 | PATHS ${ARDUINO_SDK_BIN_PATH} 9 | DOC "Path to avr's objcopy program") 10 | if (NOT ARDUINO_CMAKE_AVROBJCOPY_PROGRAM OR ${ARDUINO_CMAKE_AVROBJCOPY_PROGRAM} STREQUAL "") 11 | message(FATAL_ERROR "avr-objcopy program is required by the toolchain but can't be found") 12 | endif () 13 | set(CMAKE_OBJCOPY ${ARDUINO_CMAKE_AVROBJCOPY_PROGRAM}) 14 | 15 | endfunction() 16 | 17 | #=============================================================================# 18 | # Finds 'avrdude' tool in Arduino's SDK path. 19 | #=============================================================================# 20 | function(find_tool_avrdude) 21 | 22 | find_program(ARDUINO_CMAKE_AVRDUDE_PROGRAM 23 | NAMES avrdude 24 | PATHS ${ARDUINO_SDK_BIN_PATH} 25 | DOC "Path to avrdude program (Code Uploader)") 26 | if (NOT ARDUINO_CMAKE_AVRDUDE_PROGRAM OR ${ARDUINO_CMAKE_AVRDUDE_PROGRAM} STREQUAL "") 27 | message(FATAL_ERROR "avrdude program is required by the toolchain but can't be found") 28 | endif () 29 | 30 | endfunction() 31 | 32 | #=============================================================================# 33 | # Finds 'avrdude' tool's configuration file in Arduino's SDK path. 34 | #=============================================================================# 35 | function(find_tool_avrdude_configuration) 36 | 37 | find_file(ARDUINO_CMAKE_AVRDUDE_CONFIG_PATH 38 | NAMES avrdude.conf 39 | PATHS ${ARDUINO_SDK_ROOT_PATH} 40 | PATH_SUFFIXES /etc /etc/avrdude 41 | DOC "Path to avrdude's programmer configuration file") 42 | if (NOT ARDUINO_CMAKE_AVRDUDE_CONFIG_PATH OR ${ARDUINO_CMAKE_AVRDUDE_CONFIG_PATH} STREQUAL "") 43 | message(FATAL_ERROR "avrdude program is required by the toolchain but can't be found") 44 | endif () 45 | 46 | endfunction() 47 | 48 | #=============================================================================# 49 | # Finds 'avr-size' tool in Arduino's SDK path. 50 | #=============================================================================# 51 | function(find_tool_avrsize) 52 | 53 | find_program(ARDUINO_CMAKE_AVRSIZE_PROGRAM 54 | NAMES avr-size 55 | PATHS ${ARDUINO_SDK_BIN_PATH} 56 | DOC "Path to avr-size program (Size Calculator)") 57 | if (NOT ARDUINO_CMAKE_AVRSIZE_PROGRAM OR ${ARDUINO_CMAKE_AVRSIZE_PROGRAM} STREQUAL "") 58 | message(FATAL_ERROR "avrdude program is required by the toolchain but can't be found") 59 | endif () 60 | 61 | endfunction() 62 | -------------------------------------------------------------------------------- /cmake/Platform/System/BuildSystemInitializer.cmake: -------------------------------------------------------------------------------- 1 | include(AvrToolsFinder) 2 | include(VersionDetector) 3 | include(PlatformInitializer) 4 | include(LinuxDistDetector) 5 | include(SketchbookFinder) 6 | 7 | function(find_required_platform_tools) 8 | 9 | find_tool_avr_objcopy() 10 | find_tool_avrdude() 11 | find_tool_avrdude_configuration() 12 | find_tool_avrsize() 13 | 14 | endfunction() 15 | 16 | #=============================================================================# 17 | # Initializes build system by setting defaults, finding tools and initializing the hardware-platform. 18 | #=============================================================================# 19 | function(initialize_build_system) 20 | 21 | define_custom_properties() 22 | 23 | set_arduino_cmake_defaults() 24 | 25 | find_required_platform_tools() 26 | 27 | detect_sdk_version() 28 | 29 | if (CMAKE_HOST_UNIX AND NOT CMAKE_HOST_APPLE) # Detect host's Linux distribution 30 | detect_host_linux_distribution() 31 | endif () 32 | 33 | if (AUTO_SET_SKETCHBOOK_PATH) 34 | find_sketchbook_path() 35 | endif () 36 | 37 | initialize_arduino_platform() 38 | 39 | endfunction() 40 | -------------------------------------------------------------------------------- /cmake/Platform/System/DefaultsManager.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Sets search patterns used internaly by the framework for searching purposes. 3 | #=============================================================================# 4 | function(set_internal_search_patterns) 5 | 6 | set(ARDUINO_CMAKE_SEMICOLON_REPLACEMENT "!@&#%" CACHE STRING 7 | "String replacement for the semicolon char, required when treating lists as code") 8 | set(ARDUINO_CMAKE_HEADER_INCLUDE_REGEX_PATTERN "^#include.*[<\"]" CACHE STRING 9 | "Regex pattern matching header inclusion in a source file") 10 | set(ARDUINO_CMAKE_HEADER_NAME_REGEX_PATTERN 11 | "${ARDUINO_CMAKE_HEADER_INCLUDE_REGEX_PATTERN}(.+)[>\"]$" CACHE STRING 12 | "Regex pattern matching a header's name when wrapped in inclusion line") 13 | set(ARDUINO_CMAKE_HEADER_FILE_EXTENSION_REGEX_PATTERN ".+\\.h.*$" CACHE STRING 14 | "Regex pattern matching all header file extensions") 15 | set(ARDUINO_CMAKE_NAME_WE_REGEX_PATTERN "(.+)\\." CACHE STRING 16 | "Regex pattern matching name without file extension") 17 | set(ARDUINO_CMAKE_FUNCTION_REGEX_PATTERN "^([a-z]|[A-Z])+.*\(([a-z]|[A-Z])*\)" CACHE STRING 18 | "Regex pattern matching a function signature in a source file") 19 | 20 | endfunction() 21 | 22 | #=============================================================================# 23 | # Sets globb patterns for various types of source files, used mostly for searching purposes. 24 | #=============================================================================# 25 | function(set_source_files_patterns) 26 | 27 | set(ARDUINO_CMAKE_SOURCE_FILES_PATTERN *.c *.cc *.cpp *.cxx *.[Ss] CACHE STRING 28 | "Source Files Pattern") 29 | set(ARDUINO_CMAKE_HEADER_FILES_PATTERN *.h *.hh *.hpp *.hxx CACHE STRING 30 | "Header Files Pattern") 31 | set(ARDUINO_CMAKE_SKETCH_FILES_PATTERN *.ino *.pde CACHE STRING 32 | "Sketch Files Pattern") 33 | 34 | endfunction() 35 | 36 | #=============================================================================# 37 | # Sets various options specific for the Arduino-CMake framework. 38 | #=============================================================================# 39 | function(set_default_arduino_cmake_options) 40 | 41 | option(USE_DEFAULT_PLATFORM_IF_NONE_EXISTING 42 | "Whether to use Arduino as default platform if none is supplied" 43 | ON) 44 | option(USE_CUSTOM_PLATFORM_HEADER 45 | "Whether to expect and use a custom-supplied platform header, \ 46 | skipping the selection algorithm" 47 | OFF) 48 | option(USE_ARCHLINUX_BUILTIN_SUPPORT 49 | "Whether to use Arduino CMake's built-in support for the archlinux distribution" 50 | ON) 51 | option(CONVERT_SKETCHES_IF_CONVERTED_SOURCES_EXISTS 52 | "Whether to convert sketches to source files even if converted sources already exist" 53 | OFF) 54 | option(AUTO_SET_SKETCHBOOK_PATH 55 | "Whether Arduino IDE's Sketchbook Location should be automatically found" 56 | OFF) 57 | 58 | endfunction() 59 | 60 | #=============================================================================# 61 | # Sets default paths used by the framework 62 | #=============================================================================# 63 | function(set_default_paths) 64 | 65 | set(ARDUINO_CMAKE_LIBRARY_PROPERTIES_FILE_NAME "library.properties" CACHE STRING 66 | "Name of the libraries' properties file") 67 | 68 | endfunction() 69 | 70 | #=============================================================================# 71 | # Sets various defaults used throughout the platform. 72 | #=============================================================================# 73 | function(set_arduino_cmake_defaults) 74 | 75 | set_internal_search_patterns() 76 | set_source_files_patterns() 77 | set_default_arduino_cmake_options() 78 | set_default_paths() 79 | 80 | endfunction() 81 | -------------------------------------------------------------------------------- /cmake/Platform/System/LinuxDistDetector.cmake: -------------------------------------------------------------------------------- 1 | function(detect_host_linux_distribution) 2 | 3 | if (NOT ${CMAKE_HOST_UNIX}) 4 | message(AUTHOR_WARNING "Linux distribution detection called on non-Unix platform") 5 | elseif (${CMAKE_HOST_APPLE}) 6 | message(AUTHOR_WARNING "Linux distribution detection called on Apple platform") 7 | else () # Linux host 8 | find_program(lsb_release_exec lsb_release) 9 | 10 | if ("lsb_release_exec-NOTFOUND" STREQUAL "${lsb_release_exec}") 11 | message(WARNING "Linux distribution couldn't be detected - Please install 'lsb_release'.") 12 | endif() 13 | 14 | execute_process(COMMAND ${lsb_release_exec} -is 15 | OUTPUT_VARIABLE lsb_release_id_short 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | string(TOUPPER dist ${lsb_release_id_short}) 18 | set(CMAKE_HOST_${dist} TRUE CACHE BOOL 19 | "Whether host system is ${lsb_release_id_short}" ADVANCED) 20 | endif () 21 | 22 | endfunction() 23 | -------------------------------------------------------------------------------- /cmake/Platform/System/PlatformFlagsSetter.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Setups any remaining Arduino platform-related flags which haven't been set 3 | # when platform file has been read 4 | #=============================================================================# 5 | function(setup_remaining_platform_flags) 6 | 7 | set(ARDUINO_CMAKE_AVRDUDE_FLAGS ${tools_avrdude_upload_params_verbose}) 8 | 9 | # Set AR flags based on the platform file 10 | if (compiler_ar_flags) 11 | set(CMAKE_ASM_ARCHIVE_CREATE 12 | " ${compiler_ar_flags} " 13 | CACHE STRING "" FORCE) 14 | set(CMAKE_C_ARCHIVE_CREATE 15 | " ${compiler_ar_flags} " 16 | CACHE STRING "" FORCE) 17 | set(CMAKE_CXX_ARCHIVE_CREATE 18 | " ${compiler_ar_flags} " 19 | CACHE STRING "" FORCE) 20 | endif () 21 | 22 | endfunction() 23 | -------------------------------------------------------------------------------- /cmake/Platform/System/PlatformInitializer.cmake: -------------------------------------------------------------------------------- 1 | include(PlatformElementsManager) 2 | include(PropertiesReader) 3 | include(BoardPropertiesReader) 4 | include(PlatformFlagsSetter) 5 | 6 | function(find_required_platform_elements) 7 | 8 | find_platform_cores() 9 | find_platform_variants() 10 | find_platform_bootloaders() 11 | find_platform_programmers() 12 | find_platform_properties_file() 13 | find_platform_boards() 14 | find_platform_libraries() 15 | if (NOT USE_CUSTOM_PLATFORM_HEADER) 16 | find_platform_main_header() 17 | endif () 18 | 19 | endfunction() 20 | 21 | #=============================================================================# 22 | # Initializes platform-related properties by parsing all property files. 23 | #=============================================================================# 24 | function(initialize_platform_properties) 25 | 26 | read_properties_from_file(${ARDUINO_CMAKE_PLATFORM_PROPERTIES_FILE_PATH}) 27 | read_properties_from_file(${ARDUINO_CMAKE_PLATFORM_PROGRAMMERS_PATH}) 28 | read_boards_properties(${ARDUINO_CMAKE_PLATFORM_BOARDS_PATH}) 29 | 30 | endfunction() 31 | 32 | #=============================================================================# 33 | # Initializes the Arduino-platform by defining the platform's path, 34 | # parsing property files and setupping any remaining flags. 35 | #=============================================================================# 36 | function(initialize_arduino_platform) 37 | 38 | if (NOT DEFINED ARDUINO_CMAKE_PLATFORM_NAME OR NOT DEFINED ARDUINO_CMAKE_PLATFORM_PATH) 39 | if (USE_DEFAULT_PLATFORM_IF_NONE_EXISTING) 40 | if (IS_DIRECTORY "${ARDUINO_SDK_PATH}/hardware/archlinux-arduino") 41 | set(ARDUINO_CMAKE_PLATFORM_NAME "archlinux-arduino" CACHE STRING "") 42 | else () 43 | set(ARDUINO_CMAKE_PLATFORM_NAME "arduino" CACHE STRING "") 44 | endif () 45 | set(ARDUINO_CMAKE_PLATFORM_ARCHITECTURE "avr" CACHE STRING "") 46 | string(CONCAT platform_path "${ARDUINO_SDK_PATH}" 47 | /hardware/ 48 | "${ARDUINO_CMAKE_PLATFORM_NAME}/" 49 | "${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE}") 50 | set(ARDUINO_CMAKE_PLATFORM_PATH "${platform_path}" CACHE PATH "") 51 | else () 52 | message(FATAL_ERROR "Arduino Platform must be defined through name and path") 53 | endif () 54 | elseif (NOT DEFINED ARDUINO_CMAKE_PLATFORM_ARCHITECTURE) # Platform defined without architecture 55 | set(ARDUINO_CMAKE_PLATFORM_ARCHITECTURE "avr" CACHE STRING "") 56 | endif () 57 | 58 | # Find all platform elements 59 | find_required_platform_elements() 60 | initialize_platform_properties() 61 | setup_remaining_platform_flags() 62 | 63 | endfunction() 64 | -------------------------------------------------------------------------------- /cmake/Platform/System/SketchbookFinder.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Gets the path of the user's Arduino IDE preferences file, usually located in a hidden directory 3 | # under the home directory. 4 | # _return_var - Name of variable in parent-scope holding the return value. 5 | # Returns - Filtered list of architectures. 6 | #=============================================================================# 7 | function(_get_user_preferences_file_path _return_var) 8 | 9 | set(preferences_file_name preferences.txt) 10 | 11 | if (${CMAKE_HOST_UNIX}) 12 | if (${CMAKE_HOST_APPLE}) # Mac OS X 13 | if (EXISTS "$ENV{HOME}/Library/Arduino15/${preferences_file_name}") 14 | set(dir_path "$ENV{HOME}/Library/Arduino15/${preferences_file_name}") 15 | else () 16 | set(dir_path "$ENV{HOME}/Library/Processing/${preferences_file_name}") 17 | endif () 18 | else () # Linux 19 | if (EXISTS "$ENV{HOME}/.arduino15/${preferences_file_name}") 20 | set(dir_path "$ENV{HOME}/.arduino15/${preferences_file_name}") 21 | else () 22 | set(dir_path "$ENV{HOME}/.processing/${preferences_file_name}") 23 | endif () 24 | endif () 25 | else () # Windows 26 | string(REPLACE "\\" "/" home_path $ENV{HOMEPATH}) 27 | string(REPLACE "\\" "/" home_drive $ENV{HOMEDRIVE}) 28 | string(CONCAT home_path ${home_drive} ${home_path}) 29 | set(dir_path "${home_path}/AppData/Local/arduino15/${preferences_file_name}") 30 | endif () 31 | 32 | set(${_return_var} ${dir_path} PARENT_SCOPE) 33 | 34 | endfunction() 35 | 36 | #=============================================================================# 37 | # Finds the location of Arduino IDE's Sketchbook directory, where all libraries and sketches 38 | # are downloaded to. 39 | #=============================================================================# 40 | function(find_sketchbook_path) 41 | 42 | _get_user_preferences_file_path(arduino_ide_preferences_file) 43 | if (NOT EXISTS "${arduino_ide_preferences_file}") 44 | string(CONCAT error_message 45 | "Arduino IDE preferences file couldn't be found at " 46 | "${arduino_ide_preferences_file}.\n" 47 | "ARDUINO_CMAKE_SKETCHBOOK_PATH should be manually set to the real Sketchbook path") 48 | message(WARNING ${error_message}) 49 | return() 50 | endif () 51 | 52 | file(STRINGS "${arduino_ide_preferences_file}" arduino_ide_preferences) 53 | list(FILTER arduino_ide_preferences INCLUDE REGEX "sketchbook") 54 | _get_property_value(${arduino_ide_preferences} sketchbook_path) 55 | 56 | set(ARDUINO_CMAKE_SKETCHBOOK_PATH "${sketchbook_path}" CACHE PATH 57 | "Arduino IDE's Sketchbook Path") 58 | 59 | endfunction() 60 | -------------------------------------------------------------------------------- /cmake/Platform/System/VersionDetector.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Appends a suffic zero to the given version part if it's below than the given limit. 3 | # Otherwise, the version part is returned as it is. 4 | # 5 | # _version_part - Version to check and possibly append to. 6 | # Must be a version part - Major, Minor or Patch. 7 | # _version_limit - Append limit. For a version greater than this number 8 | # a zero will NOT be appended. 9 | # _return_var - Returned variable storing the normalized version. 10 | # 11 | #=============================================================================# 12 | function(_append_suffix_zero _version_part _return_var) 13 | set(${_return_var} "${_version_part}0" PARENT_SCOPE) 14 | endfunction() 15 | 16 | #=============================================================================# 17 | # _get_normalized_sdk_version 18 | # [PRIVATE/INTERNAL] 19 | # 20 | # _get_normalized_sdk_version(_return_var) 21 | # 22 | # _return_var - Returned variable storing the normalized version 23 | # 24 | # Normalizes SDK's version for a proper use of the '-DARDUINO' compile flag. 25 | # Note that there are differences between normalized versions in specific SDK versions: 26 | # e.g Version 1.6.5 will be normalized as 10605 27 | # 28 | #=============================================================================# 29 | function(_get_normalized_sdk_version _return_var) 30 | 31 | # -DARDUINO format has changed since 1.6.0 by appending zeros when required 32 | _append_suffix_zero(${ARDUINO_CMAKE_SDK_VERSION_MAJOR} major_version) 33 | _append_suffix_zero(${ARDUINO_CMAKE_SDK_VERSION_MINOR} minor_version) 34 | set(normalized_version "${major_version}${minor_version}${ARDUINO_CMAKE_SDK_VERSION_PATCH}") 35 | 36 | set(${_return_var} "${normalized_version}" PARENT_SCOPE) 37 | 38 | endfunction() 39 | 40 | #=============================================================================# 41 | # Detects the Arduino SDK Version based on the dedicated version 1file. 42 | # The following variables will be generated: 43 | # 44 | # ${ARDUINO_CMAKE_SDK_VERSION} -> the full version (major.minor.patch) 45 | # ${ARDUINO_CMAKE_SDK_VERSION}_MAJOR -> the major version 46 | # ${ARDUINO_CMAKE_SDK_VERSION}_MINOR -> the minor version 47 | # ${ARDUINO_CMAKE_SDK_VERSION}_PATCH -> the patch version 48 | # 49 | #=============================================================================# 50 | function(detect_sdk_version) 51 | 52 | find_file(ARDUINO_CMAKE_VERSION_FILE_PATH 53 | NAMES version.txt 54 | PATHS "${ARDUINO_SDK_PATH}" 55 | PATH_SUFFIXES lib 56 | DOC "Path to Arduino's version file" 57 | NO_DEFAULT_PATH 58 | NO_CMAKE_FIND_ROOT_PATH) 59 | 60 | if (NOT ARDUINO_CMAKE_VERSION_FILE_PATH) 61 | message(FATAL_ERROR "Couldn't find SDK's version file, aborting.") 62 | endif () 63 | 64 | file(READ ${ARDUINO_CMAKE_VERSION_FILE_PATH} raw_version) 65 | 66 | if ("${raw_version}" STREQUAL "") 67 | message(FATAL_ERROR "Version file is found but its empty") 68 | endif () 69 | 70 | string(REPLACE "." ";" split_version ${raw_version}) 71 | list(GET split_version 0 split_version_major) 72 | list(GET split_version 1 split_version_minor) 73 | list(GET split_version 2 split_version_patch) 74 | 75 | set(ARDUINO_CMAKE_SDK_VERSION "${raw_version}" CACHE STRING "Arduino SDK Version") 76 | set(ARDUINO_CMAKE_SDK_VERSION_MAJOR ${split_version_major} CACHE STRING 77 | "Arduino SDK Major Version") 78 | set(ARDUINO_CMAKE_SDK_VERSION_MINOR ${split_version_minor} CACHE STRING 79 | "Arduino SDK Minor Version") 80 | set(ARDUINO_CMAKE_SDK_VERSION_PATCH ${split_version_patch} CACHE STRING 81 | "Arduino SDK Patch Version") 82 | 83 | if (ARDUINO_CMAKE_SDK_VERSION VERSION_LESS 1.6.0) 84 | message(FATAL_ERROR "Unsupported Arduino SDK (requires version 1.6 or higher)") 85 | endif () 86 | 87 | _get_normalized_sdk_version(normalized_sdk_version) 88 | set(runtime_ide_version "${normalized_sdk_version}" CACHE STRING "") 89 | 90 | message(STATUS "Arduino SDK version ${ARDUINO_CMAKE_SDK_VERSION}: ${ARDUINO_SDK_PATH}") 91 | 92 | endfunction() 93 | -------------------------------------------------------------------------------- /cmake/Platform/Targets/ArduinoCMakeLibraryTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Creates a library target compliant with the Arduino library standard. 3 | # One can also specify an architecture for the library, which will result in a special parsing 4 | # of the sources, ommiting non-compliant sources. 5 | # _target_name - Name of the library target to be created. Usually library's real name. 6 | # _sources - Source and header files to create library target from. 7 | # [ARCH] - Optional library architecture (Such as 'avr', 'nrf52', etc.). 8 | # [INTERFACE] - Whether the library should be created as an interface library (header-only). 9 | #=============================================================================# 10 | function(_add_arduino_cmake_library _target_name _sources) 11 | 12 | cmake_parse_arguments(parsed_args "INTERFACE" "" "" ${ARGN}) 13 | 14 | if (parsed_args_INTERFACE) 15 | 16 | add_library(${_target_name} INTERFACE) 17 | set(scope INTERFACE) 18 | 19 | else () 20 | 21 | add_library(${_target_name} STATIC "${_sources}") 22 | set(scope PUBLIC) 23 | 24 | endif () 25 | 26 | # Treat headers' parent directories as include directories of the target 27 | get_headers_parent_directories("${_sources}" include_dirs) 28 | target_include_directories(${_target_name} ${scope} ${include_dirs}) 29 | 30 | set_library_flags(${_target_name} ${scope}) 31 | 32 | set_target_architecture_definition(${_target_name} ${scope} ${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE}) 33 | 34 | endfunction() 35 | 36 | #=============================================================================# 37 | # Links the given library target to the given target, be it an executable or another library. 38 | # The function first adds the includes of the Core Lib to the given library, 39 | # then links it to the library. 40 | # _target_name - Name of the target to link against. 41 | # _library_name - Name of the library target to link. 42 | # [PRIVATE|PUBLIC|INTERFACE] - Optional link scope for the internally linked Core-Lib. 43 | # [BOARD_CORE_TARGET] - Optional target name of the Core Lib to use. Use when the target is a library. 44 | #=============================================================================# 45 | function(_link_arduino_cmake_library _target_name _library_name) 46 | 47 | if (NOT TARGET ${_target_name}) 48 | message(FATAL_ERROR "Target doesn't exist - It must be created first!") 49 | endif () 50 | 51 | cmake_parse_arguments(parsed_args "" "BOARD_CORE_TARGET" "" ${ARGN}) 52 | parse_scope_argument(scope "${ARGN}") 53 | 54 | # Resolve Core-Lib's target 55 | if (parsed_args_BOARD_CORE_TARGET) 56 | set(core_target ${parsed_args_BOARD_CORE_TARGET}) 57 | else () 58 | set(core_target ${${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD}_CORELIB_TARGET}) 59 | endif () 60 | 61 | get_target_property(core_lib_includes ${core_target} INCLUDE_DIRECTORIES) 62 | 63 | # Include core lib's include directories in library target, then link to it 64 | target_include_directories(${_library_name} ${scope} "${core_lib_includes}") 65 | target_link_libraries(${_library_name} ${scope} ${core_target}) 66 | 67 | # Link library target to linked-to target 68 | if (parsed_args_PRIVATE) 69 | target_link_libraries(${_target_name} PRIVATE ${_library_name}) 70 | else () 71 | # Link 'INTERFACE' targets publicly, otherwise code won't compile 72 | target_link_libraries(${_target_name} PUBLIC ${_library_name}) 73 | endif () 74 | 75 | endfunction() 76 | -------------------------------------------------------------------------------- /cmake/Platform/Targets/ArduinoExampleTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Adds/Creates an Arduino-Example executable target with the given name, 3 | # using the given board ID and example's sources. 4 | # _target_name - Name of the target (Executable) to create. 5 | # _example_name - Name of the example to use, such as 'Blink'. 6 | # [CATEGORY cat] - Optional argument representing the category of the Example to use. 7 | # e.g The 'Blink' example is under the '01.Basics' category. 8 | # Generally, all this does is improving search performance by narrowing. 9 | #=============================================================================# 10 | function(add_arduino_example _target_name _example_name) 11 | 12 | convert_string_to_pascal_case(${_example_name} arduino_compliant_example_name) 13 | 14 | find_arduino_example_sources("${ARDUINO_SDK_EXAMPLES_PATH}" 15 | ${arduino_compliant_example_name} example_sketches ${ARGN}) 16 | 17 | # First create the target (Without sources), then add sketches as converted sources 18 | add_arduino_executable(${_target_name}) 19 | 20 | target_sketches(${_target_name} "${example_sketches}") 21 | 22 | endfunction() 23 | 24 | #=============================================================================# 25 | # Adds/Creates an Arduino-Library-Example executable target with the given name, 26 | # using the given board ID and library example's sources. 27 | # _target_name - Name of the target (Executable) to create. 28 | # _library_target_name - Name of an already-existing library target. 29 | # This means the library should first be found by the user. 30 | # _library_name - Name of the library the example belongs to, such as 'Servo'. 31 | # _example_name - Name of the example to use, such as 'Knob'. 32 | # [CATEGORY cat] - Optional argument representing the category of the Example to use. 33 | # e.g The 'Blink' example is under the '01.Basics' category. 34 | # Generally, all this does is improving search performance by narrowing. 35 | #=============================================================================# 36 | function(add_arduino_library_example _target_name _library_target_name _library_name _example_name) 37 | 38 | convert_string_to_pascal_case(${_example_name} arduino_compliant_example_name) 39 | convert_string_to_pascal_case(${_library_name} arduino_compliant_library_name) 40 | 41 | if (NOT TARGET ${_library_target_name}) 42 | message(SEND_ERROR "Library target doesn't exist - It must be created first!") 43 | endif () 44 | 45 | find_file(library_path 46 | NAMES ${arduino_compliant_library_name} 47 | PATHS ${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH} ${ARDUINO_SDK_LIBRARIES_PATH} 48 | ${ARDUINO_CMAKE_SKETCHBOOK_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR} 49 | PATH_SUFFIXES libraries dependencies 50 | NO_DEFAULT_PATH 51 | NO_CMAKE_FIND_ROOT_PATH) 52 | 53 | find_arduino_library_example_sources("${library_path}" 54 | ${arduino_compliant_example_name} example_sketches ${ARGN}) 55 | 56 | add_arduino_executable(${_target_name}) 57 | 58 | target_sketches(${_target_name} "${example_sketches}") 59 | 60 | link_arduino_library(${_target_name} ${_library_target_name}) 61 | 62 | endfunction() -------------------------------------------------------------------------------- /cmake/Platform/Targets/ArduinoLibraryTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Creates a library target for the given name and sources. 3 | # As it's an Arduino library, it also finds and links all dependent platform libraries (if any). 4 | # _target_name - Name of the library target to be created. Usually library's real name. 5 | # [PLATFORM] - 6 | # [Sources] - List of source files (Could also be headers for code-inspection in some IDEs) 7 | # to create the executable from, similar to CMake's built-in add_executable. 8 | #=============================================================================# 9 | function(add_arduino_library _target_name) 10 | 11 | # First parse keyword arguments 12 | cmake_parse_arguments(parsed_args "PLATFORM" "" "" ${ARGN}) 13 | # Then parse unlimited sources 14 | parse_sources_arguments(parsed_sources "PLATFORM" "" "" "${ARGN}") 15 | 16 | if (parsed_sources) 17 | 18 | get_sources_root_directory("${parsed_sources}" library_root_dir) 19 | 20 | get_library_properties_file(${library_root_dir} library_properties_file) 21 | if (library_properties_file) # Properties file has been found 22 | resolve_library_architecture("${parsed_sources}" arch_resolved_sources 23 | LIB_PROPS_FILE ${library_properties_file}) 24 | else () 25 | resolve_library_architecture("${parsed_sources}" arch_resolved_sources) 26 | endif () 27 | 28 | _add_arduino_cmake_library(${_target_name} "${arch_resolved_sources}") 29 | 30 | else () # No sources have been provided at this stage, simply create a library target 31 | _add_arduino_cmake_library(${_target_name} "") 32 | endif () 33 | 34 | if (parsed_args_PLATFORM) 35 | return() 36 | endif () 37 | 38 | find_dependent_platform_libraries("${arch_resolved_sources}" lib_platform_libs) 39 | 40 | foreach (platform_lib ${lib_platform_libs}) 41 | link_platform_library(${_target_name} ${platform_lib}) 42 | endforeach () 43 | 44 | endfunction() 45 | 46 | #=============================================================================# 47 | # Creates a header-only library target for the given name and sources. 48 | # _target_name - Name of the "executable" target. 49 | #=============================================================================# 50 | function(add_arduino_header_only_library _target_name) 51 | 52 | parse_sources_arguments(parsed_headers "" "" "" "${ARGN}") 53 | 54 | _add_arduino_cmake_library(${_target_name} "${parsed_headers}" INTERFACE) 55 | 56 | endfunction() 57 | 58 | #=============================================================================# 59 | # Links the given library target to the given "executable" target, but first, 60 | # it adds core lib's include directories to the libraries include directories. 61 | # _target_name - Name of the "executable" target. 62 | # _library_target_name - Name of the library target. 63 | # [HEADER_ONLY] - Whether library is a header-only library, i.e has no source files 64 | #=============================================================================# 65 | function(link_arduino_library _target_name _library_target_name) 66 | 67 | cmake_parse_arguments(parsed_args "HEADER_ONLY" "" "" ${ARGN}) 68 | 69 | if (NOT TARGET ${_target_name}) 70 | message(FATAL_ERROR "Target doesn't exist - It must be created first!") 71 | elseif (NOT TARGET ${_library_target_name}) 72 | message(FATAL_ERROR "Library target doesn't exist - It must be created first!") 73 | endif () 74 | 75 | # Infer scope 76 | if (parsed_args_HEADER_ONLY) 77 | set(scope INTERFACE) 78 | else () 79 | set(scope PUBLIC) 80 | endif () 81 | 82 | _link_arduino_cmake_library(${_target_name} ${_library_target_name} 83 | ${scope} 84 | BOARD_CORE_TARGET ${${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD}_CORELIB_TARGET}) 85 | 86 | endfunction() 87 | -------------------------------------------------------------------------------- /cmake/Platform/Targets/ExecutableTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Adds/Creates an Arduino-Executable target with the given name, 3 | # using the given board ID and source files. 4 | # _target_name - Name of the target (Executable) to create. 5 | # [Sources] - List of source files (Could also be headers for code-inspection in some IDEs) 6 | # to create the executable from, similar to CMake's built-in add_executable. 7 | #=============================================================================# 8 | function(add_arduino_executable _target_name) 9 | 10 | list(APPEND sources "${ARGN}") # Treat all remaining arguments as sources 11 | 12 | add_executable(${_target_name} "${sources}") 13 | 14 | target_link_libraries(${_target_name} PRIVATE ${${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD}_CORELIB_TARGET}) 15 | 16 | # Add compiler and linker flags 17 | set_executable_target_flags(${_target_name}) 18 | 19 | set(target_path "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}") 20 | 21 | # Create EEP object file from build's ELF object file 22 | add_custom_command(TARGET ${_target_name} POST_BUILD 23 | COMMAND ${CMAKE_OBJCOPY} 24 | ARGS ${compiler_objcopy_eep_flags} 25 | ${target_path}.elf 26 | ${target_path}.eep 27 | COMMENT "Generating EEP image" 28 | VERBATIM) 29 | 30 | # Convert firmware image to ASCII HEX format 31 | add_custom_command(TARGET ${_target_name} POST_BUILD 32 | COMMAND ${CMAKE_OBJCOPY} 33 | ARGS ${compiler_elf2hex_flags} 34 | ${target_path}.elf 35 | ${target_path}.hex 36 | COMMENT "Generating HEX image" 37 | VERBATIM) 38 | 39 | # Required for avr-size 40 | get_board_property(${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD} build.mcu board_mcu) 41 | 42 | set(avr_size_script "${ARDUINO_CMAKE_TOOLCHAIN_DIR}/Platform/Other/FirmwareSizeCalculator.cmake") 43 | 44 | add_custom_command(TARGET ${_target_name} POST_BUILD 45 | COMMAND ${CMAKE_COMMAND} 46 | ARGS -DFIRMWARE_IMAGE=${target_path}.elf -DEEPROM_IMAGE=${target_path}.eep 47 | -DMCU=${board_mcu} -DAVRSIZE_PROGRAM=${ARDUINO_CMAKE_AVRSIZE_PROGRAM} 48 | -P "${avr_size_script}" 49 | COMMENT "Calculating ${_target_name} size" 50 | VERBATIM) 51 | 52 | endfunction() 53 | -------------------------------------------------------------------------------- /cmake/Platform/Targets/PlatformLibraryTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Looks for any platform libraries (Resolved earlier when platform has been initialized) 3 | # within the given sources and returns them in a list. 4 | # _sources - Source and header files to search dependent platform libraries in. 5 | # _return_var - Name of variable in parent-scope holding the return value. 6 | # Returns - List of found dependent platform libraries. 7 | #=============================================================================# 8 | function(find_dependent_platform_libraries _sources _return_var) 9 | 10 | foreach (source ${_sources}) 11 | get_source_file_included_headers(${source} source_includes WE) 12 | list(APPEND included_headers_names ${source_includes}) 13 | endforeach () 14 | 15 | if (included_headers_names) 16 | list(REMOVE_DUPLICATES included_headers_names) 17 | endif () 18 | 19 | get_platform_libraries_from_names("${included_headers_names}" dependent_libs) 20 | 21 | set(${_return_var} ${dependent_libs} PARENT_SCOPE) 22 | 23 | endfunction() 24 | 25 | #=============================================================================# 26 | # Creates a platform library target with the given name. 27 | # _target_name - Name of the target to link against. 28 | # _library_name - Name of the library target to create, usually the platform library name. 29 | #=============================================================================# 30 | function(_add_target_dependent_platform_library _target_name _library_name) 31 | 32 | find_library_header_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_headers) 33 | find_library_source_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_source_files) 34 | 35 | set(lib_sources ${lib_headers} ${lib_source_files}) 36 | 37 | _add_arduino_cmake_library("${_target_name}_${_library_name}" "${lib_sources}") 38 | 39 | endfunction() 40 | 41 | #=============================================================================# 42 | # Links the given platform library target to the given target. 43 | # _target_name - Name of the target to link against. 44 | # _library_name - Platform library's name. 45 | #=============================================================================# 46 | function(link_platform_library _target_name _platform_library_name) 47 | 48 | if (NOT TARGET ${_target_name}) 49 | message(FATAL_ERROR "Target ${_target_name} doesn't exist - It must be created first!") 50 | endif () 51 | 52 | parse_scope_argument(scope "${ARGN}" 53 | DEFAULT_SCOPE PUBLIC) 54 | 55 | if (NOT TARGET ${_platform_library_name}) 56 | 57 | _add_target_dependent_platform_library(${_target_name} ${_platform_library_name}) 58 | 59 | _link_arduino_cmake_library(${_target_name} "${_target_name}_${_platform_library_name}" 60 | ${scope} 61 | BOARD_CORE_TARGET ${${PROJECT_${ARDUINO_CMAKE_PROJECT_NAME}_BOARD}_CORELIB_TARGET}) 62 | 63 | else () 64 | target_link_libraries(${_target_name} ${scope} ${_platform_library_name}) 65 | endif () 66 | 67 | endfunction() 68 | -------------------------------------------------------------------------------- /cmake/Platform/Targets/UploadTarget.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Uploads the given target to te connected Arduino board using the given board ID and port. 3 | # _target_name - Name of the target (Executable) to upload. 4 | # _port - Serial port on the host system used to upload/flash the connected Arduino board. 5 | #=============================================================================# 6 | function(set_target_upload_port _target_name _port) 7 | 8 | if (NOT TARGET ${_target_name}) 9 | message(FATAL_ERROR "Can't create upload target for an invalid target ${_target_name}") 10 | else () 11 | get_target_property(target_type ${_target_name} TYPE) 12 | if (NOT ${target_type} STREQUAL "EXECUTABLE") # Target is not executable 13 | message(SEND_ERROR "Upload target ${_target_name} must be an executable target") 14 | endif () 15 | endif () 16 | 17 | set_upload_target_flags(${_target_name} ${_port} upload_args) 18 | 19 | add_custom_target(${_target_name}_flash 20 | COMMAND ${ARDUINO_CMAKE_AVRDUDE_PROGRAM} ${upload_args} 21 | COMMENT "Uploading ${_target_name} target") 22 | 23 | add_dependencies(${_target_name}_flash ${_target_name}) 24 | 25 | endfunction() 26 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/LibraryUtils.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Gets the full path to a library's properties file based on the given library root directory. 3 | # If the root ditectory doesn't exist, CMake generates an error and stops. 4 | # If the properties file doesn't exist under the given root directory, 5 | # CMake generates a warning and returns an empty string. 6 | # _library_root_directory - Path to library's root directory. Can be relative. 7 | # _return_var - Name of a CMake variable that will hold the extraction result. 8 | # Returns - Full path to library's properties file if found, otherwise nothing. 9 | #=============================================================================# 10 | function(get_library_properties_file _library_root_directory _return_var) 11 | 12 | get_filename_component(absolute_lib_root_dir ${_library_root_directory} ABSOLUTE) 13 | 14 | if (NOT EXISTS ${absolute_lib_root_dir}) 15 | message(SEND_ERROR "Can't get library's properties file - Root directory doesn't exist.\n" 16 | "Root directory: ${absolute_lib_root_dir}") 17 | endif () 18 | 19 | set(lib_props_file ${absolute_lib_root_dir}/${ARDUINO_CMAKE_LIBRARY_PROPERTIES_FILE_NAME}) 20 | 21 | if (NOT EXISTS ${lib_props_file}) 22 | message(STATUS "Library's properties file doesn't exist under the given root directory, " 23 | "assuming it's architecture-agnostic (supports all architectures)\n\t" 24 | "Root directory: ${absolute_lib_root_dir}") 25 | return() 26 | endif () 27 | 28 | set(${_return_var} ${lib_props_file} PARENT_SCOPE) 29 | 30 | endfunction() 31 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/ListUtils.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Replaces an element at the given index with another element in the given list. 3 | # _list - List to replace one its' elements. 4 | # _index - Index of the element to replace. 5 | # Must not be negative or greater than 'list_length'-1. 6 | #=============================================================================# 7 | macro(list_replace _list _index _new_element) 8 | 9 | list(REMOVE_AT ${_list} ${_index}) 10 | 11 | list(INSERT ${_list} ${_index} "${_new_element}") 12 | 13 | endmacro() 14 | 15 | #=============================================================================# 16 | # Checks whether the given list is empty. If it is - Initializes it with a theoretically 17 | # impossible to reproduce value, so if it's used to check whether an item is in it 18 | # the answer will be false. 19 | # _list - List to initialize. 20 | #=============================================================================# 21 | macro(initialize_list _list) 22 | 23 | if ("${${_list}}" STREQUAL "") 24 | set(${_list} "+-*/") 25 | endif () 26 | 27 | endmacro() 28 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/MathUtils.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Increments the given integer by the requested amount. 3 | # Note that this is a macro so it applies directly on the calling scope. 4 | # _integer_var - Name of the integer variable to increment. 5 | # _increment - Amount to increment the given integer by. 6 | # Returns - Incremented integer. Return value isn't required since it's a macro. 7 | #=============================================================================# 8 | macro(increment_integer _integer_var _increment) 9 | math(EXPR ${_integer_var} "${${_integer_var}}+${_increment}") 10 | endmacro() 11 | 12 | #=============================================================================# 13 | # Decrements the given integer by the requested amount. 14 | # Note that this is a macro so it applies directly on the calling scope. 15 | # _integer_var - Name of the integer variable to decrement. 16 | # _decrement - Amount to decrement the given integer by. 17 | # Returns - Decremented integer. Return value isn't required since it's a macro. 18 | #=============================================================================# 19 | macro(decrement_integer _integer_var _decrement) 20 | math(EXPR ${_integer_var} "${${_integer_var}}-${_decrement}") 21 | endmacro() 22 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/PathUtils.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Finds the shallowest path among the given sources, where shallowest is the path having 3 | # the least nesting level, i.e. The least number of '/' separators in its' path. 4 | # _sources - List of sources paths to find shallowest path from. 5 | # _return_var - Name of variable in parent-scope holding the return value. 6 | # Returns - Shallowest path among given sources (Lowest nesting level). 7 | #=============================================================================# 8 | function(get_shallowest_directory_structure_path _sources _return_var) 9 | 10 | set(min_nesting_level 9999) 11 | 12 | foreach (source ${_sources}) 13 | 14 | string(REGEX MATCHALL "/" nesting_regex_match ${source}) 15 | 16 | list(LENGTH nesting_regex_match source_nesting_level) 17 | 18 | if (${source_nesting_level} LESS ${min_nesting_level}) 19 | set(min_nested_path ${source}) 20 | set(min_nesting_level ${source_nesting_level}) 21 | endif () 22 | 23 | endforeach () 24 | 25 | set(${_return_var} ${min_nested_path} PARENT_SCOPE) 26 | 27 | endfunction() 28 | 29 | #=============================================================================# 30 | # Gets the path of the common root directory of all given sources. 31 | # It is expected that indeed all sources will have the same, common root directory. 32 | # E.g. src/foo.h and src/utility/bar.h both have 'src' in common. 33 | # However, if src/foo.c is a relative path under the C:\ drive (in Windows), and src/bar.c is 34 | # a relative path under the D:\ drive - This is invalid and the function will misbehave. 35 | # _sources - List of sources that have a common root directory which needs to be found. 36 | # _return_var - Name of variable in parent-scope holding the return value. 37 | # Returns - Path to the common root directory of the given list of sources. 38 | #=============================================================================# 39 | function(get_sources_root_directory _sources _return_var) 40 | 41 | get_shallowest_directory_structure_path("${_sources}" shallowest_path) 42 | 43 | get_filename_component(root_dir ${shallowest_path} DIRECTORY) 44 | 45 | if ("${root_dir}" MATCHES ".+src$") # 'src' directory has been retrieved as shallowest path 46 | # The actual root directory is one level above 'src' 47 | get_filename_component(root_dir ${root_dir} DIRECTORY) 48 | endif () 49 | 50 | set(${_return_var} ${root_dir} PARENT_SCOPE) 51 | 52 | endfunction() 53 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/PlatformLibraryUtils.cmake: -------------------------------------------------------------------------------- 1 | #=============================================================================# 2 | # Checks whether the given name resolves to one of the platform libraries' names. 3 | # _name - Name to check. 4 | # _return_var - Name of variable in parent-scope holding the return value. 5 | # Returns - True if name resolves to a platform library's name, false otherwise. 6 | #=============================================================================# 7 | function(is_platform_library _name _return_var) 8 | 9 | string(TOLOWER "${_name}" name_lower) 10 | if ("${name_lower}" IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES) 11 | set(lib_found TRUE) 12 | else () 13 | set(lib_found FALSE) 14 | endif () 15 | 16 | set(${_return_var} ${lib_found} PARENT_SCOPE) 17 | 18 | endfunction() 19 | 20 | #=============================================================================# 21 | # Retrieves all registered platform library names from the given list of names, 22 | # which usually resolves to names of headers included by a source file. 23 | # _names - List of names that possibly contain a registered platform library's name. 24 | # _return_var - Name of variable in parent-scope holding the return value. 25 | # Returns - List of retrieved platform libraries names. 26 | #=============================================================================# 27 | function(get_platform_libraries_from_names _names _return_var) 28 | 29 | foreach (name ${_names}) 30 | # Can't use `is_platform_library` function since it returns just a boolean 31 | string(TOLOWER "${name}" name_lower) 32 | if ("${name_lower}" IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES) 33 | list(APPEND platform_libs "${name}") 34 | endif () 35 | endforeach () 36 | 37 | set(${_return_var} ${platform_libs} PARENT_SCOPE) 38 | 39 | endfunction() 40 | 41 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/PropertyUtils.cmake: -------------------------------------------------------------------------------- 1 | include(PropertyValueResolver) 2 | 3 | #=============================================================================# 4 | # Gets the name of the property from the given property-line (Combining both name and value). 5 | # Name of the property is the string usually located before the '=' char. 6 | # _property - Full property as a property-line. 7 | # _return_var - Name of variable in parent-scope holding the return value. 8 | # Returns - Extracted property name from the given property-line. 9 | #=============================================================================# 10 | function(_get_property_name _property _return_var) 11 | 12 | string(REGEX MATCH "^[^=]+" property_name "${_property}") 13 | set(${_return_var} "${property_name}" PARENT_SCOPE) 14 | 15 | endfunction() 16 | 17 | #=============================================================================# 18 | # Gets the value of the property from the given property-line (Combining both name and value). 19 | # Value of the property is the string usually located after the '=' char. 20 | # _property - Full property as a property-line. 21 | # _return_var - Name of variable in parent-scope holding the return value. 22 | # Returns - Extracted property value from the given property-line. 23 | #=============================================================================# 24 | function(_get_property_value _property _return_var) 25 | 26 | string(REGEX REPLACE "^[^=]+=(.*)" "\\1" property_value "${_property}") 27 | string(STRIP "${property_value}" property_value) 28 | 29 | set(${_return_var} "${property_value}" PARENT_SCOPE) 30 | 31 | endfunction() 32 | -------------------------------------------------------------------------------- /cmake/Platform/Utilities/Utilities.cmake: -------------------------------------------------------------------------------- 1 | include(MathUtils) 2 | include(ListUtils) 3 | include(StringUtils) 4 | include(PathUtils) 5 | include(PropertyUtils) 6 | include(LibraryUtils) 7 | include(PlatformLibraryUtils) 8 | include(CMakeArgumentsUtils) 9 | -------------------------------------------------------------------------------- /examples/3rd-party-library/3rd_party.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "NeoPixelTest.hpp" 3 | #include "GFXTest.h" 4 | #include "LiquidCrystalTest.hpp" 5 | 6 | void setup() 7 | { 8 | testNeoPixel(); 9 | testGFX(); 10 | testLiquidCrystal(); 11 | } 12 | 13 | void loop() 14 | { 15 | 16 | } -------------------------------------------------------------------------------- /examples/3rd-party-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(3rd_Party_Arduino_Library) 4 | 5 | arduino_cmake_project(3rd_Party_Arduino_Library BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | # First, declare and create our executable - It'll use 4 sources 8 | add_arduino_executable(3rd_Party_Arduino_Library 3rd_party.cpp 9 | NeoPixelTest.cpp GFXTest.cpp LiquidCrystalTest.cpp) 10 | target_include_directories(3rd_Party_Arduino_Library PRIVATE include) 11 | 12 | # Add the "NeoPixel" library manually using the library addition API 13 | add_arduino_library(adafruit_NeoPixel libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp) 14 | target_include_directories(adafruit_NeoPixel PUBLIC libraries/Adafruit_NeoPixel) 15 | link_arduino_library(3rd_Party_Arduino_Library adafruit_NeoPixel) 16 | 17 | # Find the "GFX" library - It's located under the 'libraries' sub-dir, which is a valid search path 18 | find_arduino_library(adafruit_GFX Adafruit-GFX-Library 3RD_PARTY) 19 | # We can also explicitly add additional directories to the target, 20 | # as only root dir and 'src' and 'utility' sub-dirs are added by default 21 | target_source_directories(adafruit_GFX DIRS libraries/Adafruit-GFX-Library/Fonts) 22 | link_arduino_library(3rd_Party_Arduino_Library adafruit_GFX) 23 | 24 | # We can even automatically find a library that doesn't have a properties file! 25 | find_arduino_library(sky_writer Skywriter 3RD_PARTY) 26 | link_arduino_library(3rd_Party_Arduino_Library sky_writer) 27 | 28 | # Libraries that have an inner-dependency on a platform library are also suported! 29 | find_arduino_library(liquid_Crystal LiquidCrystal_I2C 3RD_PARTY) 30 | link_arduino_library(3rd_Party_Arduino_Library liquid_Crystal) 31 | -------------------------------------------------------------------------------- /examples/3rd-party-library/GFXTest.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GFXTest.h" 2 | 3 | static Adafruit_GFX_Button gfxButton; 4 | 5 | void testGFX() 6 | { 7 | gfxButton.isPressed(); 8 | } 9 | -------------------------------------------------------------------------------- /examples/3rd-party-library/LiquidCrystalTest.cpp: -------------------------------------------------------------------------------- 1 | #include "LiquidCrystalTest.hpp" 2 | 3 | LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS); 4 | 5 | void testLiquidCrystal() 6 | { 7 | lcd.begin(LCD_COLUMNS, LCD_ROWS); 8 | lcd.clear(); 9 | } 10 | -------------------------------------------------------------------------------- /examples/3rd-party-library/NeoPixelTest.cpp: -------------------------------------------------------------------------------- 1 | #include "include/NeoPixelTest.hpp" 2 | 3 | Adafruit_NeoPixel neoPixel; 4 | 5 | void testNeoPixel() 6 | { 7 | neoPixel.clear(); 8 | } 9 | -------------------------------------------------------------------------------- /examples/3rd-party-library/include/GFXTest.h: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLES_GFXTEST_HPP 2 | #define EXAMPLES_GFXTEST_HPP 3 | 4 | #include 5 | 6 | void testGFX(); 7 | 8 | #endif //EXAMPLES_GFXTEST_HPP 9 | -------------------------------------------------------------------------------- /examples/3rd-party-library/include/LiquidCrystalTest.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLES_LIQUIDCRYSTALTEST_HPP 2 | #define EXAMPLES_LIQUIDCRYSTALTEST_HPP 3 | 4 | #include 5 | #include 6 | 7 | #define LCD_ADDRESS 0x27 8 | #define LCD_COLUMNS 20 9 | #define LCD_ROWS 4 10 | 11 | void testLiquidCrystal(); 12 | 13 | #endif //EXAMPLES_LIQUIDCRYSTALTEST_HPP 14 | -------------------------------------------------------------------------------- /examples/3rd-party-library/include/NeoPixelTest.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLES_NEOPIXELTEST_HPP 2 | #define EXAMPLES_NEOPIXELTEST_HPP 3 | 4 | #include 5 | 6 | void testNeoPixel(); 7 | 8 | #endif //EXAMPLES_NEOPIXELTEST_HPP 9 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_SPITFT_MACROS 2 | #define _ADAFRUIT_SPITFT_MACROS 3 | 4 | /* 5 | * Control Pins 6 | * */ 7 | 8 | #ifdef USE_FAST_PINIO 9 | #define SPI_DC_HIGH() *dcport |= dcpinmask 10 | #define SPI_DC_LOW() *dcport &= ~dcpinmask 11 | #define SPI_CS_HIGH() *csport |= cspinmask 12 | #define SPI_CS_LOW() *csport &= ~cspinmask 13 | #else 14 | #define SPI_DC_HIGH() digitalWrite(_dc, HIGH) 15 | #define SPI_DC_LOW() digitalWrite(_dc, LOW) 16 | #define SPI_CS_HIGH() { if(_cs >= 0) digitalWrite(_cs, HIGH); } 17 | #define SPI_CS_LOW() { if(_cs >= 0) digitalWrite(_cs, LOW); } 18 | #endif 19 | 20 | /* 21 | * Software SPI Macros 22 | * */ 23 | 24 | #ifdef USE_FAST_PINIO 25 | #define SSPI_MOSI_HIGH() *mosiport |= mosipinmask 26 | #define SSPI_MOSI_LOW() *mosiport &= ~mosipinmask 27 | #define SSPI_SCK_HIGH() *clkport |= clkpinmask 28 | #define SSPI_SCK_LOW() *clkport &= ~clkpinmask 29 | #define SSPI_MISO_READ() ((*misoport & misopinmask) != 0) 30 | #else 31 | #define SSPI_MOSI_HIGH() digitalWrite(_mosi, HIGH) 32 | #define SSPI_MOSI_LOW() digitalWrite(_mosi, LOW) 33 | #define SSPI_SCK_HIGH() digitalWrite(_sclk, HIGH) 34 | #define SSPI_SCK_LOW() digitalWrite(_sclk, LOW) 35 | #define SSPI_MISO_READ() digitalRead(_miso) 36 | #endif 37 | 38 | #define SSPI_BEGIN_TRANSACTION() 39 | #define SSPI_END_TRANSACTION() 40 | #define SSPI_WRITE(v) spiWrite(v) 41 | #define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s) 42 | #define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l) 43 | #define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); } 44 | 45 | /* 46 | * Hardware SPI Macros 47 | * */ 48 | 49 | #define SPI_OBJECT SPI 50 | 51 | #if defined (__AVR__) || defined(TEENSYDUINO) || defined(ARDUINO_ARCH_STM32F1) 52 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(SPI_CLOCK_DIV2); 53 | #elif defined (__arm__) 54 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(11); 55 | #elif defined(ESP8266) || defined(ESP32) 56 | #define HSPI_SET_CLOCK() SPI_OBJECT.setFrequency(_freq); 57 | #elif defined(RASPI) 58 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq); 59 | #elif defined(ARDUINO_ARCH_STM32F1) 60 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq); 61 | #else 62 | #define HSPI_SET_CLOCK() 63 | #endif 64 | 65 | #ifdef SPI_HAS_TRANSACTION 66 | #define HSPI_BEGIN_TRANSACTION() SPI_OBJECT.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0)) 67 | #define HSPI_END_TRANSACTION() SPI_OBJECT.endTransaction() 68 | #else 69 | #define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); SPI_OBJECT.setBitOrder(MSBFIRST); SPI_OBJECT.setDataMode(SPI_MODE0) 70 | #define HSPI_END_TRANSACTION() 71 | #endif 72 | 73 | #ifdef ESP32 74 | #define SPI_HAS_WRITE_PIXELS 75 | #endif 76 | #if defined(ESP8266) || defined(ESP32) 77 | // Optimized SPI (ESP8266 and ESP32) 78 | #define HSPI_READ() SPI_OBJECT.transfer(0) 79 | #define HSPI_WRITE(b) SPI_OBJECT.write(b) 80 | #define HSPI_WRITE16(s) SPI_OBJECT.write16(s) 81 | #define HSPI_WRITE32(l) SPI_OBJECT.write32(l) 82 | #ifdef SPI_HAS_WRITE_PIXELS 83 | #define SPI_MAX_PIXELS_AT_ONCE 32 84 | #define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l) 85 | #else 86 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); } 87 | #endif 88 | #else 89 | // Standard Byte-by-Byte SPI 90 | 91 | #if defined (__AVR__) || defined(TEENSYDUINO) 92 | static inline uint8_t _avr_spi_read(void) __attribute__((always_inline)); 93 | static inline uint8_t _avr_spi_read(void) { 94 | uint8_t r = 0; 95 | SPDR = r; 96 | while(!(SPSR & _BV(SPIF))); 97 | r = SPDR; 98 | return r; 99 | } 100 | #define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));} 101 | #define HSPI_READ() _avr_spi_read() 102 | #else 103 | #define HSPI_WRITE(b) SPI_OBJECT.transfer((uint8_t)(b)) 104 | #define HSPI_READ() HSPI_WRITE(0) 105 | #endif 106 | #define HSPI_WRITE16(s) HSPI_WRITE((s) >> 8); HSPI_WRITE(s) 107 | #define HSPI_WRITE32(l) HSPI_WRITE((l) >> 24); HSPI_WRITE((l) >> 16); HSPI_WRITE((l) >> 8); HSPI_WRITE(l) 108 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); } 109 | #endif 110 | 111 | #define SPI_BEGIN() if(_sclk < 0){SPI_OBJECT.begin();} 112 | #define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();} 113 | #define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();} 114 | #define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);} 115 | #define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);} 116 | #define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);} 117 | 118 | #endif // _ADAFRUIT_SPITFT_MACROS 119 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/fontconvert/fontconvert_win.md: -------------------------------------------------------------------------------- 1 | ### A short guide to use fontconvert.c to create your own fonts using MinGW. 2 | 3 | #### STEP 1: INSTALL MinGW 4 | 5 | Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). 6 | Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). 7 | I suggest installing with the "Graphical User Interface Installer". 8 | To complete your initial installation you should further install some "packages". 9 | For our purpose you should only install the "Basic Setup" packages. 10 | To do that: 11 | 12 | 1. Open the MinGW Installation Manager 13 | 2. From the left panel click "Basic Setup". 14 | 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" 15 | and click "Mark for installation" 16 | 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". 17 | 18 | 19 | #### STEP 2: INSTALL Freetype Library 20 | 21 | To read about the freetype project visit [freetype.org](https://www.freetype.org/). 22 | To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) 23 | and choose "freetype-2.7.tar.gz" file (or a newer version if available). 24 | To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. 25 | (I also renamed the folder to "ft27") 26 | Before you build the library it's good to read these articles: 27 | * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) 28 | * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) 29 | * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) 30 | 31 | Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). 32 | Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. 33 | To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. 34 | Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. 35 | Enter "ft27" directory using the cd commands: 36 | ``` 37 | cd /c 38 | cd ft27 39 | ``` 40 | 41 | and then type one by one the commands: 42 | ``` 43 | ./configure --prefix=/mingw 44 | make 45 | make install 46 | ``` 47 | Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". 48 | That, hopefully, means that you have installed the library correctly !! 49 | 50 | #### STEP 3: Build fontconvert.c 51 | 52 | Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. 53 | Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). 54 | Change the commands so in the end the program looks like : 55 | ``` 56 | all: fontconvert 57 | 58 | CC = gcc 59 | CFLAGS = -Wall -I c:/mingw/include/freetype2 60 | LIBS = -lfreetype 61 | 62 | fontconvert: fontconvert.c 63 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 64 | 65 | clean: 66 | rm -f fontconvert 67 | ``` 68 | Go back in the command prompt and with a cd command enter the fontconvert directory. 69 | ``` 70 | cd /c/adafruit_gfx_library\fontconvert 71 | ``` 72 | Give the command: 73 | ``` 74 | make 75 | ``` 76 | This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. 77 | 78 | #### STEP 4: Create your own font header files 79 | 80 | Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. 81 | So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: 82 | ``` 83 | ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h 84 | ``` 85 | You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). 86 | 87 | Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee 88 | and start playing with your Arduino (or whatever else ....)+ display module project. 89 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | GFXglyph *glyph; ///< Glyph array 24 | uint8_t first; ///< ASCII extents (first char) 25 | uint8_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.2.9 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit-GFX-Library/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/esp8266.c: -------------------------------------------------------------------------------- 1 | // This is a mash-up of the Due show() code + insights from Michael Miller's 2 | // ESP8266 work for the NeoPixelBus library: github.com/Makuna/NeoPixelBus 3 | // Needs to be a separate .c file to enforce ICACHE_RAM_ATTR execution. 4 | 5 | #if defined(ESP8266) || defined(ESP32) 6 | 7 | #include 8 | #ifdef ESP8266 9 | #include 10 | #endif 11 | 12 | static uint32_t _getCycleCount(void) __attribute__((always_inline)); 13 | static inline uint32_t _getCycleCount(void) { 14 | uint32_t ccount; 15 | __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); 16 | return ccount; 17 | } 18 | 19 | #ifdef ESP8266 20 | void ICACHE_RAM_ATTR espShow( 21 | uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { 22 | #else 23 | void espShow( 24 | uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { 25 | #endif 26 | 27 | #define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us 28 | #define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us 29 | #define CYCLES_800 (F_CPU / 800000) // 1.25us per bit 30 | #define CYCLES_400_T0H (F_CPU / 2000000) // 0.5uS 31 | #define CYCLES_400_T1H (F_CPU / 833333) // 1.2us 32 | #define CYCLES_400 (F_CPU / 400000) // 2.5us per bit 33 | 34 | uint8_t *p, *end, pix, mask; 35 | uint32_t t, time0, time1, period, c, startTime, pinMask; 36 | 37 | pinMask = _BV(pin); 38 | p = pixels; 39 | end = p + numBytes; 40 | pix = *p++; 41 | mask = 0x80; 42 | startTime = 0; 43 | 44 | #ifdef NEO_KHZ400 45 | if(is800KHz) { 46 | #endif 47 | time0 = CYCLES_800_T0H; 48 | time1 = CYCLES_800_T1H; 49 | period = CYCLES_800; 50 | #ifdef NEO_KHZ400 51 | } else { // 400 KHz bitstream 52 | time0 = CYCLES_400_T0H; 53 | time1 = CYCLES_400_T1H; 54 | period = CYCLES_400; 55 | } 56 | #endif 57 | 58 | for(t = time0;; t = time0) { 59 | if(pix & mask) t = time1; // Bit high duration 60 | while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start 61 | #ifdef ESP8266 62 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // Set high 63 | #else 64 | gpio_set_level(pin, HIGH); 65 | #endif 66 | startTime = c; // Save start time 67 | while(((c = _getCycleCount()) - startTime) < t); // Wait high duration 68 | #ifdef ESP8266 69 | GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // Set low 70 | #else 71 | gpio_set_level(pin, LOW); 72 | #endif 73 | if(!(mask >>= 1)) { // Next bit/byte 74 | if(p >= end) break; 75 | pix = *p++; 76 | mask = 0x80; 77 | } 78 | } 79 | while((_getCycleCount() - startTime) < period); // Wait for last bit 80 | } 81 | 82 | #endif // ESP8266 83 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/RGBWstrandtest/.trinket.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/RGBWstrandtest/.trinket.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/StrandtestBLE/.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/StrandtestBLE/.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/StrandtestBLE/BLESerial.cpp: -------------------------------------------------------------------------------- 1 | #include "BLESerial.h" 2 | 3 | // #define BLE_SERIAL_DEBUG 4 | 5 | BLESerial *BLESerial::_instance = NULL; 6 | 7 | BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) : 8 | BLEPeripheral(req, rdy, rst) 9 | { 10 | this->_txCount = 0; 11 | this->_rxHead = this->_rxTail = 0; 12 | this->_flushed = 0; 13 | BLESerial::_instance = this; 14 | 15 | addAttribute(this->_uartService); 16 | addAttribute(this->_uartNameDescriptor); 17 | setAdvertisedServiceUuid(this->_uartService.uuid()); 18 | addAttribute(this->_rxCharacteristic); 19 | addAttribute(this->_rxNameDescriptor); 20 | this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received); 21 | addAttribute(this->_txCharacteristic); 22 | addAttribute(this->_txNameDescriptor); 23 | } 24 | 25 | void BLESerial::begin(...) 26 | { 27 | BLEPeripheral::begin(); 28 | #ifdef BLE_SERIAL_DEBUG 29 | Serial.println(F("BLESerial::begin()")); 30 | #endif 31 | } 32 | 33 | void BLESerial::poll() 34 | { 35 | if (millis() < this->_flushed + 100) 36 | { 37 | BLEPeripheral::poll(); 38 | } 39 | else 40 | { 41 | flush(); 42 | } 43 | } 44 | 45 | void BLESerial::end() 46 | { 47 | this->_rxCharacteristic.setEventHandler(BLEWritten, NULL); 48 | this->_rxHead = this->_rxTail = 0; 49 | flush(); 50 | BLEPeripheral::disconnect(); 51 | } 52 | 53 | int BLESerial::available(void) 54 | { 55 | BLEPeripheral::poll(); 56 | int retval = 57 | (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % sizeof(this->_rxBuffer); 58 | #ifdef BLE_SERIAL_DEBUG 59 | Serial.print(F("BLESerial::available() = ")); 60 | Serial.println(retval); 61 | #endif 62 | return retval; 63 | } 64 | 65 | int BLESerial::peek(void) 66 | { 67 | BLEPeripheral::poll(); 68 | if (this->_rxTail == this->_rxHead) return -1; 69 | uint8_t byte = this->_rxBuffer[this->_rxTail]; 70 | #ifdef BLE_SERIAL_DEBUG 71 | Serial.print(F("BLESerial::peek() = ")); 72 | Serial.print((char) byte); 73 | Serial.print(F(" 0x")); 74 | Serial.println(byte, HEX); 75 | #endif 76 | return byte; 77 | } 78 | 79 | int BLESerial::read(void) 80 | { 81 | BLEPeripheral::poll(); 82 | if (this->_rxTail == this->_rxHead) return -1; 83 | this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer); 84 | uint8_t byte = this->_rxBuffer[this->_rxTail]; 85 | #ifdef BLE_SERIAL_DEBUG 86 | Serial.print(F("BLESerial::read() = ")); 87 | Serial.print((char) byte); 88 | Serial.print(F(" 0x")); 89 | Serial.println(byte, HEX); 90 | #endif 91 | return byte; 92 | } 93 | 94 | void BLESerial::flush(void) 95 | { 96 | if (this->_txCount == 0) return; 97 | this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount); 98 | this->_flushed = millis(); 99 | this->_txCount = 0; 100 | BLEPeripheral::poll(); 101 | #ifdef BLE_SERIAL_DEBUG 102 | Serial.println(F("BLESerial::flush()")); 103 | #endif 104 | } 105 | 106 | size_t BLESerial::write(uint8_t byte) 107 | { 108 | BLEPeripheral::poll(); 109 | if (this->_txCharacteristic.subscribed() == false) return 0; 110 | this->_txBuffer[this->_txCount++] = byte; 111 | if (this->_txCount == sizeof(this->_txBuffer)) flush(); 112 | #ifdef BLE_SERIAL_DEBUG 113 | Serial.print(F("BLESerial::write(")); 114 | Serial.print((char) byte); 115 | Serial.print(F(" 0x")); 116 | Serial.print(byte, HEX); 117 | Serial.println(F(") = 1")); 118 | #endif 119 | return 1; 120 | } 121 | 122 | BLESerial::operator bool() 123 | { 124 | bool retval = BLEPeripheral::connected(); 125 | #ifdef BLE_SERIAL_DEBUG 126 | Serial.print(F("BLESerial::operator bool() = ")); 127 | Serial.println(retval); 128 | #endif 129 | return retval; 130 | } 131 | 132 | void BLESerial::_received(const uint8_t *data, size_t size) 133 | { 134 | for (int i = 0; i < size; i++) 135 | { 136 | this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer); 137 | this->_rxBuffer[this->_rxHead] = data[i]; 138 | } 139 | #ifdef BLE_SERIAL_DEBUG 140 | Serial.print(F("BLESerial::received(")); 141 | for (int i = 0; i < size; i++) Serial.print((char) data[i]); 142 | Serial.println(F(")")); 143 | #endif 144 | } 145 | 146 | void BLESerial::_received(BLECentral & /*central*/, BLECharacteristic &rxCharacteristic) 147 | { 148 | BLESerial::_instance->_received(rxCharacteristic.value(), rxCharacteristic.valueLength()); 149 | } 150 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/StrandtestBLE/BLESerial.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLE_SERIAL_H_ 2 | #define _BLE_SERIAL_H_ 3 | 4 | #include 5 | #include 6 | 7 | class BLESerial : public BLEPeripheral, public Stream 8 | { 9 | public: 10 | BLESerial(unsigned char req, unsigned char rdy, unsigned char rst); 11 | 12 | void begin(...); 13 | 14 | void poll(); 15 | 16 | void end(); 17 | 18 | virtual int available(void); 19 | 20 | virtual int peek(void); 21 | 22 | virtual int read(void); 23 | 24 | virtual void flush(void); 25 | 26 | virtual size_t write(uint8_t byte); 27 | 28 | using Print::write; 29 | 30 | virtual operator bool(); 31 | 32 | private: 33 | unsigned long _flushed; 34 | static BLESerial *_instance; 35 | 36 | size_t _rxHead; 37 | size_t _rxTail; 38 | 39 | size_t _rxCount() const; 40 | 41 | uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 42 | size_t _txCount; 43 | uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 44 | 45 | BLEService _uartService = BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); 46 | BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART"); 47 | BLECharacteristic _rxCharacteristic = BLECharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", 48 | BLEWriteWithoutResponse, 49 | BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 50 | BLEDescriptor _rxNameDescriptor = BLEDescriptor("2901", "RX - Receive Data (Write)"); 51 | BLECharacteristic _txCharacteristic = BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", 52 | BLENotify, 53 | BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 54 | BLEDescriptor _txNameDescriptor = BLEDescriptor("2901", "TX - Transfer Data (Notify)"); 55 | 56 | void _received(const uint8_t *data, size_t size); 57 | 58 | static void _received(BLECentral & /*central*/, BLECharacteristic &rxCharacteristic); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/buttoncycler/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/buttoncycler/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple/simple.ino: -------------------------------------------------------------------------------- 1 | // NeoPixel Ring simple sketch (c) 2013 Shae Erisson 2 | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library 3 | 4 | #include 5 | 6 | #ifdef __AVR__ 7 | 8 | #include 9 | 10 | #endif 11 | 12 | // Which pin on the Arduino is connected to the NeoPixels? 13 | // On a Trinket or Gemma we suggest changing this to 1 14 | #define PIN 6 15 | 16 | // How many NeoPixels are attached to the Arduino? 17 | #define NUMPIXELS 16 18 | 19 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 20 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 21 | // example for more information on possible values. 22 | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 23 | 24 | int delayval = 500; // delay for half a second 25 | 26 | void setup() 27 | { 28 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 29 | #if defined (__AVR_ATtiny85__) 30 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 31 | #endif 32 | // End of trinket special code 33 | 34 | pixels.begin(); // This initializes the NeoPixel library. 35 | } 36 | 37 | void loop() 38 | { 39 | 40 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 41 | 42 | for (int i = 0; i < NUMPIXELS; i++) 43 | { 44 | 45 | // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 46 | pixels.setPixelColor(i, pixels.Color(0, 150, 0)); // Moderately bright green color. 47 | 48 | pixels.show(); // This sends the updated pixel color to the hardware. 49 | 50 | delay(delayval); // Delay for a period of time (in milliseconds). 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple_new_operator/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple_new_operator/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/simple_new_operator/simple_new_operator.ino: -------------------------------------------------------------------------------- 1 | // NeoPixel Ring simple sketch (c) 2013 Shae Erisson 2 | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library 3 | // This sketch show how to use "new" operator with Adafruit_NeoPixel library 4 | // It's helpful if you don't know NeoPixel settings at compile time or 5 | // you just want to store this settings in EEPROM 6 | 7 | #include 8 | 9 | #ifdef __AVR__ 10 | 11 | #include 12 | 13 | #endif 14 | 15 | // Which pin on the Arduino is connected to the NeoPixels? 16 | // On a Trinket or Gemma we suggest changing this to 1 17 | #define PIN 6 18 | 19 | // How many NeoPixels are attached to the Arduino? 20 | int numPixel = 16; 21 | 22 | // Color order, for more information see https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h 23 | uint8_t colorOrder = 0x52; //or just use NEO_GBR 24 | 25 | // Define new pointer for NeoPixel 26 | Adafruit_NeoPixel *pixels; 27 | 28 | 29 | int delayval = 500; // delay for half a second 30 | 31 | void setup() 32 | { 33 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 34 | #if defined (__AVR_ATtiny85__) 35 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 36 | #endif 37 | // End of trinket special code 38 | 39 | // Here is a good place to read numPixel & colorOrder from EEPROM or what ever. 40 | // create a new NeoPixel instance with new values 41 | pixels = new Adafruit_NeoPixel(numPixel, PIN, colorOrder); 42 | pixels->begin(); // This initializes the NeoPixel library. 43 | } 44 | 45 | void loop() 46 | { 47 | 48 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 49 | 50 | for (int i = 0; i < numPixel; i++) 51 | { 52 | 53 | // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 54 | pixels->setPixelColor(i, pixels->Color(0, 150, 0)); // Moderately bright green color. 55 | 56 | pixels->show(); // This sends the updated pixel color to the hardware. 57 | 58 | delay(delayval); // Delay for a period of time (in milliseconds). 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/strandtest/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/strandtest/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/examples/strandtest/strandtest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __AVR__ 4 | 5 | #include 6 | 7 | #endif 8 | 9 | #define PIN 6 10 | 11 | // Parameter 1 = number of pixels in strip 12 | // Parameter 2 = Arduino pin number (most are valid) 13 | // Parameter 3 = pixel type flags, add together as needed: 14 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 15 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 16 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 17 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 18 | // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 19 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); 20 | 21 | // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across 22 | // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input 23 | // and minimize distance between Arduino and first pixel. Avoid connecting 24 | // on a live circuit...if you must, connect GND first. 25 | 26 | void setup() 27 | { 28 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 29 | #if defined (__AVR_ATtiny85__) 30 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 31 | #endif 32 | // End of trinket special code 33 | 34 | 35 | strip.begin(); 36 | strip.show(); // Initialize all pixels to 'off' 37 | } 38 | 39 | void loop() 40 | { 41 | // Some example procedures showing how to display to the pixels: 42 | colorWipe(strip.Color(255, 0, 0), 50); // Red 43 | colorWipe(strip.Color(0, 255, 0), 50); // Green 44 | colorWipe(strip.Color(0, 0, 255), 50); // Blue 45 | //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW 46 | // Send a theater pixel chase in... 47 | theaterChase(strip.Color(127, 127, 127), 50); // White 48 | theaterChase(strip.Color(127, 0, 0), 50); // Red 49 | theaterChase(strip.Color(0, 0, 127), 50); // Blue 50 | 51 | rainbow(20); 52 | rainbowCycle(20); 53 | theaterChaseRainbow(50); 54 | } 55 | 56 | // Fill the dots one after the other with a color 57 | void colorWipe(uint32_t c, uint8_t wait) 58 | { 59 | for (uint16_t i = 0; i < strip.numPixels(); i++) 60 | { 61 | strip.setPixelColor(i, c); 62 | strip.show(); 63 | delay(wait); 64 | } 65 | } 66 | 67 | void rainbow(uint8_t wait) 68 | { 69 | uint16_t i, j; 70 | 71 | for (j = 0; j < 256; j++) 72 | { 73 | for (i = 0; i < strip.numPixels(); i++) 74 | { 75 | strip.setPixelColor(i, Wheel((i + j) & 255)); 76 | } 77 | strip.show(); 78 | delay(wait); 79 | } 80 | } 81 | 82 | // Slightly different, this makes the rainbow equally distributed throughout 83 | void rainbowCycle(uint8_t wait) 84 | { 85 | uint16_t i, j; 86 | 87 | for (j = 0; j < 256 * 5; j++) 88 | { // 5 cycles of all colors on wheel 89 | for (i = 0; i < strip.numPixels(); i++) 90 | { 91 | strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); 92 | } 93 | strip.show(); 94 | delay(wait); 95 | } 96 | } 97 | 98 | //Theatre-style crawling lights. 99 | void theaterChase(uint32_t c, uint8_t wait) 100 | { 101 | for (int j = 0; j < 10; j++) 102 | { //do 10 cycles of chasing 103 | for (int q = 0; q < 3; q++) 104 | { 105 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 106 | { 107 | strip.setPixelColor(i + q, c); //turn every third pixel on 108 | } 109 | strip.show(); 110 | 111 | delay(wait); 112 | 113 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 114 | { 115 | strip.setPixelColor(i + q, 0); //turn every third pixel off 116 | } 117 | } 118 | } 119 | } 120 | 121 | //Theatre-style crawling lights with rainbow effect 122 | void theaterChaseRainbow(uint8_t wait) 123 | { 124 | for (int j = 0; j < 256; j++) 125 | { // cycle all 256 colors in the wheel 126 | for (int q = 0; q < 3; q++) 127 | { 128 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 129 | { 130 | strip.setPixelColor(i + q, Wheel((i + j) % 255)); //turn every third pixel on 131 | } 132 | strip.show(); 133 | 134 | delay(wait); 135 | 136 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 137 | { 138 | strip.setPixelColor(i + q, 0); //turn every third pixel off 139 | } 140 | } 141 | } 142 | } 143 | 144 | // Input a value 0 to 255 to get a color value. 145 | // The colours are a transition r - g - b - back to r. 146 | uint32_t Wheel(byte WheelPos) 147 | { 148 | WheelPos = 255 - WheelPos; 149 | if (WheelPos < 85) 150 | { 151 | return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 152 | } 153 | if (WheelPos < 170) 154 | { 155 | WheelPos -= 85; 156 | return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 157 | } 158 | WheelPos -= 170; 159 | return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 160 | } 161 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Adafruit_NeoPixel 3 | ####################################### 4 | # Class 5 | ####################################### 6 | 7 | Adafruit_NeoPixel KEYWORD1 8 | 9 | ####################################### 10 | # Methods and Functions 11 | ####################################### 12 | 13 | setPixelColor KEYWORD2 14 | setPin KEYWORD2 15 | setBrightness KEYWORD2 16 | numPixels KEYWORD2 17 | getPixelColor KEYWORD2 18 | Color KEYWORD2 19 | show KEYWORD2 20 | 21 | clear KEYWORD2 22 | updateLength KEYWORD2 23 | updateType KEYWORD2 24 | getPixels KEYWORD2 25 | getBrightness KEYWORD2 26 | getPin KEYWORD2 27 | canShow KEYWORD2 28 | 29 | 30 | ####################################### 31 | # Constants 32 | ####################################### 33 | 34 | NEO_COLMASK LITERAL1 35 | NEO_SPDMASK LITERAL1 36 | NEO_KHZ800 LITERAL1 37 | NEO_KHZ400 LITERAL1 38 | NEO_RGB LITERAL1 39 | NEO_RBG LITERAL1 40 | NEO_GRB LITERAL1 41 | NEO_GBR LITERAL1 42 | NEO_BRG LITERAL1 43 | NEO_BGR LITERAL1 44 | NEO_WRGB LITERAL1 45 | NEO_WRBG LITERAL1 46 | NEO_WGRB LITERAL1 47 | NEO_WGBR LITERAL1 48 | NEO_WBRG LITERAL1 49 | NEO_WBGR LITERAL1 50 | NEO_RWGB LITERAL1 51 | NEO_RWBG LITERAL1 52 | NEO_RGWB LITERAL1 53 | NEO_RGBW LITERAL1 54 | NEO_RBWG LITERAL1 55 | NEO_RBGW LITERAL1 56 | NEO_GWRB LITERAL1 57 | NEO_GWBR LITERAL1 58 | NEO_GRWB LITERAL1 59 | NEO_GRBW LITERAL1 60 | NEO_GBWR LITERAL1 61 | NEO_GBRW LITERAL1 62 | NEO_BWRG LITERAL1 63 | NEO_BWGR LITERAL1 64 | NEO_BRWG LITERAL1 65 | NEO_BRGW LITERAL1 66 | NEO_BGWR LITERAL1 67 | NEO_BGRW LITERAL1 68 | 69 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Adafruit_NeoPixel/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit NeoPixel 2 | version=1.1.6 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for controlling single-wire-based LED pixels and strip. 6 | paragraph=Arduino library for controlling single-wire-based LED pixels and strip. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit_NeoPixel 9 | architectures=* 10 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/LiquidCrystal_I2C.h: -------------------------------------------------------------------------------- 1 | //YWROBOT 2 | #ifndef LiquidCrystal_I2C_h 3 | #define LiquidCrystal_I2C_h 4 | 5 | #include 6 | #include "Print.h" 7 | #include 8 | 9 | // commands 10 | #define LCD_CLEARDISPLAY 0x01 11 | #define LCD_RETURNHOME 0x02 12 | #define LCD_ENTRYMODESET 0x04 13 | #define LCD_DISPLAYCONTROL 0x08 14 | #define LCD_CURSORSHIFT 0x10 15 | #define LCD_FUNCTIONSET 0x20 16 | #define LCD_SETCGRAMADDR 0x40 17 | #define LCD_SETDDRAMADDR 0x80 18 | 19 | // flags for display entry mode 20 | #define LCD_ENTRYRIGHT 0x00 21 | #define LCD_ENTRYLEFT 0x02 22 | #define LCD_ENTRYSHIFTINCREMENT 0x01 23 | #define LCD_ENTRYSHIFTDECREMENT 0x00 24 | 25 | // flags for display on/off control 26 | #define LCD_DISPLAYON 0x04 27 | #define LCD_DISPLAYOFF 0x00 28 | #define LCD_CURSORON 0x02 29 | #define LCD_CURSOROFF 0x00 30 | #define LCD_BLINKON 0x01 31 | #define LCD_BLINKOFF 0x00 32 | 33 | // flags for display/cursor shift 34 | #define LCD_DISPLAYMOVE 0x08 35 | #define LCD_CURSORMOVE 0x00 36 | #define LCD_MOVERIGHT 0x04 37 | #define LCD_MOVELEFT 0x00 38 | 39 | // flags for function set 40 | #define LCD_8BITMODE 0x10 41 | #define LCD_4BITMODE 0x00 42 | #define LCD_2LINE 0x08 43 | #define LCD_1LINE 0x00 44 | #define LCD_5x10DOTS 0x04 45 | #define LCD_5x8DOTS 0x00 46 | 47 | // flags for backlight control 48 | #define LCD_BACKLIGHT 0x08 49 | #define LCD_NOBACKLIGHT 0x00 50 | 51 | #define En B00000100 // Enable bit 52 | #define Rw B00000010 // Read/Write bit 53 | #define Rs B00000001 // Register select bit 54 | 55 | class LiquidCrystal_I2C : public Print { 56 | public: 57 | LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows); 58 | void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS ); 59 | void clear(); 60 | void home(); 61 | void noDisplay(); 62 | void display(); 63 | void noBlink(); 64 | void blink(); 65 | void noCursor(); 66 | void cursor(); 67 | void scrollDisplayLeft(); 68 | void scrollDisplayRight(); 69 | void printLeft(); 70 | void printRight(); 71 | void leftToRight(); 72 | void rightToLeft(); 73 | void shiftIncrement(); 74 | void shiftDecrement(); 75 | void noBacklight(); 76 | void backlight(); 77 | void autoscroll(); 78 | void noAutoscroll(); 79 | void createChar(uint8_t, uint8_t[]); 80 | void createChar(uint8_t location, const char *charmap); 81 | // Example: const char bell[8] PROGMEM = {B00100,B01110,B01110,B01110,B11111,B00000,B00100,B00000}; 82 | 83 | void setCursor(uint8_t, uint8_t); 84 | #if defined(ARDUINO) && ARDUINO >= 100 85 | virtual size_t write(uint8_t); 86 | #else 87 | virtual void write(uint8_t); 88 | #endif 89 | void command(uint8_t); 90 | void init(); 91 | void oled_init(); 92 | 93 | ////compatibility API function aliases 94 | void blink_on(); // alias for blink() 95 | void blink_off(); // alias for noBlink() 96 | void cursor_on(); // alias for cursor() 97 | void cursor_off(); // alias for noCursor() 98 | void setBacklight(uint8_t new_val); // alias for backlight() and nobacklight() 99 | void load_custom_character(uint8_t char_num, uint8_t *rows); // alias for createChar() 100 | void printstr(const char[]); 101 | 102 | ////Unsupported API functions (not implemented in this library) 103 | uint8_t status(); 104 | void setContrast(uint8_t new_val); 105 | uint8_t keypad(); 106 | void setDelay(int,int); 107 | void on(); 108 | void off(); 109 | uint8_t init_bargraph(uint8_t graphtype); 110 | void draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); 111 | void draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); 112 | 113 | 114 | private: 115 | void init_priv(); 116 | void send(uint8_t, uint8_t); 117 | void write4bits(uint8_t); 118 | void expanderWrite(uint8_t); 119 | void pulseEnable(uint8_t); 120 | uint8_t _Addr; 121 | uint8_t _displayfunction; 122 | uint8_t _displaycontrol; 123 | uint8_t _displaymode; 124 | uint8_t _numlines; 125 | bool _oled = false; 126 | uint8_t _cols; 127 | uint8_t _rows; 128 | uint8_t _backlightval; 129 | }; 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/examples/CustomChars/CustomChars.pde: -------------------------------------------------------------------------------- 1 | //YWROBOT 2 | //Compatible with the Arduino IDE 1.0 3 | //Library version:1.1 4 | #include 5 | #include 6 | 7 | #if defined(ARDUINO) && ARDUINO >= 100 8 | #define printByte(args) write(args); 9 | #else 10 | #define printByte(args) print(args,BYTE); 11 | #endif 12 | 13 | uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4}; 14 | uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0}; 15 | uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0}; 16 | uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0}; 17 | uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0}; 18 | uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0}; 19 | uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0}; 20 | uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4}; 21 | 22 | LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display 23 | 24 | void setup() 25 | { 26 | lcd.init(); // initialize the lcd 27 | lcd.backlight(); 28 | 29 | lcd.createChar(0, bell); 30 | lcd.createChar(1, note); 31 | lcd.createChar(2, clock); 32 | lcd.createChar(3, heart); 33 | lcd.createChar(4, duck); 34 | lcd.createChar(5, check); 35 | lcd.createChar(6, cross); 36 | lcd.createChar(7, retarrow); 37 | lcd.home(); 38 | 39 | lcd.print("Hello world..."); 40 | lcd.setCursor(0, 1); 41 | lcd.print(" i "); 42 | lcd.printByte(3); 43 | lcd.print(" arduinos!"); 44 | delay(5000); 45 | displayKeyCodes(); 46 | 47 | } 48 | 49 | // display all keycodes 50 | void displayKeyCodes(void) { 51 | uint8_t i = 0; 52 | while (1) { 53 | lcd.clear(); 54 | lcd.print("Codes 0x"); lcd.print(i, HEX); 55 | lcd.print("-0x"); lcd.print(i+15, HEX); 56 | lcd.setCursor(0, 1); 57 | for (int j=0; j<16; j++) { 58 | lcd.printByte(i+j); 59 | } 60 | i+=16; 61 | 62 | delay(4000); 63 | } 64 | } 65 | 66 | void loop() 67 | { 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.pde: -------------------------------------------------------------------------------- 1 | //YWROBOT 2 | //Compatible with the Arduino IDE 1.0 3 | //Library version:1.1 4 | #include 5 | 6 | LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display 7 | 8 | void setup() 9 | { 10 | lcd.init(); // initialize the lcd 11 | // Print a message to the LCD. 12 | lcd.backlight(); 13 | lcd.setCursor(3,0); 14 | lcd.print("Hello, world!"); 15 | lcd.setCursor(2,1); 16 | lcd.print("Ywrobot Arduino!"); 17 | lcd.setCursor(0,2); 18 | lcd.print("Arduino LCM IIC 2004"); 19 | lcd.setCursor(2,3); 20 | lcd.print("Power By Ec-yuan!"); 21 | } 22 | 23 | 24 | void loop() 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/examples/SerialDisplay/SerialDisplay.pde: -------------------------------------------------------------------------------- 1 | /* 2 | * Displays text sent over the serial port (e.g. from the Serial Monitor) on 3 | * an attached LCD. 4 | * YWROBOT 5 | *Compatible with the Arduino IDE 1.0 6 | *Library version:1.1 7 | */ 8 | #include 9 | #include 10 | 11 | LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display 12 | 13 | void setup() 14 | { 15 | lcd.init(); // initialize the lcd 16 | lcd.backlight(); 17 | Serial.begin(9600); 18 | } 19 | 20 | void loop() 21 | { 22 | // when characters arrive over the serial port... 23 | if (Serial.available()) { 24 | // wait a bit for the entire message to arrive 25 | delay(100); 26 | // clear the screen 27 | lcd.clear(); 28 | // read all the available characters 29 | while (Serial.available() > 0) { 30 | // display each character to the LCD 31 | lcd.write(Serial.read()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Syntax Coloring Map For LiquidCrystal_I2C 3 | ########################################### 4 | 5 | ########################################### 6 | # Datatypes (KEYWORD1) 7 | ########################################### 8 | 9 | LiquidCrystal_I2C KEYWORD1 10 | 11 | ########################################### 12 | # Methods and Functions (KEYWORD2) 13 | ########################################### 14 | init KEYWORD2 15 | begin KEYWORD2 16 | clear KEYWORD2 17 | home KEYWORD2 18 | noDisplay KEYWORD2 19 | display KEYWORD2 20 | noBlink KEYWORD2 21 | blink KEYWORD2 22 | noCursor KEYWORD2 23 | cursor KEYWORD2 24 | scrollDisplayLeft KEYWORD2 25 | scrollDisplayRight KEYWORD2 26 | leftToRight KEYWORD2 27 | rightToLeft KEYWORD2 28 | shiftIncrement KEYWORD2 29 | shiftDecrement KEYWORD2 30 | noBacklight KEYWORD2 31 | backlight KEYWORD2 32 | autoscroll KEYWORD2 33 | noAutoscroll KEYWORD2 34 | createChar KEYWORD2 35 | setCursor KEYWORD2 36 | print KEYWORD2 37 | blink_on KEYWORD2 38 | blink_off KEYWORD2 39 | cursor_on KEYWORD2 40 | cursor_off KEYWORD2 41 | setBacklight KEYWORD2 42 | load_custom_character KEYWORD2 43 | printstr KEYWORD2 44 | ########################################### 45 | # Constants (LITERAL1) 46 | ########################################### 47 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "LiquidCrystal_I2C", 3 | "keywords": "LCD, liquidcrystal, I2C", 4 | "description": "A library for DFRobot I2C LCD displays", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/marcoschwartz/LiquidCrystal_I2C.git" 9 | }, 10 | "frameworks": "arduino", 11 | "platforms": 12 | [ 13 | "atmelavr", 14 | "espressif8266" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/LiquidCrystal_I2C/library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal_I2C 2 | version=1.1.4 3 | author=Frank de Brabander 4 | maintainer=Marco Schwartz 5 | sentence=A library for I2C LCD displays. 6 | paragraph= The library allows to control I2C displays with functions extremely similar to LiquidCrystal library. THIS LIBRARY MIGHT NOT BE COMPATIBLE WITH EXISTING SKETCHES. 7 | category=Display 8 | url=https://github.com/marcoschwartz/LiquidCrystal_I2C 9 | architectures=avr 10 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Skywriter/examples/NeoPaint/NeoPaint.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define PIN 8 5 | 6 | Adafruit_NeoPixel Neopixel = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800); 7 | 8 | unsigned long brightness = 50; 9 | unsigned char color = 0; 10 | 11 | // Include string names of gestures/touches for testing 12 | //#define SKYWRITER_INC_DEBUG_STRINGS 13 | #include "skywriter.h" 14 | 15 | unsigned int max_x, max_y, max_z; 16 | unsigned int min_x, min_y, min_z; 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | while(!Serial){}; 21 | Serial.println("Hello world!"); 22 | 23 | Neopixel.begin(); 24 | Neopixel.setBrightness(brightness); 25 | Neopixel.show(); // Initialize all pixels to 'off' 26 | 27 | 28 | Skywriter.begin(12, 13); 29 | Skywriter.onTouch(touch); 30 | //Skywriter.onAirwheel(airwheel); 31 | Skywriter.onGesture(gesture); 32 | Skywriter.onXYZ(xyz); 33 | } 34 | 35 | void loop() { 36 | Skywriter.poll(); 37 | /*int x; 38 | for(x = 0; x < 64; x++){ 39 | Neopixel.setPixelColor(x, Wheel(color)); 40 | }*/ 41 | Neopixel.show(); 42 | } 43 | 44 | void xyz(unsigned int x, unsigned int y, unsigned int z){ 45 | if (x < min_x) min_x = x; 46 | if (y < min_y) min_y = y; 47 | if (z < min_z) min_z = z; 48 | if (x > max_x) max_x = x; 49 | if (y > max_y) max_y = y; 50 | if (z > max_z) max_z = z; 51 | 52 | unsigned char pixel_x = map(x, min_x, max_x, 0, 7); 53 | unsigned char pixel_y = map(y, min_y, max_y, 0, 7); 54 | uint32_t color = Wheel(map(z, min_z, max_z, 0, 255)); 55 | 56 | 57 | Neopixel.setPixelColor(pixel_x*8 + pixel_y, color); 58 | 59 | char buf[64]; 60 | sprintf(buf, "%05u:%05u:%05u gest:%02u touch:%02u", x, y, z, Skywriter.last_gesture, Skywriter.last_touch); 61 | Serial.println(buf); 62 | } 63 | 64 | void gesture(unsigned char type){ 65 | Serial.println("Got gesture "); 66 | Serial.print(type,DEC); 67 | Serial.print('\n'); 68 | 69 | if( type == SW_FLICK_WEST_EAST ){ 70 | Neopixel.clear(); 71 | } 72 | } 73 | 74 | void touch(unsigned char type){ 75 | Serial.println("Got touch "); 76 | Serial.print(type,DEC); 77 | Serial.print('\n'); 78 | 79 | if( type == SW_TOUCH_CENTER ){ 80 | Neopixel.setBrightness(map(Skywriter.x, min_x, max_x, 0, 255)); 81 | //color = map(Skywriter.y, min_y, max_y, 0, 255); 82 | } 83 | /*else if( type == SW_TOUCH_EAST ){ 84 | Neopixel.setBrightness(0); 85 | } 86 | else if( type == SW_TOUCH_WEST ){ 87 | Neopixel.setBrightness(255); 88 | }*/ 89 | } 90 | 91 | void airwheel(int delta){ 92 | Serial.println("Got airwheel "); 93 | Serial.print(delta); 94 | Serial.print('\n'); 95 | 96 | brightness += (delta/100.0); 97 | Neopixel.setBrightness(brightness % 255); 98 | } 99 | 100 | uint32_t Wheel(byte WheelPos) { 101 | if(WheelPos < 85) { 102 | return Neopixel.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 103 | } else if(WheelPos < 170) { 104 | WheelPos -= 85; 105 | return Neopixel.Color(255 - WheelPos * 3, 0, WheelPos * 3); 106 | } else { 107 | WheelPos -= 170; 108 | return Neopixel.Color(0, WheelPos * 3, 255 - WheelPos * 3); 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Skywriter/examples/SkyPainter/SkyPainter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SkyPainter 3 | An advanced example showing the SkyWriter board acting as a 3D paint input 4 | for a NeoPixel matrix. 5 | 6 | Paint in the air with your finger, X/Y translate as normal, and Z is colour! 7 | */ 8 | #include 9 | #include 10 | #include 11 | 12 | #define PIN 8 // Pin for NeoPixel matrix 13 | #define PIN_TRFR 2 // TRFR Pin of Skywriter 14 | #define PIN_RESET 3 // Reset Pin of Skywriter 15 | 16 | Adafruit_NeoPixel Neopixel = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800); 17 | 18 | unsigned long brightness = 50; 19 | unsigned char color = 0; 20 | 21 | long touch_timeout = 0; 22 | 23 | /* 24 | Keep track of the minimum and maximum X, Y, Z values 25 | for on-the-fly calibration of finger-to-led relationship 26 | */ 27 | unsigned int max_x, max_y, max_z; 28 | unsigned int min_x, min_y, min_z; 29 | 30 | void setup() { 31 | min_x = 255; 32 | min_y = 255; 33 | min_z = 255; 34 | 35 | Serial.begin(9600); 36 | while(!Serial){}; 37 | Serial.println("Hello world!"); 38 | 39 | Neopixel.begin(); 40 | Neopixel.setBrightness(brightness); 41 | Neopixel.show(); 42 | 43 | Skywriter.begin(PIN_TRFR, PIN_RESET); 44 | Skywriter.onTouch(touch); 45 | 46 | // Track gestures for clearing the screen 47 | Skywriter.onGesture(gesture); 48 | Skywriter.onXYZ(xyz); 49 | } 50 | 51 | /* 52 | Poll from any updates form Skywriter 53 | */ 54 | void loop() { 55 | // Poll for any updates from Skywriter 56 | // And update the NeoPixel matrix 57 | Skywriter.poll(); 58 | Neopixel.show(); 59 | if( touch_timeout > 0 ) touch_timeout--; 60 | } 61 | 62 | /* 63 | Handle the XYZ updates, determine min/max 64 | values and scale them to fit the display 65 | */ 66 | void xyz(unsigned int x, unsigned int y, unsigned int z){ 67 | if( touch_timeout > 0 ) return; 68 | 69 | if (x < min_x) min_x = x; 70 | if (y < min_y) min_y = y; 71 | if (z < min_z) min_z = z; 72 | if (x > max_x) max_x = x; 73 | if (y > max_y) max_y = y; 74 | if (z > max_z) max_z = z; 75 | 76 | unsigned char pixel_x = map(x, min_x, max_x, 0, 7); 77 | unsigned char pixel_y = map(y, min_y, max_y, 0, 7); 78 | uint32_t color = Wheel(map(z, min_z, max_z, 0, 255)); 79 | 80 | Neopixel.setPixelColor(pixel_x*8 + pixel_y, color); 81 | 82 | char buf[18]; 83 | sprintf(buf, "%05u:%05u:%05u", x, y, z); 84 | Serial.println(buf); 85 | } 86 | 87 | /* 88 | Flicking from West to East will clear 89 | the Matrix. 90 | */ 91 | void gesture(unsigned char type){ 92 | Serial.println("Got gesture "); 93 | Serial.print(type,DEC); 94 | Serial.print('\n'); 95 | 96 | if( type == SW_FLICK_WEST_EAST ){ 97 | Neopixel.clear(); 98 | } 99 | } 100 | 101 | /* 102 | Touching the center of Skywriter will switch 103 | to brightness control mode. Letting you 104 | adjust the brightness of the pixels. 105 | */ 106 | void touch(unsigned char type){ 107 | Serial.println("Got touch "); 108 | Serial.print(type,DEC); 109 | Serial.print('\n'); 110 | 111 | if( type == SW_TOUCH_CENTER ){ 112 | touch_timeout = 100; 113 | Neopixel.setBrightness(map(Skywriter.x, min_x, max_x, 0, 255)); 114 | } 115 | } 116 | 117 | uint32_t Wheel(byte WheelPos) { 118 | if(WheelPos < 85) { 119 | return Neopixel.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 120 | } else if(WheelPos < 170) { 121 | WheelPos -= 85; 122 | return Neopixel.Color(255 - WheelPos * 3, 0, WheelPos * 3); 123 | } else { 124 | WheelPos -= 170; 125 | return Neopixel.Color(0, WheelPos * 3, 255 - WheelPos * 3); 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Skywriter/examples/SkywriterInterrupt/SkywriterInterrupt.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Because interrupts vary from device to device, 3 | this example might not work out of the box for you. 4 | 5 | Read: http://arduino.cc/en/Reference/attachInterrupt 6 | and adjust the code for your device accordingly. 7 | 8 | */ 9 | #include 10 | #include 11 | 12 | /* 13 | Pin 2 is 14 | interrupt 0 on the Uno 15 | interrupt 0 on the Mega2560 16 | interrupt 1 on the Leonardo 17 | just referred to as pin 2 for Due 18 | */ 19 | #define PIN_TRFR 2 20 | #define PIN_RESET 3 21 | 22 | void setup() { 23 | Serial.begin(9600); 24 | while(!Serial){}; 25 | 26 | Skywriter.begin(PIN_TRFR, PIN_RESET); 27 | Skywriter.onTouch(touch); 28 | 29 | Serial.println("Hello world!"); 30 | 31 | /* Set up the initial interrupt */ 32 | attachInterrupt(PIN_TRFR,poll,FALLING); // Arduino Due 33 | //attachInterrupt(0,poll,FALLING); // Arduino Uno 34 | //attachInterrupt(1,poll,FALLING); // Arduino Leonardo 35 | 36 | } 37 | 38 | void poll(){ 39 | /* It doesn't matter how heavy this interrupt 40 | handler is. It will *not* fire again until 41 | Skywriter has finished processing the new data 42 | and we have re-attached the interrupt. */ 43 | 44 | /* Handle the new data */ 45 | Skywriter.poll(); 46 | 47 | /* Skywriter must twiddle PIN_TRFR to tell 48 | the hardware it's processing the new data. 49 | Interrupt needs re-attaching afterwards! */ 50 | attachInterrupt(PIN_TRFR,poll,FALLING); // Arduino Due 51 | //attachInterrupt(0,poll,FALLING); // Arduino Uno 52 | //attachInterrupt(1,poll,FALLING); // Arduino Leonardo 53 | } 54 | 55 | void loop() { 56 | /* Do something in our loop! */ 57 | Serial.println("I'm alive!"); 58 | delay(1000); 59 | } 60 | 61 | void touch(unsigned char type){ 62 | Serial.println("Got touch "); 63 | Serial.print(type,DEC); 64 | Serial.print('\n'); 65 | } 66 | -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Skywriter/keywords.txt: -------------------------------------------------------------------------------- 1 | Skywriter KEYWORD1 2 | begin KEYWORD2 3 | poll KEYWORD2 4 | onGesture KEYWORD2 5 | onTouch KEYWORD2 6 | onAirwheel KEYWORD2 7 | onXYZ KEYWORD2 8 | x KEYWORD3 9 | y KEYWORD3 10 | z KEYWORD3 11 | last_gesture KEYWORD3 12 | last_touch KEYWORD3 -------------------------------------------------------------------------------- /examples/3rd-party-library/libraries/Skywriter/skywriter.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef _SKYWRITER_H 4 | #define _SKYWRITER_H 5 | 6 | #define SW_ADDR 0x42 7 | 8 | #define SW_HEADER_SIZE 4 9 | 10 | #define SW_DATA_DSP 1 //0b0000000000000001 11 | #define SW_DATA_GESTURE 1 << 1 //0b0000000000000010 12 | #define SW_DATA_TOUCH 1 << 2 //0b0000000000000100 13 | #define SW_DATA_AIRWHEEL 1 << 3 //0b0000000000001000 14 | #define SW_DATA_XYZ 1 << 4 //0b0000000000010000 15 | 16 | #define SW_SYSTEM_STATUS 0x15 17 | #define SW_REQUEST_MSG 0x06 18 | #define SW_FW_VERSION 0x83 19 | #define SW_SET_RUNTIME 0xA2 20 | #define SW_SENSOR_DATA 0x91 21 | 22 | #define SW_PAYLOAD_HDR_CONFIGMASK 0 // 2 Bytes 23 | #define SW_PAYLOAD_HDR_TS 2 // 1 Byte 24 | #define SW_PAYLOAD_HDR_SYSINFO 3 // 1 Byte 25 | #define SW_PAYLOAD_DSP_STATUS 4 26 | #define SW_PAYLOAD_GESTURE 6 // 4 Bytes 27 | #define SW_PAYLOAD_TOUCH 10 // 4 Bytes 28 | #define SW_PAYLOAD_AIRWHEEL 14 // 2 Bytes 29 | #define SW_PAYLOAD_X 16 // 2 bytes 30 | #define SW_PAYLOAD_Y 18 // 2 bytes 31 | #define SW_PAYLOAD_Z 20 // 2 bytes 32 | 33 | #define SW_SYS_POSITION 1 34 | #define SW_SYS_AIRWHEEL 1 << 1 35 | 36 | /* 37 | Constants for identifying tap 38 | */ 39 | #define SW_DOUBLETAP_CENTER 0 40 | #define SW_DOUBLETAP_EAST 1 41 | #define SW_DOUBLETAP_NORTH 2 42 | #define SW_DOUBLETAP_WEST 3 43 | #define SW_DOUBLETAP_SOUTH 4 44 | #define SW_TAP_CENTER 5 45 | #define SW_TAP_EAST 6 46 | #define SW_TAP_NORTH 7 47 | #define SW_TAP_WEST 8 48 | #define SW_TAP_SOUTH 9 49 | #define SW_TOUCH_CENTER 10 50 | #define SW_TOUCH_EAST 11 51 | #define SW_TOUCH_NORTH 12 52 | #define SW_TOUCH_WEST 13 53 | #define SW_TOUCH_SOUTH 14 54 | 55 | #define SW_GESTURE_GARBAGE 1 56 | #define SW_FLICK_WEST_EAST 2 57 | #define SW_FLICK_EAST_WEST 3 58 | #define SW_FLICK_SOUTH_NORTH 4 59 | #define SW_FLICK_NORTH_SOUTH 5 60 | #define SW_CIRCLE_CLOCKWISE 6 61 | #define SW_CIRCLE_CCLOCKWISE 7 62 | 63 | class _SkyWriter 64 | { 65 | public: 66 | void begin(unsigned char pin_xfer, unsigned char pin_reset); 67 | void poll(); 68 | void onTouch( void (*)(unsigned char) ); 69 | void onAirwheel( void (*)(int) ); 70 | void onGesture( void (*)(unsigned char) ); 71 | void onXYZ( void (*)(unsigned int, unsigned int, unsigned int) ); 72 | unsigned char last_gesture, last_touch; 73 | unsigned int x, y, z; 74 | int rotation; 75 | private: 76 | void (*handle_touch)(unsigned char) = NULL; 77 | void (*handle_airwheel)(int) = NULL; 78 | void (*handle_gesture)(unsigned char) = NULL; 79 | void (*handle_xyz)(unsigned int, unsigned int, unsigned int); 80 | int lastrotation; 81 | unsigned char xfer, rst, addr; 82 | unsigned char command_buffer[32]; 83 | void handle_sensor_data(unsigned char* data); 84 | }; 85 | 86 | namespace { _SkyWriter Skywriter; } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Examples LANGUAGES C CXX ASM) 4 | 5 | add_subdirectory(hello-world) 6 | add_subdirectory(arduino-library) 7 | add_subdirectory(platform-library) 8 | add_subdirectory(3rd-party-library) 9 | add_subdirectory(header-only-library) 10 | add_subdirectory(blink-example) 11 | add_subdirectory(servo-knob-example) 12 | add_subdirectory(sketch) 13 | add_subdirectory(misc) 14 | -------------------------------------------------------------------------------- /examples/arduino-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Arduino_Library) 4 | 5 | arduino_cmake_project(Arduino_Library BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | add_arduino_executable(Arduino_Library test.cpp) 8 | 9 | # Find and link the Stepper library 10 | find_arduino_library(stepper_lib stePpEr) # Library name is case-insensitive to the user 11 | link_arduino_library(Arduino_Library stepper_lib) 12 | 13 | # Find and link the Servo library - Custom implementation for many architectures, 14 | # 'avr' is used by default 15 | find_arduino_library(servo_lib Servo) 16 | link_arduino_library(Arduino_Library servo_lib) 17 | 18 | # Find and link the Ethernet library - Depends on the SPI avr-platform library 19 | find_arduino_library(ethernet_lib Ethernet) 20 | link_arduino_library(Arduino_Library ethernet_lib) 21 | 22 | #upload_arduino_target(Arduino_Library "" COM3) 23 | -------------------------------------------------------------------------------- /examples/arduino-library/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | Stepper stepper{1, 7, 6}; 7 | Servo servo; 8 | EthernetClient client{}; 9 | 10 | void setup() 11 | { 12 | stepper.version(); 13 | } 14 | 15 | void loop() 16 | { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /examples/blink-example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Blink_Example) 4 | 5 | arduino_cmake_project(Blink_Example BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | add_arduino_example(Blink_Example Blink) 8 | -------------------------------------------------------------------------------- /examples/header-only-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Header_Only_Lib) 4 | 5 | arduino_cmake_project(Header_Only_Lib BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | add_arduino_executable(Header_Only_Lib headerOnlyTest.cpp) 8 | 9 | # Find the library by 'tricking' the framework to use current directory as the Sketchbook path, 10 | # allowing us to use the 'find' API 11 | set(ARDUINO_CMAKE_SKETCHBOOK_PATH "${CMAKE_CURRENT_LIST_DIR}") 12 | 13 | find_arduino_library(headerTest test-lib 3RD_PARTY HEADER_ONLY) 14 | link_arduino_library(Header_Only_Lib headerTest HEADER_ONLY) 15 | -------------------------------------------------------------------------------- /examples/header-only-library/headerOnlyTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void setup() 5 | { 6 | pinMode(BAR, OUTPUT); 7 | } 8 | 9 | void loop() 10 | { 11 | foo(); 12 | delayMicroseconds(SOME_DELAY); 13 | } 14 | 15 | void foo() 16 | { 17 | digitalWrite(BAR, HIGH); 18 | } 19 | -------------------------------------------------------------------------------- /examples/header-only-library/libraries/test-lib/library.properties: -------------------------------------------------------------------------------- 1 | name=Test Library 2 | version=0.1 3 | author=Arduino-CMake-NG 4 | maintainer=Arduino-CMake-NG 5 | sentence=Arduino library to test header-only feature support in the Arduino-CMake framework 6 | paragraph=Arduino library to test header-only feature support in the Arduino-CMake framework 7 | category=Display 8 | url=https://github.com/arduino-cmake/Arduino-CMake-NG 9 | architectures=* 10 | -------------------------------------------------------------------------------- /examples/header-only-library/libraries/test-lib/src/TestLib.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLES_TESTLIB_HPP 2 | #define EXAMPLES_TESTLIB_HPP 3 | 4 | #include 5 | 6 | #define BAR 1 7 | #define SOME_DELAY 200 8 | 9 | void foo(); 10 | 11 | #endif //EXAMPLES_TESTLIB_HPP 12 | -------------------------------------------------------------------------------- /examples/hello-world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Hello_World) 4 | 5 | arduino_cmake_project(Hello_World BOARD_NAME uno) 6 | 7 | add_arduino_executable(Hello_World helloWorld.cpp) 8 | 9 | set_target_upload_port(Hello_World COM3) 10 | -------------------------------------------------------------------------------- /examples/hello-world/helloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void setup() 4 | { 5 | pinMode(LED_BUILTIN, OUTPUT); 6 | } 7 | 8 | void loop() 9 | { 10 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 11 | delay(1000); // wait for a second 12 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 13 | delay(1000); // wait for a second 14 | } 15 | -------------------------------------------------------------------------------- /examples/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | add_subdirectory(libraries) 4 | -------------------------------------------------------------------------------- /examples/misc/libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | add_subdirectory(late-sources-library) 4 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/esp8266.c: -------------------------------------------------------------------------------- 1 | // This is a mash-up of the Due show() code + insights from Michael Miller's 2 | // ESP8266 work for the NeoPixelBus library: github.com/Makuna/NeoPixelBus 3 | // Needs to be a separate .c file to enforce ICACHE_RAM_ATTR execution. 4 | 5 | #if defined(ESP8266) || defined(ESP32) 6 | 7 | #include 8 | #ifdef ESP8266 9 | #include 10 | #endif 11 | 12 | static uint32_t _getCycleCount(void) __attribute__((always_inline)); 13 | static inline uint32_t _getCycleCount(void) { 14 | uint32_t ccount; 15 | __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); 16 | return ccount; 17 | } 18 | 19 | #ifdef ESP8266 20 | void ICACHE_RAM_ATTR espShow( 21 | uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { 22 | #else 23 | void espShow( 24 | uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { 25 | #endif 26 | 27 | #define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us 28 | #define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us 29 | #define CYCLES_800 (F_CPU / 800000) // 1.25us per bit 30 | #define CYCLES_400_T0H (F_CPU / 2000000) // 0.5uS 31 | #define CYCLES_400_T1H (F_CPU / 833333) // 1.2us 32 | #define CYCLES_400 (F_CPU / 400000) // 2.5us per bit 33 | 34 | uint8_t *p, *end, pix, mask; 35 | uint32_t t, time0, time1, period, c, startTime, pinMask; 36 | 37 | pinMask = _BV(pin); 38 | p = pixels; 39 | end = p + numBytes; 40 | pix = *p++; 41 | mask = 0x80; 42 | startTime = 0; 43 | 44 | #ifdef NEO_KHZ400 45 | if(is800KHz) { 46 | #endif 47 | time0 = CYCLES_800_T0H; 48 | time1 = CYCLES_800_T1H; 49 | period = CYCLES_800; 50 | #ifdef NEO_KHZ400 51 | } else { // 400 KHz bitstream 52 | time0 = CYCLES_400_T0H; 53 | time1 = CYCLES_400_T1H; 54 | period = CYCLES_400; 55 | } 56 | #endif 57 | 58 | for(t = time0;; t = time0) { 59 | if(pix & mask) t = time1; // Bit high duration 60 | while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start 61 | #ifdef ESP8266 62 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // Set high 63 | #else 64 | gpio_set_level(pin, HIGH); 65 | #endif 66 | startTime = c; // Save start time 67 | while(((c = _getCycleCount()) - startTime) < t); // Wait high duration 68 | #ifdef ESP8266 69 | GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // Set low 70 | #else 71 | gpio_set_level(pin, LOW); 72 | #endif 73 | if(!(mask >>= 1)) { // Next bit/byte 74 | if(p >= end) break; 75 | pix = *p++; 76 | mask = 0x80; 77 | } 78 | } 79 | while((_getCycleCount() - startTime) < period); // Wait for last bit 80 | } 81 | 82 | #endif // ESP8266 83 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/RGBWstrandtest/.trinket.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/RGBWstrandtest/.trinket.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/StrandtestBLE/.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/StrandtestBLE/.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/StrandtestBLE/BLESerial.cpp: -------------------------------------------------------------------------------- 1 | #include "BLESerial.h" 2 | 3 | // #define BLE_SERIAL_DEBUG 4 | 5 | BLESerial *BLESerial::_instance = NULL; 6 | 7 | BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) : 8 | BLEPeripheral(req, rdy, rst) 9 | { 10 | this->_txCount = 0; 11 | this->_rxHead = this->_rxTail = 0; 12 | this->_flushed = 0; 13 | BLESerial::_instance = this; 14 | 15 | addAttribute(this->_uartService); 16 | addAttribute(this->_uartNameDescriptor); 17 | setAdvertisedServiceUuid(this->_uartService.uuid()); 18 | addAttribute(this->_rxCharacteristic); 19 | addAttribute(this->_rxNameDescriptor); 20 | this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received); 21 | addAttribute(this->_txCharacteristic); 22 | addAttribute(this->_txNameDescriptor); 23 | } 24 | 25 | void BLESerial::begin(...) 26 | { 27 | BLEPeripheral::begin(); 28 | #ifdef BLE_SERIAL_DEBUG 29 | Serial.println(F("BLESerial::begin()")); 30 | #endif 31 | } 32 | 33 | void BLESerial::poll() 34 | { 35 | if (millis() < this->_flushed + 100) 36 | { 37 | BLEPeripheral::poll(); 38 | } 39 | else 40 | { 41 | flush(); 42 | } 43 | } 44 | 45 | void BLESerial::end() 46 | { 47 | this->_rxCharacteristic.setEventHandler(BLEWritten, NULL); 48 | this->_rxHead = this->_rxTail = 0; 49 | flush(); 50 | BLEPeripheral::disconnect(); 51 | } 52 | 53 | int BLESerial::available(void) 54 | { 55 | BLEPeripheral::poll(); 56 | int retval = 57 | (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % sizeof(this->_rxBuffer); 58 | #ifdef BLE_SERIAL_DEBUG 59 | Serial.print(F("BLESerial::available() = ")); 60 | Serial.println(retval); 61 | #endif 62 | return retval; 63 | } 64 | 65 | int BLESerial::peek(void) 66 | { 67 | BLEPeripheral::poll(); 68 | if (this->_rxTail == this->_rxHead) return -1; 69 | uint8_t byte = this->_rxBuffer[this->_rxTail]; 70 | #ifdef BLE_SERIAL_DEBUG 71 | Serial.print(F("BLESerial::peek() = ")); 72 | Serial.print((char) byte); 73 | Serial.print(F(" 0x")); 74 | Serial.println(byte, HEX); 75 | #endif 76 | return byte; 77 | } 78 | 79 | int BLESerial::read(void) 80 | { 81 | BLEPeripheral::poll(); 82 | if (this->_rxTail == this->_rxHead) return -1; 83 | this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer); 84 | uint8_t byte = this->_rxBuffer[this->_rxTail]; 85 | #ifdef BLE_SERIAL_DEBUG 86 | Serial.print(F("BLESerial::read() = ")); 87 | Serial.print((char) byte); 88 | Serial.print(F(" 0x")); 89 | Serial.println(byte, HEX); 90 | #endif 91 | return byte; 92 | } 93 | 94 | void BLESerial::flush(void) 95 | { 96 | if (this->_txCount == 0) return; 97 | this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount); 98 | this->_flushed = millis(); 99 | this->_txCount = 0; 100 | BLEPeripheral::poll(); 101 | #ifdef BLE_SERIAL_DEBUG 102 | Serial.println(F("BLESerial::flush()")); 103 | #endif 104 | } 105 | 106 | size_t BLESerial::write(uint8_t byte) 107 | { 108 | BLEPeripheral::poll(); 109 | if (this->_txCharacteristic.subscribed() == false) return 0; 110 | this->_txBuffer[this->_txCount++] = byte; 111 | if (this->_txCount == sizeof(this->_txBuffer)) flush(); 112 | #ifdef BLE_SERIAL_DEBUG 113 | Serial.print(F("BLESerial::write(")); 114 | Serial.print((char) byte); 115 | Serial.print(F(" 0x")); 116 | Serial.print(byte, HEX); 117 | Serial.println(F(") = 1")); 118 | #endif 119 | return 1; 120 | } 121 | 122 | BLESerial::operator bool() 123 | { 124 | bool retval = BLEPeripheral::connected(); 125 | #ifdef BLE_SERIAL_DEBUG 126 | Serial.print(F("BLESerial::operator bool() = ")); 127 | Serial.println(retval); 128 | #endif 129 | return retval; 130 | } 131 | 132 | void BLESerial::_received(const uint8_t *data, size_t size) 133 | { 134 | for (int i = 0; i < size; i++) 135 | { 136 | this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer); 137 | this->_rxBuffer[this->_rxHead] = data[i]; 138 | } 139 | #ifdef BLE_SERIAL_DEBUG 140 | Serial.print(F("BLESerial::received(")); 141 | for (int i = 0; i < size; i++) Serial.print((char) data[i]); 142 | Serial.println(F(")")); 143 | #endif 144 | } 145 | 146 | void BLESerial::_received(BLECentral & /*central*/, BLECharacteristic &rxCharacteristic) 147 | { 148 | BLESerial::_instance->_received(rxCharacteristic.value(), rxCharacteristic.valueLength()); 149 | } 150 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/StrandtestBLE/BLESerial.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLE_SERIAL_H_ 2 | #define _BLE_SERIAL_H_ 3 | 4 | #include 5 | #include 6 | 7 | class BLESerial : public BLEPeripheral, public Stream 8 | { 9 | public: 10 | BLESerial(unsigned char req, unsigned char rdy, unsigned char rst); 11 | 12 | void begin(...); 13 | 14 | void poll(); 15 | 16 | void end(); 17 | 18 | virtual int available(void); 19 | 20 | virtual int peek(void); 21 | 22 | virtual int read(void); 23 | 24 | virtual void flush(void); 25 | 26 | virtual size_t write(uint8_t byte); 27 | 28 | using Print::write; 29 | 30 | virtual operator bool(); 31 | 32 | private: 33 | unsigned long _flushed; 34 | static BLESerial *_instance; 35 | 36 | size_t _rxHead; 37 | size_t _rxTail; 38 | 39 | size_t _rxCount() const; 40 | 41 | uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 42 | size_t _txCount; 43 | uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; 44 | 45 | BLEService _uartService = BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); 46 | BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART"); 47 | BLECharacteristic _rxCharacteristic = BLECharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", 48 | BLEWriteWithoutResponse, 49 | BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 50 | BLEDescriptor _rxNameDescriptor = BLEDescriptor("2901", "RX - Receive Data (Write)"); 51 | BLECharacteristic _txCharacteristic = BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", 52 | BLENotify, 53 | BLE_ATTRIBUTE_MAX_VALUE_LENGTH); 54 | BLEDescriptor _txNameDescriptor = BLEDescriptor("2901", "TX - Transfer Data (Notify)"); 55 | 56 | void _received(const uint8_t *data, size_t size); 57 | 58 | static void _received(BLECentral & /*central*/, BLECharacteristic &rxCharacteristic); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/buttoncycler/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/buttoncycler/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple/simple.ino: -------------------------------------------------------------------------------- 1 | // NeoPixel Ring simple sketch (c) 2013 Shae Erisson 2 | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library 3 | 4 | #include 5 | 6 | #ifdef __AVR__ 7 | 8 | #include 9 | 10 | #endif 11 | 12 | // Which pin on the Arduino is connected to the NeoPixels? 13 | // On a Trinket or Gemma we suggest changing this to 1 14 | #define PIN 6 15 | 16 | // How many NeoPixels are attached to the Arduino? 17 | #define NUMPIXELS 16 18 | 19 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 20 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 21 | // example for more information on possible values. 22 | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 23 | 24 | int delayval = 500; // delay for half a second 25 | 26 | void setup() 27 | { 28 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 29 | #if defined (__AVR_ATtiny85__) 30 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 31 | #endif 32 | // End of trinket special code 33 | 34 | pixels.begin(); // This initializes the NeoPixel library. 35 | } 36 | 37 | void loop() 38 | { 39 | 40 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 41 | 42 | for (int i = 0; i < NUMPIXELS; i++) 43 | { 44 | 45 | // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 46 | pixels.setPixelColor(i, pixels.Color(0, 150, 0)); // Moderately bright green color. 47 | 48 | pixels.show(); // This sends the updated pixel color to the hardware. 49 | 50 | delay(delayval); // Delay for a period of time (in milliseconds). 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple_new_operator/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple_new_operator/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/simple_new_operator/simple_new_operator.ino: -------------------------------------------------------------------------------- 1 | // NeoPixel Ring simple sketch (c) 2013 Shae Erisson 2 | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library 3 | // This sketch show how to use "new" operator with Adafruit_NeoPixel library 4 | // It's helpful if you don't know NeoPixel settings at compile time or 5 | // you just want to store this settings in EEPROM 6 | 7 | #include 8 | 9 | #ifdef __AVR__ 10 | 11 | #include 12 | 13 | #endif 14 | 15 | // Which pin on the Arduino is connected to the NeoPixels? 16 | // On a Trinket or Gemma we suggest changing this to 1 17 | #define PIN 6 18 | 19 | // How many NeoPixels are attached to the Arduino? 20 | int numPixel = 16; 21 | 22 | // Color order, for more information see https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h 23 | uint8_t colorOrder = 0x52; //or just use NEO_GBR 24 | 25 | // Define new pointer for NeoPixel 26 | Adafruit_NeoPixel *pixels; 27 | 28 | 29 | int delayval = 500; // delay for half a second 30 | 31 | void setup() 32 | { 33 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 34 | #if defined (__AVR_ATtiny85__) 35 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 36 | #endif 37 | // End of trinket special code 38 | 39 | // Here is a good place to read numPixel & colorOrder from EEPROM or what ever. 40 | // create a new NeoPixel instance with new values 41 | pixels = new Adafruit_NeoPixel(numPixel, PIN, colorOrder); 42 | pixels->begin(); // This initializes the NeoPixel library. 43 | } 44 | 45 | void loop() 46 | { 47 | 48 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 49 | 50 | for (int i = 0; i < numPixel; i++) 51 | { 52 | 53 | // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 54 | pixels->setPixelColor(i, pixels->Color(0, 150, 0)); // Moderately bright green color. 55 | 56 | pixels->show(); // This sends the updated pixel color to the hardware. 57 | 58 | delay(delayval); // Delay for a period of time (in milliseconds). 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/strandtest/.esp8266.test.skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arduino-cmake/Arduino-CMake-NG/1f358b5df162cfde69ad6a29b4236c1dbeb71296/examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/strandtest/.esp8266.test.skip -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/examples/strandtest/strandtest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __AVR__ 4 | 5 | #include 6 | 7 | #endif 8 | 9 | #define PIN 6 10 | 11 | // Parameter 1 = number of pixels in strip 12 | // Parameter 2 = Arduino pin number (most are valid) 13 | // Parameter 3 = pixel type flags, add together as needed: 14 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 15 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 16 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 17 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 18 | // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 19 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); 20 | 21 | // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across 22 | // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input 23 | // and minimize distance between Arduino and first pixel. Avoid connecting 24 | // on a live circuit...if you must, connect GND first. 25 | 26 | void setup() 27 | { 28 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 29 | #if defined (__AVR_ATtiny85__) 30 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 31 | #endif 32 | // End of trinket special code 33 | 34 | 35 | strip.begin(); 36 | strip.show(); // Initialize all pixels to 'off' 37 | } 38 | 39 | void loop() 40 | { 41 | // Some example procedures showing how to display to the pixels: 42 | colorWipe(strip.Color(255, 0, 0), 50); // Red 43 | colorWipe(strip.Color(0, 255, 0), 50); // Green 44 | colorWipe(strip.Color(0, 0, 255), 50); // Blue 45 | //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW 46 | // Send a theater pixel chase in... 47 | theaterChase(strip.Color(127, 127, 127), 50); // White 48 | theaterChase(strip.Color(127, 0, 0), 50); // Red 49 | theaterChase(strip.Color(0, 0, 127), 50); // Blue 50 | 51 | rainbow(20); 52 | rainbowCycle(20); 53 | theaterChaseRainbow(50); 54 | } 55 | 56 | // Fill the dots one after the other with a color 57 | void colorWipe(uint32_t c, uint8_t wait) 58 | { 59 | for (uint16_t i = 0; i < strip.numPixels(); i++) 60 | { 61 | strip.setPixelColor(i, c); 62 | strip.show(); 63 | delay(wait); 64 | } 65 | } 66 | 67 | void rainbow(uint8_t wait) 68 | { 69 | uint16_t i, j; 70 | 71 | for (j = 0; j < 256; j++) 72 | { 73 | for (i = 0; i < strip.numPixels(); i++) 74 | { 75 | strip.setPixelColor(i, Wheel((i + j) & 255)); 76 | } 77 | strip.show(); 78 | delay(wait); 79 | } 80 | } 81 | 82 | // Slightly different, this makes the rainbow equally distributed throughout 83 | void rainbowCycle(uint8_t wait) 84 | { 85 | uint16_t i, j; 86 | 87 | for (j = 0; j < 256 * 5; j++) 88 | { // 5 cycles of all colors on wheel 89 | for (i = 0; i < strip.numPixels(); i++) 90 | { 91 | strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); 92 | } 93 | strip.show(); 94 | delay(wait); 95 | } 96 | } 97 | 98 | //Theatre-style crawling lights. 99 | void theaterChase(uint32_t c, uint8_t wait) 100 | { 101 | for (int j = 0; j < 10; j++) 102 | { //do 10 cycles of chasing 103 | for (int q = 0; q < 3; q++) 104 | { 105 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 106 | { 107 | strip.setPixelColor(i + q, c); //turn every third pixel on 108 | } 109 | strip.show(); 110 | 111 | delay(wait); 112 | 113 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 114 | { 115 | strip.setPixelColor(i + q, 0); //turn every third pixel off 116 | } 117 | } 118 | } 119 | } 120 | 121 | //Theatre-style crawling lights with rainbow effect 122 | void theaterChaseRainbow(uint8_t wait) 123 | { 124 | for (int j = 0; j < 256; j++) 125 | { // cycle all 256 colors in the wheel 126 | for (int q = 0; q < 3; q++) 127 | { 128 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 129 | { 130 | strip.setPixelColor(i + q, Wheel((i + j) % 255)); //turn every third pixel on 131 | } 132 | strip.show(); 133 | 134 | delay(wait); 135 | 136 | for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) 137 | { 138 | strip.setPixelColor(i + q, 0); //turn every third pixel off 139 | } 140 | } 141 | } 142 | } 143 | 144 | // Input a value 0 to 255 to get a color value. 145 | // The colours are a transition r - g - b - back to r. 146 | uint32_t Wheel(byte WheelPos) 147 | { 148 | WheelPos = 255 - WheelPos; 149 | if (WheelPos < 85) 150 | { 151 | return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 152 | } 153 | if (WheelPos < 170) 154 | { 155 | WheelPos -= 85; 156 | return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 157 | } 158 | WheelPos -= 170; 159 | return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 160 | } 161 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Adafruit_NeoPixel 3 | ####################################### 4 | # Class 5 | ####################################### 6 | 7 | Adafruit_NeoPixel KEYWORD1 8 | 9 | ####################################### 10 | # Methods and Functions 11 | ####################################### 12 | 13 | setPixelColor KEYWORD2 14 | setPin KEYWORD2 15 | setBrightness KEYWORD2 16 | numPixels KEYWORD2 17 | getPixelColor KEYWORD2 18 | Color KEYWORD2 19 | show KEYWORD2 20 | 21 | clear KEYWORD2 22 | updateLength KEYWORD2 23 | updateType KEYWORD2 24 | getPixels KEYWORD2 25 | getBrightness KEYWORD2 26 | getPin KEYWORD2 27 | canShow KEYWORD2 28 | 29 | 30 | ####################################### 31 | # Constants 32 | ####################################### 33 | 34 | NEO_COLMASK LITERAL1 35 | NEO_SPDMASK LITERAL1 36 | NEO_KHZ800 LITERAL1 37 | NEO_KHZ400 LITERAL1 38 | NEO_RGB LITERAL1 39 | NEO_RBG LITERAL1 40 | NEO_GRB LITERAL1 41 | NEO_GBR LITERAL1 42 | NEO_BRG LITERAL1 43 | NEO_BGR LITERAL1 44 | NEO_WRGB LITERAL1 45 | NEO_WRBG LITERAL1 46 | NEO_WGRB LITERAL1 47 | NEO_WGBR LITERAL1 48 | NEO_WBRG LITERAL1 49 | NEO_WBGR LITERAL1 50 | NEO_RWGB LITERAL1 51 | NEO_RWBG LITERAL1 52 | NEO_RGWB LITERAL1 53 | NEO_RGBW LITERAL1 54 | NEO_RBWG LITERAL1 55 | NEO_RBGW LITERAL1 56 | NEO_GWRB LITERAL1 57 | NEO_GWBR LITERAL1 58 | NEO_GRWB LITERAL1 59 | NEO_GRBW LITERAL1 60 | NEO_GBWR LITERAL1 61 | NEO_GBRW LITERAL1 62 | NEO_BWRG LITERAL1 63 | NEO_BWGR LITERAL1 64 | NEO_BRWG LITERAL1 65 | NEO_BRGW LITERAL1 66 | NEO_BGWR LITERAL1 67 | NEO_BGRW LITERAL1 68 | 69 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/Adafruit_NeoPixel/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit NeoPixel 2 | version=1.1.6 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for controlling single-wire-based LED pixels and strip. 6 | paragraph=Arduino library for controlling single-wire-based LED pixels and strip. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit_NeoPixel 9 | architectures=* 10 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Late_Source_Library) 4 | 5 | arduino_cmake_project(Late_Source_Library BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | # Explictly/Manually add a library without any sources at this stage 8 | add_arduino_library(adafruit_NeoPixel_Late) 9 | 10 | add_arduino_executable(Late_Source_Library late-sources-lib.cpp) 11 | 12 | # Complete required sources for the library that was manaully created earlier 13 | target_sources(adafruit_NeoPixel_Late PUBLIC ${CMAKE_CURRENT_LIST_DIR}/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp) 14 | target_include_directories(adafruit_NeoPixel_Late PUBLIC Adafruit_NeoPixel) 15 | 16 | link_arduino_library(Late_Source_Library adafruit_NeoPixel_Late) 17 | -------------------------------------------------------------------------------- /examples/misc/libraries/late-sources-library/late-sources-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Adafruit_NeoPixel neoPixel; 5 | 6 | void setup() 7 | { 8 | neoPixel.clear(); 9 | } 10 | 11 | void loop() 12 | { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /examples/platform-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Platform_Library) 4 | 5 | arduino_cmake_project(Platform_Library BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | add_arduino_executable(Platform_Library platformLibrary.cpp) 8 | 9 | find_arduino_library(wire Wire) 10 | link_arduino_library(Platform_Library wire) 11 | 12 | find_arduino_library(spi SPI) 13 | link_arduino_library(Platform_Library spi) 14 | -------------------------------------------------------------------------------- /examples/platform-library/platformLibrary.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void setup() 6 | { 7 | pinMode(LED_BUILTIN, OUTPUT); 8 | SPIClass::setDataMode(0); 9 | } 10 | 11 | void loop() 12 | { 13 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 14 | delay(1000); // wait for a second 15 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 16 | delay(1000); // wait for a second 17 | } 18 | -------------------------------------------------------------------------------- /examples/servo-knob-example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Knob_Example) 4 | 5 | arduino_cmake_project(Knob_Example BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | find_arduino_library(servo_example_lib Servo) 8 | add_arduino_library_example(Knob_Example servo_example_lib Servo Knob) 9 | -------------------------------------------------------------------------------- /examples/sketch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.2) 2 | 3 | project(Sketch) 4 | 5 | arduino_cmake_project(Sketch BOARD_NAME nano BOARD_CPU atmega328) 6 | 7 | add_arduino_executable(Sketch) 8 | target_sketches(Sketch sketch1.ino sketch2.pde) 9 | -------------------------------------------------------------------------------- /examples/sketch/sketch1.ino: -------------------------------------------------------------------------------- 1 | // This is a sketch 2 | 3 | void setup() 4 | { 5 | pinMode(LED_BUILTIN, OUTPUT); 6 | } 7 | 8 | void loop() 9 | { 10 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 11 | delay(1000); // wait for a second 12 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 13 | delay(1000); // wait for a second 14 | } 15 | -------------------------------------------------------------------------------- /examples/sketch/sketch2.pde: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int x = 5; 4 | 5 | void foo() 6 | { 7 | Serial.print(x); 8 | } 9 | --------------------------------------------------------------------------------