i have a matrix of a binay image in a text file. i am reading the values (1 & 0 )out of it to display each pixel. but its not working. here is my code.
/*
* 640x480 60Hz fullgraphic monochrome VGA Driver demo program
*
* Copyright (C) 2011 by Ivo van Poorten <ivop(at)euronet.nl>
* and Gert van der Knokke <gertk(at)xs4all.nl>
* This file is licensed under the terms of the GNU Lesser
* General Public License, version 3.
*
* Inspired by Simon's (not Ford) Cookbook entry and Cliff Biffle's
* assembly code.
*/
#include "mbed.h"
#include "vga640x480g.h"
LocalFileSystem local("local");
unsigned char data[8000];
void pixel(int x,int y,int d)
{
if( d==0)
{
vga_plot(x,y,WHITE);
}
else if( d==1)
{
vga_plot(x,y,BLACK);
}
}
// visual feedback
DigitalOut myled(LED1);
// define serial port for debug
Serial linktopc(USBTX,USBRX);
int main() {
FILE *fo,*fp=NULL;
fp = fopen("/local/yo.txt", "r");
fo = fopen("/local/out.txt", "w");
// init the VGA subsystem (always do this first!)
init_vga();
int s,t;
// serial port on at 115200 baud
linktopc.baud(115200);
setbuf(stdout, NULL); // no buffering for this filehandle
// clear the screen
vga_cls();
int i=0;
int k=0;
int l=0;
//q:
while(!feof(fp))
{
//q:
data[i] = fgetc(fp);
if(i==8000)
{
i=0;
}
fprintf(fo, "%c",data[i]);
//for (int k=0;k<=400;k++)
//{
//for(int l=0;l<600;l++)
//{
pixel(l,k,data[i]);
if (l==599)
{
k++;
l=0;
// goto q;
}
}
fclose(fo);
fclose(fp);
// draw some circles
// for (t=10; t<200; t+=5)
//vga_circle(20+t,399-t,t,WHITE);
// draw some boxes
// for (t=10; t<100; t+=5)
//vga_box(400+t,100+t,400+t*2,100+t*2,WHITE);
// circumfence the screen
vga_box(0,0,639,479,WHITE);
// show the complete character set
// for (s=0; s<4; s++) {
// for (t=0; t<64; t++) {
// vga_putchar(20+t*8,20+16*s,t+s*64,WHITE);
//}
// }
// put a string on screen
vga_putstring(600,400,"Hello World",WHITE);
// draw some lines
// vga_line(400,390,500,390,WHITE);
//vga_line(500,475,600,375,WHITE);
// draw a filled box
// vga_filledbox(0,0,50,50,1);
//vga_filledbox(150,0,50,50,1);
// vga_filledbox(550,430,300,300,1);
// vga_plot(500,50,WHITE);
//vga_plot(500,51,WHITE);
//vga_plot(500,52,WHITE);
pixel(500,53,1);
pixel(500,54,0);
pixel(500,55,1);
pixel(500,56,1);
pixel(500,57,0);
pixel(500,58,0);
// draw some more boxes
// for (t=10; t<320; t+=5)
// vga_box(100+t,440-t/16,110+t,440+t/16,WHITE);
// all done
while (1){
wait(0.5);
myled=1;
wait(0.5);
myled=0;
}
}
Hi
I am working on a project and am looking to switch VGA inputs (2) to one VGA output. I have only managed to find one suitable chip MAX4885, but this isn't really in a suitable package for prototyping on a breadboard.
Does anyone have any ideas of chips that are suitable ? If not can anyone recommend a good multiplexor for the job ?