LiquidCristal library

20 Nov 2014

Could somebody port subj to mbed, please. I really need cirillic symbols.

20 Nov 2014

Are you referring to TextLCD character displays based on HD44780 or compatible controller types or are you looking for graphics displays?

The Text LCD modules have internal ROM tables for the fonts. They are usually available for different character sets (eg English, japanese, cyrillic). You need to select a module that has the required HD44780 controller type. The controller font type is identified by some additional letters or codes added to the HD44780 type number (eg HD44780-XXX). Your best option is to buy a character LCD module from an eastern European vendor (eg Poland). When you need only a few (max 8) symbols the User Defined Characters are an option. You can store a number of symbols as 5x7 pixels in the controller and then show them on the display. See here.

Graphics displays usually dont have any built-in fonts. You must provide a fonttable as sourcecode. Obviously many tables are available on the internet. Google is your friend..

21 Nov 2014

Yes, thank you for you answer. I've got the table, you've told about. The current problem for me now - i can't understand how transform lcd.printf("Hello!") to lcd.printf("Привет!"); also bacause the compiler doesn't accept the cyrillic.

25 Nov 2014

Anton Boyt wrote:

The current problem for me now - i can't understand how transform lcd.printf("Hello!") to lcd.printf("Привет!"); also bacause the compiler doesn't accept the cyrillic.

That is harder to fix unless we can use some extended character set. The best option when you have a known set of messages is probably a constant defined list with all the messages decoded into the correct cyrillic characters codes.

const char HELLO_TEXT[]  = {0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x00};   // insert the correct codes for all characters in the cyrillic fonttable

main () {
  lcd.printf("%s", HELLO_TEXT);
}

Similar lists are used to switch between languages in user interfaces.

24 Nov 2014

Thanks, Wim! Your method works well, but my idea is - to show some customer defined cyrillic strings. I need to allow users to write any cyrillic strings. Now I'm Trying to modify the "puts" method from library freetronicsLCDShield to manage It. There were some LiquidCrystalRus library for arduino, but it doesn't work in mbed.

25 Nov 2014

Anton Boyt wrote:

Thanks, Wim! Your method works well, but my idea is - to show some customer defined cyrillic strings. I need to allow users to write any cyrillic strings. Now I'm Trying to modify the "puts" method from library freetronicsLCDShield to manage It. There were some LiquidCrystalRus library for arduino, but it doesn't work in mbed.

The TextLCD lib will use the charactercodes that you print to display the characters that it finds in its fonttable for that charactercode. So the text will display correctly as long as you construct a string out of the charactercodes that match the correct cyrillic characters in the ROM fonttable of the controller. You could for example map keyboardcodes to the matching characters in the fonttable using some translation rule.

Serial serial(USBTX, USBRX);
TextLCD lcd(...); // add all parameters

char c;
const char cyrillic[256] = {0x00,.....};  //conversion table between char codes from keyboard and cyrillic fonttable in controller

main {
while (1) {
  c=serial.getc();
  lcd.putc ( cyrillic[c] );
} 

}
25 Nov 2014

ок, just to make it clear for me, please

char c;
const char cyrillic[2]= {0x41,0xA0};  //latin A and cyrillic Б codes in LCD ROM
unsigned char cyr_b='Б';
long int icyr_b=(long int)cyr_b; // is 91
int main() {
while (1) {
//  c=serial.getc();  // Gives me ERR Expression must have type c=serial.getc();
//  lcd.putc (cyrillic[c]);
  wait(1);
//  puts("БББ"); // how to make it alive? override the method in TextLCD.cpp?
  printf("hex code cyr b %x\r\n",icyr_b); // gives 91
  }
}

The main question is - if i want to use printf for example, do I have to override this method and make some changes there? So, I can't see It in TextLCD files. Seems to I need to override It from stream class? How can I do It right? Or, Is there some other method, more suitable for It?

25 Nov 2014

The code above did not compile since it was not complete and just pseudo code example: the table for cyrillic should be completed for all 256 entries, the lcd needs to be instantiated etc.

You can override the putc() in the source of TextLCD to use the conversion table for each character. The printf method of TextLCD will use the internal method putc() to display every character in the string on the LCD. The string will typically have to consist of characters that each take up one byte. You need to convert the source cyrillic data entered by the user and translate that to the correct LCD font entry to show up on the display.

Here is a more complete example that waits for keyboard entries and responds to A and b by showing latin A and cyrillic b.

#include "mbed.h"
#include "TextLCD.h"

Serial serial(USBTX, USBRX);
TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7
 
char c;
const char cyrillic[2] = {0x41,0xA0};  //conversion table between char codes from keyboard and cyrillic fonttable in controller
 
int main() {

  while (1) {
    c=serial.getc();

//table is not completely filled at the moment so make sure you dont access illegal entries
    switch (c) {
      case 'A': lcd.putc ( cyrillic[0] );
                serial.printf("hex code cyr 0x%x\r\n", cyrillic[0]); // gives 0x41            
                break;
      case 'b': lcd.putc ( cyrillic[1] );
                serial.printf("hex code cyr 0x%x\r\n", cyrillic[1]); // gives 0xA0      
                break;
      default:  lcd.putc ('*');
                break;          
    }  
     
    wait(1);
  } 

}

When the table is completed for all 256 entries you can delete the switch and simply use

    c=serial.getc();
    lcd.putc ( cyrillic[c] );
    serial.printf("hex code cyr 0x%x\r\n", cyrillic[c]); 
26 Nov 2014

Hi, Wim! Funny results I've got :-). I added serial.printf to default case in your snippet:

      default:  lcd.putc ('*');
                serial.printf("hex codez 0x%x\r\n", c); // gives c            
                break;  

and It gives 2 codes! for cyrillic А it for example d0 and 90. it seems to UTF-8. But idea is clear, and I know how to manage It now.

Although I have to recalculate the cyrillic symbols adress before use. Otherwise my table will be FFFF number of lenght :-). Thanks a lot for your time!

27 Nov 2014

Hi, Wim, Hi all! I managed It, and your help was really useful. Here is the library: http://developer.mbed.org/users/margadon/code/Freetronics_16x2_LCD_Rus/ Thanks a lot!

15 Apr 2015

Anton Boyt wrote:

Could somebody port subj to mbed, please. I really need cirillic symbols.

Добрый день! Можете воспользоваться мною модифицированными библиотеками

https://developer.mbed.org/users/vbogom/code/TextLCD_Rus/ или

https://developer.mbed.org/users/vbogom/code/TextLCD_595/

Вторая позволяет подключить модуль через сдвиговый регистр (по SPI), я проверял на 74HC595

07 Dec 2016

Василий, добрый день! А что за шрифт или какую кодировку нужно использовать??? Ваш пример работает, а если даже в вашем примере я корректирую надписи, то текст отображается не корректно.