master
parent efd695e54a
commit 69bbd82a85

@ -7,9 +7,12 @@ Use one include file to replace the Serial.print from Arduino library.
[What is the problem with Arduino Serial.print ?](#what-is-the-problem-with-arduino-serialprint-)
[Example comparison between Didel TerSer and Arduino Serial](#example-comparison-between-didel-terser-and-arduino-serial)
[Using tabular data](#using-tabular-data)
[How to switch from Arduino Serial](#howto-switch-from-arduino-serial)
[Installation](#terser-installation)
[Using tabular data](#using-tabular-data)
[TerSer Limitations](#terser-limitations)
[Code size and timing comparison](#code-size-and-timing-comparison)
[How to switch from Arduino Serial](#howto_switch)
[Function reference](#function-reference)
### What is the problem with Arduino Serial.print ?
Serial.print is is most of the time used as a debugging tool, and with limited resources it is even more important to have the most lighweight solution for this task.
@ -24,28 +27,33 @@ It is admittedly very convenient to just use Serial.print(var); since it doesn't
The TerSer.h offer the choice of 4 print format for numbers. Signed variables have a + or sign in front.
| Normal (moz=0) | Spaces (moz=1) | Zeros (moz=2) | Compact (moz=3) | Serial.print |
| -------------- | -------------- | -------------- | -------------- | -------------- |
| ![moz0](docs/images/tab_moz0.png?raw=true "Example moz=0") | ![moz1](docs/images/tab_moz1.png?raw=true "Example moz=1") | ![moz2](docs/images/tab_moz2.png?raw=true "Example moz=2") | ![moz3](docs/images/tab_moz3.png?raw=true "Example moz=3") | ![Aserial](docs/images/tab_arduino_serial.png?raw=true "Example Arduino Serial.print") |
<a name="howto_switch"/>
### How to switch from Arduino Serial
If you are looking for a drop-in replacement for Arduino Serial with a smaller memory footprint follow the procedure outlined below to quickly switch your project to Didel TerSer:
* Add **#include <TerSer.h>** at the top of your sketch or select the library from your Arduino IDE (*Sketch* | *Include Library*)
* Add ** #include <TerSer.h> ** at the top of your sketch or select the library from your Arduino IDE (*Sketch* | *Include Library*)
* Use the either the library function names we provide or define your own function names, for example:
`#define Serialprint(x) Text(x)`
`#define Serialprint(x) Text(x)`
* Search for all occurences or `Serial.print` and replace with `Serialprint`
Voila, you have switched to TerSer and enjoy smaller footprint at less mcu cycles
#### Function aliasing
If you do not like our function/method names, feel free to define names that suit your tastes with i.e.:
`#define Serialprint(x) Text(x)`
`#define Serialprint(x,BIN) Bin8(x)`
`#define Serialprint(x,BIN) Bin16(x)`
`#define Serialprint(x) Dec16(x)`
etc.
### TerSer Installation
Go to library manager in your Arduino IDE and search for 'TerSer'.
<a name="example_comparison"/>
### Example comparison between Didel TerSer and Arduino Serial
| TerSer | Output TerSer | Output Serial | Arduino Serial |
| ------------- | ------------- | ------------- | ------------- |
@ -60,6 +68,7 @@ etc.
*uint16_t v16=1120; uint16_t v16b=20; int16_t v16s=20;*
### Using tabular data
Filling the non significative digits with zero or space is a general options, named ShowZ(); and HideZ();
@ -77,6 +86,7 @@ HideZ();Dec8s(3); SetTab(15);
It is up to you to add functions like TextNL();
if you need to keep your Serial.println() habits.
### TerSer Limitations
TerSer does not print floating point numbers.
The may happen some day with one more file to import, e.g. names TerFloat.h.
@ -90,4 +100,26 @@ Code size has been obtained by calling one function at a time, compiler under th
Execution time has been measured with a Nop replacing the SendCar function. The time depends on the baud rate, ~1 ms per character displayed at 9600 bits/s.
### Function reference
| TerSer function | |
| --------------- | --------------- |
| Car(cc); | Send code cc to the UART |
| cc=Get(); | Wait for a key depressed. Use Teraterm, too tricky with Arduino Terminal |
| Text("abcd"); | Send the text and add a space |
|Textln("abcd"); | Same with CRLF |
| CR(); | Send a CR-LF |
| Bin8(v); | Display the 8 low bits of the variable v, converted to integers (all add a space) |
| Bin16(v); | Display the 16 bits of the variable v, with a dot in the middle |
| Hex8(v); | Display the 2 nibbles of the variable v, converted to integers |
| Hex16(v); | Display the 4 nibbles of the variable v, converted to integers |
| Hex32(v); | Display the 8 nibbles of the variable v, converted to integers |
| Dec8(v); | Display the variable v, with its signs if signed and non-significative space or zeros |
| Dec16(v); | Display the variable v, with its signs if signed and non-significative space or zeros |
| Dec8u(unsigned); Dec8s(signed); | Shorter code |
| Dec16u(unsigned); Dec16s(signed); | Shorter code |
| Normal(); | ..+nnn default mode (a dot represents a space) |
| Spaces(); | +..nnn best for tabular data |
| Zeros(); | +00nnn if you prefer |
| Compact(); | +nnn same as Arduino, but a + is shown if positive signed variable |

Loading…
Cancel
Save