#ifndef __LIQUID_CRYSTAL_H
#define __LIQUID_CRYSTAL_H

#include "lcd_drv.h"
#include "_config_cpu_display.h"

// commands
#define LCD_CLEAR_DISPLAY 	0x01
#define LCD_RETURN_HOME 	0x02
#define LCD_ENTRY_MODE_SET 	0x04
#define LCD_DISPLAY_CONTROL	0x08
#define LCD_CURSOR_SHIFT 	0x10
#define LCD_FUNCTION_SET 	0x20
#define LCD_SET_CGRAM_ADDR 	0x40
#define LCD_SET_DDRAM_ADDR 	0x80

// flags for display entry mode
#define LCD_ENTRY_RIGHT 			0x00
#define LCD_ENTRY_LEFT 				0x02
#define LCD_ENTRY_SHIFT_INCREMENT 	0x01
#define LCD_ENTRY_SHIFT_DECREMENT 	0x00

// flags for display on/off control
#define LCD_DISPLAY_ON 	0x04
#define LCD_DISPLAY_OFF 0x00
#define LCD_CURSOR_ON	0x02
#define LCD_CURSOR_OFF 	0x00
#define LCD_BLINK_ON 	0x01
#define LCD_BLINK_OFF 	0x00

// flags for display/cursor shift
#define LCD_DISPLAY_MOVE 	0x08
#define LCD_CURSOR_MOVE 	0x00
#define LCD_MOVE_RIGHT 		0x04
#define LCD_MOVE_LEFT 		0x00

// flags for function set
#define LCD_8BIT_MODE 	0x10
#define LCD_4BIT_MODE 	0x00
#define LCD_2LINE 		0x08
#define LCD_1LINE 		0x00
#define LCD_5x10DOTS 	0x04
#define LCD_5x8DOTS 	0x00

void lcd_Init(u8 cols, u8 lines, u8 dotsize);
void lcd_Clear(void);
void lcd_Home(void);
void lcd_SetCursor(u8 col, u8 row);
void lcd_NoDisplay(void);
void lcd_Display(void);
void lcd_NoCursor(void);
void lcd_Cursor(void);
void lcd_NoBlink(void);
void lcd_Blink(void);
void lcd_ScrollDisplayLeft(void);
void lcd_ScrollDisplayRight(void);
void lcd_LeftToRight(void);
void lcd_RightToLeft(void);
void lcd_AutoScroll(void);
void lcd_NoAutoScroll(void);
void lcd_CreateChar(u8 location, u8 charmap[]);
int lcd_PutChar(n16 ch);

#if (LCD_USE_PRINTF == pdON)
void lcd_printfInit(uint cols, uint dev);
void lcd_printf(const cpchar fmt, ...);
#endif

#endif
