VT100 Terminal for HC2016

rear view ESP8266 VT100Well, I had to give it a go, didn’t I – porting the code for the cheap VT100-type serial terminal into the main ESP8266 home control software.

BOY was that difficult but… after 2 days of head-scratching – check out the home control manual in the source code repository for Home Control 2016 – this is classed as experimental as I’ve not thoroughly checked what interaction it has with other stuff and it uses up lots of precious port bits (GPIO 13,14,15,16).

However I have the terminal code up and running (minus baud rate controls… and the bottom line is now a general status line) and I have to say, fast doesn’t start to explain it.

As you can see in the image above, all we have here is the display with a slim ESP8266 board behind it – the FTDI you see attached to the back is merely there to provide 5v power and, erm, stand the unit up!!!

I need to separate the code out into C files – it was just an experiment about which I did not have high hopes so it is all inline – but as it develops I think it needs it’s own source files.

ESP8266 VT100 front viewI did some tests to see if how fast I could make it -  I’ve already optimised the SPI and character routines – the board will not operate at all under ESP8266 at the fastest SPI speed so that is probably a dead-end, I tried caching the ROM reads (which are 8 bits – meaning you have to read 32 bits at a time and select the right 8 bits.

Caching that info actually very marginally slowed things down – I tried all sorts, writing 16 bits at a time to SPI – and finally after being able to obtain no more speed improvements, I stopped – not sure why I needed any of this as it was already blazingly fast.  Now, writing an X to every location on the screen (that’s 1600 character writes) takes 330ms so that is 200us per character (5*7). I think that is fast enough for now. Clear screen is near enough instant and scrolling is instant.

See this demo video of the ESP8266 version – the 328 version isn’t  quite THIS fast but it is still fast.

https://www.youtube.com/watch?v=YXqLVmoyKPE

So I’ve made 4 commands in the HC2016 project

{ili_set:1}
The above will setup the display and make it available to accept data – once set the display will set itself up on power up of the unit.  Setting that command to 0 stops any data and from there on the display will NOT initialise on powerup.
{ili_text:"\e[35;40mHello there \e[32;40mmate\r\n"}
{ili_status:"All working exceedingly well"}
{ili_title:"\e[37;40mESP8266 Status Monitor"}

I may well change the first one – as it should be automatic on first use… and also It may be there’s a good use for a version without scrolling and the top and bottom lines – but for now that’s it.

Hence by firing serial or MQTT commands at the board, I can get stuff onto the display.  To monitor all MQTT traffic was easy – over to the Pi and MQTT..

In Node-Red – a simple MQTT node picks up all traffic, passes it to a function – which then passes the result to the board which in this case is called “thisone”.

tmpPayload=”  “ + msg.payload;
tmpTopic="
\\e[36;40m"+msg.topic+"\\e[32;40m\r\n";
if (msg.topic!="thisone/toesp")
{
msg.topic="thisone/toesp";
msg.payload="{ili_text:\"" + tmpTopic + tmpPayload + "\r\n\"}";
return msg;
}

DisplayHence the board gets all traffic except for traffic destined for the board (which could end up in an infinite loop).

And now thanks to a conversation with reader Bob Green –  a WIFI signal strength (RSSI) indicator for the board and the time in the bottom left. I deliberately left the seconds out as this would typically not be refreshed that often – maybe every couple of seconds...

Bob suggested that by plugging the board into a battery pack you have a simple range tester and he’s absolutely right of course. Now, how to teach it to make coffee…

On the subject of terminals

No need to talk about VT100-type terminals for PCs – they’re coming out of our ears – but…

Android

I’d put this all together and I thought…an 80 line or 132 line version of this would be nice – I’ll put one on my Android phone. Well, you may well write in and tell me I’m wrong but I cannot find a VT-100 compatible serial modem for Android anywhere (I did find one but it was not clear if scrolling regions worked and it had a limited range of serial settings). Surprising considering that it can be done on a  relatively simple unit like the ESP8266

Linux

And that led me to Linux - or rather - I was thinking about the various single board computers I have lying around - a Pi would do but I have a rather nice FriendlyArm NanoPC T2 which was not quite fast enough for Android but runs a nice Debian.  I started looking for fancy graphical terminals - not a lot - nothing to anywhere near TOUCH some of the stuff on Windows - however I had this T3 with a little 7" LCD touch screen lying around and was determined it would not go to waste.

It turns out that the humble LX terminal does at least some VT 100 - but that pulls up a command line and lets you interact with it  -was there any way to get it to talk to serial instead - preferably one of it's own rather than a USB serial as it has FOUR serial ports on it.

Well, yes. I discovered this..

cu -l /dev/device -s baud-rate-speed

It looked as if this would let me use the terminal with serial instead of a keyboard- but of course when I tried it using:

cu -l /dev/ttyAMAT3-s 115200

I got zilch. The system didn't have a clue what CU is (neither did I for that matter).

Anyway, just for a laugh I tried SUDO APT-GET CU

And it worked. I tried again. THIS time all was well - but it could not contact the serial port - as it was "busy" - yeah right.

I added user FA (the user in control of that terminal session) to the relevant group - no difference - so as is often the case I just gave 777 permissions to the serial port and VOILA.

Terminal on Debian running serial

I tested some colour escape sequences from my PC Serial Terminal I wrote some time ago (and just recently updated to let me put ESC in there) and all worked well but for some visible representation of the ESCAPE sequences (which still worked). I continued experimenting and the UX terminal that comes with Debian LDXE does not suffer that particular issue – so it has the job!!!

Facebooktwittergoogle_pluspinterestlinkedin

25 thoughts on “VT100 Terminal for HC2016

  1. Nice Job Peter. I have an ESP12 linked to a similar display with SPI using Arduino / ESP and standard libraries. It's brilliant for testing MQTT and for range testing. Powered by the Ravpower I can move it around and check that I can receive the MQTT messages. I have been using it for months and it works flawlessly.

    1. Done - bottom right of status line - -xxdb
      I need to make one of those little indicators they have on Android phones to show the signal strength - that would be better. Looking at it, white rectangles and grey - but what signal strength to attach to each bar... hmmmm.

        1. Right chaps - refresh browsers and take a look at the end of the blog entry.... I'm quite chuffed with this.. thanks Bob. Oh, -55db to -95db works REALLY well as an indicator - so at -95 there is only one bar left on - shortly after that I lose signal... and bearing in mind my software has dual SSID capability - I may well put some kind of indication to say which one is in use...

    2. Right- went off range testing and -45 seems to be a very GOOD signal and much after -95db the board loses the plot (I took your lead and plugged it into the RavPower - what a good idea). So I reckon 10px high, 8px, 6px,4px and 2px - all by 2px wide with 2px in-between - at maybe <-50, <-61, <-72 <-83 <94 should make for a pretty good phone-like signal strength indicator...

  2. Why not use the standard Wi-Fi RSSI symbol of a dot with concentric arcs of circle figuring RF waves above it?

    The "staircase" style RSSI is more dedicated to the cellular network, is it?

    Just to avoid confusion.

  3. Peter, actually I like the staircase version as it is easy to see at a glance. Probably takes less coding / code space than concentric circles as well. I originally made my unit so I could leave it running and see MQTT traffic without having to leave the PC running with MQTT-Spy.

    1. Yup, I'm leaving it in - and that is just what I'm using it for - next challenge - a bezel or neat non-amateur looking case... I put the time on and there's room for more. and no I don't have a 3d printer 🙂

      Interestingly I've just spent HOURS tackling putting a new font in and had issues - turns out they were because I don't (didn't) disable interrupts around the code to grab fonts from FLASH - I'm guessing an issue with the internal SPI - anyway - resolved - will update code tomorrow as soon as I figure out why my 16 bit retrieval doesn't work (8-bit does)... so I can add an option for 16*16 chars for static displays... whole host of fonts using the same format is the reward for getting it working. Most likely in the morning.

      1. Peter, just ordered from the link in the other blog post, the italian link i gave you a few days ago... now let's wait for shipment, as soon as it arrive i'll make a box and publish on thingiverse... can you publish a little schematic of how you attached the esp8266 on the back? A better back photo maybe could help, too... maybe even without the lcd itself i can make a 3d model, if you send me the measurements... let me look online if i found something, keep in contact this evening... i imagine you'd like to leave a little space on the back for better air flow, and for ftdi connection... in the end it should have only a battery to power it, or a side power socket, maybe... mmm... many ideas... publish other if you'd like... maybe a small lipo with microusb charger, so to have it independent and not carry around a powerbank? mmm... mumble mumble 😀

  4. I like this a lot. Especially the RSSI.

    Your comment about the bezel / non-amateur case is a subject that a lot of my projects fall foul of with 'she who must be obeyed'.

    I think that manufactures of iOT boards could make a killing if they made cases for their stuff as well. I'd certainly buy a case with a board. Even a case for something simple like an ftdi board would be useful.

  5. Great Work !
    Do you think there is a chance to get an ESP8266 to serve this VT100 screen on a webpage ?

    I would love a universal frontend to bring serial port data to a webpage with at least some basic VT100 functions

    This should enable almost any client with a web browser to view the formatted serial data

    1. Hi there

      Getting this working on a web page would be a completely separate project. The code is designed to fire off to a video controller. The idea is that you would buy one of these very cheap displays and use that for debugging instead of a PC. If you want a VT100 display on a bigger screen why not just use the VT100-kind-of-compatible serial terminal on any old Linux computer - like the VERY cheap FriendlyArm NanoPi NEO - or a Raspberry Pi. The CU program lets that take it's input from serial.

      1. Peter,
        you are right - for just a bigger screen this suggestion is perfectly ok

        However, I would like to "decouple" the screen from the serial port
        and have a cheap standard frontend to different embedded systems

        A VT100 as a webpage would allow to use almost any client from any location, without any special client SW Terminal app
        All the available terminal apps have various dialects and glitches

        Locally it could be i.e. a cheapo Android tablet acting as screen
        Remotely any smartphone or tablet

        I looked for possible solutions and found some Javacode to emulate a VT100,
        but my programming skills are rather oldfashioned (VAX & PDP11 Machinecode...)
        - so I have no real clue how to put this on a ESP8266

        I just hoped that you eventually have some idea, how to achieve this

        cheers
        Guenter

        1. See elsewhere on the blog. Any old or PC using Linux. The standard terminal is partly VT100 compatible... and a program called CU can be run to redirect keyboard to serial and serial to the screen hence making a handy serial monitor.

Leave a Reply

Your email address will not be published. Required fields are marked *