Hola. Estoy teniendo un problema con la implementación de mi programa en físico.
Pues aparentemente debe funcionar, estoy usando la librería ks0108 y la simulación en proteus va bien,
pero al momento de implementar todo, no grafica nada!, no sé si se debe a un problema de compatibilidad, pues ya me aseguré varias veces de que las conexiones estén bien.
Este es el código:
Pues aparentemente debe funcionar, estoy usando la librería ks0108 y la simulación en proteus va bien,
pero al momento de implementar todo, no grafica nada!, no sé si se debe a un problema de compatibilidad, pues ya me aseguré varias veces de que las conexiones estén bien.
Este es el código:
Código:
/*
* ssadasdasd.c
*
* Created: 10/8/2013 7:56:23 PM
* Author:
*/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
// se utilizara la libreria ks0108
#include "ks0108.h"
#include "font12x16.h" // contiene arreglos de simbolos 12x16 las cuales serviran para imprimir los mensajes
#include "font6x8.h" // contiene arreglo de simbolos de 6x8
// se utilizan constantes para que se impriman los mensajes
const char pgmString0[] PROGMEM = "CARGANDO.";
const char pgmString1[] PROGMEM = "CARGANDO..";
const char pgmString2[] PROGMEM = "CARGANDO...";
const char pgmString3[] PROGMEM = "TAP TAP";
//los siguientes arreglos son los que se mostraran en la pantalla y sirven para encender
const uint8_t BotonSinPres_16x16[32] PROGMEM = {
0xC0, 0xF0, 0xFC, 0xFC,
0x06, 0x06, 0x0F, 0x0F,
0x1F, 0x1F, 0x3E, 0x3E,
0xFC, 0xFC, 0xF0, 0xC0,
0x03, 0x0F, 0x3F, 0x3F,
0x60, 0x60, 0xF0, 0xF0,
0xF8, 0xF8, 0x7C, 0x7C,
0x3E, 0x3F, 0x0F, 0x03
};
const uint8_t BotonSinPres_12x12[24] PROGMEM = {
0xF0, 0xFC, 0xFE, 0x06,
0x07, 0x0F, 0x0F, 0x9F,
0x9E, 0xFE, 0xFC, 0xF0,
0x00, 0x03, 0x07, 0x06,
0x0E, 0x0F, 0x0F, 0x0F,
0x07, 0x07, 0x03, 0x00
};
const uint8_t BotonConPres_12x12[24]PROGMEM = {
0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF0,
0xF0, 0x60, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int referencia;
// esta funcion imprime un boton de 12x12 bits en la posicion indicada
void imprime_boton_12x12(uint8_t POSX, uint8_t POSY){
int j = 0;
int PosIni;
int k = 0;
for(k=0;k<2;k++){
PosIni = 0;
for(j=POSX;j<(POSX+12);j++){
ks0108GotoXY(j,POSY);
referencia = pgm_read_byte(&BotonSinPres_12x12[PosIni+(k*12)]);
ks0108WriteData(referencia);
PosIni++;
}
POSY = POSY + 8;
}
}
//esta funcion imprime el boton presionado de 12x12 bits, se utilizan la variable X e Y para referenciar la posicion dentro de la pantalla
void imprime_botonPres_12x12(uint8_t POSX, uint8_t POSY){
int j = 0;
int PosIni;
int k = 0;
for(k=0;k<2;k++){
PosIni = 0;
for(j=POSX;j<(POSX+12);j++){
ks0108GotoXY(j,POSY);
referencia = pgm_read_byte(&BotonConPres_12x12[PosIni+(k*12)]);
ks0108WriteData(referencia);
PosIni++;
}
POSY = POSY + 8;
}
}
// esta funcion imprime un boton sin presionar de 16x16 bits, al igual que las anteriores tiene variables de posicion
void imprime_boton_16x16(uint8_t POSX, uint8_t POSY){
int j = 0;
int PosIni;
int k = 0;
for(k=0;k<2;k++){
PosIni = 0;
for(j=POSX;j<(POSX+16);j++){
ks0108GotoXY(j,POSY);
referencia = pgm_read_byte(&BotonSinPres_16x16[PosIni+(k*16)]);
ks0108WriteData(referencia);
PosIni++;
}
POSY = POSY + 8;
}
}
int main(void) {
volatile uint16_t i;int k;
struct font largeFont, smallFont;
for(i=0; i<15000; i++);
largeFont.width = FONT12X16_WIDTH;
largeFont.height = FONT12X16_HEIGHT;
largeFont.charData = Font12x16;
smallFont.width = FONT6X8_WIDTH;
smallFont.height = FONT6X8_HEIGHT;
smallFont.charData = Font6x8;
// la funcion ks0108Init envia los comandos necesarios para la inicializacion de la pantalla antes de esta funcion el lcd no puede mostrar ningun simbolo
ks0108Init();
// la funcion ks0108GotoXY le indica la posicion en donde se comenzara a mostrar los datos
ks0108GotoXY(0,0);
// la funcion ks0108PutString imprime una cadena caracteres o un caracter
ks0108PutString("iniciando juego", smallFont);
ks0108GotoXY(30,28);
// la funcion ks0108PutStringP imprime arreglos de caracteres, estos arreglos deben ser declarados como constantes
ks0108PutStringP(pgmString0, smallFont);
// las siguientes funciones imprimen botones de 16x16 bits y 12x12 bits en las posiciones deseadas
imprime_boton_16x16(5,48 );
imprime_boton_16x16(25,48 );
imprime_boton_12x12(65,48);
imprime_botonPres_12x12(65,48);
while(1);
}
Adjuntos
Última edición por un moderador: