From c209dd991631f9bea468c0bd726eaf12883749f3 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Mon, 13 Nov 2023 12:02:45 +0100 Subject: [PATCH] add experimental code --- CHANGELOG.md | 9 +++ README.md | 46 +++++++++++--- ansi.cpp | 2 +- ansi.h | 34 ++++++----- examples/ansiTestPrint/ansiTestPrint.ino | 78 ++++++++++++++++++++++++ keywords.txt | 10 ++- library.json | 2 +- library.properties | 2 +- supportMatrix.md | 29 +++++++++ 9 files changed, 186 insertions(+), 26 deletions(-) create mode 100644 examples/ansiTestPrint/ansiTestPrint.ino create mode 100644 supportMatrix.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 8baf85a..928e2b2 100644 --- a/CHANGELOG.md +++ b/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/README.md b/README.md index f35e340..653c5ee 100644 --- a/README.md +++ b/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,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. @@ -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 @@ -175,6 +204,7 @@ Although it are small improvements these add up. - elaborate interface - colour info + #### Should - test experimental functions @@ -182,10 +212,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/ansi.cpp b/ansi.cpp index 4da9e58..b27df3f 100644 --- a/ansi.cpp +++ b/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/ansi.h b/ansi.h index 8348455..6facc30 100644 --- a/ansi.h +++ b/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 @@ -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 @@ -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"); }; // + @@ -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); @@ -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; diff --git a/examples/ansiTestPrint/ansiTestPrint.ino b/examples/ansiTestPrint/ansiTestPrint.ino new file mode 100644 index 0000000..103a58c --- /dev/null +++ b/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.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 -- diff --git a/keywords.txt b/keywords.txt index a972b82..8ff6ad1 100644 --- a/keywords.txt +++ b/keywords.txt @@ -33,6 +33,7 @@ gray2color KEYWORD2 grey2color KEYWORD2 rgb2color KEYWORD2 +################################# # EXPERIMENTAL deviceType KEYWORD2 @@ -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 diff --git a/library.json b/library.json index cb246e9..b55397f 100644 --- a/library.json +++ b/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/library.properties b/library.properties index 6c2aba3..964aa0a 100644 --- a/library.properties +++ b/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/supportMatrix.md b/supportMatrix.md new file mode 100644 index 0000000..a6a4dad --- /dev/null +++ b/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.