Skip to content

Commit

Permalink
add experimental code
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Nov 13, 2023
1 parent bf27f1c commit c209dd9
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 26 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).


## [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
- fix missing 0 in normal (#19, Kudos to d0m1n1qu3)
- fix basic escape strings write length (normal, bold etc eating one char).
Expand Down
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- **gotoXY(uint8_t column, uint8_t row)**


#### Related

https://en.wikipedia.org/wiki/ANSI_escape_code
Expand All @@ -42,15 +43,12 @@ Tests are done with
- TeraTerm 4.102 + 4.106 (VT100, VT202, VT525 mode)
- Putty 0.71

See **supportMatrix.md** (limited)

Other terminal program's exist so please let me know if yours is working too.
If not, please open an issue.


## Operation

See examples


## Interface

```cpp
Expand Down Expand Up @@ -120,7 +118,7 @@ Note X == row and Y == column. See #13.
Look into **ansi.h** for experimental functions and notes.

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.


Expand Down Expand Up @@ -157,6 +155,36 @@ See - https://github.com/RobTillaart/ANSI/issues/9
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?


## Performance

Since 0.1.5 there is some focus on performance.
Expand All @@ -167,6 +195,7 @@ Since 0.2.0 the (internal) print() statements are replaced by write().
Although it are small improvements these add up.



## Future

#### Must
Expand All @@ -175,17 +204,20 @@ Although it are small improvements these add up.
- elaborate interface
- colour info


#### Should

- test experimental functions
- test more terminal programs (Linux mac)
- add examples
- DOS emulator?
- experimental section
- evaluate experimental code


#### Could

- investigate a class hierarchy?
- base class vs more extended class? (footprint?)
- increase functionality
- which codes are generic / useful ?
- investigate performance.
Expand Down
2 changes: 1 addition & 1 deletion ansi.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: ansi.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: Arduino library to send ANSI escape sequences
// DATE: 2020-04-28
// URL: https://github.com/RobTillaart/ANSI
Expand Down
34 changes: 19 additions & 15 deletions ansi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: ansi.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: Arduino library to send ANSI escape sequences
// DATE: 2020-04-28
// URL: https://github.com/RobTillaart/ANSI
Expand Down Expand Up @@ -92,8 +92,13 @@ class ANSI : public Stream
uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b);


///////////////////////////////////////////////////////
//
// EXPERIMENTAL SECTION
// use at own risk
//
// use at own risk
// check if it works on your terminal


// TERMINAL TYPE
// - https://github.com/RobTillaart/ANSI/issues/9
Expand All @@ -119,16 +124,24 @@ class ANSI : public Stream
inline uint16_t screenHeight() { return _height; };


// check if it works on your terminal
// TERATERM
// COLUMNS
// check if it works on your terminal TERATERM
void set132columns() { print("\033[?3h"); }; // +
void set80columns() { print("\033[?3l"); }; // +


// MOVE WINDOW
// check if it works on your terminal TERATERM
void moveWindowDown() { print("\033M"); }; // +
void moveWindowUp() { print("\033D"); }; // +


// PRINTING
// check if it works on your terminal TERATERM
void printScreen() { print("\033[i"); }; // +
void setPrintingMode(bool on) // +
{ print( on ? "\e[5i" : "\e[4i"); }


// RESET terminal to initial state
void reset() { print("\033c"); }; // +
Expand All @@ -137,21 +150,12 @@ class ANSI : public Stream
// NOT working on TERATERM (or need more testing)
// use at own risk
// check if it works on your terminal TERATERM
/*
void setSmoothScroll() { print("\033[?4h"); }; // -
void setJumpScroll() { print("\033[?4l"); }; // -
void printLine() { print("\033[1i"); }; // -
// to be used for password?
void invisible() { print("\033[8m"); }; // -

// PRINTING
// use at own risk
// check if it works on your terminal TERATERM
void printLine() { print("\033[1i"); }; // ?
void startPrintLog() { print("\033[4i"); }; // ?
void stopPrintLog() { print("\033[5i"); }; // ?
*/


protected:
size_t write(uint8_t c);
Expand All @@ -162,7 +166,7 @@ class ANSI : public Stream
void colors4(uint8_t fgcolor, uint8_t bgcolor);
void color8(uint8_t base, uint8_t color);

Stream * _stream;
Stream * _stream;

// screen size parameters
uint16_t _width = 0;
Expand Down
78 changes: 78 additions & 0 deletions examples/ansiTestPrint/ansiTestPrint.ino
Original file line number Diff line number Diff line change
@@ -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.startPrintMode();
ansi.println(lorem);
ansi.stopPrintMode();
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 --
10 changes: 9 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ gray2color KEYWORD2
grey2color KEYWORD2
rgb2color KEYWORD2

#################################
# EXPERIMENTAL

deviceType KEYWORD2
Expand All @@ -42,14 +43,21 @@ getScreenSize KEYWORD2
screenWidth KEYWORD2
screenHeight KEYWORD2


set132columns KEYWORD2
set80columns KEYWORD2
moveWindowDown KEYWORD2
moveWindowUp KEYWORD2

printScreen KEYWORD2
setPrintingMode KEYWORD2

reset KEYWORD2

setSmoothScroll KEYWORD2
setJumpScroll KEYWORD2
printLine KEYWORD2
invisible KEYWORD2


# Constants (LITERAL1)
ANSI_LIB_VERSION LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ANSI.git"
},
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ANSI
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library to send ANSI escape sequences.
Expand Down
29 changes: 29 additions & 0 deletions supportMatrix.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit c209dd9

Please sign in to comment.