Skip to content

Commit

Permalink
Added examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Nov 17, 2023
1 parent 73aa0e3 commit 309344b
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.o
*.swp
examples/*/build/
tests/run_tests
1 change: 1 addition & 0 deletions examples/arrayArgument/Makefile
18 changes: 18 additions & 0 deletions examples/arrayArgument/arrayArgument.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <arrayHelpers.h>


void printArray(Span<int> s) {
for (int const& i: s) {
Serial.println(i);
}
}


void setup() {
Serial.begin(9600);

int a[] {1, 2, 3, 4, 5};
printArray(a);
}

void loop() {}
24 changes: 24 additions & 0 deletions examples/size/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FQBN := arduino:avr:pro
PORT := /dev/ttyUSB0
BUILD := build
FLAGS := -pedantic

ARDUINO := arduino-cli
PICOCOM := picocom

SKETCH := $(wildcard *.ino)
LIBS := $(wildcard *.cpp *.h *.tcc)
HEX := $(BUILD)/$(addsuffix .hex, $(SKETCH))


all: $(HEX)

$(HEX): $(SKETCH) $(LIBS)
$(ARDUINO) compile --fqbn $(FQBN) --warnings all --output-dir $(BUILD) \
--build-property compiler.cpp.extra_flags="$(FLAGS)"

upload: $(HEX)
$(ARDUINO) upload --fqbn $(FQBN) --port $(PORT) --input-file $(HEX)

comm:
$(PICOCOM) -q $(PORT)
11 changes: 11 additions & 0 deletions examples/size/size.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <arrayHelpers.h>


void setup() {
Serial.begin(9600);

int a[] {1, 2, 3, 4, 5};
Serial.println(arraySize(a)); // Prints "5".
}

void loop() {}
10 changes: 10 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=arrayhelpers
version=1.0.0
author=Jeroen F.J. Laros <jlaros@fixedpoint.nl>
maintainer=Jeroen F.J. Laros <jlaros@fixedpoint.nl>
sentence=Array helper classes and functions.
paragraph=This library provides a number of helper classes and functions to ease working with arrays.
category=Other
url=https://arrayhelpers.readthedocs.io
architectures=*
includes=arrayHelpers.h

0 comments on commit 309344b

Please sign in to comment.