Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 3ee6753

Browse files
committed
Refactored '3rd-party-library' example to be more organized.
Also added some more doc-comments to the example's 'CMakeLists.txt' file.
1 parent 7dd18ac commit 3ee6753

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+7019
-15
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <Arduino.h>
2+
#include "NeoPixelTest.hpp"
3+
#include "GFXTest.h"
4+
#include "InterruptTest.hpp"
5+
6+
void setup()
7+
{
8+
testNeoPixel();
9+
testGFX();
10+
}
11+
12+
void loop()
13+
{
14+
15+
}

examples/3rd-party-library/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@ cmake_minimum_required(VERSION 3.8.2)
33
project(3rd_Party_Arduino_Library)
44
get_board_id(board_id nano atmega328)
55

6-
add_arduino_executable(3rd_Party_Arduino_Library ${board_id} NeoPixelTest.cpp GFXTest.cpp)
6+
# First, declare and create our executable - It'll use 4 sources
7+
add_arduino_executable(3rd_Party_Arduino_Library ${board_id} 3rd_party.cpp
8+
NeoPixelTest.cpp GFXTest.cpp InterruptTest.cpp)
79
target_include_directories(3rd_Party_Arduino_Library PRIVATE include)
810

11+
# Add the "NeoPixel" library manually using the library addition API
912
add_arduino_library(Adafruit_NeoPixel ${board_id} libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp)
1013
target_include_directories(Adafruit_NeoPixel PUBLIC libraries/Adafruit_NeoPixel)
1114

12-
# 'Trick' the framework to use current directory as Sketchbook, allowing us to use the 'find' API
15+
# Find the "GFX" library by 'tricking' the framework to use current directory as the Sketchbook path,
16+
# allowing us to use the 'find' API
1317
set(ARDUINO_CMAKE_SKETCHBOOK_PATH "${CMAKE_CURRENT_LIST_DIR}")
1418
find_arduino_library(Adafruit_GFX Adafruit-GFX-Library ${board_id} 3RD_PARTY)
15-
target_source_directories(Adafruit_GFX
16-
DIRS libraries/Adafruit-GFX-Library/Fonts)
19+
# We can also explicitly add additional directories to the target,
20+
# as only root dir and 'src' sub-dir are added by default
21+
target_source_directories(Adafruit_GFX DIRS libraries/Adafruit-GFX-Library/Fonts)
1722

23+
# Find the "EnableInterrupt" a header-only library
24+
#find_arduino_library(enableInterrupt EnableInterrupt ${board_id} 3RD_PARTY)
25+
26+
# Link all libraries to our previously created target
1827
link_arduino_library(3rd_Party_Arduino_Library Adafruit_NeoPixel ${board_id})
1928
link_arduino_library(3rd_Party_Arduino_Library Adafruit_GFX ${board_id})
29+
#link_arduino_library(3rd_Party_Arduino_Library enableInterrupt ${board_id})

examples/3rd-party-library/GFXTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
static Adafruit_GFX_Button gfxButton;
44

5-
void doSomething()
5+
void testGFX()
66
{
77
gfxButton.isPressed();
88
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "include/InterruptTest.hpp"
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
#include <Adafruit_NeoPixel.h>
2-
#include "GFXTest.h"
1+
2+
#include <NeoPixelTest.hpp>
3+
4+
#include "include/NeoPixelTest.hpp"
35

46
Adafruit_NeoPixel neoPixel;
57

6-
void setup()
8+
void testNeoPixel()
79
{
810
neoPixel.clear();
9-
doSomething();
10-
}
11-
12-
void loop()
13-
{
14-
1511
}

examples/3rd-party-library/include/GFXTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
#include <Adafruit_GFX.h>
55

6-
void doSomething();
6+
void testGFX();
77

88
#endif //EXAMPLES_GFXTEST_HPP
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef EXAMPLES_INTERRUPTTEST_HPP
2+
#define EXAMPLES_INTERRUPTTEST_HPP
3+
4+
#endif //EXAMPLES_INTERRUPTTEST_HPP
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef EXAMPLES_NEOPIXELTEST_HPP
2+
#define EXAMPLES_NEOPIXELTEST_HPP
3+
4+
#include <Adafruit_NeoPixel.h>
5+
6+
void testNeoPixel();
7+
8+
#endif //EXAMPLES_NEOPIXELTEST_HPP

0 commit comments

Comments
 (0)