LCD Custom character

Odpovědět
Riso
Příspěvky: 27
Registrován: 24 srp 2018, 15:36
Reputation: 0

LCD Custom character

Příspěvek od Riso » 13 zář 2018, 20:28

Zdravím, mám otázku či je nejaké obmedzené množstvo custom characterov. Mám ich vytvorených 9. Prvý je "ô" a posledný "á", no keď zadám príkaz na "á" na display mi vypíše "ô" ak jeden z tých 9 znakov zmažem tak to ide ako má. Ostatné znaky idú dobre, tak ako majú. Používam arduino mega.

martinius96
Příspěvky: 579
Registrován: 01 srp 2017, 19:29
Reputation: 0
Bydliště: Poprad
Kontaktovat uživatele:

Re: LCD Custom character

Příspěvek od martinius96 » 13 zář 2018, 20:32

Ak sa nemýlim, tak max je 8 charakterov, ktoré je možné vytvoriť.
Je to z dôvodu "RAM" na kontroléri displeja, ktorá je konštruovaná pre uloženie max 8 charakterov, takto som to pochopil z origo popisu.

Riso
Příspěvky: 27
Registrován: 24 srp 2018, 15:36
Reputation: 0

Re: LCD Custom character

Příspěvek od Riso » 13 zář 2018, 20:34

Vďaka za odpoveď, tak si budem musieť vystačiť s ôsmymi :D

AstroMiK
Příspěvky: 592
Registrován: 08 pro 2017, 19:05
Reputation: 0

Re: LCD Custom character

Příspěvek od AstroMiK » 13 zář 2018, 22:12

Pokud máš "evropskou" verzi displeje, tak jsou některé znaky s diakritikou dostupné i ve znacích s kódy 128 až 255.
Jestli máš "čínskou" verzi, tak i tam se v těch klikihácích dají najít nějaké rozumné znaky jako přehlasované a, u, o nebo malé ň.

Koukni na katalogový list a porovnej si strany 17 a 18:
http://astromik.org/raspi/meteostanice/ ... y_40x2.pdf



.... Zobrazení na displeji je pak příkazem:

lcd.write(byte(kod_znaku));

lukinool
Příspěvky: 17
Registrován: 11 črc 2018, 11:53
Reputation: 0

Re: LCD Custom character

Příspěvek od lukinool » 14 zář 2018, 07:12

