Matteo Costa / PCF2119LCD
Embed: (wiki syntax)

« Back to documentation index

TextLCD Class Reference

TextLCD Class Reference

A TextLCD interface for driving PCF2119-based LCDs. More...

#include <pcf2119.h>

Public Types

enum  LCDType {
  LCD16x2, LCD16x2B, LCD20x2, LCD20x4,
  LCD24x2, LCDuser
}
 

LCD panel format.

More...

Public Member Functions

 TextLCD (PinName pSDA, PinName pSCL, PinName pReset, LCDType type=LCD16x2)
 Create a TextLCD interface.
int putc (int c)
 Write a character to the LCD.
int printf (const char *format,...)
 Write a formated string to the LCD.
void locate (int column, int row)
 Locate to a screen column and row.
void cls ()
 Clear the screen and locate to 0,0.
void writeCGRAM (int address, int pattern[8])
 write a user defined char
void writeCommand (int command)
 Get the char at the current position.

Detailed Description

A TextLCD interface for driving PCF2119-based LCDs.

Currently supports 16x2, 20x2 and 20x4 panels

 #include "mbed.h"
 #include "NewTextLCD.h"
 
 TextLCD lcd(p10, p12, p13, p15, p16, p29, p30); // rs, e, d0-d3
 
 int main() {
     lcd.printf("Hello mbed\n");

 //define user chars
  int pattern[8];
  int pattern1[8];
  pattern[0] = 1;              //     *
  pattern[1] = 3;              //    **
  pattern[2] = 5;              //   * *
  pattern[3] = 9;              //  *  *
  pattern[4] = 0x11;           // *   *     
  pattern[5] = 0x19;           // **  * 
  pattern[6] = 0x1d;           // *** *
  pattern[7] = 0x1f;           // *****
  
  pattern1[0] = 0x10;          // *
  pattern1[1] = 0x18;          // **
  pattern1[2] = 0x14;          // * *
  pattern1[3] = 0x12;          // *  *
  pattern1[4] = 0x11;          // *   *
  pattern1[5] = 0x13;          // *  **
  pattern1[6] = 0x17;          // * ***
  pattern1[7] = 0x1f;          // *****
 
  lcd.writeCGRAM(0, pattern);
  lcd.writeCGRAM(1, pattern1);
  
  lcd.locate(15,0);
  lcd.putc(0);   // user pattern 0
  lcd.putc(1);   // user pattern 1   
 }

Definition at line 72 of file pcf2119.h.


Member Enumeration Documentation

enum LCDType

LCD panel format.

Enumerator:
LCD16x2 

16x2 LCD panel (default)

LCD16x2B 

16x2 LCD panel alternate addressing

LCD20x2 

20x2 LCD panel

LCD20x4 

20x4 LCD panel

LCD24x2 

24x2 LCD panel

LCDuser 

User defined LCD, rows/columns must be set.

Definition at line 76 of file pcf2119.h.


Constructor & Destructor Documentation

TextLCD ( PinName  pSDA,
PinName  pSCL,
PinName  pReset,
LCDType  type = LCD16x2 
)

Create a TextLCD interface.

Parameters:
rsInstruction/data control line
eEnable line (clock)
d4-d7Data lines
typeSets the panel size/addressing mode (default = LCD16x2)

Definition at line 34 of file pcf2119.cpp.


Member Function Documentation

void cls (  )

Clear the screen and locate to 0,0.

Definition at line 61 of file pcf2119.cpp.

void locate ( int  column,
int  row 
)

Locate to a screen column and row.

Parameters:
columnThe horizontal position from the left, indexed from 0
rowThe vertical position from the top, indexed from 0

Definition at line 79 of file pcf2119.cpp.

int printf ( const char *  format,
  ... 
)

Write a formated string to the LCD.

Parameters:
formatA printf-style format string, followed by the variables to use in formating the string.
int putc ( int  c )

Write a character to the LCD.

Parameters:
cThe character to write to the display
void writeCGRAM ( int  address,
int  pattern[8] 
)

write a user defined char

Parameters:
addressThe user defined char (0-7)
pattern[8]bit pattern 5*8 of char

Definition at line 127 of file pcf2119.cpp.

void writeCommand ( int  command )

Get the char at the current position.

int getc()

Definition at line 110 of file pcf2119.cpp.