OK, here are the complete code and names:
main file. Name: lectura_comandos.ino
#define COL_PIXEL 64
#define ROW_PIXEL 16
int latchPin=8; //LT
int clockPin=12;//SK
int dataPin=11; //R1
int en_74138 = 2;
int la_74138 = 3;
int lb_74138 = 4;
int lc_74138 = 5;
int ld_74138 = 6;
unsigned int ROW_xPixel;
unsigned int ROW_num;
unsigned char Col_num_1;
unsigned char Col_num_2;
unsigned char Col_num_3;
unsigned char Col_num_4;
unsigned char Col_num_5;
unsigned char Col_num_6;
unsigned char Col_num_7;
unsigned char Col_num_8;
//****************************DEFINICIOES MIAS******************************************//
String comandoDeEntrada = "";
boolean comandoRecibido = false;
boolean a = false;
unsigned char buffer[]={
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};
unsigned char letra_ab[16]={0x00,0x78,0x84,0x84,0xFC,0x84,0x84,0x00,0x00,0xF8,0x84,0xF8,0x84,0x84,0xF8,0x00};
//*************************************************************************************//
//*************************************************************************************//
//*****************SETUP****************//
void setup() {
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(dataPin,OUTPUT);
pinMode(en_74138,OUTPUT);
pinMode(la_74138,OUTPUT);
pinMode(lb_74138,OUTPUT);
pinMode(lc_74138,OUTPUT);
pinMode(ld_74138,OUTPUT);
digitalWrite(en_74138, LOW);
//traducir caracteres
for (int n=0;n<16;n++){
traducir_a_reverseDobleBit(letra_ab[n],buffer[n*16],buffer[(n*16)+1]);
letra_ab[1]=fuente[2];
}
Serial.begin(9600);
comandoDeEntrada.reserve(200);
}
//**************************************//
//*************FUNCIONES MATRIX******************//
void shiftOut(unsigned char dataOut)
{
for(int i=0;i<=7;i++)
{
PORTB &=~(1<<(6));//PB6 = 0 equate digitalWrite(clockPin,LOW);
if(dataOut & (0x01<<i)) PORTB |=1<<(5); //PB5=1 equate digitalWrite(dataPin,HIGH);
else PORTB &=~(1<<(5));//PB5 = 0 equate digitalWrite(clockPin,LOW);
PORTB |=1<<(6);//PB6=1 equate digitalWrite(clockPin,HIGH);
}
}
//Combine 2 bits/pixel to 1 bits/pixel
unsigned char Combine_2BitsTo1Bit(unsigned char num,unsigned char *BMP)
{
unsigned char Col_num_tem_1;
unsigned char Col_num_tem_2;
unsigned int Col_num_tem = 0;
unsigned char i=0;
unsigned char Col_num_1bit = 0x00;
Col_num_tem_1 = *(BMP+num);
Col_num_tem_2 = *(BMP+num+1);
Col_num_tem = Col_num_tem_1;
Col_num_tem |= (Col_num_tem_2 << 8);
for(i=0;i<8;i++)
{
if(Col_num_tem&(0x0003<<i*2)) Col_num_1bit |= (0x01<<i);
}
return ~Col_num_1bit;
}
//display one picture
void display_matrix(unsigned char *BMP, int delay_refresco, int sustain)
{
//Display count
unsigned int dis_cnt=256;
unsigned int i;
for(i=0;i<sustain;i++)
{
digitalWrite(en_74138, HIGH);//Turn off display
//Col scanning
shiftOut(Col_num_1);
shiftOut(Col_num_2);
shiftOut(Col_num_3);
shiftOut(Col_num_4);
shiftOut(Col_num_5);
shiftOut(Col_num_6);
shiftOut(Col_num_7);
shiftOut(Col_num_8);
digitalWrite(latchPin, LOW);
digitalWrite(latchPin, HIGH);
//Row scanning
// AVR Port Operation
//PORTD = ((ROW_xPixel << 3 ) & 0X78) | (PORTD & 0X87);//Write PIN 3 4 5 6 la_74138 lb_74138 lc_74138 ld_74138
PORTE = ((ROW_xPixel << (5-0) ) & 0X20) | (PORTE & 0XDF);////Write PIN 3(PE5) la_74138
PORTG = ((ROW_xPixel << (5-1) ) & 0X20) | (PORTG & 0XDF);////Write PIN 4(PG5) lb_74138
PORTE = ((ROW_xPixel << (3-2) ) & 0X08) | (PORTE & 0XF7);////Write PIN 5(PE3) lc_74138
PORTH = ((ROW_xPixel << (3-3) ) & 0X08) | (PORTH & 0XF7);////Write PIN 5(PH3) ld_74138
digitalWrite(en_74138, LOW);//Turn on display
if(ROW_xPixel==15) ROW_xPixel=0; else ROW_xPixel++;
/*
// Single color,1 bits/pixel
Col_num_1=~BMP[(COL_PIXEL/8)*ROW_xPixel];
Col_num_2=~BMP[(COL_PIXEL/8)*ROW_xPixel+1];
Col_num_3=~BMP[(COL_PIXEL/8)*ROW_xPixel+2];
Col_num_4=~BMP[(COL_PIXEL/8)*ROW_xPixel+3];
Col_num_5=~BMP[(COL_PIXEL/8)*ROW_xPixel+4];
Col_num_6=~BMP[(COL_PIXEL/8)*ROW_xPixel+5];
Col_num_7=~BMP[(COL_PIXEL/8)*ROW_xPixel+6];
Col_num_8=~BMP[(COL_PIXEL/8)*ROW_xPixel+7];
*/
//Single color,2 bits/pixel
Col_num_1 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2,BMP);
Col_num_2 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+2,BMP);
Col_num_3 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+4,BMP);
Col_num_4 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+6,BMP);
Col_num_5 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+8,BMP);
Col_num_6 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+10,BMP);
Col_num_7 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+12,BMP);
Col_num_8 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+14,BMP);
if (delay_refresco > 0) {
delayMicroseconds(delay_refresco);
}
}
}
void loop() {
// display_matrix(buffer,0,1000);
digitalWrite(en_74138, HIGH);
}
byte getVal(char c)
{
if(c >= '0' && c <= '9')
return (byte)(c - '0');
else
return (byte)(c-'A'+10);
}
void traducir_a_reverseDobleBit(unsigned char bits_origen, unsigned char &bits_altos_destino,unsigned char &bits_bajos_destino)
{
unsigned char tabla_equivalencia[16] =
{0x0, // 0
0xc0, // 1
0x30, // 2
0xf0, // 3
0xc, // 4
0xcc, // 5
0x3c, // 6
0xfc, // 7
0x3, // 8
0xc3, // 9
0x33, //10
0xf3, //11
0xf, //12
0xcf, //13
0x3f, //14
0xff }; //15
//char x[16] = {0x0a,0x1b,0x2c,0x3d,0x4e,0x5f,0x60,0x71,0x82,0x93,0xA4,0xB5,0xC6,0xD7,0xE8,0xF9};
// obtener 4 bits altos y 4 bits bajos por separado.
byte bits_altos=bits_origen;
bits_altos=bits_altos>>4; //dividir por 16 sin resto
byte bits_bajos=bits_origen & B00001111; //quedarse solo con los 4 bits bajos.
//obtener valor equivalente displayable en la matriz.
bits_bajos_destino=tabla_equivalencia[bits_bajos];
bits_altos_destino=tabla_equivalencia[bits_altos];
byte imprime1=bits_altos_destino;
byte imprime2=bits_bajos_destino;
byte imprime3=bits_altos;
byte imprime4=bits_bajos;
/*
Serial.print("Bits altos Origen:");
Serial.print(imprime3);
Serial.print(" -> ");
Serial.println(imprime1);
Serial.print("Bits bajos Origen:");
Serial.print(imprime4);
Serial.print(" -> ");
Serial.println(imprime2);
*/
}
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
comandoDeEntrada += inChar;
if (inChar == '\n') { //configurar serie con "nueva linea"
comandoRecibido = true;
}
}
}
The second file. Name: a_fuentes.ino (created adding a tab).
char fuente[764]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // <space>
0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00, // !
0x14,0x14,0x00,0x00,0x00,0x00,0x00,0x00, // "
0x00,0x24,0x7E,0x24,0x24,0x7E,0x24,0x00, // #
0x10,0x7C,0x50,0x7C,0x14,0x7C,0x10,0x00, // $
0x00,0x62,0x64,0x08,0x10,0x26,0x46,0x00, // %
0x00,0x10,0x28,0x10,0x2A,0x44,0x3A,0x00, // &
..
..
};
In the second file i have deleted the last values of the matrix, because i was getting an error (post too long).
When i compile the project, i get the error:
lectura_comandos:85: error: 'fuente' was not declared in this scope