A, vlastních znaků můžeš vytvořit libovolné množství
B, najednou jich dokážeš však zobrazit na displeji pouze osm, to je limit CGRAM pro HD44780 a spol.
C, samozřejmě existuje možnost změny obsahu CGRAM a tím změnit ten který znak(zdroj https://forum.arduino.cc/index.php?topic=48508.0):

Kód: Vybrat vše

// include the library
#include <LiquidCrystal.h>

// initialize the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

// define integers for the cursor location
int x = 0;
int y = 0;
int j = 0;

void setup()
{
 // sets the LCD's rows and colums:
 lcd.begin(16, 2);
}

void customclear() 
{
 // ensures all custom character slots are clear before new custom
 // characters can be defined. 
 byte blank[8] =
 {
   B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00000
 };
 for(int i = 0; i < 8; i++)
 {
   lcd.createChar(i, blank);
 }
}
// filles a segment one line at a time fron left to right.
void customset1()
{
 customclear();
 j = 4;
 // arrays to form one set of custom characters
 byte line1[8] = 
 {
   B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000 
 };
 byte line2[8] =
 {
   B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000 
 };
 byte line3[8] =
 {
   B11100, B11100, B11100, B11100, B11100, B11100, B11100, B11100
 };
 byte line4[8] =
 {
   B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110
 };

 // assignes each segment a write number
 lcd.createChar(0, line1);
 lcd.createChar(1, line2);
 lcd.createChar(2, line3);
 lcd.createChar(3, line4);  
}

// fills a segment one line at a time from top to bottom. 
void customset2()
{
 customclear();
 j = 7;
 // arrays to form one set of custom characters
 byte line1[8] = 
 {
   B11111, B00000, B00000, B00000, B00000, B00000, B00000, B00000
 };
 byte line2[8] =
 {
   B11111, B11111, B00000, B00000, B00000, B00000, B00000, B00000
 };
 byte line3[8] =
 {
   B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000
 };
 byte line4[8] =
 {
   B11111, B11111, B11111, B11111, B00000, B00000, B00000, B00000
 };
 byte line5[8] =
 {
   B11111, B11111, B11111, B11111, B11111, B00000, B00000, B00000
 };
 byte line6[8] =
 {
   B11111, B11111, B11111, B11111, B11111, B11111, B00000, B00000
 };
 byte line7[8] =
 {
   B11111, B11111, B11111, B11111, B11111, B11111, B11111, B00000
 };

 // assignes each segment a write number
 lcd.createChar(0, line1);
 lcd.createChar(1, line2);
 lcd.createChar(2, line3);
 lcd.createChar(3, line4); 
 lcd.createChar(4, line5);
 lcd.createChar(5, line6);
 lcd.createChar(6, line7);
}

void mediaChar()
{
 customclear();

 byte play[8] =
 {
   B00000, B01000, B01100, B01110, B01100, B01000, B00000, B00000
 };
 byte fastforward[8] =
 {
   B00000, B10100, B01010, B00101, B01010, B10100, B00000, B00000
 };
 byte forward[8] =
 {
   B00000, B01000, B00100, B00010, B00100, B01000, B00000, B00000
 };
 byte fastback[8] =
 {
   B00000, B00101, B01010, B10100, B01010, B00101, B00000, B00000
 };
 byte back[8] =
 {
   B00000, B00010, B00100, B01000, B00100, B00010, B00000, B00000
 };
 byte Stop[8] =
 {
   B00000, B11111, B11111, B11111, B11111, B11111, B00000, B00000
 };
 byte record[8] =
 {
   B00000, B01110, B11111, B11111, B11111, B01110, B00000, B00000
 };
 byte pause[8] =
 {
   B00000, B11011, B11011, B11011, B11011, B11011, B00000, B00000
 };
 // assignes each segment a write number
 lcd.createChar(2, play);
 lcd.createChar(4, fastforward);
 lcd.createChar(3, forward);
 lcd.createChar(0, fastback); 
 lcd.createChar(1, back);
 lcd.createChar(6, Stop);
 lcd.createChar(7, record);
 lcd.createChar(5, pause);
}

void cardChar()
{
 customclear();

 byte heart[8] =
 {
   B00000, B01010, B11111, B11111, B01110, B00100, B00000, B00000
 };
 byte diamond[8] =
 {
   B00000, B00100, B01110, B11111, B01110, B00100, B00000, B00000
 };
 byte spade[8] =
 {
   B00000, B00100, B01110, B11111, B11111, B01110, B00100, B01110
 };
 byte club[8] =
 {
   B00000, B01110, B10101, B11111, B10101, B00100, B01110, B00000
 };
 // assignes each segment a write number
 lcd.createChar(0, heart);
 lcd.createChar(1, diamond);
 lcd.createChar(2, spade);
 lcd.createChar(3, club); 
}

void boarderChar()
{
 customclear();

 byte topleft[8] =
 {
   B11111, B10000, B10000, B10000, B10000, B10000, B10000, B10000
 };
 byte topright[8] =
 {
   B11111, B00001, B00001, B00001, B00001, B00001, B00001, B00001
 };
 byte bottomleft[8] =
 {
   B10000, B10000, B10000, B10000, B10000, B10000, B10000, B11111
 };
 byte bottomright[8] =
 {
   B00001, B00001, B00001, B00001, B00001, B00001, B00001, B11111
 };
 byte leftside[8] =
 {
   B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000
 };
 byte rightside[8] =
 {
   B00001, B00001, B00001, B00001, B00001, B00001, B00001, B00001
 };
 byte top[8] =
 {
   B11111, B00000, B00000, B00000, B00000, B00000, B00000, B00000
 };
 byte bottom[8] =
 {
   B00000, B00000, B00000, B00000, B00000, B00000, B00000, B11111
 };
 // assignes each segment a write number
 lcd.createChar(0, topleft);
 lcd.createChar(1, topright);
 lcd.createChar(2, bottomleft);
 lcd.createChar(3, bottomright); 
 lcd.createChar(4, leftside);
 lcd.createChar(5, rightside);
 lcd.createChar(6, top);
 lcd.createChar(7, bottom);
}

void arrowChar()
{
 customclear();

 byte up[8] =
 {
   B00000, B00100, B01110, B10101, B00100, B00100, B00100, B00000
 };
 byte down[8] =
 {
   B00000, B00100, B00100, B00100, B10101, B01110, B00100, B00000
 };
 byte lowleftcorner[8] = 
 {
   B00000, B00000, B00001, B10010, B10100, B11000, B11110, B00000,
 };
 byte lowrightcorner[8] =
 {
   B00000, B00000, B10000, B01001, B00101, B00011, B01111, B00000,
 };
 byte upleftcorner[8] =
 {
   B00000, B11110, B11000, B10100, B10010, B00001, B00000, B00000
 };
 byte uprightcorner[8] =
 {
   B00000, B01111, B00011, B00101, B01001, B10000, B00000, B00000
 };
 byte updown[8] =
 {
   B00100, B01110, B10101, B00100, B00100, B10101, B01110,  B00100
 };  
 // assignes each segment a write number
 lcd.createChar(0, up);
 lcd.createChar(1, down);
 lcd.createChar(2, lowleftcorner);
 lcd.createChar(3, lowrightcorner); 
 lcd.createChar(4, upleftcorner);
 lcd.createChar(5, uprightcorner);
 lcd.createChar(6, updown);
}
void fillset()
{
 for(int i = 0; i < j; i++)
 {
   lcd.setCursor(x, y);
   lcd.write(i);
   delay(100);
 }
 lcd.setCursor(x, y);
 lcd.write(255);
 delay(100);
 x++;
 if(x < 16)
 {
   fillset();
 }
 if(x > 15)
 {
   x = 0;
   y++;
   if (y < 2)
   {
     fillset();
   }
 }
 if(y > 1)
 {
   x = 0;
   y = 0;
   lcd.clear();   
 }
}

void loop()
{
 customset1();
 fillset();
 customset2();
 fillset();
 customclear();
 for(int i = 0; i <8; i++)
 {
   lcd.setCursor(x,y);
   lcd.write(i);
   x++;
 }
 x=0;
 mediaChar();
 delay(2000);
 cardChar();
 delay(2000);
 arrowChar();
 delay(2000);
 lcd.clear();  
 boarderChar();
 lcd.setCursor(0,0);
 lcd.write(0);
 lcd.setCursor(0,1);
 lcd.write(2);
 lcd.setCursor(15,0);
 lcd.write(1);
 lcd.setCursor(15,1);
 lcd.write(3);
 lcd.setCursor(6,0);
 lcd.write(0);
 lcd.setCursor(9,0);
 lcd.write(1);
 lcd.setCursor(6,1);
 lcd.write(2);
 lcd.setCursor(9,1);
 lcd.write(3);
 lcd.setCursor(7,0);
 lcd.write(6);
 lcd.write(6);
 lcd.setCursor(7,1);
 lcd.write(7);
 lcd.write(7);
 delay(2000);
 x=0;
 lcd.clear();
}


Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 9 hostů