📜 ⬆️ ⬇️

Arduino terminal

Sometimes you desperately need a device that is not in any store. You can wait and hope that someday the manufacturers will release what you lack. You can lock yourself in the garage, stock up on pizza and beer - and in a dozen or two months, show Apple, a flying car or a super search engine to the world. And you can take the Arduino and make a device for a couple of weekends, without which you are like without hands. Personally, for the last six months, I categorically lacked a head-mounted display that would connect to a computer without wire strings. And I picked up the Arduino ...

Why do I need such an exotic device? I have been using a self-assembly wearable computer for several years For me, this is a working tool that gives me the opportunity to use the time on the road between home and office to work on my own projects. And 2 working hours 5 times a week are 2 * 5 * 52 = 520 working hours per year, or 520/40 / 4.5 = almost three full working months. Three months not divorced from family, weekends or sleep, but appearing "from nowhere." Only due to the fact that I can work on the road in any situation - at rush hour, on the go from the metro to the office, at midnight at the bus stop. In situations where the laptop does not use.

Naturally, in addition to the working tools, my NK (wearable computer) has gradually become overgrown with side functions - music playback, VoIP-telephony. Appeared head-mounted display. But to use it outdoors only for the sake of shocking others. Long, stretched from the head cover to a computer lying in the bag, clinging to all the wire with the adapter / battery / remote control hanging on it ... You don’t use this on the street, you need a wireless solution. I know about video adapters that appeared not so long ago and are able to drive video from a computer to a TV over WiFi (http://habrahabr.ru/blogs/hardware/80314/, ferralabs.ru/index.php?news=2989 ). But the prospect of placing a WiFi module at my own temple doesn’t particularly inspire me. On the other hand, many are now wearing a bluetooth-ear in the ear - and nothing, alive. Of course, you will not watch the video over bluetooth, but working with a text console is quite real. Since I work mainly under Linux, and the main one of my own projects is the development of “server software for NK”, I have more than enough console to work with.

In the alpha version of the device (which will be discussed below), I decided to somewhat simplify the task:
- temporarily abandon the bluetooth module (it will be easy to connect it later, and the creation of an autonomous power supply is transferred "for later");
- As a microcontroller board, use not the miniature Freeduino Nano or Arduino Mini, but the full-sized and excessively powerful Seeeduino Mega.
')
With the “iron component” everything turned out to be surprisingly simple. I bought a TellyMate expansion card. Connecting TellyMate to Seeeduino Mega took a couple of seconds. Everything! The iron part is ready!



It's time to briefly talk about what these very Seeeduino Mega and TellyMate are.



Seeeduino mega



Seeeduino Mega is an Arduino-compatible motherboard. I will not dwell on what Arduino is - I already wrote about it. I will cite only the characteristics of Seeeduino Mega in comparison with the Arduino Mega, redundant for this project:




Tellymate



TellyMate is an expansion card for Arduino, developed by British craftsmen . Allows you to display text on the TV screen on the usual composite output ("tulip"). TellyMate supports a subset of VT-52 terminal commands, provides a black and white image, the screen size is 38 * 25 characters. Allows you to store in memory from 1 to 11 font sets (depending on the model of the board). Each font set contains 256 characters with an 8 * 9 matrix. Any font set can be programmatically overridden. In this case, the redefined font is retained in the memory of the board even after shutdown. So, in addition to text, you can also display graphics using redefined characters.

Of course, the 38 * 25 black and white screen is not exactly what I would like to receive, but for the first version it is quite enough. The board is built on an ATmega8 microcontroller, open source (you can independently solder a similar device using the schemes laid out in the Internet). The text is displayed on the TV screen using standard Serial.print (), Serial.println () commands. TellyMate communicates with Arduino via a standard COM port - the one that Arduino communicates with a computer. Therefore, when the program is loaded onto the device, symbols start running on the TV screen.

Because of this, sharing the COM port for communication between the Arduin and the computer, and with TellyMate, I initially had doubts whether such a design feature would become an insurmountable obstacle to creating a terminal. As experience has shown, the fears were in vain, it all worked :)



If the assembly of the “iron” part took very little time, then I had to spend a couple of weekends on the software component. On my ASUS EeePC 901 netbook, Eeebuntu 3.0 is installed. Therefore, I used the standard Linux technique of working with pseudo-terminals (thank you so much LJ-user tzirechnoy for your help!). Launched on a laptop samopisny "terminal server", opens the pseudo-terminal and runs it bash. After that, it starts sending characters displayed on the pseudo-screen of the pseudo-terminal to my device via the virtual COM port. So far, the device communicates with the computer via a wired USB connection. When I replace it with a wireless bluetooth, I will have to make some changes to the program, but this will not affect much on the architecture.

In MS Windows, there are no mechanisms similar to Linux pseudo-terminals, so I still have to break my head over porting software under Windows. I have no experience in programming applications under Windows, so I will be grateful for advice on writing a similar program for Windows, as well as for advice in choosing a toolkit (free development tools are interested).

The source of the "terminal server": ardu-term.c

Write a program running on the device, it was much easier. But first, it is worthwhile to download the Cyrillic alphabet to the device - it is absent in the standard Tell-Mate firmware. I took the Press Start font, which was created and laid out for free use by a certain user with the nickname Codeman38, as a basis. Here is my version of the font, adapted for KOI8-R:



At first I made the font in accordance with CP-1251, but, finding out that there are no pseudographic characters in this layout, I redid the font for KOI-8R.

The next problem was loading the created font in shild. On the TellyMate developers site, you can download a program that loads the font in the memory of the device. There is also a link to a google application that allows you to create your own font. Honestly, by drawing the font in a graphic editor, I was too lazy to re-enter the characters in the Tell-Mei google graphite by the dots, so I had to analyze the font download application and parse the font data format. The first 256 bytes of font data are the top 8 pixels of all 256 characters. The next 256 bytes is the second from the top line of each of the 256 characters - and so on, up to the lowest, 9th line. I wrote a simple program on Processing , creating an array of data for the font on the font image: tv_img2font.pde . Why processing? Since I am writing for Arduino on the Arduino IDE , it is logical to use a closely related package for developing on a computer. To create the data for downloading the font, you need to enter in the text tv_img2font.pde the name of the file with the image-font and run the program in the Processing environment. A code (0x00, 0xAB, 0xC3, ...) appears in the output window, specifying the font. This code must be copied and pasted into the program to download the font.

The program loading the font in KOI-8R on Arduino: tv_font_upload.pde . In this version of the program the Cyrillic font I need is already registered. We connect our Arduino terminal to a computer, launch the Arduino IDE, compile this program in it and upload it to our terminal:



After downloading the font, it remains to load the software onto the device, which finally turns Seeeduino + TellyMate into a terminal: tv_terminal.pde (compile into the Arduino IDE and load onto the terminal).

Voila! Now you can use the TV or head-mounted display as a text console. And in order not to touch the laptop at all, to enter text let's take a bluetooth keyboard, for example, Nokia SU-8W .





Noticeable disadvantages of the system:
- Function keys and arrows do not work when running Midnight Commander.
- The “default” command line prompt is too long. To know how immediately after running bash, to force it to execute export PS1 = "\ u \ $" ...

It remains to finish:
- Replace the connection of the device to the netbook via USB to connect via Bluetooth.
- Make autonomous power for the device.
- Replace Seeeduino Mega with Freeduino Nano .

Source: https://habr.com/ru/post/96595/


All Articles