pyrorf/lcd.h
arnaud.houdelette 044633f59d Ecriture suite
2019-09-05 11:44:41 +02:00

88 lines
2.6 KiB
C

#ifndef defines_lcd
#define defines_lcd
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "i2c.h"
// LCD Commands
// ---------------------------------------------------------------------------
#define LCD_CLEARDISPLAY 0x01
#define LCD_RETURNHOME 0x02
#define LCD_ENTRYMODESET 0x04
#define LCD_DISPLAYCONTROL 0x08
#define LCD_CURSORSHIFT 0x10
#define LCD_FUNCTIONSET 0x20
#define LCD_SETCGRAMADDR 0x40
#define LCD_SETDDRAMADDR 0x80
// flags for display entry mode
// ---------------------------------------------------------------------------
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00
// flags for display on/off and cursor control
// ---------------------------------------------------------------------------
#define LCD_DISPLAYON 0x04
#define LCD_DISPLAYOFF 0x00
#define LCD_CURSORON 0x02
#define LCD_CURSOROFF 0x00
#define LCD_BLINKON 0x01
#define LCD_BLINKOFF 0x00
// flags for display/cursor shift
// ---------------------------------------------------------------------------
#define LCD_DISPLAYMOVE 0x08
#define LCD_CURSORMOVE 0x00
#define LCD_MOVERIGHT 0x04
#define LCD_MOVELEFT 0x00
// flags for function set
// ---------------------------------------------------------------------------
#define LCD_8BITMODE 0x10
#define LCD_4BITMODE 0x00
#define LCD_2LINE 0x08
#define LCD_1LINE 0x00
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00
// Define COMMAND and DATA LCD Rs (used by send method).
// ---------------------------------------------------------------------------
#define COMMAND 0
#define LCD_DATA 1
#define FOUR_BITS 2
#define HOME_CLEAR_EXEC 2000
#define LCD_ADDRESS 0x37
void lcd_init(uint8_t cols, uint8_t lines);
void lcd_clear();
void lcd_home();
void lcd_setCursor(uint8_t col, uint8_t row);
void lcd_write(uint8_t value);
void lcd_createChar(uint8_t location, const char *charmap);
void lcd_noDisplay() ;
void lcd_display() ;
void lcd_noCursor() ;
void lcd_cursor() ;
void lcd_noBlink() ;
void lcd_blink() ;
void lcd_scrollDisplayLeft(void) ;
void lcd_scrollDisplayRight(void) ;
void lcd_moveCursorRight(void);
void lcd_moveCursorLeft(void);
void lcd_leftToRight(void) ;
void lcd_rightToLeft(void) ;
void lcd_autoscroll(void) ;
void lcd_noAutoscroll(void);
#endif