Half-Byte Serial Graphical Terminal

BLACK_6_5_2014 6_03_05 PMIn a previous post, I wrote of a dual screen Arduino set up. Using the Half-Byte Console and one of the early prototypes for the console, I wrote a simple terminal program that will allow not only ASCII data from the host, but also will interpret special commands to clear the screen, set or reset pixels, draw lines and boxes. Even at 9600baud (which, if you do not know, is pretty slow) the speed is more than adequate. This opens the door for some simple two player graphical games (remember, the console only has 1k available in Tiny Basic or 1.5k if you use the Arduino IDE) or want to display secondary game info on a second screen.

The current version lacks keyboard support, but that is coming as well as Nunchuck support. 

I am going to explore wireless connections as well. Either Bluetooth or the simpler NRF24L01 wireless transmitter/receiver combo.  The range of the NRF is decent and they are cheap enough.

The terminal is super simple and uses the TVOut library. Currently, for max use, I am using a resolution of 136 by 96 which yields about 32 characters wide by 16 lines down, using a 4 by 6 font (not the prettiest, but it works.)

Communications, via serial on the Arduino/Half-Byte Console, can be done via Tiny Basic’s ECHO, SPRINT and OUT statements.  SPRINT will display data on the screen. Anything you can do on the consoles main screen via PRINT, you can do on the serial screen.  In addition, using CHR, you can send the special commands via the SPRINT statement:

120 SPRINT CHR(26)

will clear the screen.

You can also use OUT:

120 OUT 26

Here is a complete list of commands to send:

Command: What it does:
26 Clear the screen
27 x,y Set the cursor position to x,y
28 x,y Set a pixel at x,y
29 x,y Reset a pixel at x,y
30 x,y,x1,y1,c Draw a box from x,y to x1,y1 either black (c=0) or white (c=1)
31 x,y,x1,y1,c Draw a line from x,y to x1,y1 either black or white (o or 1)

For commands that have parameters, send each parameter separately and without any delimiter. So, to draw a line from the top left to top right corner:

100 OUT 31: OUT 0: OUT 0: OUT 134: OUT 0: OUT 1

The 31 initiates the draw line command. The next four outs will set that start and end points and, finally, the last out will tell the terminal to light up the line. If that was a zero, the line would be erased.

I will be making the source code available for download soon. I am cleaning it up at the moment.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s