- Main Page
- Related Pages
- Files

- File List
- Globals

# lcd.h

Go to the documentation of this file.

    00001
    00013 #include <avr/io.h>
    00014 #include <stdio.h>
    00015
    00017 #define INPUT_BUFFER_SIZE 60
    00018
    00019 //set the port you want to use for your LCD
    00020 #define LCD_D_PORT              PORTC           ///< Port for Data Lines DB4-DB7 = Px0-Px3
    00021 #define LCD_E_PORT              PORTD           ///< Port for Control Line E
    00022 #define LCD_RS_PORT     PORTD           ///< Port for Control Line RS
    00023 #define LCD_RW_PORT     PORTD           ///< Port for Control Line RW
    00024 #define LCD_DATAMSK             0x0f            ///< Mask of the Data Pins
    00025
    00026 //set the Pins for Rs,R/W,E
    00027 #define LCD_RS                  4                       ///< Register Set Pin Bitposition
    00028 #define LCD_E                   2                       ///< LCD Enable Pin Bitposition
    00029 #define LCD_RW                  3                       ///< Read / Write Pin Bitposition
    00030
    00031
    00034 #define LCD_TYPE        3
    00035
    00037 #define ks0073
    00038
    00039
    00040 //Constants:
    00041 //Initial Configurations
    00042 #define ENTRY_MODE                      0b00000100
    00043 #define DISPLAY_STATUS          0b00001100
    00044 #define FUNCTION_SET            0b00101000
    00045 #define FUNCTION_SET_RE         0b00100100
    00046 #define EXT_FUNCTION_SET        0b00001001
    00047
    00048 //Command Definitions
    00049 #define LCD_CMD_CLEAR           0x01    ///< LCD Command: Clear Screen
    00050 #define LCD_CMD_HOME            0x02    ///< LCD Command: move cursor to upper left corner
    00051 #define LCD_CMD_MOVE_RIGHT      0x14    ///< LCD Command: move cursor richt by one position
    00052 #define LCD_CMD_MOVE_LEFT       0x10    ///< LCD Command: move cursor left by one position
    00053 #define LCD_CMD_SHIFT_RIGHT     0x1C    ///< LCD Command: shift right
    00054 #define LCD_CMD_SHIFT_LEFT      0x18    ///< LCD Command: shift left
    00055 #define LCD_CMD_DISPLAY_OFF     0x08    ///< LCD Command: Display off
    00056 #define LCD_CMD_DISPLAY_ON      0x0C    ///< LCD Command: Display on (CUESOR and BLINK is OFF)
    00057 #define LCD_CMD_CURSOR_ON       0x0E    ///< LCD Command: Cursor on
    00058 #define LCD_CMD_BLINK_ON        0x0D    ///< LCD Command: Blink on
    00059
    00060
    00061
    00062 #ifndef ASM_FILE
    00063
    00069 void lcd_data(uint8_t data);
    00070
    00075 void lcd_command(uint8_t cmd);
    00076
    00084 void lcd_setadr(uint8_t adr);
    00085
    00092 void lcd_puts(char const *c);
    00093
    00100 void lcd_puts_P(char const *);
    00101
    00106 void lcd_init(void);
    00107
    00112 uint8_t lcd_readadr(void);
    00113
    00126 int lcd_putchar(char data, FILE *sream);
    00127
    00133 void print_buffer(void);
    00134
    00140 void lcd_scroll(void);
    00141
    00142 //Macros
    00143
    00145 #define lcd_home()              lcd_command(LCD_CMD_HOME);
    00146
    00147 #define lcd_clear()             lcd_command(LCD_CMD_CLEAR);
    00148
    00149 #endif
    00150
    00151 #define LCD_D_DDR       (LCD_D_PORT-1)
    00152 #define LCD_D_PIN       (LCD_D_PORT-2)
    00153 #define LCD_E_DDR       (LCD_E_PORT-1)
    00154 #define LCD_RS_DDR      (LCD_RS_PORT-1)
    00155 #define LCD_RW_DDR      (LCD_RW_PORT-1)
    00156
    00157 #if LCD_TYPE == 0
    00158 #define LCD_ROWS 2
    00159 #define LCD_COLS 16
    00160 #endif
    00161
    00162 #if LCD_TYPE == 1
    00163 #define LCD_ROWS 4
    00164 #define LCD_COLS 16
    00165 #endif
    00166
    00167 #if LCD_TYPE == 2
    00168 #define LCD_ROWS 2
    00169 #define LCD_COLS 40
    00170 #endif
    00171
    00172 #if LCD_TYPE == 3
    00173 #define LCD_ROWS 4
    00174 #define LCD_COLS 20
    00175 #endif
    00176
    00177   #ifndef ks0073
    00178         #if LCD_ROWS==4
    00179         #define LCD_LINE1       0x00
    00180         #define LCD_LINE2       0x40
    00181         #define LCD_LINE3       0x14
    00182         #define LCD_LINE4       0x54
    00183         #endif
    00184   #else
    00185         #if LCD_ROWS==2
    00186         #define LCD_LINE1       0x00
    00187         #define LCD_LINE2       0x40
    00188         #elif LCD_ROWS==4
    00189         #define LCD_LINE1       0x00
    00190         #define LCD_LINE2       0x20
    00191         #define LCD_LINE3       0x40
    00192         #define LCD_LINE4       0x60
    00193         #endif
    00194   #endif
    00195