VGA 640x400 fullgraphic monochrome demo program

Dependencies:   vga640x400g mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  * 640x400 70Hz fullgraphic monochrome VGA Driver demo program
00003  *
00004  * Copyright (C) 2011 by Ivo van Poorten <ivop(at)euronet.nl>
00005  * and Gert van der Knokke <gertk(at)xs4all.nl>
00006  * This file is licensed under the terms of the GNU Lesser
00007  * General Public License, version 3.
00008  *
00009  * Inspired by Simon's (not Ford) Cookbook entry and Cliff Biffle's
00010  * assembly code.
00011  */
00012  
00013 #include "mbed.h"
00014 #include "vga640x400g.h"
00015 
00016 // visual feedback
00017 DigitalOut myled(LED1);
00018 
00019 // define serial port for debug
00020 Serial linktopc(USBTX,USBRX);
00021 
00022 int main() {
00023     // init the VGA subsystem (always do this first!)
00024     init_vga();
00025 
00026     int s,t;
00027 
00028     // serial port on at 115200 baud
00029     linktopc.baud(115200);
00030     setbuf(stdout, NULL); // no buffering for this filehandle
00031     
00032     
00033     // clear the screen
00034     vga_cls();
00035     
00036     // draw some circles
00037     for (t=10; t<200; t+=5)
00038     vga_circle(20+t,399-t,t,WHITE);
00039 
00040     // draw some boxes
00041     for (t=10; t<100; t+=5)
00042     vga_box(400+t,100+t,400+t*2,100+t*2,WHITE);
00043   
00044     // circumfence the screen
00045     vga_box(0,0,639,399,WHITE);
00046     
00047     // show the complete character set
00048     for (s=0; s<4; s++) {
00049         for (t=0; t<64; t++) {
00050             vga_putchar(20+t*8,20+16*s,t+s*64,WHITE);
00051         }
00052     }
00053 
00054     // put a string on screen
00055     vga_putstring(400,370,"Hello World!",WHITE);
00056 
00057     // draw a line
00058     vga_line(400,390,500,390,WHITE);
00059     
00060     // draw a filled box
00061     vga_filledbox(450,330,550,360,1);
00062     
00063  
00064     // all done
00065     while (1){
00066          wait(1);
00067        myled=!myled;
00068     }
00069  }