Caratteri Custom LCD

Salve a tutti,
Sto incappando in alcuni problemi nel visualizzare dei caratteri custom su un lcd 16x2, vi spiego il problema, ho riutilizzato parte di un programma che visualizza una barra scorrevole in base all'ingresso analogico sulla 2° riga (realizzato grazie a caratteri speciali) e sulla 1° ho inserito degli altri caratteri creati da me, il problema è che i miei caratteri a volte compaiono nella 2° stringa (e da programma non dovrebbero esserci) e sulla 1° riga dove dovrebbero stare non si vedono proprio >:(
Posto il listato spero qualcuno possa aiutarmi, il problema credo giri attorno alle prime stringhe e ai registri dei caratteri.
Grazie mille
Luca

#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);
int giri = 1;
float val;

void defChar (LiquidCrystal &thelcd, int asc, const unsigned char row[0])
{
int i;

if ((asc < 0) || (asc > 7))
return;

thelcd.command (0x40 | (asc << 3));

for (i = 0; i < 8; i++)
thelcd.write (row*);*

  • thelcd.home ();*
    }
    void setup ()
    {

  • lcd.begin(16, 2);*

  • static unsigned char cheq[8] = {*

  • 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00*

  • };*

  • static unsigned char bar[8] = {*

  • 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00*

  • };*

  • static unsigned char barr[8] = {*

  • 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10*

  • }; *

  • static unsigned char barrr[8] = {*

  • 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18*

  • };*

  • static unsigned char barrrr[8] = {*

  • 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c*

  • };*

  • static unsigned char barrrrr[8] = {*

  • 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e*

  • };*

  • static unsigned char barrrrrr[8] = {*

  • 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f*

  • };*

  • static unsigned char a[8] = {*

  • 0x01, 0x03, 0x01, 0x01, 0x01, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aa[8] = {*

  • 0x07, 0x01, 0x07, 0x04, 0x07, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaa[8] = {*

  • 0x07, 0x01, 0x03, 0x01, 0x07, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaaa[8] = {*

  • 0x01, 0x02, 0x04, 0x07, 0x01, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaaaa[8] = {*

  • 0x07, 0x04, 0x07, 0x01, 0x07, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaaaaa[8] = {*

  • 0x07, 0x04, 0x07, 0x05, 0x07, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaaaaaa[8] = {*

  • 0x07, 0x01, 0x01, 0x01, 0x01, 0x00, 0x10, 0x10*

  • };*

  • static unsigned char aaaaaaaa[8] = {*

  • 0x07, 0x05, 0x07, 0x05, 0x07, 0x00, 0x10, 0x10*

  • };*

  • lcd.clear ();*

  • defChar (lcd, 0x01, bar);*

  • defChar (lcd, 0x40, bar);*

  • defChar (lcd, 0x02, barr);*

  • defChar (lcd, 0x03, barrr);*

  • defChar (lcd, 0x04, barrrr);*

  • defChar (lcd, 0x05, barrrrr);*

  • defChar (lcd, 0x06, barrrrrr);*

  • defChar (lcd, 0x07, cheq);*

  • defChar (lcd, 0x08, a);*

  • defChar (lcd, 0x09, aa);*

  • defChar (lcd, 0x10, aaa);*

  • defChar (lcd, 0x11, aaaa);*

  • defChar (lcd, 0x12, aaaaa);*

  • defChar (lcd, 0x13, aaaaaa);*

  • defChar (lcd, 0x14, aaaaaaa);*

  • defChar (lcd, 0x15, aaaaaaaa);*

}
void loop ()
{

  • int ana;*

  • ana = analogRead (1); *

  • lcd.setCursor (0, 0);*

  • lcd.print (" ");*

  • lcd.write (0x08);*

  • lcd.print (" ");*

  • lcd.write (0x09);*

  • lcd.print (" ");*

  • lcd.write (0x10);*

  • lcd.print (" ");*

  • lcd.write (0x11);*

  • lcd.print (" ");*

  • lcd.write (0x12);*

  • lcd.print (" ");*

  • lcd.write (0x13);*

  • lcd.print (" ");*

  • lcd.write (0x14);*

  • lcd.print (" ");*

  • lcd.write (0x15);*

  • lcd.setCursor (0, 1);*

  • drawbar (1, ana);*

  • delay (20);*
    }
    void drawbar (int row, int ana)
    {

  • int bar;*

  • int i;*

  • lcd.setCursor (0, row);*

_ bar = ((long int)ana * 80L) / 1023L;_

  • for (i = 0; i < bar / 5; i++)*

  • lcd.write (0x06);*

  • if ( i < 20) {*

  • lcd.write (bar % 5);*

  • i++;*

  • }*

  • for ( ; i < 20; i++)*

  • lcd.write (0x01);*

  • }*

Heeeelp! :-/

http://icontexto.com/charactercreator/

Si... l'ho già visto, ma non risolve il problema... ::slight_smile: :stuck_out_tongue: :wink:

Sempre bloccato, non trovo soluzione :-[

ciao Locke
3 cose:

  • perché non usi il comando createChar() della libreria LiquidCrystal - Arduino Reference ?
  • Quanto ne so io con il controller HD44780 e compatibili possono essere definiti solo 8 simboli non 16 come fai Tu.
  • perché definisci il simbolo 0X40?
defChar (lcd, 0x01, bar);
 defChar (lcd, 0x40, bar);
 defChar (lcd, 0x02, barr);

Ciao Uwe