master
parent d617984562
commit 26132003f6

@ -3,8 +3,15 @@
A much smaller and more efficient serial library than Arduinos Serial.
Use an include file to replace the Serial.print from Arduino library.
## What is the problem with Arduino Serial.print ?
##### Table of Contents
[What is the problem with Arduino Serial.print ?](#arduino_serial_problems)
[Example comparison between Didel TerSer and Arduino Serial](#example_comparison)
[Using tabular data](#using_tabular_data)
[TerSer Limitations](#terser_limitations)
[Code size and timing comparison](#code_size_timing_comparison)
<a name="arduino_serial_problems"/>
### 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.
Also when Serial debugging is used to display sensor values, as shown next, suppressing non significative zeros is not adequate for tabular data, specially when the screen is scrolling.
@ -15,6 +22,7 @@ We propose to use a compact C portable library. Compatibility with an Oled displ
It is admittedly very convenient to just use Serial.print(var); since it doesn't require you to specify the type of variable. Though when trying for example to output data in tabular style the processor needs to know the data type used so that it can reserve the adequate space for it in its output. It might seem like a big inconvenience to specify the data type with any statement that outputs data over serial but then again for debugging purposes it makes perfectly sense in terms of speed AND size of the resulting code. By the same reasons we also do not use a buffer as it is needed only in specific situations.
<a name="example_comparison"/>
### Example comparison between Didel TerSer and Arduino Serial
| TerSer | Output TerSer | Output Serial | Arduino Serial |
| ------------- | ------------- | ------------- | ------------- |
@ -29,6 +37,7 @@ It is admittedly very convenient to just use Serial.print(var); since it doesn't
*uint16_t v16=1120; uint16_t v16b=20; int16_t v16s=20;*
<a name="using_tabular_data"/>
### Using tabular data
Filling the non significative digits with zero or space is a general options, named ShowZ(); and HideZ();
@ -46,6 +55,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.
<a name="terser_limitations"/>
### 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.
@ -54,12 +64,14 @@ Dec8(); and Dec16(); use a tricky macro to recognize the signed or unsigned data
Code will be shorter and there will be no limitation if you use Dec8u(any unsigned expr); and
Dec8s(any signed expr);, same of course Dec16u(); and Dec16s();
<a name="code_size_timing_comparison"/>
### Code size and timing comparison
Code size has been obtained by calling one function at a time, compiler under the usual -0s mode. Size is the difference with the empty file size. TerSer.h can of course be used with setup() and loop(). It add the ~300 bytes Arduino initializations.
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.
#### TerSer.ino Terminal série 174b 0v
Adds 174b for total size: ```c
#### TerSer.ino Terminal 174b 0v
Adds 174b for total size:
```c
#include "TerSer.h"
int main() {
SetupTerSer();
@ -78,7 +90,7 @@ while(1) {
} // end main()
```
#### PrintArduino empty1426b 184v
#### PrintArduino empty 1426b 184v
Adds 1426b for program size:
```cpp
void setup() {

Loading…
Cancel
Save