ASURO Library  2.80
Macros | Functions | Variables
lcd.h File Reference

Library to control LCD over I²c More...

#include "asuro.h"
#include "myasuro.h"
Include dependency graph for lcd.h:

Go to the source code of this file.

Macros

#define LCD_INIT   {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0}
 
#define LCD_DEV   0x40
 
#define LCD_LINES   2
 
#define LCD_CHARS   8
 
#define LCD_LINE1   0x00
 
#define LCD_LINE2   0x40
 
#define LCD_LINE3   0x10
 
#define LCD_LINE4   0x50
 
#define LD4   MY_LCD_LD4
 
#define LD5   MY_LCD_LD5
 
#define LD6   MY_LCD_LD6
 
#define LD7   MY_LCD_LD7
 
#define LRS   MY_LCD_LRS
 
#define LRW   MY_LCD_LRW
 
#define LEN   MY_LCD_LEN
 
#define LBL   MY_LCD_LBL
 
#define LCD_D0   (1 << LD4)
 
#define LCD_D1   (1 << LD5)
 
#define LCD_D2   (1 << LD6)
 
#define LCD_D3   (1 << LD7)
 
#define LCD_D4   (1 << LD4)
 
#define LCD_D5   (1 << LD5)
 
#define LCD_D6   (1 << LD6)
 
#define LCD_D7   (1 << LD7)
 
#define LCD_RS   (1 << LRS)
 
#define LCD_RW   (1 << LRW)
 
#define LCD_EN   (1 << LEN)
 
#define LCD_BL   (1 << LBL)
 
#define LCD_CLEAR   0x01
 
#define LCD_HOME   0x02
 
#define LCD_ENTRYMODE   0x04
 
#define LCD_INCREASE   (LCD_ENTRYMODE | 0x02)
 
#define LCD_DECREASE   (LCD_ENTRYMODE | 0x00)
 
#define LCD_DISPLAYSHIFTON   (LCD_ENTRYMODE | 0x01)
 
#define LCD_DISPLAYSHIFTOFF   (LCD_ENTRYMODE | 0x00)
 
#define LCD_DISPLAYMODE   0x08
 
#define LCD_DISPLAYON   (LCD_DISPLAYMODE | 0x04)
 
#define LCD_DISPLAYOFF   (LCD_DISPLAYMODE | 0x00)
 
#define LCD_CURSORON   (LCD_DISPLAYMODE | 0x02)
 
#define LCD_CURSOROFF   (LCD_DISPLAYMODE | 0x00)
 
#define LCD_BLINKINGON   (LCD_DISPLAYMODE | 0x01)
 
#define LCD_BLINKINGOFF   (LCD_DISPLAYMODE | 0x00)
 
#define LCD_SHIFTMODE   0x10
 
#define LCD_DISPLAYSHIFT   (LCD_SHIFTMODE | 0x08)
 
#define LCD_CURSORMOVE   (LCD_SHIFTMODE | 0x00)
 
#define LCD_RIGHT   (LCD_SHIFTMODE | 0x04)
 
#define LCD_LEFT   (LCD_SHIFTMODE | 0x00)
 
#define LCD_CONFIGURATION   0x20
 
#define LCD_8BIT   (LCD_CONFIGURATION | 0x10)
 
#define LCD_4BIT   (LCD_CONFIGURATION | 0x00)
 
#define LCD_2LINE   (LCD_CONFIGURATION | 0x08)
 
#define LCD_1LINE   (LCD_CONFIGURATION | 0x00)
 
#define LCD_5X10   (LCD_CONFIGURATION | 0x04)
 
#define LCD_5X7   (LCD_CONFIGURATION | 0x00)
 
#define LCD_CGRAM   0x40
 
#define LCD_DDRAM   0x80
 
#define LCD_KEY_YELLOW   (1<<PD6)
 
#define LCD_KEY_RED   (1<<PD2)
 
#define LCD_KEY_BLUE   (1<<PB3)
 
#define PrintLCD_P(_str)   PrintLCD_p(PSTR(_str))
 
#define SetCharLCD_P(_asc, _str)   SetCharLCD_p(_asc, PSTR(_str))
 

Functions

void InitLCD (void)
 Init LCD Hardware.
 
void InitLCDKeys (void)
 Init LCD Keys.
 
void BacklightLCD (unsigned char state)
 Switch LCD Backlight on/off.
 
void SetIOLCD (unsigned char setCommand, unsigned char bits)
 Set LCD IO Port.
 
unsigned char GetIOLCD (void)
 Read LCD IO Port.
 
void SetCursorLCD (unsigned char cursor, unsigned char line)
 Set Cursor.
 
void ClearLCD (void)
 Clears the Display.
 
void SetDataLCD (unsigned char data)
 Write Data LCD, for use with CommandLCD or WriteLCD.
 
void CommandLCD (unsigned char command)
 Set LCD Command, implemented as macro.
 
void WriteLCD (unsigned char data)
 Write Data.
 
void PrintLCD (char *string, unsigned char wrap)
 Print String to LCD.
 
void PrintSetLCD (unsigned char cursor, unsigned char line, char *string)
 Print String at cursor position.
 
void PrintIntLCD (int value)
 Print Integer Value.
 
void PrintAlignLCD (unsigned char line, unsigned char alignment, char *string)
 Print a String at aligned position (left, center right)
 
void PrintLCD_p (const char *progmem_s)
 Print String from Program Space to LCD.
 
void SetCharLCD_p (unsigned char AsciiCode, const char *progmem_s)
 Set special character from Program Space to LCD user character.
 
int PollSwitchLCD (void)
 poll LCD module keys
 

Variables

unsigned char portLCD
 
unsigned char lineLCD
 
unsigned char cursorLCD
 

Detailed Description

Library to control LCD over I²c

LCD Library

This Library is designed for HD44870 based LCDs with I2C expander PCF8574p. It requires I²C Master Software from Peter Fleury. PIN-Assignment: P0-P3 -> DB4-DB7, P4 -> RS, P5 -> R/w, P7 -> Enable. For Use with ASURO Robot

Inspiration from I²C-LCD library by "Nico Eichelmann, Thomas Eichelmann"

Definition in file lcd.h.

Macro Definition Documentation

#define LBL   MY_LCD_LBL

Definition at line 78 of file lcd.h.

#define LCD_1LINE   (LCD_CONFIGURATION | 0x00)

Definition at line 134 of file lcd.h.

#define LCD_2LINE   (LCD_CONFIGURATION | 0x08)

Definition at line 133 of file lcd.h.

#define LCD_4BIT   (LCD_CONFIGURATION | 0x00)

Definition at line 132 of file lcd.h.

#define LCD_5X10   (LCD_CONFIGURATION | 0x04)

Definition at line 135 of file lcd.h.

#define LCD_5X7   (LCD_CONFIGURATION | 0x00)

Definition at line 136 of file lcd.h.

#define LCD_8BIT   (LCD_CONFIGURATION | 0x10)

Definition at line 131 of file lcd.h.

#define LCD_BL   (1 << LBL)

Definition at line 97 of file lcd.h.

#define LCD_BLINKINGOFF   (LCD_DISPLAYMODE | 0x00)

Definition at line 122 of file lcd.h.

#define LCD_BLINKINGON   (LCD_DISPLAYMODE | 0x01)

Definition at line 121 of file lcd.h.

#define LCD_CGRAM   0x40

Definition at line 138 of file lcd.h.

#define LCD_CHARS   8

Definition at line 61 of file lcd.h.

#define LCD_CLEAR   0x01

Definition at line 107 of file lcd.h.

#define LCD_CONFIGURATION   0x20

Definition at line 130 of file lcd.h.

#define LCD_CURSORMOVE   (LCD_SHIFTMODE | 0x00)

Definition at line 126 of file lcd.h.

#define LCD_CURSOROFF   (LCD_DISPLAYMODE | 0x00)

Definition at line 120 of file lcd.h.

#define LCD_CURSORON   (LCD_DISPLAYMODE | 0x02)

Definition at line 119 of file lcd.h.

#define LCD_D0   (1 << LD4)

Definition at line 84 of file lcd.h.

#define LCD_D1   (1 << LD5)

Definition at line 85 of file lcd.h.

#define LCD_D2   (1 << LD6)

Definition at line 86 of file lcd.h.

#define LCD_D3   (1 << LD7)

Definition at line 87 of file lcd.h.

#define LCD_D4   (1 << LD4)

Definition at line 89 of file lcd.h.

#define LCD_D5   (1 << LD5)

Definition at line 90 of file lcd.h.

#define LCD_D6   (1 << LD6)

Definition at line 91 of file lcd.h.

#define LCD_D7   (1 << LD7)

Definition at line 92 of file lcd.h.

#define LCD_DDRAM   0x80

Definition at line 139 of file lcd.h.

#define LCD_DECREASE   (LCD_ENTRYMODE | 0x00)

Definition at line 112 of file lcd.h.

#define LCD_DEV   0x40

Definition at line 59 of file lcd.h.

#define LCD_DISPLAYMODE   0x08

Definition at line 116 of file lcd.h.

#define LCD_DISPLAYOFF   (LCD_DISPLAYMODE | 0x00)

Definition at line 118 of file lcd.h.

#define LCD_DISPLAYON   (LCD_DISPLAYMODE | 0x04)

Definition at line 117 of file lcd.h.

#define LCD_DISPLAYSHIFT   (LCD_SHIFTMODE | 0x08)

Definition at line 125 of file lcd.h.

#define LCD_DISPLAYSHIFTOFF   (LCD_ENTRYMODE | 0x00)

Definition at line 114 of file lcd.h.

#define LCD_DISPLAYSHIFTON   (LCD_ENTRYMODE | 0x01)

Definition at line 113 of file lcd.h.

