diff --git a/libraries/ANSI/CHANGELOG.md b/libraries/ANSI/CHANGELOG.md index 8baf85a7..928e2b21 100644 --- a/libraries/ANSI/CHANGELOG.md +++ b/libraries/ANSI/CHANGELOG.md @@ -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). diff --git a/libraries/ANSI/README.md b/libraries/ANSI/README.md index f35e3409..3b454ced 100644 --- a/libraries/ANSI/README.md +++ b/libraries/ANSI/README.md @@ -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 @@ -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 @@ -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. @@ -157,6 +155,39 @@ 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? +- **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 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. + ## Future #### Must @@ -175,6 +207,7 @@ Although it are small improvements these add up. - elaborate interface - colour info + #### Should - test experimental functions @@ -182,10 +215,12 @@ Although it are small improvements these add up. - 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. diff --git a/libraries/ANSI/ansi.cpp b/libraries/ANSI/ansi.cpp index 4da9e58e..b27df3f4 100644 --- a/libraries/ANSI/ansi.cpp +++ b/libraries/ANSI/ansi.cpp @@ -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 diff --git a/libraries/ANSI/ansi.h b/libraries/ANSI/ansi.h index 83484552..b1f25b1c 100644 --- a/libraries/ANSI/ansi.h +++ b/libraries/ANSI/ansi.h @@ -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 @@ -10,7 +10,7 @@ #include "Arduino.h" -#define ANSI_LIB_VERSION (F("0.3.0")) +#define ANSI_LIB_VERSION (F("0.3.1")) class ANSI : public Stream @@ -92,8 +92,13 @@ public: 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 @@ -119,16 +124,24 @@ public: 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"); }; // + @@ -137,20 +150,37 @@ public: // 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"); }; // - + void strikeThrough() { print("\033[9m"); }; // - (mobaXterm works) - // 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"); }; // ? - */ + + // RGB_COLOR + void setRGBforeground(uint8_t r, uint8_t g, uint8_t b) // - + { + print("\033[38;2;"); + 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: @@ -162,7 +192,7 @@ protected: 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; diff --git a/libraries/ANSI/examples/ansiDemo01/ansiDemo01.ino b/libraries/ANSI/examples/ansiDemo01/ansiDemo01.ino index c482fe68..6c8e2b08 100644 --- a/libraries/ANSI/examples/ansiDemo01/ansiDemo01.ino +++ b/libraries/ANSI/examples/ansiDemo01/ansiDemo01.ino @@ -88,6 +88,29 @@ void setup() delay(1000); 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..."); } diff --git a/libraries/ANSI/examples/ansiTestPrint/ansiTestPrint.ino b/libraries/ANSI/examples/ansiTestPrint/ansiTestPrint.ino new file mode 100644 index 00000000..36ec22fa --- /dev/null +++ b/libraries/ANSI/examples/ansiTestPrint/ansiTestPrint.ino @@ -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 -- diff --git a/libraries/ANSI/keywords.txt b/libraries/ANSI/keywords.txt index a972b82e..2736285f 100644 --- a/libraries/ANSI/keywords.txt +++ b/libraries/ANSI/keywords.txt @@ -33,6 +33,7 @@ gray2color KEYWORD2 grey2color KEYWORD2 rgb2color KEYWORD2 +################################# # EXPERIMENTAL deviceType KEYWORD2 @@ -42,14 +43,26 @@ 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 +strikeThrough KEYWORD2 + +setRGBforeground KEYWORD2 +setRGBbackground KEYWORD2 + # Constants (LITERAL1) ANSI_LIB_VERSION LITERAL1 diff --git a/libraries/ANSI/library.json b/libraries/ANSI/library.json index cb246e9c..b55397f9 100644 --- a/libraries/ANSI/library.json +++ b/libraries/ANSI/library.json @@ -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": "*", diff --git a/libraries/ANSI/library.properties b/libraries/ANSI/library.properties index 6c2aba33..964aa0a3 100644 --- a/libraries/ANSI/library.properties +++ b/libraries/ANSI/library.properties @@ -1,5 +1,5 @@ name=ANSI -version=0.3.0 +version=0.3.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library to send ANSI escape sequences. diff --git a/libraries/ANSI/supportMatrix.md b/libraries/ANSI/supportMatrix.md new file mode 100644 index 00000000..a6a4dada --- /dev/null +++ b/libraries/ANSI/supportMatrix.md @@ -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.