22//
33// FILE: ansi.h
44// AUTHOR: Rob Tillaart
5- // VERSION: 0.1.3
5+ // VERSION: 0.1.4
66// PURPOSE: Arduino library to send ANSI escape sequences
77// DATE: 2020-04-28
88// URL: https://github.com/RobTillaart/ANSI
99//
1010
11+
1112#include " Arduino.h"
1213
14+ #define ANSI_LIB_VERSION (F(" 0.1.4" ))
15+
16+
1317class ANSI : public Stream
1418{
1519public:
@@ -21,14 +25,16 @@ class ANSI : public Stream
2125 int peek ();
2226 void flush () { return ; }; // placeholder to keep CI happy
2327
28+
2429 // CHAR MODES
2530 void normal () { print (" \033 [0m" ); };
2631 void bold () { print (" \033 [1m" ); };
2732 void low () { print (" \033 [2m" ); };
2833 void underline () { print (" \033 [4m" ); };
2934 void blink () { print (" \033 [5m" ); };
3035 void reverse () { print (" \033 [7m" ); };
31-
36+
37+
3238 // COLOR
3339 enum {
3440 black = 0 ,
@@ -62,7 +68,8 @@ class ANSI : public Stream
6268 // Convert RGB color to ANSI color in 4-bit colorspace
6369 // Pass in a RGB level from 0 (dark) to 255 (light)
6470 uint8_t rgb2color (uint8_t r, uint8_t g, uint8_t b);
65-
71+
72+
6673 // POSITIONING
6774 enum {
6875 toEnd = 0 ,
@@ -74,22 +81,23 @@ class ANSI : public Stream
7481 void clearLine (uint8_t clear = toEnd);
7582
7683 void home () { print (" \033 [H" ); };
77-
84+
7885 void gotoXY (uint8_t x, uint8_t y);
7986 void cursorUp (uint8_t x);
8087 void cursorDown (uint8_t x);
8188 void cursorForward (uint8_t x);
8289 void cursorBack (uint8_t x);
8390
91+
8492private:
8593 size_t write (uint8_t c);
8694 void color4 (uint8_t base, uint8_t color);
8795 void color4_code (uint8_t base, uint8_t color);
8896 void colors4 (uint8_t fgcolor, uint8_t bgcolor);
8997 void color8 (uint8_t base, uint8_t color);
9098
91- Stream * _stream;
92-
99+ Stream * _stream;
100+
93101};
94102
95103// -- END OF FILE --
0 commit comments