#define LCD_EN   (1 << LEN)

Definition at line 96 of file lcd.h.

#define LCD_ENTRYMODE   0x04

Definition at line 110 of file lcd.h.

#define LCD_HOME   0x02

Definition at line 108 of file lcd.h.

#define LCD_INCREASE   (LCD_ENTRYMODE | 0x02)

Definition at line 111 of file lcd.h.

#define LCD_INIT   {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0}

Definition at line 56 of file lcd.h.

#define LCD_KEY_BLUE   (1<<PB3)

Definition at line 144 of file lcd.h.

#define LCD_KEY_RED   (1<<PD2)

Definition at line 143 of file lcd.h.

#define LCD_KEY_YELLOW   (1<<PD6)

Definition at line 142 of file lcd.h.

#define LCD_LEFT   (LCD_SHIFTMODE | 0x00)

Definition at line 128 of file lcd.h.

#define LCD_LINE1   0x00

Definition at line 63 of file lcd.h.

#define LCD_LINE2   0x40

Definition at line 64 of file lcd.h.

#define LCD_LINE3   0x10

Definition at line 65 of file lcd.h.

#define LCD_LINE4   0x50

Definition at line 66 of file lcd.h.

#define LCD_LINES   2

Definition at line 60 of file lcd.h.

#define LCD_RIGHT   (LCD_SHIFTMODE | 0x04)

Definition at line 127 of file lcd.h.

#define LCD_RS   (1 << LRS)

Definition at line 94 of file lcd.h.

#define LCD_RW   (1 << LRW)

Definition at line 95 of file lcd.h.

#define LCD_SHIFTMODE   0x10

Definition at line 124 of file lcd.h.

#define LD4   MY_LCD_LD4

Definition at line 70 of file lcd.h.

#define LD5   MY_LCD_LD5

Definition at line 71 of file lcd.h.

#define LD6   MY_LCD_LD6

Definition at line 72 of file lcd.h.

#define LD7   MY_LCD_LD7

Definition at line 73 of file lcd.h.

#define LEN   MY_LCD_LEN

Definition at line 77 of file lcd.h.

#define LRS   MY_LCD_LRS

Definition at line 75 of file lcd.h.

#define LRW   MY_LCD_LRW

Definition at line 76 of file lcd.h.

#define PrintLCD_P (   _str)    PrintLCD_p(PSTR(_str))

Definition at line 262 of file lcd.h.

#define SetCharLCD_P (   _asc,
  _str 
)    SetCharLCD_p(_asc, PSTR(_str))

Definition at line 271 of file lcd.h.

Function Documentation

void BacklightLCD ( unsigned char  state)

Switch LCD Backlight on/off.

Parameters
stateOn or off
void ClearLCD ( void  )

Clears the Display.

void CommandLCD ( unsigned char  command)

Set LCD Command, implemented as macro.

Parameters
commandLCD command
unsigned char GetIOLCD ( void  )

Read LCD IO Port.

Returns
IO Port
void InitLCD ( void  )

Init LCD Hardware.

void InitLCDKeys ( void  )

Init LCD Keys.

int PollSwitchLCD ( void  )

poll LCD module keys

Returns
keys pressed bit coded
void PrintAlignLCD ( unsigned char  line,
unsigned char  alignment,
char *  string 
)

Print a String at aligned position (left, center right)

Parameters
lineLine number
alignmentleft, center or right aligned
stringstring pointer
void PrintIntLCD ( int  value)

Print Integer Value.

Parameters
valueInteger value
void PrintLCD ( char *  string,
unsigned char  wrap 
)

Print String to LCD.

Parameters
stringString pointer
wrapString Wrapped or not
void PrintLCD_p ( const char *  progmem_s)

Print String from Program Space to LCD.

Parameters
progmem_sString pointer
void PrintSetLCD ( unsigned char  cursor,
unsigned char  line,
char *  string 
)

Print String at cursor position.

Parameters
cursorCursor position
lineline number
stringString pointer
void SetCharLCD_p ( unsigned char  AsciiCode,
const char *  progmem_s 
)

Set special character from Program Space to LCD user character.

Parameters
AsciiCodeASCII code
progmem_sString pointer
void SetCursorLCD ( unsigned char  cursor,
unsigned char  line 
)

Set Cursor.

Parameters
cursorcursor position
lineline number
void SetDataLCD ( unsigned char  data)

Write Data LCD, for use with CommandLCD or WriteLCD.

Parameters
dataLCD Data
void SetIOLCD ( unsigned char  setCommand,
unsigned char  bits 
)

Set LCD IO Port.

Parameters
setCommandON or OFF
bitsBits to set
void WriteLCD ( unsigned char  data)

Write Data.

Parameters
dataLCD Data

Variable Documentation

unsigned char cursorLCD

Definition at line 150 of file lcd.h.

unsigned char lineLCD

Definition at line 149 of file lcd.h.

unsigned char portLCD

Definition at line 148 of file lcd.h.