-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added splitString, reworked printArray
- Loading branch information
Showing
6 changed files
with
138 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pioenvs | ||
.vscode | ||
platformio.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# Utilities | ||
|
||
This is a collection of useful functions for the Arduino Framerwork | ||
This is a collection of useful functions for the Arduino Framerwork, like: | ||
- printArray | ||
- pinModeGroup | ||
- digitalWriteGroup | ||
- digitalToggle | ||
- digitalToggleGroup | ||
- split | ||
|
||
Upload the example to see them working |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,59 @@ | ||
#include <Utilities.h> | ||
|
||
void setup() { | ||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
delay(1000); | ||
|
||
// Create a group of pin | ||
uint8_t group[] = {LED_BUILTIN, 12, 11, 10, 9, 8}; | ||
|
||
// Print that group | ||
printArray(group, LEN(group)); | ||
|
||
// Set their pinMode | ||
pinModeGroup(group, LEN(group), OUTPUT); | ||
|
||
// Write their state | ||
digitalWriteGroup(group, LEN(group), HIGH); | ||
delay(1000); | ||
digitalWriteGroup(group, LEN(group), LOW); | ||
|
||
for (uint8_t n = 0; n < 5; n++) { | ||
// Toggle the state of a pin | ||
for (uint8_t n = 0; n < 5; n++) | ||
{ | ||
digitalToggle(LED_BUILTIN); | ||
delay(500); | ||
} | ||
|
||
printArray(group, LEN(group)); | ||
// Or toggle a group of pins | ||
for (uint8_t n = 0; n < 5; n++) | ||
{ | ||
digitalToggleGroup(group, LEN(group)); | ||
delay(500); | ||
} | ||
|
||
// Create a string | ||
char str[] = "hello, this is a test"; | ||
|
||
// Split it and get the 4th part (starting from 0) | ||
char *substring = splitString(str, 4, " ,"); | ||
|
||
// Print it | ||
Serial.print("substring: "); | ||
Serial.println(substring); // this will output "test" | ||
|
||
// A more complex array for printArray | ||
uint8_t array[] = {1, 0x56, 0b1011}; | ||
|
||
// Print the array as hexadecimal values with a ":" between the items and invert it (from the last to the first) | ||
printArray(array, LEN(array), ":", HEX, true); | ||
|
||
// Print the array as binary values with a newline ("\n") between the items and write the index before every element | ||
printArray(array, LEN(array), "\n", BIN, false, true); | ||
|
||
echo(&Serial, &Serial2); | ||
// If you have more then one serial (like Serial2 or SoftwareSerial) you can make an echo between them | ||
//echo(&Serial, &Serial2); | ||
} | ||
|
||
void loop() {} | ||
void loop() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=Utilities | ||
version=0.0.2 | ||
version=0.1.0 | ||
author=Vincenzo G. | ||
maintainer=Vincenzo G. | ||
sentence=A library that makes using Arduino a breeze. | ||
paragraph=Useful functions for the hobbist | ||
paragraph=Useful functions for the hobbyist, like: printArray, digitalToggle, pinModeGroup, digitalWriteGroup and others! | ||
category=Other | ||
url=https://github.com/aster94/Utilities | ||
architectures=* | ||
architectures=* |