B4R Code Snippet Define LCD custom characters for HD44780 controllers and compatible.

Discussion in 'B4R Code Snippets' started by tigrot, Nov 30, 2017.

Similar threads

B4R Tutorial Arduino + Raspberry Pi
B4R Question Sending command to LCD HD44780.
B4R Tutorial LCD Clock example
B4R Library LiquidCrystal_I2C
B4R Code Snippet STM32 - With int/ext RTC and LCD
  1. tigrot

    tigrot Well-Known Member Licensed User

    Hi everybody,
    here is a code snippet to define custom chars in HD44780 controllers:

    Code:
    #if C
    #include <LiquidCrystal.h>
    byte  psensc[8]= {
        B00100,
        B00100,
        B00100,
        B00100,
        B00100,
        B00100,
        B00100,
        B00000
        };
        byte puntooffc[8] ={
        B00000,
        B11111,
        B10001,
        B10001,
        B10001,
        B10001,
        B11111,
        B00000
        };
      
        byte infc[8] ={
        B00000,
        B00000,
        B00000,
        B01011,
        B10101,
        B11010,
        B00000,
        B00000
        };
        byte frecciadxc[8] ={
        B00000,
        B00100,
        B00010,
        B11111,
        B00010,
        B00100,
        B00000,
        B00000
        };
        byte frecciasxc[8] ={
        B00000,
        B00100,
        B01000,
        B11111,
        B01000,
        B00100,
        B00000,
        B00000
        };

    void Initchar (B4R::Object* o) {
    LiquidCrystal lcd(9,8,7,6,5,4); //adapt to you hardware cabling
    lcd.begin (20,4);
    lcd.createChar(1, psensc);
    lcd.createChar(2, infc);
    lcd.createChar(3, frecciadxc);
    lcd.createChar(4, frecciasxc);
    lcd.createChar(5, puntooffc);
    };
    #end if
    To print use
    Code:
    RunNative("Initchar",Null)
    lcd.print(
    chr(1))
    lcd.print(
    chr(2))
    .....
    .....
    Have fun!

    Mauro Zanin
     
    Erel likes this.
Loading...