TODOPIC
Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: pK_kraken en 07 de Enero de 2006, 15:40:00
-
Hola todos,
Hace un par de día me hize con un LCD gráfico de 128x64 pixels basado en un controlador KS0108, concretamente el modelo CFAG12864B de CrystalFontz.com.
Estoy intentando toquetearlo un poco con un PIC 16F876 funcionando a 4Mhz, usando el ejemplo que viene con el compilador con nombre HDM64GS12.c hehci para manejar precisamente LCD de este tipo. Sin ambargo, no hay manera de eescribir algo coerente en el display.
Hize una simulación en proteus para saver si tenia mal el hardware pero ocurre lo mismo. Esto es lo que ocurre cuando intento hacer un recuadro rellenado de color en la posicion 10,10 y de 10 pixeles de ancho y alto.:
El codigo es este:
Cita:
void Rectangle(int x, int y, int width, int height)
{
int cx, cy = 0;
for (cy=y ; cy<(y+height) ; cy++)
{
for (cx=x ; cx<(x+width) ; cx++)
{
putpixel(cx, cy, ON);
}
}
}
Y eso el resultado:

La funcion putpixel es esta:
Cita:
void putpixel(int8 x, int8 y, int1 color)
{
BYTE data;
char side = GLCD_LEFT; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
{
x -= 64;
side = GLCD_RIGHT;
}
output_low(GLCD_DI); // Set for instruction
bit_clear(x,7); // Clear the MSB. Part of an instruction code
bit_set(x,6); // Set bit 6. Also part of an instruction code
glcd_writeByte(side, x); // Set the horizontal address
glcd_writeByte(side, (y/8 & 0xBF) | 0xB8); // Set the vertical page address
output_high(GLCD_DI); // Set for data
glcd_readByte(side); // Need two reads to get data
data = glcd_readByte(side); // at new address
if(color == ON)
bit_set(data, y%8); // Turn the pixel on
else // or
bit_clear(data, y%8); // turn the pixel off
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(side, x); // Set the horizontal address
output_high(GLCD_DI); // Set for data
glcd_writeByte(side, data); // Write the pixel data
}
La funcion glcd_writebyte esta aqui y viene del ejemplo de CCS:
Cita:
void glcd_writeByte(int1 side, BYTE data)
{
/*
if(side) // Choose which side to write to
output_high(GLCD_CS2);
else
output_low(GLCD_CS2);
*/
output_low(GLCD_E);
if (side)
{
output_high(GLCD_CS2);
output_low(GLCD_CS1);
}
else
{
output_high(GLCD_CS1);
output_low(GLCD_CS2);
}
output_low(GLCD_RW);
delay_us(1); // tas
output_high(GLCD_E); // Subo E
// Escribo dato en PORTB
output_b(data);
delay_us(1);
output_low(GLCD_E); // Bajo E
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
Lo inicializo de esta forma (segun el ejemplo):
Cita:
void glcd_init(int1 mode)
{
// Initialze some pins
output_high(GLCD_RST);
output_low(GLCD_E);
output_low(GLCD_CS1);
output_low(GLCD_CS2);
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
if(mode == ON)
{
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_RIGHT, 0x3F);
}
else
{
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_RIGHT, 0x3E);
}
glcd_fillScreen(OFF); // Clear the display
}
Realmente cuando escribo por ejemplo un linea horizontal lo hace bien, pero cuando hago un salto de linea en Y es cuando desvaría.
Estoy realmente desquiciado con este display. El datasheet no ofrece demasiada informacion y no escuentro por ningun lado ejemplos en C para CSS.
Agradecería cualquier ayuda o código fuente para resolver este problema. En adelanto un millon de gracias 
Un saludo a todos.
-
Nadie ha probado un LCD con un KS0108?
Segun estuve investigando, el fallo para ser la funcion de pixel que por alguna oscura razon no indexa bien la coordenada Y que se le pasa. He probado con un fichero de CCS llamado KS0108.c que se encarga de un solo chip y le pasa lo mismo.
La prueba que hize fue en proteus y fue la siguiente:
Bibuja uno linea vertical pixel por pixel de arriba a abajo con la funciona pixel del fichero KS0108.c del CCS. Lo que ocurre es que se pintan todo los pixels, pero segun va avanzando cada pixel se borra el anterior menos el septimo escrito que queda ahi.
Aver si consigo explicar un poco el problema de forma grafica. POnemos por ejemplo 10 pixels de arriba a abajo, lo que seria la linea a dibujar:
[X]
[X]
[X]
[X]
[X]
[X]
[X]
[X]
[X]
[X]
Al dubujar, el resultado final es este:
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[X]
[ ]
[X]
Segun se va dibujando de arriba a abajo, se ve cada pixel como se dibuja, pero al incrementar Y (para que valla hacia abajo, se borra el anterior. sin embargo el pixel numero 8 se queda ahi bibujado y el ultimo en ser dibujado (en este caso el 10) tambien. Esto se repite caeda 8 pixeles de alto. Es decir, si dibujo una linea de 32 pixel de alto, solo quedarían dibujados los pixels 8, 16 y 32 en la pantalla.
Realmente es muy raro y me esta desquiciando. Agradecería cualquier tipo de ayuda o información sobre esto que me esta pasando. Muchisimas gracias.
-
estroy trabajando con un lcd y todo funciona bien menos como imprimir los graficos si te sirve avisame
-
HOLA MIRA TE VOY A YUDAR PARA QUE LUEGO ME AYUDES,, ESTOY UTILIZANDO LA LIBRERIA GLCD.C DE PICC Y ME FUNCIONA A LA PERFECCION A CONTINUACION TE DEJO UN EJEMPLO DONDE USO LAS RUTINAS DISEÑADAS PARA ESTA LIBRERIA JUNTO CON EL ESQUEMA DE CONEXION DE PINES ENTRE EL MCU Y LA GLCD,, ADEMAS TENGO LA MISMA GLCD TUYA Y YA LA PROBE Y FUNCIONA MUY BIEN.
AHORA EL PROBLEMAS ES QUE NO SE COMO IMPRIMIR UNA IMAGEN EN EL GRAFICO SERIA BUENO QUE LO AVERIGUARAS Y E COLABORARAS CON ESO.. TROYANO
-
Hola, te paso una pagina donde explica la forma de mostrar un bmp en ese display, yo recien estoy leyendo para saber como hacerlo...
http://www.geocities.com/dinceraydin/lcd/gfxintro.htm
Esta en ingles, pero bien explicado, ya que hay que trabajar el bmp para poder enviarlo al LCD, espero te sirva.
Podrias subir los archivos de la libreria glcd.c...?
Desde ya gracias.
Saludos.
Alejandro
-
Hola:
Mirar en http://www.illasaron.com , descargas directas, descargas, videotutoriales, 23 curso de proteus, pagina 2, VT 13 curso Proteus. Uso LCD Gráficos por Germán Tojeiro.
Es un videotutorial muy interesante sobre como programar LCDs graficos con proteus, en C y en Basic.
Saludos.