-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a9c5b4
commit 7342eb2
Showing
9 changed files
with
294 additions
and
17 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
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
90 changes: 90 additions & 0 deletions
90
libraries/printHelpers/examples/print_hex_bin/print_hex_bin.ino
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,90 @@ | ||
// | ||
// FILE: print_hex_bin.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: demo hex(value, sep); | ||
|
||
|
||
#include "printHelpers.h" | ||
|
||
volatile uint32_t n = 0; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println(); | ||
Serial.println(__FILE__); | ||
|
||
Serial.println(); | ||
uint8_t a = 111; | ||
int8_t b = 112; | ||
uint16_t c = 113; | ||
int16_t d = 114; | ||
uint32_t e = 113; | ||
int32_t f = 114; | ||
Serial.print(hex(a)); | ||
Serial.print("\t"); | ||
Serial.println(bin(a)); | ||
|
||
Serial.print(hex((uint8_t)b)); | ||
Serial.print("\t"); | ||
Serial.println(bin((uint8_t)b)); | ||
|
||
Serial.print(hex(c)); | ||
Serial.print("\t"); | ||
Serial.println(bin(c)); | ||
|
||
Serial.print(hex((uint16_t)d)); | ||
Serial.print("\t"); | ||
Serial.println(bin((uint16_t)d)); | ||
|
||
Serial.print(hex(e)); | ||
Serial.print("\t"); | ||
Serial.println(bin(e)); | ||
|
||
Serial.print(hex((uint32_t)f)); | ||
Serial.print("\t"); | ||
Serial.println(bin((uint32_t)f)); | ||
|
||
Serial.println(hex((uint64_t)a)); | ||
Serial.println(bin((uint64_t)a)); | ||
|
||
|
||
Serial.println(); | ||
Serial.println("10 random() HEX values"); | ||
for (uint8_t i = 0; i < 10; i++) | ||
{ | ||
n = 2 * random(2000000000) + random(2); // 0 .. 2^32-1 | ||
Serial.print(n); | ||
Serial.print('\t'); | ||
Serial.print(hex(n)); | ||
Serial.print('\t'); | ||
Serial.println(n, HEX); | ||
} | ||
Serial.println(); | ||
|
||
|
||
|
||
|
||
|
||
Serial.println("10 random() BIN values"); | ||
for (uint8_t i = 0; i < 10; i++) | ||
{ | ||
n = 2 * random(2000000000) + random(2); // 0 .. 2^32-1 | ||
Serial.print(n); | ||
Serial.print('\t'); | ||
Serial.print(bin(n)); | ||
Serial.print('\t'); | ||
Serial.println(n, BIN); | ||
} | ||
Serial.println(); | ||
|
||
Serial.println("\ndone..."); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
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
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,5 +1,5 @@ | ||
name=printHelpers | ||
version=0.2.5 | ||
version=0.3.0 | ||
author=Rob Tillaart <[email protected]> | ||
maintainer=Rob Tillaart <[email protected]> | ||
sentence=Arduino library to help formatting data for printing. 64 bit integers (base 10 and 16). Engineering and scientific notation. | ||
|
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
Oops, something went wrong.