mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.3.1 ANSI
This commit is contained in:
parent
a25fbcbfec
commit
19bf1b6290
@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
|
||||||
|
## [0.3.1] - 2023-11-13
|
||||||
|
- added experimental functions (to get feedback)
|
||||||
|
- if these work depends on terminal (app) used.
|
||||||
|
- feedback welcome.
|
||||||
|
- updated readme.md with above functions
|
||||||
|
- add initial version of **supportMatrix.md**
|
||||||
|
- updated keywords.txt
|
||||||
|
|
||||||
|
|
||||||
## [0.3.0] - 2023-11-09
|
## [0.3.0] - 2023-11-09
|
||||||
- fix missing 0 in normal (#19, Kudos to d0m1n1qu3)
|
- fix missing 0 in normal (#19, Kudos to d0m1n1qu3)
|
||||||
- fix basic escape strings write length (normal, bold etc eating one char).
|
- fix basic escape strings write length (normal, bold etc eating one char).
|
||||||
|
@ -31,6 +31,7 @@ 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.
|
The code has been updated to explicitly mention which is row and which is column.
|
||||||
- **gotoXY(uint8_t column, uint8_t row)**
|
- **gotoXY(uint8_t column, uint8_t row)**
|
||||||
|
|
||||||
|
|
||||||
#### Related
|
#### Related
|
||||||
|
|
||||||
https://en.wikipedia.org/wiki/ANSI_escape_code
|
https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
@ -42,15 +43,12 @@ Tests are done with
|
|||||||
- TeraTerm 4.102 + 4.106 (VT100, VT202, VT525 mode)
|
- TeraTerm 4.102 + 4.106 (VT100, VT202, VT525 mode)
|
||||||
- Putty 0.71
|
- Putty 0.71
|
||||||
|
|
||||||
|
See **supportMatrix.md** (limited)
|
||||||
|
|
||||||
Other terminal program's exist so please let me know if yours is working too.
|
Other terminal program's exist so please let me know if yours is working too.
|
||||||
If not, please open an issue.
|
If not, please open an issue.
|
||||||
|
|
||||||
|
|
||||||
## Operation
|
|
||||||
|
|
||||||
See examples
|
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@ -120,7 +118,7 @@ Note X == row and Y == column. See #13.
|
|||||||
Look into **ansi.h** for experimental functions and notes.
|
Look into **ansi.h** for experimental functions and notes.
|
||||||
|
|
||||||
Version 0.1.6 added a number of experimental function that need more testing.
|
Version 0.1.6 added a number of experimental function that need more testing.
|
||||||
Some are working with Teraterm, others are unclear of fail.
|
Some are working with TeraTerm, others are unclear of fail.
|
||||||
The user can uncomment these and verify if these work with their terminal.
|
The user can uncomment these and verify if these work with their terminal.
|
||||||
|
|
||||||
|
|
||||||
@ -157,6 +155,39 @@ See - https://github.com/RobTillaart/ANSI/issues/9
|
|||||||
As always, constructive feedback is welcome.
|
As always, constructive feedback is welcome.
|
||||||
|
|
||||||
|
|
||||||
|
##### Experimental (working TeraTerm)
|
||||||
|
|
||||||
|
These functions need more testing and might work on
|
||||||
|
your favourite terminal.
|
||||||
|
As always feedback is welcome.
|
||||||
|
|
||||||
|
COLUMNS
|
||||||
|
- **void set132columns()**
|
||||||
|
- **void set80columns()**
|
||||||
|
|
||||||
|
MOVE WINDOW
|
||||||
|
- **void moveWindowDown()**
|
||||||
|
- **void moveWindowUp()**
|
||||||
|
|
||||||
|
PRINTING
|
||||||
|
- **void printScreen()**
|
||||||
|
- **void setPrintingMode(bool on)**
|
||||||
|
|
||||||
|
RESET
|
||||||
|
- **void reset()** terminal to initial state
|
||||||
|
|
||||||
|
|
||||||
|
##### Experimental (NOT working TeraTerm)
|
||||||
|
|
||||||
|
- **void setSmoothScroll()**
|
||||||
|
- **void setJumpScroll()**
|
||||||
|
- **void printLine()**
|
||||||
|
- **void invisible()** to be used for password?
|
||||||
|
- **void strikeThrough()**
|
||||||
|
- **void setRGBforeground(uint8_t r, uint8_t g, uint8_t b)**
|
||||||
|
- **void setRGBbackground(uint8_t r, uint8_t g, uint8_t b)**
|
||||||
|
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
Since 0.1.5 there is some focus on performance.
|
Since 0.1.5 there is some focus on performance.
|
||||||
@ -167,6 +198,7 @@ Since 0.2.0 the (internal) print() statements are replaced by write().
|
|||||||
Although it are small improvements these add up.
|
Although it are small improvements these add up.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Future
|
## Future
|
||||||
|
|
||||||
#### Must
|
#### Must
|
||||||
@ -175,6 +207,7 @@ Although it are small improvements these add up.
|
|||||||
- elaborate interface
|
- elaborate interface
|
||||||
- colour info
|
- colour info
|
||||||
|
|
||||||
|
|
||||||
#### Should
|
#### Should
|
||||||
|
|
||||||
- test experimental functions
|
- test experimental functions
|
||||||
@ -182,10 +215,12 @@ Although it are small improvements these add up.
|
|||||||
- add examples
|
- add examples
|
||||||
- DOS emulator?
|
- DOS emulator?
|
||||||
- experimental section
|
- experimental section
|
||||||
- evaluate experimental code
|
|
||||||
|
|
||||||
#### Could
|
#### Could
|
||||||
|
|
||||||
|
- investigate a class hierarchy?
|
||||||
|
- base class vs more extended class? (footprint?)
|
||||||
- increase functionality
|
- increase functionality
|
||||||
- which codes are generic / useful ?
|
- which codes are generic / useful ?
|
||||||
- investigate performance.
|
- investigate performance.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: ansi.cpp
|
// FILE: ansi.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.3.0
|
// VERSION: 0.3.1
|
||||||
// PURPOSE: Arduino library to send ANSI escape sequences
|
// PURPOSE: Arduino library to send ANSI escape sequences
|
||||||
// DATE: 2020-04-28
|
// DATE: 2020-04-28
|
||||||
// URL: https://github.com/RobTillaart/ANSI
|
// URL: https://github.com/RobTillaart/ANSI
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: ansi.h
|
// FILE: ansi.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 0.3.0
|
// VERSION: 0.3.1
|
||||||
// PURPOSE: Arduino library to send ANSI escape sequences
|
// PURPOSE: Arduino library to send ANSI escape sequences
|
||||||
// DATE: 2020-04-28
|
// DATE: 2020-04-28
|
||||||
// URL: https://github.com/RobTillaart/ANSI
|
// URL: https://github.com/RobTillaart/ANSI
|
||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
#define ANSI_LIB_VERSION (F("0.3.0"))
|
#define ANSI_LIB_VERSION (F("0.3.1"))
|
||||||
|
|
||||||
|
|
||||||
class ANSI : public Stream
|
class ANSI : public Stream
|
||||||
@ -92,8 +92,13 @@ public:
|
|||||||
uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b);
|
uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// EXPERIMENTAL SECTION
|
// EXPERIMENTAL SECTION
|
||||||
// use at own risk
|
//
|
||||||
|
// use at own risk
|
||||||
|
// check if it works on your terminal
|
||||||
|
|
||||||
|
|
||||||
// TERMINAL TYPE
|
// TERMINAL TYPE
|
||||||
// - https://github.com/RobTillaart/ANSI/issues/9
|
// - https://github.com/RobTillaart/ANSI/issues/9
|
||||||
@ -119,16 +124,24 @@ public:
|
|||||||
inline uint16_t screenHeight() { return _height; };
|
inline uint16_t screenHeight() { return _height; };
|
||||||
|
|
||||||
|
|
||||||
// check if it works on your terminal
|
// COLUMNS
|
||||||
// TERATERM
|
// check if it works on your terminal TERATERM
|
||||||
void set132columns() { print("\033[?3h"); }; // +
|
void set132columns() { print("\033[?3h"); }; // +
|
||||||
void set80columns() { print("\033[?3l"); }; // +
|
void set80columns() { print("\033[?3l"); }; // +
|
||||||
|
|
||||||
|
|
||||||
|
// MOVE WINDOW
|
||||||
|
// check if it works on your terminal TERATERM
|
||||||
void moveWindowDown() { print("\033M"); }; // +
|
void moveWindowDown() { print("\033M"); }; // +
|
||||||
void moveWindowUp() { print("\033D"); }; // +
|
void moveWindowUp() { print("\033D"); }; // +
|
||||||
|
|
||||||
|
|
||||||
// PRINTING
|
// PRINTING
|
||||||
|
// check if it works on your terminal TERATERM
|
||||||
void printScreen() { print("\033[i"); }; // +
|
void printScreen() { print("\033[i"); }; // +
|
||||||
|
void setPrintingMode(bool on) // +
|
||||||
|
{ print( on ? "\e[5i" : "\e[4i"); }
|
||||||
|
|
||||||
|
|
||||||
// RESET terminal to initial state
|
// RESET terminal to initial state
|
||||||
void reset() { print("\033c"); }; // +
|
void reset() { print("\033c"); }; // +
|
||||||
@ -137,20 +150,37 @@ public:
|
|||||||
// NOT working on TERATERM (or need more testing)
|
// NOT working on TERATERM (or need more testing)
|
||||||
// use at own risk
|
// use at own risk
|
||||||
// check if it works on your terminal TERATERM
|
// check if it works on your terminal TERATERM
|
||||||
/*
|
|
||||||
void setSmoothScroll() { print("\033[?4h"); }; // -
|
void setSmoothScroll() { print("\033[?4h"); }; // -
|
||||||
void setJumpScroll() { print("\033[?4l"); }; // -
|
void setJumpScroll() { print("\033[?4l"); }; // -
|
||||||
|
void printLine() { print("\033[1i"); }; // -
|
||||||
|
|
||||||
// to be used for password?
|
// to be used for password?
|
||||||
void invisible() { print("\033[8m"); }; // -
|
void invisible() { print("\033[8m"); }; // -
|
||||||
|
void strikeThrough() { print("\033[9m"); }; // - (mobaXterm works)
|
||||||
|
|
||||||
// PRINTING
|
|
||||||
// use at own risk
|
// RGB_COLOR
|
||||||
// check if it works on your terminal TERATERM
|
void setRGBforeground(uint8_t r, uint8_t g, uint8_t b) // -
|
||||||
void printLine() { print("\033[1i"); }; // ?
|
{
|
||||||
void startPrintLog() { print("\033[4i"); }; // ?
|
print("\033[38;2;");
|
||||||
void stopPrintLog() { print("\033[5i"); }; // ?
|
write(r);
|
||||||
*/
|
write(';');
|
||||||
|
write(g);
|
||||||
|
write(';');
|
||||||
|
write(b);
|
||||||
|
print("m");
|
||||||
|
};
|
||||||
|
|
||||||
|
void setRGBbackground(uint8_t r, uint8_t g, uint8_t b) // -
|
||||||
|
{
|
||||||
|
print("\033[48;2;");
|
||||||
|
write(r);
|
||||||
|
write(';');
|
||||||
|
write(g);
|
||||||
|
write(';');
|
||||||
|
write(b);
|
||||||
|
print("m");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -162,7 +192,7 @@ protected:
|
|||||||
void colors4(uint8_t fgcolor, uint8_t bgcolor);
|
void colors4(uint8_t fgcolor, uint8_t bgcolor);
|
||||||
void color8(uint8_t base, uint8_t color);
|
void color8(uint8_t base, uint8_t color);
|
||||||
|
|
||||||
Stream * _stream;
|
Stream * _stream;
|
||||||
|
|
||||||
// screen size parameters
|
// screen size parameters
|
||||||
uint16_t _width = 0;
|
uint16_t _width = 0;
|
||||||
|
@ -88,6 +88,29 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
ansi.normal();
|
ansi.normal();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// EXPERIMENTAL PART
|
||||||
|
//
|
||||||
|
ansi.clearScreen();
|
||||||
|
ansi.println("Experimental");
|
||||||
|
ansi.invisible();
|
||||||
|
ansi.println("invisible");
|
||||||
|
ansi.normal();
|
||||||
|
ansi.strikeThrough();
|
||||||
|
ansi.println("strikethrough");
|
||||||
|
ansi.normal();
|
||||||
|
|
||||||
|
// RGB color test
|
||||||
|
ansi.println("Experimental");
|
||||||
|
ansi.setRGBforeground(180, 0, 158);
|
||||||
|
ansi.print("foreground");
|
||||||
|
ansi.normal();
|
||||||
|
ansi.setRGBbackground(180, 0, 158);
|
||||||
|
ansi.println("background");
|
||||||
|
ansi.normal();
|
||||||
|
|
||||||
|
|
||||||
ansi.println("\ndone...");
|
ansi.println("\ndone...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
78
libraries/ANSI/examples/ansiTestPrint/ansiTestPrint.ino
Normal file
78
libraries/ANSI/examples/ansiTestPrint/ansiTestPrint.ino
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
//
|
||||||
|
// FILE: ansiTestPrint.ino
|
||||||
|
// AUTHOR: Rob Tillaart
|
||||||
|
// PURPOSE: demo
|
||||||
|
// URL: https://github.com/RobTillaart/ANSI
|
||||||
|
|
||||||
|
|
||||||
|
#include "ansi.h"
|
||||||
|
|
||||||
|
ANSI ansi(&Serial);
|
||||||
|
|
||||||
|
char lorem[] = "Lorem ipsum dolor sit amet, \
|
||||||
|
consectetuer adipiscing elit. Aenean commodo ligula eget dolor. \
|
||||||
|
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient \
|
||||||
|
montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, \
|
||||||
|
pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. \
|
||||||
|
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. \
|
||||||
|
In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. \
|
||||||
|
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. \
|
||||||
|
Cras dapibus. Vivamus elementum semper nisi. \
|
||||||
|
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, \
|
||||||
|
consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, \
|
||||||
|
viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus \
|
||||||
|
varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies \
|
||||||
|
nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
ansi.println(__FILE__);
|
||||||
|
ansi.print("ANSI_LIB_VERSION: ");
|
||||||
|
ansi.println(ANSI_LIB_VERSION);
|
||||||
|
ansi.println();
|
||||||
|
|
||||||
|
ansi.println("\nTest invisible");
|
||||||
|
ansi.invisible();
|
||||||
|
ansi.println("INVISIBLE?");
|
||||||
|
ansi.normal();
|
||||||
|
ansi.println("VISIBLE?");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
ansi.println("\nTest printMode");
|
||||||
|
ansi.clearScreen();
|
||||||
|
ansi.setPrintingMode(true);
|
||||||
|
ansi.println(lorem);
|
||||||
|
ansi.setPrintingMode(false);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
ansi.println("\nTest printScreen");
|
||||||
|
ansi.clearScreen();
|
||||||
|
ansi.println("Hello World");
|
||||||
|
ansi.printScreen();
|
||||||
|
ansi.println("done");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
ansi.println("\nTest printLine");
|
||||||
|
ansi.clearScreen();
|
||||||
|
ansi.println("Hello 1");
|
||||||
|
ansi.println("Hello 2");
|
||||||
|
ansi.printLine();
|
||||||
|
ansi.println("Hello 3");
|
||||||
|
ansi.println("Hello 4");
|
||||||
|
ansi.println("done");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
|
||||||
|
ansi.println("\ndone...");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -- END OF FILE --
|
@ -33,6 +33,7 @@ gray2color KEYWORD2
|
|||||||
grey2color KEYWORD2
|
grey2color KEYWORD2
|
||||||
rgb2color KEYWORD2
|
rgb2color KEYWORD2
|
||||||
|
|
||||||
|
#################################
|
||||||
# EXPERIMENTAL
|
# EXPERIMENTAL
|
||||||
|
|
||||||
deviceType KEYWORD2
|
deviceType KEYWORD2
|
||||||
@ -42,14 +43,26 @@ getScreenSize KEYWORD2
|
|||||||
screenWidth KEYWORD2
|
screenWidth KEYWORD2
|
||||||
screenHeight KEYWORD2
|
screenHeight KEYWORD2
|
||||||
|
|
||||||
|
|
||||||
set132columns KEYWORD2
|
set132columns KEYWORD2
|
||||||
set80columns KEYWORD2
|
set80columns KEYWORD2
|
||||||
moveWindowDown KEYWORD2
|
moveWindowDown KEYWORD2
|
||||||
moveWindowUp KEYWORD2
|
moveWindowUp KEYWORD2
|
||||||
|
|
||||||
printScreen KEYWORD2
|
printScreen KEYWORD2
|
||||||
|
setPrintingMode KEYWORD2
|
||||||
|
|
||||||
reset KEYWORD2
|
reset KEYWORD2
|
||||||
|
|
||||||
|
setSmoothScroll KEYWORD2
|
||||||
|
setJumpScroll KEYWORD2
|
||||||
|
printLine KEYWORD2
|
||||||
|
|
||||||
|
invisible KEYWORD2
|
||||||
|
strikeThrough KEYWORD2
|
||||||
|
|
||||||
|
setRGBforeground KEYWORD2
|
||||||
|
setRGBbackground KEYWORD2
|
||||||
|
|
||||||
|
|
||||||
# Constants (LITERAL1)
|
# Constants (LITERAL1)
|
||||||
ANSI_LIB_VERSION LITERAL1
|
ANSI_LIB_VERSION LITERAL1
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/ANSI.git"
|
"url": "https://github.com/RobTillaart/ANSI.git"
|
||||||
},
|
},
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=ANSI
|
name=ANSI
|
||||||
version=0.3.0
|
version=0.3.1
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library to send ANSI escape sequences.
|
sentence=Arduino library to send ANSI escape sequences.
|
||||||
|
29
libraries/ANSI/supportMatrix.md
Normal file
29
libraries/ANSI/supportMatrix.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
# Support Matrix
|
||||||
|
|
||||||
|
- To be updated when time permits.
|
||||||
|
- name might change
|
||||||
|
|
||||||
|
|
||||||
|
| function | TeraTerm | puTTY | miniCom |
|
||||||
|
|:--------------|:--------:|:-----:|:---------:|
|
||||||
|
| normal | Y | Y | |
|
||||||
|
| bold | Y | Y | |
|
||||||
|
| low | Y | Y | |
|
||||||
|
| underline | Y | Y | |
|
||||||
|
| blink | Y | Y | |
|
||||||
|
| blinkFast | - | - | |
|
||||||
|
| reverse | Y | Y | |
|
||||||
|
| clearScreen | Y | Y | |
|
||||||
|
| clearLine | Y | Y | |
|
||||||
|
| home | Y | Y | |
|
||||||
|
| gotoXY | Y | Y | |
|
||||||
|
| cursorUp | Y | Y | |
|
||||||
|
| cursorDown | Y | Y | |
|
||||||
|
| cursorForward | Y | Y | |
|
||||||
|
| cursorBack | Y | Y | |
|
||||||
|
| | | | |
|
||||||
|
| | | | |
|
||||||
|
| | | | |
|
||||||
|
|
||||||
|
Feel free to add a PR to update the table above.
|
Loading…
Reference in New Issue
Block a user