Pasos para preparar la placa STM32 para que se pueda reprogramar por el puerto micro usb:
1. Desoldamos la resistencia pull up resistor R10 de la placa, que tiene el número 103, es decir, es de 10K.
2. Soldamos entre los pines PA12 y 3.3V una resistencia del valor apropiado (1.5K).
Una vez que ya tengamos preparada la placa, podremos proceder a la instalación del bootloader STM32Duino.
Pasos para instalar el bootloader:
1. Descargamos el bootloader correspondiente para nuestra placa. En mi caso, el LED de la placa está conectado al pin PC13, por lo que elegiré el bootloader siguiente: generic_boot20_pc13.bin
Puedes descargar el bootloader correcto para tu placa aquí.
2. Movemos el jumper de BOOT0 a la posicion 1.
3. Conectamos el usb a serie (USB FTDI) con la placa según el siguiente esquema:
-TX a PA10
-RX a PA9
-GND a GND
-3.3V a 3.3V
Antes de conectar el convertidor usb a serie, asegúrate de que está configurado para una tensión de salida de 3.3V.
4. Reinicia la placa.
5. Descarga el STM Flash Loader Demostrator de la siguiente web: STM Flash Loader Demostrator Download.
6. Sigue las instrucciones del software.
7. Vuelve a colocar el jumper de BOOT0 en la posición 0.
A partir de ese momento, tu placa STM32 puede ser reprogramada a través del puerto USB.
Espero que os sea de utilidad.
Hasta la próxima.
Bibliografía: stm32duino.com
Desde aquí se puede descargar el software.
/***********************************************
*********Created by Ingeniería en casa ********
***************28.02.2017**********************
***********************************************/
#include <EEPROM.h> //EEPROM library from stmduino.com to store string when power off
#define PIN_CLK PA3 //clock pin max7219
#define PIN_CS PA2 //chip select pin max7219
#define PIN_DIN PA1 //data pin max 7219
#define MAX_NUM 30 //max number of letters allowed to display
#define TIMEOUT 15000 //timeout to wait serial connection 15 seconds
unsigned int DATA; //variable to store shift data to max7219
unsigned long DATA_L; //store data to shift the 2 right 8x8 matrix led arrays
unsigned long DATA_H; //store data to shift the 2 left 8x8 matrix led arrays
byte max_letters; //max number of leters to display
byte pos_create_text; //position of the next letter
boolean configDone; //to know if there is a new string from the serial port
String inputString = ""; // a string to hold incoming data
String defaultString = ""; //ingenieria en casa
uint16 AddressWrite = 0xF0; //Adress to store string in emulated EEPROM 0x10
const byte matrix_letter_a [8][8] = { {0, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
const byte matrix_letter_b [8][8] = { {1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0}};
const byte matrix_letter_c [8][8] = { {0, 0, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 1, 1, 1, 1, 1, 1}};
const byte matrix_letter_d [8][8] = { {1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 0, 0}};
const byte matrix_letter_e [8][8] = {{ 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}};
const byte matrix_letter_f [8][8] = {{ 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0}};
const byte matrix_letter_g [8][8] = { {0, 0, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0}};
const byte matrix_letter_h [8][8] = { {1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
const byte matrix_letter_i[8][8] = {{ 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}};
const byte matrix_letter_j[8][8] = {{ 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 1, 0, 0},
{1, 1, 0, 0, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 0}};
const byte matrix_letter_k [8][8] = {{ 1, 1, 0, 0, 0, 1, 1, 0},
{1, 1, 0, 0, 1, 1, 1, 0},
{1, 1, 0, 1, 1, 0, 0, 0},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 0, 1, 1, 0, 0, 0},
{1, 1, 0, 0, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 1, 1, 0}};
const byte matrix_letter_l [8][8] = {{ 1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}};
const byte matrix_letter_m [8][8] = {{ 1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
const byte matrix_letter_n [8][8] = {{ 1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 0, 0, 1, 1},
{1, 1, 0, 1, 1, 0, 1, 1},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
/*const byte matrix_letter_ñ [8][8] = {{ 0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};*/
const byte matrix_letter_o [8][8] = {{ 0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0}};
const byte matrix_letter_p [8][8] = {{ 1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0}};
const byte matrix_letter_q [8][8] = {{ 0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 1}};
const byte matrix_letter_r [8][8] = {{ 1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
const byte matrix_letter_s [8][8] = { {0, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0}};
const byte matrix_letter_t[8][8] = {{ 1, 1, 1, 1, 1, 1, 1, 1,},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}};
const byte matrix_letter_u [8][8] = {{ 1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 0}};
const byte matrix_letter_v [8][8] = {{ 1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}};
const byte matrix_letter_w [8][8] = {{ 1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0}};
const byte matrix_letter_x [8][8] = { {1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1}};
const byte matrix_letter_y [8][8] = { {1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}};
const byte matrix_letter_z [8][8] = { {1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 1, 1, 0},
{0, 0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}};
/*const byte matrix_letter_esc [8][8] = {{ 0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}};*/
const byte matrix_letter_null [8][8] = {{ 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}};
byte text[8][8*MAX_NUM]; //GLOBAL VARIABLE TO STORE THE COMPLETE STRING OF TEXT
/*shift 16 bits*/
void shiftOut2(void){
for(int x = 0; x < 16; x++){
digitalWrite(PIN_CLK,LOW);
if(DATA & 0X8000)
digitalWrite(PIN_DIN, HIGH);
else
digitalWrite(PIN_DIN, LOW);
digitalWrite(PIN_CLK,HIGH);
DATA <<= 1;
}
}
/*shift 16*4 bits*/
void shiftOut4(void){
digitalWrite(PIN_CS,LOW);
DATA = (unsigned int)DATA_H;
shiftOut2();
DATA = (unsigned int)(DATA_H>>16);
shiftOut2();
DATA = (unsigned int)DATA_L;
shiftOut2();
DATA = (unsigned int)(DATA_L>>16);
shiftOut2();
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
}
/*makes the movement (change wich part of the variable text to show)*/
void roll_text_matrix4(byte roll_delay){
//roll forward
for(byte pos = 0; pos< pos_create_text -4*8-1; pos++){
for(int i = 7; i>= 0; i--){
DATA_L = 0x00000000;
DATA_H = 0x00000000;
for(int k = 0;k<4; k++){
byte temp = 0;
DATA = 0x0000;
for(int j = 0; j<8; j++){
temp |= (byte)text[i][8*k+j+pos] << j;
}
DATA = (8-(int)i)<<8 | (byte)temp;
//shiftOut();
switch(k){
case 0: DATA_L |= (unsigned long)DATA <<16;break;
case 1: DATA_L |= (unsigned long)DATA & 0x0000FFFF;break;
case 2: DATA_H |= (unsigned long)DATA <<16;break;
case 3: DATA_H |= (unsigned long)DATA & 0x0000FFFF;break;
}
}
shiftOut4();
}
delay(roll_delay);
}
//roll backward
for(byte pos = pos_create_text-4*8-1; pos> 0; pos--){
for(int i = 7; i>= 0; i--){
DATA_L = 0x00000000;
DATA_H = 0x00000000;
for(int k = 0;k<4; k++){
byte temp = 0;
DATA = 0x0000;
for(int j = 0; j<8; j++){
temp |= (byte)text[i][8*k+j+pos] << j;
}
DATA = (8-(int)i)<<8 | (byte)temp;
//shiftOut();
switch(k){
case 0: DATA_L |= (unsigned long)DATA <<16;break;
case 1: DATA_L |= (unsigned long)DATA & 0x0000FFFF;break;
case 2: DATA_H |= (unsigned long)DATA <<16;break;
case 3: DATA_H |= (unsigned long)DATA & 0x0000FFFF;break;
}
}
shiftOut4();
}
delay(roll_delay);
}
}
void test_display(char dir){
static const unsigned int test_on = 0x0F01;
static const unsigned int test_off = 0x0F00;
DATA_L = (unsigned int)test_off | (unsigned int)test_off << 16;
DATA_H = (unsigned int)test_off | (unsigned int)test_off << 16;
shiftOut4();
if(dir == 'l'){ //lights from right to the left
DATA_H |= test_on;
shiftOut4();
delay(500);
DATA_H = (unsigned int)test_on << 16 | (unsigned int)test_off;
shiftOut4();
delay(500);
DATA_L = (unsigned int)test_on;
DATA_H = (unsigned int)test_off | ((unsigned int)test_off << 16 );
shiftOut4();
delay(500);
DATA_L = (unsigned int)test_on << 16 | (unsigned int)test_off;
shiftOut4();
delay(500);
}
else if(dir == 'r'){ //lights from the left to the right
DATA_L = (unsigned int)test_off << 16 | (unsigned int)test_on;
shiftOut4();
delay(500);
DATA_L = (unsigned int)test_off << 16 | (unsigned int)test_off;
DATA_H = (unsigned int)test_on << 16 | (unsigned int)test_off;
shiftOut4();
delay(500);
DATA_H = (unsigned int)test_off << 16 | (unsigned int)test_on;
shiftOut4();
delay(500);
DATA_L = test_off | test_off << 16;
DATA_H = test_off | test_off << 16;
shiftOut4();
}
}
void config_display(){
//0x XX XX XX XX
// D15 D12 D11-D8 D7-D0
//0b ---- AAAA DDDD DDDD
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0x0F01; // display test 0x0F01 01 ON 00 OFF
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
delay(1000);
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0x0F00; // display test 0x0F01 01 ON 00 OFF
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0x0C01; // normal operation mode
//Serial.println(DATA,HEX);
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0x0900; //no decode
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0X0A00; //max brightness 0x0A0F min brightness 0x0A00
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
digitalWrite(PIN_CS,LOW);
for(int i = 0; i<4 ; i++){
DATA = 0x0B07; // 7 digits scan
shiftOut2();
}
digitalWrite(PIN_CS,LOW);
digitalWrite(PIN_CS,HIGH);
}
void add_letter(const byte letter[8][8],byte pre_space){
pos_create_text += pre_space;
for(int i =0; i<8; i++){
for(int j = 0;j<8; j++){
text[i][j+pos_create_text] = (byte)letter[i][j];
}
}
max_letters ++;
pos_create_text += 8;
}
void createText(){
byte lengthString = inputString.length();
byte nextPos = 1;
add_letter(matrix_letter_null,0);
add_letter(matrix_letter_null,0);
for(int i = 0; i<lengthString; i++){
switch(inputString.charAt(i)){
case ' ': nextPos = 4; break;
case 'a': add_letter(matrix_letter_a,nextPos); nextPos = 1; break;
case 'b': add_letter(matrix_letter_b,nextPos); nextPos = 1; break;
case 'c': add_letter(matrix_letter_c,nextPos); nextPos = 1; break;
case 'd': add_letter(matrix_letter_d,nextPos); nextPos = 1; break;
case 'e': add_letter(matrix_letter_e,nextPos); nextPos = 1; break;
case 'f': add_letter(matrix_letter_f,nextPos); nextPos = 1; break;
case 'g': add_letter(matrix_letter_g,nextPos); nextPos = 1; break;
case 'h': add_letter(matrix_letter_h,nextPos); nextPos = 1; break;
case 'i': add_letter(matrix_letter_i,nextPos); nextPos = 1; break;
case 'j': add_letter(matrix_letter_j,nextPos); nextPos = 1; break;
case 'k': add_letter(matrix_letter_k,nextPos); nextPos = 1; break;
case 'l': add_letter(matrix_letter_l,nextPos); nextPos = 1; break;
case 'm': add_letter(matrix_letter_m,nextPos); nextPos = 1; break;
case 'n': add_letter(matrix_letter_n,nextPos); nextPos = 1; break;
//case 'ñ': add_letter(matrix_letter_ñ,nextPos); nextPos = 1; break;
case 'o': add_letter(matrix_letter_o,nextPos); nextPos = 1; break;
case 'p': add_letter(matrix_letter_p,nextPos); nextPos = 1; break;
case 'q': add_letter(matrix_letter_q,nextPos); nextPos = 1; break;
case 'r': add_letter(matrix_letter_r,nextPos); nextPos = 1; break;
case 's': add_letter(matrix_letter_s,nextPos); nextPos = 1; break;
case 't': add_letter(matrix_letter_t,nextPos); nextPos = 1; break;
case 'u': add_letter(matrix_letter_u,nextPos); nextPos = 1; break;
case 'v': add_letter(matrix_letter_v,nextPos); nextPos = 1; break;
case 'w': add_letter(matrix_letter_w,nextPos); nextPos = 1; break;
case 'x': add_letter(matrix_letter_x,nextPos); nextPos = 1; break;
case 'y': add_letter(matrix_letter_y,nextPos); nextPos = 1; break;
case 'z': add_letter(matrix_letter_z,nextPos); nextPos = 1; break;
default: add_letter(matrix_letter_null,nextPos); break;
}
}
}
void setup() {
// put your setup code here, to run once:
pinMode(PIN_CLK,OUTPUT);
pinMode(PIN_CS,OUTPUT);
pinMode(PIN_DIN,OUTPUT);
digitalWrite(PIN_CLK,LOW);
digitalWrite(PIN_CS,HIGH);
digitalWrite(PIN_DIN,LOW);
Serial.begin(9600);
// reserve 200 bytes for the inputString and defaultString:
inputString.reserve(200);
defaultString.reserve(200);
EEPROM.init(); //initialize eeprom library
delay(100);
EEPROM.PageBase0 = 0x8011000; //0x801F000
EEPROM.PageBase1 = 0x8011800; //0x801F800
EEPROM.PageSize = 0x400;
//while(!Serial.isConnected()){}; // wait on USB is up and running
config_display();
test_display('l');
uint16 testChar;
EEPROM.read(AddressWrite, &testChar);
unsigned long time_begin = millis();
unsigned long time_now;
do{
Serial.println("Input string to display:");
while(Serial.available()){
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
configDone = true;
createText();
defaultString = "";
defaultString += inputString; //actualizamos el string default
EEPROM.format(); //format eeprom
EEPROM.write(AddressWrite, defaultString.length());
for(int i = 1; i<= defaultString.length(); i++){
EEPROM.write(AddressWrite+i, defaultString[i-1]); //EEPROM.write(AddressWrite, DataWrite);
Serial.print(AddressWrite+i);
Serial.print("--");
Serial.print(defaultString[i-1],HEX);
Serial.println();
uint16 debug;
EEPROM.read(AddressWrite+i, &debug); //EEPROM.write(AddressWrite, DataWrite);
Serial.print(AddressWrite+i);
Serial.print("--");
Serial.print(debug,HEX);
Serial.println();
}
Serial.print("input String--");
Serial.print(inputString);
Serial.println("--String recorded OK");
Serial.print("default String--");
Serial.println(defaultString);
}
}
time_now = millis();
}while(time_now < (time_begin + TIMEOUT) && !configDone);
if(testChar != 0xFFFF && !configDone){
uint16 length_read = 0;
EEPROM.read(AddressWrite, &length_read);
uint16 readChar;
for(int j = 1; j<= length_read; j++){
EEPROM.read(AddressWrite+j, &readChar); //EEPROM.write(AddressWrite, DataWrite);
defaultString += (char)readChar;
}
inputString = defaultString;
createText();
configDone = true;
}
test_display('r');
}
void loop() {
// put your main code here, to run repeatedly:
roll_text_matrix4(50); //delay 50 ms
}
¡Hola amigo!
ReplyDeleteEste código no es para arduino Uno o Nano? Gracias