You are viewing an older revision! See the latest version

uVGAII printf demo

/media/uploads/4180_1/uvgaii.jpg
The uVGA II board from 4D Systems

This code acts as a wrapper library for the the UVGAII Board demo http://mbed.org/cookbook/uVGAII by Jim Hamblem. It utilizes this library to implement a basic printf function.

Here is the Code for the library to try out:

Import programuVGAII_demo

A demo program for the uVGAII board using the mbed cookbook 4DGL library in 640 by 480 VGA mode


Here is the wiring for the program:

mbeduVGA II
5V5V
GndGnd
TXRX
RXTX
P11Reset

uVGAIIpins

In the drawing above, the pins are labeled from the mbed's perspective with TX and RX pins already swapped. So mbed TX goes to the middle pin on the connector which is the uVGA II RX pin.

Just plug in any VGA monitor to the DB15 connector and watch the display printf any text that you have inputted.

/media/uploads/4180_1/uvgaii_demo.jpg
mbed uVGA II demo program output on a VGA monitor in 640 by 480 mode.


Use the demo code as an initial starting point to develop your own display code. The module starts in 320 by 240 graphics mode and a special display command in main.cpp, “ecran.display_control(0x0c, 0x01);” is sent to switch to 640 by 480 mode in the demo code before sending any text and graphics data to the display. The 4DGL library *.h file, TFT_4GL.h, has a SIZE_X and SIZE_Y #define that should be edited and set to the number of pixels in the display, after you have a copy of the library in your local directory. The demo code segment for the text and graphics calls is shown below:

Demo_Graphics_Calls

void myprintf(const char* format, ...) {
    char dest[256];
    va_list argptr;
    va_start(argptr, format);
    vsprintf(dest, format, argptr);
    va_end(argptr);
    for ( int i = 0; i < 256; i++) {
        buffer[256*j+i]= dest[i];
    }
    j++;
    int linenum = j;

    for (int k = 0; k <256; k++) {
        printbuf[k] = buffer[256*(linenum-1)+k];
    }
    ecran.rectangle(0, 8*outputrow, 639, 8*outputrow+30, BLACK);
    ecran.text_string( dest, 0 , outputrow , FONT_8X8, WHITE);
    outputrow+= 1;
    if(outputrow>58){
        outputrow =1;
    }
}




Because printing to through the vga is slow, any prints off the screen will wrap around to the top of the screen and override the the existing text on the screen 1 line at a time. Therefore, the user has the ability to print as much as possible.


All wikipages