Moderadores: andre_luis, 51, guest2003, Renie
rebelk escreveu:e ai jerek consigui mais alguma coisa com as funçoes do glcd,
estou apanhando pra dedeu e ainda não consegui entender como
é que depois de convertido o desenho para .bas como é q é organizado para ser gravado na eeprom , ele cria umas matrizis
de valores , é ai onde me amarro, vc poderia me explicar como é isso ?
void fazJanela(int go_row, int go_col, int row, int col, int CG)
{
int row_cont = 0;
int col_cont = 0;
for(row_cont=0; row_cont <row; row_cont++){
for(col_cont =0; col_cont <col; col_cont++){
if((col_cont == 0)&&(row_cont == 0))
{
GDispCGCharAt(col_cont+go_col, row_cont+go_row, cg++);
}
if((col_cont == (col -1))&&(row_cont == 0))
{
GDispCGCharAt(col_cont +1+go_col, row_cont+go_row, cg++);
}
}
col_cont =0;
if((col_cont == 0)&&(row_cont == (row -1)))
{
GDispCGCharAt(col_cont+go_col, row_cont+1+go_row, cg++);
}
}
GDispCGCharAt(col+go_col, row+go_row, cg++);
}
// coloca bordas nas janelas
void FazBorda(int go_row, int go_col, int row, int col, int CG)
{
int row_cont = 0;
int col_cont = 0;
for(row_cont=0; row_cont< row; row_cont++)
{
for(col_cont =0; col_cont< col; col_cont++)
{
if((row_cont>0)&&(row_cont<row)&&(col_cont==col-1))
{
GDispCGCharAt(col_cont+ 1 + go_col, row_cont + go_row, CG +1);
}
if((row_cont>0)&&(row_cont<row)&&(col_cont==0))
{
GDispCGCharAt(col_cont + go_col, row_cont + go_row, CG);
}
if((col_cont>0)&&(col_cont<col)&&(row_cont==0))
{
GDispCGCharAt(col_cont + go_col, row_cont + go_row, CG +2);
}
if((row_cont==row-1)&&(col_cont>0))
{
GDispCGCharAt(col_cont + go_col, row_cont + 1 + go_row, CG +3);
}
}
}
}
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "t6963.h"
#include "t6963.c"
#include "Janela 1.h"
void figura(); // carrega figura na CG RAM
void main()
{
GDispInit(); // Inicialização do display T6963C
FontSize = 8; // Fonte no modo tamanho 8 ou 6
GDispSetMode(XOR_MODE|INT_CG_MODE); // Exclusive OR mode, internal CG character RAM
GDispSetMode(TEXT_GRH_ON); // Text ON, Graphics ON
GDispClrTxt(); // Limpa a area de texto
GDispClrGrh(); // Limpa a area de grafico (ponto-a-ponto)
figura(); // função que carega a figura da janela na CG RAM
while(1)
{
fazJanela(0,0, 11, 3, 0); // Mostra os cantos da janela 1 nas:
// Coordenadas = col 0
// = row 0
// Quantidade de colunas = 11
// Quantidade de linhas = 3
// Onde esta gravado o 1° caracter na CG RAM = 0
FazBorda( 0, 0, 11, 3, 4); // Mostra a borda da janela 1:
// coordenada = col 0
GDispGoto(1,1); // row 0
printf(GDispChar,"Janela 1 "); // Quantidade de colunas = 11
delay_ms(2500); // Quantidade de linhas = 3
GDispGoto(2,1); // Onde esta gravada o 1° caracter na CG RAM = 0
printf(GDispChar,"Teste OK! ");
delay_ms(2500);
fazJanela(1,1, 11, 3, 0);
FazBorda( 1, 1, 11, 3, 4); // (int go_row, int go_col, int col, int row, int CG)
GDispGoto(2,2);
printf(GDispChar,"Janela 2 ");
delay_ms(2500);
GDispGoto(3,2);
printf(GDispChar,"Teste OK! ");
delay_ms(2500);
fazJanela(2,2, 11, 3, 0);
FazBorda( 2, 2, 11, 3, 4); // (int go_row, int go_col, int col, int row, int CG)
GDispGoto(3,3);
printf(GDispChar,"Janela 3 ");
delay_ms(2500);
GDispGoto(4,3);
printf(GDispChar,"Teste OK! ");
delay_ms(2500);
fazJanela(3,3, 11, 3, 0);
FazBorda( 3, 3, 11, 3, 4); // (int go_row, int go_col, int col, int row, int CG)
GDispGoto(4,4);
printf(GDispChar,"Janela 4 ");
delay_ms(2500);
GDispGoto(5,4);
printf(GDispChar,"Teste OK! ");
delay_ms(2500);
fazJanela(4,4, 11, 3, 0);
FazBorda( 4, 4, 11, 3, 4); // (int go_row, int go_col, int col, int row, int CG)
GDispGoto(5,5);
printf(GDispChar,"Janela 5 ");
delay_ms(2500);
GDispGoto(6,5);
printf(GDispChar,"Teste OK! ");
delay_ms(2500);
GDispClrTxt(); // Limpa a tela
fazJanela(0, 0, 15, 7, 0);
FazBorda( 0, 0, 15, 7, 4); // (int go_row, int go_col, int col, int row, int CG)
delay_ms(2000);
GDispGoto(2,1);
printf(GDispChar,"Luciano Costa");
delay_ms(2500);
GDispGoto(4,1);
printf(GDispChar,".asm51.eng.br");
delay_ms(2500);
GDispClrTxt();
GDispClrGrh();
}
} // FIM DO PROGRAMA
void figura()
{
int i =0;
for(i=0;i<8;i++) CGBuffer[i] = canto_esquerdo_superior[i]; // Armazena o desenho dos
GDispDefCGChar(0, &CGBuffer[0]); // cantos da janela na CG RAM
// do Display. É possível
for(i=0;i<8;i++) CGBuffer[i] = canto_esquerdo_inferior[i]; // acumular de 0 até 127 caracteres
GDispDefCGChar(1, &CGBuffer[0]);
for(i=0;i<8;i++) CGBuffer[i] = canto_direito_superior[i];
GDispDefCGChar(2, &CGBuffer[0]);
for(i=0;i<8;i++) CGBuffer[i] = canto_direito_inferior[i];
GDispDefCGChar(3, &CGBuffer[0]);
//////////////////////////// BORDAS ///////////////////////////////////
for(i=0;i<8;i++) CGBuffer[i] = tela_top[i]; // Armazena desenho das bordas
GDispDefCGChar(4, &CGBuffer[0]);
for(i=0;i<8;i++) CGBuffer[i] = tela_bottom[i];
GDispDefCGChar(5, &CGBuffer[0]);
for(i=0;i<8;i++) CGBuffer[i] = tela_left[i];
GDispDefCGChar(6, &CGBuffer[0]);
for(i=0;i<8;i++) CGBuffer[i] = tela_right[i];
GDispDefCGChar(7, &CGBuffer[0]);
}
// canto 1
int canto_esquerdo_superior[9]=
{
0xFF, // 11111111
0xC0, // 11000000
0x88, // 10001000
0x98, // 10011000
0x88, // 10001000
0x88, // 10001000
0x9C, // 10011100
0x80 // 10000000
};
// canto 2
int canto_direito_superior[9]=
{
0xFF, // 11111111
0x03, // 00000011
0x19, // 00011001
0x25, // 00100101
0x09, // 00001001
0x11, // 00010001
0x3D, // 00111101
0x01 // 00000001
};
// canto 3
int canto_esquerdo_inferior[9]=
{
0x80, // 10000000
0x9c, // 10011100
0x84, // 10000100
0x98, // 10011000
0x84, // 10000100
0x9c, // 10011100
0xC0, // 11000000
0xFF // 11111111
};
// canto 4
int canto_direito_inferior[9]=
{
0x01, // 00000001
0x11, // 00010001
0x15, // 00010101
0x15, // 00010101
0x1D, // 00011101
0x05, // 00000101
0x03, // 00000011
0xFF // 11111111
};
// canto 8,0
int tela_top[9]=
{
0xFF, // 11111111
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00 // 00000000
};
// canto 8,0
int tela_bottom[9]=
{
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0x00, // 00000000
0xFF // 11111111
};
// canto 8,0
int tela_left[9]=
{
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x80 // 10000000
};
// canto 8,0
int tela_right[9]=
{
0x01, // 00000001
0x01, // 00000001
0x01, // 00000001
0x01, // 00000001
0x01, // 00000001
0x01, // 00000001
0x01, // 00000001
0x01 // 00000001
};
char caracter_1[9] = {
0x00, // 00000000
0x7E, // 01111110
0x42, // 01000010
0x5A, // 01011010
0x5A, // 01011010
0x42, // 01000010
0x7E, // 01111110
0x00}; // 00000000
GDispDefCGChar(0, &caracter_1[0]); // Armazena os 8 bytes dentro da tabela
// caractet_1 na CG RAM do display na
// posição 0. Essa posição é definida pelo
// programador.
GDispCGCharAt(col,row,CGRAM); // mostra o caracter armazenado na posição
// 'CGRAM'da CG RAM dos display na
// coluna 'col', linha 'row'
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "t6963.h"
#include "t6963.c"
senoidal1(int col, int row);
void main()
{
GDispInit(); // Inicialização do display T6963C
FontSize = 8; // Fonte no modo tamanho 8 ou 6
GDispSetMode(XOR_MODE|INT_CG_MODE); // Exclusive OR mode, internal CG character RAM
GDispSetMode(TEXT_GRH_ON); // Text ON, Graphics ON
GDispClrTxt(); // Limpa a area de texto
GDispClrGrh(); // Limpa a area de grafico (ponto-a-ponto)
armazena_figura_cgram();
while(1)
{
senoidal1( 0, 15);
senoidal1(31, 15);
senoidal1(62, 15);
delay_ms(2000);
GDispClrTxt(); // Limpa a area de texto
GDispClrGrh(); // Limpa a area de grafico (ponto-a-ponto)
}
} // FIM DO PROGRAMA
senoidal1(int col, int row)
{
// 1° parte col row
GDispSetPixel(col + 0, row , BLACK);
delay_ms(20);
GDispSetPixel(col + 1, row , BLACK);
delay_ms(20);
GDispSetPixel(col + 2, row - 1, BLACK);
delay_ms(20);
GDispSetPixel(col + 3, row - 1, BLACK);
delay_ms(20);
GDispSetPixel(col + 4, row - 2, BLACK);
delay_ms(20);
GDispSetPixel(col + 5, row - 3, BLACK);
delay_ms(20);
GDispSetPixel(col + 6, row - 4, BLACK);
delay_ms(20);
GDispSetPixel(col + 6, row - 5, BLACK);
delay_ms(20);
GDispSetPixel(col + 7, row - 6, BLACK);
delay_ms(20);
GDispSetPixel(col + 7, row - 7, BLACK);
delay_ms(20);
// 2° parte
GDispSetPixel(col + 8, row - 8, BLACK);
delay_ms(20);
GDispSetPixel(col + 8, row - 9, BLACK);
delay_ms(20);
GDispSetPixel(col + 9, row - 10, BLACK);
delay_ms(20);
GDispSetPixel(col + 9, row - 11, BLACK);
delay_ms(20);
GDispSetPixel(col + 10, row - 12, BLACK);
delay_ms(20);
GDispSetPixel(col + 11, row - 13, BLACK);
delay_ms(20);
GDispSetPixel(col + 12, row - 14, BLACK);
delay_ms(20);
GDispSetPixel(col + 13, row - 14, BLACK);
delay_ms(20);
GDispSetPixel(col + 14, row - 15, BLACK);
delay_ms(20);
GDispSetPixel(col + 15, row - 15, BLACK);
// 3° parte
GDispSetPixel(col + 16, row - 15, BLACK);
delay_ms(20);
GDispSetPixel(col + 17, row - 15, BLACK);
delay_ms(20);
GDispSetPixel(col + 18, row - 14, BLACK);
delay_ms(20);
GDispSetPixel(col + 19, row - 14, BLACK);
delay_ms(20);
GDispSetPixel(col + 20, row - 13, BLACK);
delay_ms(20);
GDispSetPixel(col + 21, row - 12, BLACK);
delay_ms(20);
GDispSetPixel(col + 22, row - 11, BLACK);
delay_ms(20);
GDispSetPixel(col + 22, row - 10, BLACK);
delay_ms(20);
GDispSetPixel(col + 23, row - 9, BLACK);
delay_ms(20);
GDispSetPixel(col + 23, row - 8, BLACK);
// 4° parte
GDispSetPixel(col + 24, row - 7, BLACK);
delay_ms(20);
GDispSetPixel(col + 24, row - 6, BLACK);
delay_ms(20);
GDispSetPixel(col + 25, row - 5, BLACK);
delay_ms(20);
GDispSetPixel(col + 25, row - 4, BLACK);
delay_ms(20);
GDispSetPixel(col + 26, row - 3, BLACK);
delay_ms(20);
GDispSetPixel(col + 27, row - 2, BLACK);
delay_ms(20);
GDispSetPixel(col + 28, row - 1, BLACK);
delay_ms(20);
GDispSetPixel(col + 29, row - 1, BLACK);
delay_ms(20);
GDispSetPixel(col + 30, row - 0, BLACK);
delay_ms(20);
GDispSetPixel(col + 31, row - 0, BLACK);
}
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante