GY-63_MS5611/libraries/ANSI/README.md

166 lines
4.5 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/ANSI/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-10-18 10:35:48 -04:00
[![Arduino-lint](https://github.com/RobTillaart/ANSI/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/ANSI/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/ANSI/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/ANSI/actions/workflows/jsoncheck.yml)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/ANSI/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ANSI.svg?maxAge=3600)](https://github.com/RobTillaart/ANSI/releases)
# ANSI
Arduino library with basic ANSI display codes for terminal applications.
# Description
2023-01-31 14:16:44 -05:00
ANSI codes are special codes that are send to a terminal e.g. VT100 to add
attributes to displayed characters.
Typical examples are bold, blink or colour. ANSI codes are also known as escape codes.
The set of codes is large, however not all terminal types do support all codes.
2021-01-29 06:31:58 -05:00
2021-10-18 10:35:48 -04:00
Sending these ANSI codes to a simple ASCII only terminal like the one in the Arduino
IDE might result in garbage. So use with care.
2021-01-29 06:31:58 -05:00
2023-02-27 05:33:43 -05:00
#### Breaking change 0.2.0
The **gotoXY(x, y)** has changed as the X and Y coordinates were swapped.
The code has been updated to explicitly mention which is row and which is column.
- **gotoXY(uint8_t column, uint8_t row)**
#### Related
https://en.wikipedia.org/wiki/ANSI_escape_code
2021-01-29 06:31:58 -05:00
## Terminals tested
2023-01-31 14:16:44 -05:00
Tests are done with
2021-10-18 10:35:48 -04:00
- TeraTerm 4.102 + 4.106 (VT100, VT202, VT525 mode)
2023-01-31 14:16:44 -05:00
- Putty 0.71
2021-01-29 06:31:58 -05:00
2021-10-18 10:35:48 -04:00
Other terminal program's exist so please let me know if yours is working too.
2021-01-29 06:31:58 -05:00
If not, please open an issue.
2021-12-13 10:45:59 -05:00
## Operation
2021-01-29 06:31:58 -05:00
See examples
2021-12-13 10:45:59 -05:00
2023-01-31 14:16:44 -05:00
## Interface
```cpp
#include "ansi.h"
```
#### Constructor
- **ANSI(Stream \* stream = &Serial)** wrapper around Serial.
Can be a software serial too.
#### Stream interface
2023-02-27 05:33:43 -05:00
- **int available()** to check if chars are available on the stream.
- **int read()** read a byte from the stream.
- **int peek()** preview the byte in the stream without fetching.
- **void flush()**
2023-01-31 14:16:44 -05:00
Stream interface also includes print(), println(), write().
#### Character modi
2023-02-27 05:33:43 -05:00
- **void normal()** normal intensity.
- **void bold()** bold or high intensity.
- **void low()** low intensity.
2023-01-31 14:16:44 -05:00
- **void underline()** idem.
- **void blink()** idem.
- **void reverse()** idem.
#### Colour
- **void foreground(uint8_t fgcolor)**
- **void background(uint8_t bgcolor)**
- **void color(uint8_t fgcolor, uint8_t bgcolor)**
2023-02-27 05:33:43 -05:00
Three helpers to map to the nearest colour.
2023-01-31 14:16:44 -05:00
- **uint8_t gray2color(uint8_t gray)**
- **uint8_t grey2color(uint8_t grey)** idem
- **uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b)**
2023-02-27 05:33:43 -05:00
To do colour table
2021-12-13 10:45:59 -05:00
2023-01-31 14:16:44 -05:00
#### Positioning
2021-12-13 10:45:59 -05:00
2023-02-27 05:33:43 -05:00
- **void clearScreen()** clears screen and sets cursor to 0,0.
2023-01-31 14:16:44 -05:00
- **void clearLine(uint8_t clear = toEnd)** toEnd = 0,
2023-02-27 05:33:43 -05:00
toStart = 1, entireLine = 2,
- **void home()** set cursor to 0, 0
- **void gotoXY(uint8_t column, uint8_t row)** set cursor to position.
Note X == row and Y == column. See #13.
- **void cursorUp(uint8_t x)** idem.
- **void cursorDown(uint8_t x)** idem.
- **void cursorForward(uint8_t x)** idem.
- **void cursorBack(uint8_t x)** idem.
2023-01-31 14:16:44 -05:00
#### Experimental
look into **ansi.h** for experimental functions and notes.
2022-08-24 05:00:54 -04:00
Version 0.1.6 added a number of experimental function that need more testing.
2023-01-31 14:16:44 -05:00
Some are working with Teraterm, others are unclear of fail.
The user can uncomment these and verify if these work with their terminal.
2022-08-24 05:00:54 -04:00
2023-01-31 14:16:44 -05:00
Also added is the **int deviceType()** function which also need more testing.
2022-08-24 05:00:54 -04:00
As always, constructive feedback is welcome.
2023-01-31 14:16:44 -05:00
## Performance
Since 0.1.5 there is some focus on performance.
Using **ansi.print()** and **ansi.println()** for printing text and numbers is
improved a bit since 0.1.4 by adding the private **write(array, length)**.
2023-02-27 05:33:43 -05:00
Since 0.2.0 the print() statements are replaced by write().
Although it are small improvements these add up.
2023-01-31 14:16:44 -05:00
2021-12-13 10:45:59 -05:00
## Future
2023-01-31 14:16:44 -05:00
#### Must
- improve documentation
- elaborate interface
- colour info
#### Should
- test experimental functions
2021-12-13 10:45:59 -05:00
- test more terminal programs (Linux mac)
2023-01-31 14:16:44 -05:00
- add examples
2021-12-13 10:45:59 -05:00
- DOS emulator?
2023-01-31 14:16:44 -05:00
- experimental section
2023-02-27 05:33:43 -05:00
- evaluate experimental code
- move code from .h to .cpp
2023-01-31 14:16:44 -05:00
#### Could
2021-12-13 10:45:59 -05:00
- increase functionality
2023-01-31 14:16:44 -05:00
- which codes are generic / useful ?
- investigate performance.
2021-12-13 10:45:59 -05:00
- add line buffer in write(c) to improve throughput?
- need for flush() with line buffer?
2023-01-31 14:16:44 -05:00
#### Wont
2023-02-27 05:33:43 -05:00
- move static strings to PROGMEM? as defines?
roughly ~20 bytes progmem for 4 bytes RAM...
2021-12-13 10:45:59 -05:00