Go Down

Topic: Answered: Does anyone know how to address character map of a 16x2 LCD? (Read 1 time) previous topic - next topic

AlfaOmega

Great idea guys! Just tested it, work like a charm!
Code: [Select]
for (int i=0; i <= 255; i++){
      lcd.setCursor(0, 0);
      lcd.write(i);

      lcd.setCursor(0, 1);
      lcd.print(i);

      delay(200);
   }


This code went though page one that in the datasheet called "ROM Code: 0A". It seems to scroll down columns from top to bottom starting with the column on the left and then through columns left to right. There are all the usual ASCII characters followed by two empty columns and there is also basic set of japanise kana.

Thats definitely progress! There are also "ROM Code: 0B" and "ROM Code: 0E" with Cyrillic, special German, French and Greek characters and all kind of weird and wonderful stuff as well  :)

marco_c

#6
Apr 28, 2013, 01:49 am Last Edit: Apr 28, 2013, 01:53 am by marco_c Reason: 1
My reading of documentation has been that the LCD displays come with one rom set. Most of the ones I have seen have been the Asian extended characters. I have not found any way to 'switch' the rom code to one of the others sets - they are different part numbers from the manufacturer.
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

MAS3

#7
Apr 28, 2013, 02:18 am Last Edit: Apr 28, 2013, 02:37 am by MAS3 Reason: 1
ROM code is fixed and supposed to be printed on the chip, but these blob chips have nothing printed.

I played around and hacked a working code into a character lookup thingy:

Code: [Select]
/*
Sloppy hack of the LcdKeyShield code i found somewhere
Meant to lookup the characters and their codes using the LcdKeyShield (this one is DFRobot compatible)

 The circuit:
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* LCD BL pin to digital pin 10
* KEY pin to analog pin 0        (14)  THIS IS THE BUTTON PIN
*/

#include <LiquidCrystal.h>

//Old LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

char msgs[5][16] = {"Right Key OK ",
                   "Up Key OK    ",              
                   "Down Key OK  ",
                   "Left Key OK  ",
                   "Select Key OK" };

//int adc_key_val[5] ={1, 150, 500, 350, 800 }; // 1st change
//int adc_key_val[5] ={800, 500, 350, 150, 50 }; // Original inverted order
int adc_key_val[5] ={50, 200, 400, 600, 800 }; //Original, works after actually reading the analog0

//int adc_key_val[5] ={ 0, 133, 308, 482, 723 };// Had  to change the order of the keys to have them show up correct.
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;
int i=1;
void setup()
{
   Serial.begin(9600);
 lcd.clear();
 lcd.begin(16, 2);
 lcd.setCursor(0,0);
 // lcd.print("ADC key testing");
 lcd.print("< Char lookup >");
}

void loop()
{ //1

key = (analogRead (0));
//Serial.println(analogRead(0));
 if (key != oldkey)   // if keypress is detected "!=" means not equal!!
  {//2
   delay(50);  // wait for debounce time
   adc_key_in = analogRead(0);    // read the value from the sensor
   key = get_key(adc_key_in);    // convert into key press
   if (key != oldkey)    
   {//3  
     lcd.setCursor(0, 1);
     oldkey = key;
     if (key >=0){//4
          //lcd.print(msgs[key]);
     Serial.println(key);
     Serial.println(analogRead(0));
     
     if (key == 308)
{
 Serial.println("            down  ");
}
     
if ((key)==3) i--;
if ((key)==0) i++;
if ((i)==256) i=1;
if ((i)==0) i=255;
lcd.setCursor(1,1);  
lcd.print(i);
lcd.print("  ");
lcd.setCursor(8,1);  
lcd.write(i);
     }//4
   }//3

  }//2
 /*
if (key = 800)
{
  delay(2000);
  lcd.clear();
 }
*/
delay(100);

}//1

// Convert ADC value to key number
int get_key(unsigned int input)
{
   int k;
 
   for (k = 0; k < NUM_KEYS; k++)
   {
     //if (input == adc_key_val[k]) //works
     if (input < adc_key_val[k]) // should be more reliable as it doesn't looks for a range instead of a fixed value but it isn't
{
           return k;
       }
  }
 
   if (k >= NUM_KEYS)k = -1;  // No valid key pressed
   return k;
}


As stated, it's a bit sloppy but it works.
Use the left and right keys to go back or forth.
How about characters # 247, 249, 244 and 228 ?
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

AlfaOmega

#8
Apr 28, 2013, 03:17 am Last Edit: Apr 28, 2013, 03:36 am by AlfaOmega Reason: 1
How about characters # 247, 249, 244 and 228 ?


Yep, there are omega, sigma, tau and pi... But man, there is a whole universe stashed away on another rom code! Shame there is no way to get there..


My reading of documentation has been that the LCD displays come with one rom set.


Lets try a datasheet for a standard HD44780, like this one at Sparkfun:
https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
pages 17 and 18 give two different rom codes "ROM Code: A00" and "ROM Code: A02"...

But there indeed no instructions on how to switch... Screen that I'm playing with is form RS Components with a different controller that has three rom codes, the description is even more sketchy. Whats interesting though, first sets are the identical on both screens. Both datasheets first describe interaction with the EEPROM, then the bloody ROM tables  :), then the "Relationship between CGRAM Addresses, Character Codes (DDRAM) and Character Patterns (CGRAM Data)".
In commands for character modules there is function "Set CG RAM Address", presumably to read or write to/from it. But this is about all there is to go by.

Hence have to agree, seems like a lost cause. Its 2.30 am, not really thinking straight right now. Tomorrow will try to get through the CG RAM, only hope there might be a way to mess with addressing. There are some kind of control bits in front of character codes, thats the objective for tomorrow - if will be able to to get some sleep that is  :smiley-mr-green:

bperrybap

The character rom on a hd44780 type lcd is what it is. You cannot change it.
Different LCD modules have different glyphs for the character codes above 0x7f.
The only thing you can do is define you own characters, but....
You only get eight of those.

If you really want to have custom character glyphs you will need
to switch over to a glcd.
Most glcd libraries render the charcters from fonts data stored in the library files
so you can have any font or define any glyph you want for any character code
including different sizes.

--- bill

Go Up