Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use enum deviceTypes instead of int #22

Closed
wants to merge 7 commits into from

Conversation

chlordk
Copy link
Contributor

@chlordk chlordk commented Nov 11, 2023

Auto Format is done with Arduino IDE 2.2.1

@RobTillaart RobTillaart self-assigned this Nov 11, 2023
@RobTillaart RobTillaart added the enhancement New feature or request label Nov 11, 2023
@RobTillaart
Copy link
Owner

I don't know what the effect will be if the terminal returns a value that is not in the enum.
This might differ per compiler (needs investigation) so I prefer to keep using the integer values.

Same as with the ansi colors, defined enums for readability but just using ints to keep it straightforward for the average user.

@hanschou
Copy link

Fine with me. Just reject.
The "enum" is often a long discussion I seldomly want to participate in :-)
When I wrote:

type = deviceTypes(buffer[2]);

it was actually the wrong way to do it as only '1','2', and '3' was valid and any other UNKNOWN.

@RobTillaart
Copy link
Owner

@chlordk
For now I leave the PR open as I want to investigate if the idea of using the enum deviceType (which is good) can be made understandable for the beginning Arduino user somehow. I would really like to test it with an original VT100 I used eons ago.

If you have more ideas to improve the library, just let me know!

@chlordk
Copy link
Contributor Author

chlordk commented Nov 13, 2023

Oh, you got a original VT100? A physical one? That's cool.

I have two ideas:

  1. Extended RGB colors
  2. Logfile/printing

RGB colors
Some modern terminal emulators can take 24bit RGB color code. If you see this on read background it is working: echo -en "\e[48;2;255;0;0m-\e[m".
Fade test: for ((r=0; r<256; r+=3)) ; do echo -en "\e[48;2;${r};0;0m-\e[m" ; done ; echo
It does not work on a VT100 but if you know what a VT100 would write on the screen when it doesn't work then this could be used for a "full feature test demo". Like "if you see this garbage on the screen it doesn't work".

Logfile
This is not really an application feature more a way of doing things.
In TTY mode all new data is added to the bottom of the screen. If one want to log all data the terminal emulator can be put in log mode so all data would be written to a file. This will not work in full screen ANSI mode.
In ANSI mode one can setup the terminal emulator to switch between Transparent or pass-through printing (slave printing) and screen printing with the "\e[5i" to switch on and "[4i" to switch off.

Run this script when running PuTTY:

#! /bin/bash
cat <<EOF
In PuTTY click upper left corner
-> Change Settings...
-> Terminal (in left  side)
-> Remote-controlled-printing
and select "Microsoft XPS Document Writer".
Click [Apply]

In Windows find the file in the user "Documents" directory
(C:\> dir %USERPROFILE%\Documents).
The filename is:
"PuTTY remote printer output.oxps"

This is ANSI mode.^[[5iLine 1 in printing mode.
Line 2 in printing mode.^[[4i Back to ANSI screen mode.
EOF

The above will create one new file each time.

History
The physical VT100 terminal was connected with a RS232 cable to the server. If one wanted to have a printer next to the terminal either a cable had to be drawn from the server and using an extra serial port or the printer could be attached to the back of the VT100. Then the user could send the \e[5i command to the terminal and all data would now be passed through to the printer. During the printing the terminal could not be used and with a slow printer this could be a bit annoying.

@RobTillaart
Copy link
Owner

Oh, you got a original VT100? A physical one? That's cool.

No the opposite, I wished I had.
Worked with them in the past and they were very nice, silent good keyboard and yes a burnt in display.
Seen some for sale on the internet for too high prices several years ago. Maybe I should take a look again.

Will look into the ideas later, some other projects have prio

@RobTillaart
Copy link
Owner

@chlordk
The ANSI.h file has some commented lines for printing, these are minimal tested.

Should be renamed to (what is best)

  • startPrintingMode() + stopPrintingMode() << think I prefer this
  • screenMode() + printMode()

@chlordk
Copy link
Contributor Author

chlordk commented Nov 13, 2023

How about

ansi.setPrintingMode(true);

Then it is just:

ANSI::setprintingMode(bool on) {
  print( on ? "\e[5i" : "\e[4i");

@RobTillaart
Copy link
Owner

Created a develop branch with all experimental code enabled, including setprintingMode()
and an initial version of supportMatrix.md

Back to my other projects...

@RobTillaart
Copy link
Owner

RGB colors
Some modern terminal emulators can take 24bit RGB color code. If you see this on read background it is working: echo -en "\e[48;2;255;0;0m-\e[m".
Fade test: for ((r=0; r<256; r+=3)) ; do echo -en "\e[48;2;${r};0;0m-\e[m" ; done ; echo
It does not work on a VT100 but if you know what a VT100 would write on the screen when it doesn't work then this could be used for a "full feature test demo". Like "if you see this garbage on the screen it doesn't work".

This could be interesting to add a function for under experimental.

@RobTillaart
Copy link
Owner

@chlordk

Sorry for the inconvenience, I have other priorities to attend so some things including this PR is delayed.

wrt the RGB functions, I added these two in the latest release, and as I do not want to get into "enum trouble" I close this PR.
Keep proposing your ideas as I hope to find time again soon.

  • void setRGBforeground(uint8_t r, uint8_t g, uint8_t b)
  • void setRGBbackground(uint8_t r, uint8_t g, uint8_t b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants