Introduction: MRETV - Video, Stereo Sound and Much More From a Standard Arduino !

About: I learned to program in Sanskrit at the School of Hard Knocks.Later I home schooled myself in the new 'Morse' coding language. My teacher liked donuts.

MRETV - Video, Stereo Sound and much more from a standard Arduino !

Now Updated for Arduino 1.6.6 November 2015 !

Use only two resistors and two diodes to generate full screen video. Text 47 x 29 of 8x8 characters, double the vertical resolution (47x57) in experimental interlace modes. Use pixel level graphics with a virtual graphics coprocessor controlling font, screen resolution, vertical and horizontal centering, raster index and pixel size with single scan line resolution. ASCII read and write access of screen characters, screen print strings, decimal, hex or binary. Built in simple scrolling terminal service. Video generation has been done before, but not like this. FULL DUPLEX serial still available while generating video.
Two more resistors and two capacitors will add Stereo playback of Audio samples. One shot or continuous operation. Sound samples are used in real time from progmem and a sound sequencing example is provided. Both Audio and Video are generated automatically in the background with no intervention once started.
Two more resistors and you can now connect a PS/2 keyboard or mouse (the kind before USB). Read raw key input or ASCII chars, let keys merge into the serial stream automatically. Set the keyboard LEDs and send commands to control mouse reporting.
Code examples include Ponguino, a simple terminal, a player piano, a ShootEmUp, use your Arduino as an external video card and some technical examples. Too good to be true? Watch the video then grab your soldering iron!

Step 1: Introduction

Now Updated for Arduino 1.6.6 November 2015 !

What is MRETV ?

MRETV is a few very simple circuits and a simple to use software interface that allows an Arduino to generate Video and Stereo Sound in the background while your sketch executes as normal. Your Arduino plugs directly into the A/V inputs of your TV, VCR, or projector. MRETV also has built in support for other peripherals like keyboards and mice.

Which Arduino's does MRETV work with?

MRETV has been tested and works with Arduino boards using 168, 328, and 2560 CPU's. With the Mega 2560 software serial Tx has a small hardware limitation.

Who can build MRETV?

Any Arduino user. Even if you have never built hardware before, the audio and video circuits are so simple they make a perfect first project. People with moderate experience can build them in about 5 minutes, and probably already have the parts.

How easy is it to program with MRETV?

You can set a string, make 1 function call, and the string shows on your TV. Changing the contents of the string changes the text showing on your TV (in real time without calling any function.)

Why use MRETV ?

An Arduino user interface often involves a few buttons or switches. Indicators commonly range from LEDs to 80 character displays. These can be a large part of the time and cost in a build. MRETV replaces these with a screen of 1 to over 1000 characters, stereo sound and a full PC keyboard. It can be built quickly and cheaply using only 6 resistors 2 diodes and 2 capacitors in total for all 3 circuits (video / stereo audio / keyboard).

What resources does MRETV use ?

The smallest footprint is about a 1.5k sketch using about 35 bytes of RAM, including interrupt stack use, plus 1 byte of RAM for each character location on screen (1 or more locations). The screen character space can be dual purposed. Video uses an 8 bit timer and two IO pins. Audio uses an 8 bit timer and two IO pins. The software serial Tx stream is provided on another IO pin if needed (Rx works on the standard pin). CPU usage varies with visible screen area but is self limiting about at about 80%. A small active screen uses under 10% of the CPU cycles, with a large screen plus audio around 50% is common. Key library structures and routines are redefined each compile for efficiencies. MRETV can be turned on and off ( 0% CPU).


I have truly enjoyed reading about, constructing, and learning with Instructables. I want to take this opportunity to thank all those who have shared with me, and those who made the sharing possible. You have solved my problems, fed me, inspired me, and shown me how to do what I thought was impossible. As part of that thanks I offer the MRETV debut to the Instructable community.

This Instructable is a Build and Introduction rather than an exhaustive explanation of MRETV. You will quickly have both sound and video from your Arduino. You will have some games to play, and some useful utilities. More importantly you will have a full featured library to use sound, video and more in your own sketches. If there is interest future tutorials on the software interface are possible, it has more depth than can be explored here. Since even this build and introduction covers a lot of material, I suggest you first make the video and sound circuits then take a break and spend some time with the software examples. You can use a terminal program like 'Putty' to explore until you build the keyboard (PS/2) circuit. After making the keyboard circuit you will have all the major parts of MRETV (to use examples like Ponguino and Diode Calibration you need to build some sensors.) Please do not redistribute this Premiere Release of MRETV yet, wait till the bugs become documented features.

I have tested many versions of this project connecting to many different devices and never caused any harm to the Arduino or the other device. Most TV's hold the MRETV signal much better than the capture card I used to make the videos. Due to its simplicity, most of the time, newly built MRETV hardware works the very first try. However ...

Build and use at your own risk. I assume absolutely no liability of any kind for anything you ever do related to MRETV.

Go ahead and watch the second video then let's get building.

Step 2: Video

Supplies for all steps:

soldering iron
shrink wrap or electrical tape
sharp knife
male and female headers (that plug into the Arduino)

Safety for all steps:

This list may seem trivial but making it was a sobering experience for me. It might be a gentle reminder for others as well.

Don't wear loose clothing, and tie back long hair
Wear eye protection for the whole build, solder 'spits' and snipped wires fly around
Work in an uncluttered, well lit, and well ventilated space
Be careful while using and storing sharp knives and tools
Don't touch the tip of the soldering iron or the element (never below the handle)
Keep a wet sponge or rag to clean your soldering iron frequently, and never hold it in your hand
Use vice grips, pliers and a rubber band, or similar, NOT YOUR FINGERS, to hold parts while you solder
Do not lean into the fumes from the soldering, a small desk fan can direct air flow
'It should be cool enough ' means to wait longer before you touch
Keep track of the sniped ends of wires, they are very bad for people and electronics
Don't leave wires exposed in your circuits, be generous with shrink wrap or tape
Don't leave even cold irons within reach of young children, be careful about the cords
Wash your hands and clean the area after soldering
Don't leave the spoon in your coffee

A short time spent setting up comfortably at the start, and for each solder joint, may be the best safety measure. It also is often quicker in the long run.


resistor 1k ohm
resistor 300 ohm
diode 1n4148 (x2) or similar silicon switching diode
RCA plug female (or male with long lead)
male header 2 pin
male header 1 pin


You may wish to construct the sound (next step) and video circuits at the same time.
Look at the pictures and make it your own way or
Solder the end of a diode with the stripe to one of the resistors. Repeat with the other diode and resistor.
Solder the free ends of the two resistors and the center lead of your RCA plug together.
Solder a lead to the free end of each diode to attach to Arduino pins 1 and 2. Using shielded cable is good practice but I do not notice a difference when I don't.
Solder a lead to the ground of the RCA plug to attach to the Arduino ground.
You can now connect your Arduino to almost anything with a (usually yellow RCA) composite VIDEO IN such as TV's, VCR's, projectors and video capture cards. I sometimes use the second screen of a two screen car DVD player.

Mega 2560:

Use Arduino pins 1 and 19, use male header 1 pin (x3)


Download the
Please do a manual Install (rather than from the Arduino menu)
Close ALL Arduino windows
Copy the MRETV folder to Arduino\libraries
Copy the MRETV-examples folder to Arduino\Examples

Please read the opening of the Arduino\libraries\MRETV\ReadMe.txt before trying the examples to ensure the install goes well.

Tradition dictates you enter and run the following sketch (found in the examples folder.)

#include "MRETV.h"
#include "textfont.h"

mystring[]="Hello world";
void setup(){
void loop() {}

Adjusting the TV:

Turn the color setting as low as possible then adjust the brightness and contrast to your liking.


Instead of turning down the color, it is possible to connect MRETV to luminance on a S-Video connection. This avoids color adjustments and achieves a very clear signal. My new friend Ugifer, that I just met here on Instructables, pointed this out. It was too good an idea not to add right away. I made a small cable to adapt from RCA to S-Video and added the pictures to this step. This allows flexibility as some brands of TV do not have S-Video connections. Thanks again Ugifer!


Some of the MRETV examples are a simple demonstration of basic use, others will be more complicated showing special abilities. Later in this Instructable you will learn to program with MRETV so don't worry about understanding every example right now.

SimpleDisplay.ino - bare bones I/O, add to your existing projects
TVText.ino - the Arduino as an external video card
TestPattern.ino - a zigzag test pattern, full screen video about 1.5k (set special extensions)
Bounce.ino - a moving test pattern and bitmap graphics example (set special extensions)

Step 3: Sound


resistor 1k ohm (x2)
capacitor 1uf (x2)
RCA female (or male with long lead) (x2)
male header 2 pin
male header 1 pin


You may wish to construct the sound and video (previous step) circuits at the same time. A good time is now.
Again, the pictures may say it best.
Solder a resistor and capacitor to the center lead of an RCA plug. Repeat with the other RCA plug, resistor and capacitor.
Solder a lead to the free end of each resistor to attach to the Arduino pins 5 and 6.
Solder the free ends of the two capacitors and the two grounds for the RCA plugs together. Solder a lead to attach to the Arduino ground to this same point. This point can be attached to the of the video hardware ground to share a single ground connection.

Mega 2560:

Use Arduino pins 4 and 13, use male header 1 pin (x3)

Software Examples:

Arudion.ino - player piano, sound generation and sequencing 'Dammit Jim, I'm an Example not an EPod!' (set special extensions)
ScreenTool.ino - a full function utility for MRETV, use the MRETV keyboard or a terminal program like 'Putty' to connect (set special extensions)
Ponguino.ino - it has sound, let's build more hardware so we can play (set special extensions)

Step 4: PS/2 Keyboard - Mouse Port


resistor 1k ohm (x2)
PS/2 keyboard with round 4-6 pin connector
male header 6 pin
male header 1 pin
Optional Parts:
female and male header 4 pin
PS/2 female socket
small unclad circuit board or similar prototype material
PS/2 mouse with round 4-6 pin connector


You are probably using an older keyboard or mouse so make sure they work properly BEFORE you rework them. Cutting the keyboard cord is fast and works. Leave a few inches on the plug end so it can be reconnected for testing if needed. A PS/2 socket is hard to find, I cut an old keyboard extension to get mine. I like to make a small board to translate the Arduino pins to the 4 PS/2 lines allowing me to swap between different mice and keyboards easily. The keyboard port builds are all similar and easily done using male header pins (or female if using the ICSP) .

connect pin 10 through a 1k resistor to ground
connect pin 9 to pin 13
connect pin 9 through a 1k resistor to Vcc
connect the keyboard/mouse Vcc to 5 volts
connect the keyboard/mouse clock line to pin 9
connect the keyboard/mouse data line to pin 11
connect the keyboard/mouse ground line to ground
pin 12 is unused

4 of these 6 connections are available on the ICSP header of the Arduino. It may be useful to use it rather than the standard pins.

Mega 2560:

For the 2560 pin 53 replaces 10, 11 replaces 51, 52 replaces 13, 10 replaces 9 . Use male header 1 pin (x4) , male header 2 pin (x1). An alternate schematic is provided.

Software Examples:

TVText.ino - the Arduino as a terminal
ShootEmUp.ino - classic style game, character cell animation example, arrow keys act as a virtual joystick (set special extensions)(328 /2560 only)
Ponguino.ino - use 'j' to turn on joysticks, wasd keys act as virtual joystick2, paddles would be better (see sensors) (set special extensions)
KeyboardTool.ino - ScreenTool was preschool, way under the hood (set special extensions)
Bounce.ino - more patterns and features accessible from keyboard. (set special extensions)
Arudion.ino - keyboard organ and new features accessible from keyboard. (set special extensions)

Step 5: Software Interface

MRETV is as easy to program as it is to build, so this will be kept short. The following three examples will help you start using MRETV in your own work. They are included in as SoftwareInterfaceExample.ino . It is best to use a terminal program to connect to MRETV for testing input (rather than the built in serial monitor in the Arduino environment.)

There are 3 steps to using MRETV in your sketches.

1. include the parts
2. begin() output [and input]
3. update information

Using Video in a sketch:

//1. parts
// MRETV itself
// a font, default fontheight is 8
uchar Screenbuf [20 * 20]={
" Use a string here to set your initial display"}; // some place to put display data, 20 rows of 20 characters

// 2. begin
void setup(){
Screen.begin(textfont,Screenbuf, 20*fontheight,20,20,20,1); // start video output
// (font, buffer, ScreenHeight (pix), ScreenWidth (chars), top (pix), left (pix), mode) top and left are centering, mode=1 for normal text

//3. update screen
volatile uint a,depth=0;
void loop(){
for(a=5000;a;a--);// slow us down
Screen_progstr(8,0,"Speed "); // update information as needed
Screen_progstr(11,0,"Depth ");

Using Sound in a sketch:

Remember the 3 steps.
1. include the parts
2. begin() output
3. update information

//1. parts
// MRETV uses a special file Arduino\libraries\MRETV\MRETV.extensions to hold information about extended functions
// like sound generation. (To know why see the expert section.) To use sound you need to define an Audio type , we will
// '#define monoaudio' in this file. (see the 'default_extensions' in MRETV.extensions now.)

// MRETV itself
// a font, default fontheight is 8
#include "saw.h" // some sound samples
PROGMEM const char * sounds [] = { // optional array of sound samples, must be called 'sounds[]' and in progmem.
uchar Screenbuf [20 * 20]={
" Use a string here to set your initial display"}; // some place to put display data, 20 rows of 20 characters

// 2. begin
void setup(){
Screen.begin(textfont,Screenbuf, 20*fontheight,20,20,20,1); // start video output, sound is enabled at the same time
// (font, buffer, ScreenHeight (pix), ScreenWidth (chars), top (pix), left (pix), mode) top and left are centering, mode=1 for normal text

//3. update screen
volatile uint a,depth=0;
void loop(){
for(a=4000;a;a--);// slow us down
Screen_progstr(8,0,"Speed "); // update information as needed
Screen_progstr(11,0,"Depth ");

//3. update sound
if (!(depth&0x07f)) switch(depth/0x80){ // beep now and then
case 1:
ssample(sawBo4,50); // play a sample directly (sample, duration (1/60sec) )
case 17:
if( (depth/0x80)>5) setaudio((depth/0x80)-6,15); // play a sample from the array (sample, duration (1/60sec) )

Using Input (Keyboard and/or Serial Rx) in a sketch:

//1. parts
// in 'Arduino\libraries\MRETV\MRETV.extensions' we will
// '#define monoaudio'
//'#define firmwaremultiport // keyboard and serial
// #define translatekeys // no rawkey up/down stuff
// #define mergstreams // handle both together

// MRETV itself
// a font, default fontheight is 8
#include "saw.h" // some sound samples
PROGMEM const char * sounds [] = { // optional array of sound samples, must be called 'sounds[]' and in progmem.
uchar Screenbuf [20 * 20]={
" Use a string here to set your initial display"}; // some place to put display data, 20 rows of 20 characters

// 2. begin
void setup(){
Screen.begin(textfont,Screenbuf, 20*fontheight,20,20,20,1); // start video output, sound, keyboard and serial extensions
// (font, buffer, ScreenHeight (pix), ScreenWidth (chars), top (pix), left (pix), mode) top and left are centering, mode=1 for normal text

volatile uint a,depth=0,Speed=56;
void loop(){
uchar chin; //character in from serial/keyboard stream
for(a=4000;a;a--);// slow us down

//3. update incomming information
switch(chin=Video.readS()){ // a character from serial (with keyboard merged)
case 0: // no character received from input
case 's': // s from input
case 0x0d: //
from input

//3. update screen
Screen_progstr(8,0,"Speed "); // update information as needed
Screen_progstr(11,0,"Depth ");

//3. update sound
if (!(depth&0x07)) switch(depth/0x8){ // beep now and then
case 1:
ssample(sawBo4,50); // play a sample directly (sample, duration (1/60sec) )
case 17:
if( (depth/0x8)>5)setaudio((depth/0x8)-6,15); // play a sample from the array (sample, duration (1/60sec) )

Step 6: Sensors


  diode (x4) almost any, 1n4148 is fine
  resistor  10k ohm (x4)
  male header  2 pin (x4)
Optional Parts:
  resistors  10k 20k  ohm
  digital thermometer 0-100 c
  stiff wire
  toilet paper ( a few sheets )
  salt or sugar ( a few grams )
  variable resistor about 5k ohm linear (x2)
  CDS photo sensor
  male header 2 pin (for each sensor)


 You should read the next step (sensor management expansion) before building any sensors.


 Connect a 20k resistor to the center of a 5k variable resistor. Connect a lead from the other end of the (20k) resistor to 5 volts. Connect a lead from one end of the variable resistor to ground. Connect the center of the variable resistor with a lead to analog 1. Do it all again with new resistors but connect to analog 2. The 'j' key turns the analog input off and on in Ponguino. NOTE: analog input 1 and 2 ( not 0 and 1) Have fun!

 Which sensors you build depends on where your interests are, but I suggest you make at least one diode and try the calibration sketch.
  For most sensors simply connect a pair of leads and a two pin connector.
  The temperature sensors (thermister and diode) can be coated with clear nail polish and lots of shrink wrap as they may get wet.
  The two long wires have several inches of insulation removed. One is wrapped in half of the toilet paper. The other wire is placed beside it and the pair are wrapped in the rest of the toilet paper. Hold in place with a small amount of tape. Wet completely with a strong water solution of sugar or salt and let dry. After drying you may need to replace the tape. It is now a moisture sensor whose resistance changes several orders of magnitude with a single drop of water.
  A CDS photo cell can be found in a dollar store automatic night light. 
For the variable resistor only use two leads, the center and one end.
For the voltage divider (the two resistors) connect 3 single pin connectors. Simple as it is, monitoring the supply voltage allows the greatest accuracy from your other sensors.

Using Sensors:

  Each sensor is connected between ground and an analog input pin. It tries to make the analog input 0 volts. A matched resistor connects the same analog pin to 5 volts. It tries to make the analog input 5 volts. In the inevitable battle between good and evil the input ends up somewhere in the middle. A matched resistor is one 4-5 times the maximum resistance of the sensor. This puts the analog input between 0 and 1 volt, a range the Arduino measures very accurately. Using several sensors requires more connections than can be made directly to the Arduino board so see the Sensorbatorium (sensor management expansion) in the next step.
  A CDS photo cell not only tells you how bright it is outside but if you left the light on in the basement or if the fridge door is open. A diode temperature sensor can tell you the freezer or fridge is broken and is accurate enough to raise dough, make beer and wine or bottom heat your seed beds. Water leaks under sinks, in attics and basements and burst hot water tanks all cost more if not found early. See the status of your home / wine / greenhouse / kitchen / garage just by selecting one of those (previously unused) A/V inputs on your new 308 inch flat screen TV. You can power your Arduino by plugging its USB cord into the USB port on the TV. This is a good way to play Ponguino or power projects that do not need to run all the time as the USB port on the TV usually looses power when the TV is off.

Software Examples:

  Ponguino.ino - childhood revisited (set special extensions)
  KeyboardTool.ino - the analog pins readings are on the far right (set special extensions)
  Time to start planning your home monitoring system.

Step 7: Sensorbatorium


  Sensorbatorium - the term comes from the Latin 'the end of my old hard drive cable'. You want the one with 40 holes and 40 wires, count them both. It also is a good source of wire for use in your projects.
  male header  6 pin
  male header  1 pin (x5)


  Cut a connector off leaving a tail of about 6 inches connected.
  Separate the first 3 inches of each of the 40 wires. Try a sharp knife, or needle nose pliers, or your finger nails if they are long enough. If you have never worked with ribbon cable before practice on your scrap end first. It gets easier with practice.
  Remove the insulation from about 1/4 inch of each wire.
  Refer to the pictures. Gather all the wires connected to holes marked 0 together and connect them to the end of the 6 pin connector. Using an extra small wire may make this easier. Then do the 1's, 2's ... 5's. Use your multimeter to check you have the right wires BEFORE soldering.
  Next do the lettered groups. All the A's to one pin, the B's to another until all groups are done.

Mega 2560:

No changes.

Connecting the Sensorbatorium:

  Plug the 6 pin header into the analog pins 0 - 5. Plug the V lead into 5 volts. Plug the G lead into ground. Plug the C lead into a V hole. Plug the A lead into a G hole. This much is always the same and does not change for different sensors.

Connecting Sensors:

  A sensor plugged into the 0A holes is matched with a resistor is plugged across the 0C holes and is read on analog input 0. 1A matches 1C and read on input 1, so on up to input 5. It is this simplicity and flexibility that makes the build of the Sensorbatorium worthwhile.

Software Examples:

  KeyboardTool.ino - the analog pins readings are on the far right (set special extensions)
  DiodeCalibration.ino- automatic calibration of diodes as accurate temperature sensors (set special extensions)
If you have a thermister, connect it to A0 and match a 10k resistor at C0. Put a 2k (two 1k in series?) resistor at A1 and match 10k at C1 to make a voltage divider. Plug in 1 to 4 diode sensors at A2-A5 and match each with 10K. Now you can calibrate the diodes.

Step 8: For the Expert

YOU DO NOT NEED THIS INFORMATION TO USE MRETV. This section is intended for people with Arduino experience.

  If you read AVR assembler look at the funky start of the actual MRETV interrupt (bottom right panel of this Instructables title picture).

Software Serial Tx:

  On a 168 or 328 based Arduino Serial Tx moves from pin 1 to pin 3 . It moves to pin 18 on the 2560. MRETV software serial is always 2400 8n1.

168/328 CPU 28 pin DIP Safe Hardware Hack:

  MRETV uses the Arduino serial Tx pin in generating video. You may have noticed a side effect. If you turn on the serial monitor you see the video data as random characters coming from the serial port. I built two trivial circuits during development. One allows connecting and disconnecting the serial Tx pin without modifying your Arduino. The other connects to the first and adds the ability to switch between normal Arduino Tx and pin 3 (the software Tx) to maintain full duplex during video generation.

  Most projects can simply use pin 3 instead of pin 1 and do not need a hardware add on. The socket circuit and a removable jumper between pins 1 and 3 works fine instead a switch. So does connecting pins 0 and 3 to a serial port on your computer instead of any of this.


  SPDT switch
  28 pin socket
  some headers


  Bend out pin 3 of the socket and put a lead on it. This has to be done in such a way that the socket can be plugged in the CPU socket of your Arduino. You can take it from there, this is the expert section.
  I use a female to female and male to female jumper in combination with these circuits. It gives me enough lead length to keep things organized on my bench.

Mega 2560:

  Software serial Tx is available on communication pin 18 and Rx is pin 0 as normal. With a permanently mounted CPU you cannot simply exchange Tx signals with pin 1. The best solution is to use pins 18 and 0 to connect to a serial port on your computer. Currently MRETV always uses UART0 for video (all CPU's) but work on 2560 optimization is underway. Can you guess what might be done with 3 synchronized UARTS in MSPIM?

Why the Extensions file?

  The interrupt in MRETV.S is written in assembler so will only compile in the library folder. The MRETV.extensions is used to decide what extension routines to include at compile time and must be consistent between your sketch and the MRETV code. A speed and size improvement is achieved by hard coding certain values and decisions in the interrupt.

Diode sensors:

  The diode sensors do not rely on the battle between good and evil like the other sensors but the linearity of the band‐gap energy Eg of silicon with respect to temperature.

What's in a name?

  MRETV stands for Master Raster (Extended) Transmission Vision.

  A single visible screen of 47 x 29 of 8 x 8 pixel = 87232 pixel   / 8 bits  = 10904 bytes of changeable data (the transient raster) that  is larger than RAM so it must be generated in real time. An interrupt reads a sequence of characters from a RAM array (master source of the raster), looks up the character in the font, with the offset into the character from the scan line count, reads the character data from program memory, and continuously feeds the serial transmission stream while keeping count to stop and start each scan line. It does this using 2 clocks per pixel. At the start of the raster line and some other timing points the interrupt keeps busy with extended functions like audio.

Step 9: Bugs and Bouquets

  Although a great deal of effort has been put into testing it is inevitable that in a project this size some bugs are left. Letting me know of problems is great, sending me a code example and enough information to reproduce the problem even better. I would also be nice to hear what uses MRETV is put to.

  Thank you for making it to the end of this Instructable ! I hope you find your time has been well spent.

       Mr. E

Using MRETV to play a simple game demonstrating Video, Sound, and Keyboard.
MRETV turns an Arduino into an external video card creating a portable second screen for a laptop.
(bonus - Owner Liability Digital Falling Asset Recovery Test)

Step 10: Appendix - Programming Reference

For a more complete list of functions and other programming information see 'Arduino\libraries\MRETV\ReadMe.txt' .

// Create a screen and start video output
void Screen.begin(const prog_char* CharBase,volatile uchar * textbuf,uchar lines, uchar cols,uchar top,uchar left,uchar mode)

CharBase - a pointer to the character shape data in program memory
textbuf - a pointer to a RAM array of characters to display. Textbuf must be
cols x ( lines /( fontheight x pixelheight) ) bytes in size. Almost always
pixelheight is 1 and font height is 8 so the textbuf size = cols x lines / 8.
lines - total scan lines to display
cols - total columns to display (each column = 8 pixels)
top - scan line to start display
left - pixel count to start display
mode - pixel size ( bits 0-4 height 5-7 width ) 0 height is experimental interlace.

// display functions
Screen_progstr(line,col,string)  // put preset string on screen at a location
Screenprogstr(string)  // put preset string on screen at current location
void Screen.write(uchar a)   // place a character in the current location and  advance location
void Screen.write(uchar line, uint col, uchar c)    // set location then write() character
void Screen.render(uchar a) //place character even non printable. (big function I need help with)
void Screen.str(char* c) 
void Screen.str(uchar line, uint col, char* c) 
void Screen.hex(uchar c)
void Screen.hex(uchar line, uint col,uchar c)
void Screen.hexint(uint i)
void Screen.hexint(uchar line, uint col,uint i)
char * Screen.udec(uchar line, uint col,uint d) // return pointer to str
char * Screen.udec(uint d) // return pointer to str since we have it.
char * Screen.dec(uchar line, uint col,int d) // return pointer to str
char * Screen.dec(int d) // return pointer to str since we have it.
char * Screen.bin(uchar b) // return pointer to str since we have it.
char * Screen.bin(uchar line, uint col,uchar d) // return pointer to str

//clear a feild before over printing
void Screen.fill(uchar b,int count)  // set characters, do not change current location if count is negative
void Screen.fill(uchar line, uint col,uchar b,int count)  // set location ,set characters, do not change cur loc again if count is negative

//shape functions
void Screen.fill(uchar c) // fill the screen
void Screen.fillrow(uchar line,uchar c) // fill a row
void Screen.fillcol(uint col,uchar c)   // fill a column
void Screen.rect(uchar row,uint col, uchar wi, uchar hi,char c)
void Screen.frame(uchar row,uint col, uchar wi, uchar hi,char c)

// pixel level functions
not formalized in MRETV 1 , prototypes included in Ponguino  (see source notes)

// screen utility functions
// screen utility functions
void Screen.setcurloc(uint loc)   //  set absolute location
uint Screen.setcurloc(uchar line, uint col)   //  line col to location
uint Screen.skip(char sk)   //  advance and return position.
void Screen.bound()  // put curloc on screen
void Screen.scroll() // move screen up 1 text line
uchar Screen.get()   // get character at current location  and advance current location.
uchar Screen.get(uchar line, uint col) // set current location and return the character there, no advance
char * Screen.time()  // must be zeroed ever 24 hrs not done here....

**** Screen properties ****

uchar * Screen.poke; // pointer to curloc
uint Screen.curloc;  // current location cast as an integer
uint Screen.end; // limit of screen cast as an integer
char Screen.width; // calculated width from begin(), the real width may be dynamic

Note the two forms used in order to overload the function. Both save Ram by putting strings
only in program memory. It you do not use them text will use a lot of RAM.


usage:  screen_progstr(0,0,"Hello World ");
        screenprogstr("I eat therefore I am");

**** Video functions ****

void off(); // stop all MRETV activity and CPU use
void on();  // restart MRETV , only after an off()

// software serial port functions 2400 8 N 1
char Video.readS()   // read from serial buffer
void Video.writeS(char a)  // write out serial
void Video.stringS(const char * b) // write out serial

//keyboard functions
char Video.readK()   // read from key buffer
uchar  //filtered  read (shaken but not stirred) from keyboard stream
char Video.write2key(uchar datum)  // write out on the PS/2 port
char Video.leds(char l)   // bits 0 1 2
char Video.keyrate(char l)   // as per ps/2 keyboard specs

// mouse functions
char Video.EnableDataReporting()// Let mouse talk
char Video.SetRemoteMode()// report only when asked
char Video.SetStreamMode() // report as needed
char Video.ReadData()  // ask for report

**** Video properties ****

uint Video.LineCount;  // raster line on screen currently being drawn
uchar Video.ScreenWidth,.ScreenTop,.ScreenBottom, .ScreenCenter; // active screen area
uchar Video.ScreenMode; // pixel size ( bits 0-4 height 5-7 width ) 0 height is experimental interlace.
uint Video.FrameCount, Video.FrameHigh;  // if extension selected frame=262 rasterlines = painting one screen
const prog_char *Video.audiodatar,*Video.audiodata;
uchar Video.speckey,Video.fjin;
uchar Video.f2jin;
uchar Video.arcount, Video.alcount

//  Sound, For optimum auditory excitation use SLUG SOUND EENHANCERS
// duration count 1/60 sec, 0= off, 255 continuous
// play from array of samples        sounds[];
 setaudior(sound index,duration)
 setaudiol(sound index,duration)
 setaudio(sound index,duration)
//plays the specified sound sample.

Arduino Contest

Second Prize in the
Arduino Contest