pic_therm

PIC16F877A and BME280 thermometer
git clone git://git.margiolis.net/pic_therm.git
Log | Files | Refs | README | LICENSE

lcd.c (954B)


      1 #include "extern.h"
      2 #include "lcd.h"
      3 #include "tmr0.h"
      4 
      5 #define LCD_RS PORTCbits.RC0	/* Instruction reg: 0, Data reg: 1 */
      6 #define LCD_RW PORTCbits.RC1	/* Write: 0, Read: 1 */
      7 #define LCD_EN PORTCbits.RC2	/* Enable read/write */
      8 #define LCD_RS_TRIS TRISCbits.TRISC0
      9 #define LCD_RW_TRIS TRISCbits.TRISC1
     10 #define LCD_EN_TRIS TRISCbits.TRISC2
     11 #define LCD_PORT_DATA PORTD
     12 #define LCD_TRIS_DATA TRISD
     13 
     14 void
     15 lcd_init(void)
     16 {
     17 	LCD_RS_TRIS = OUTPUT;
     18 	LCD_RW_TRIS = OUTPUT;
     19 	LCD_EN_TRIS = OUTPUT;
     20 	LCD_PORT_DATA = OUTPUT;
     21 	LCD_TRIS_DATA = OUTPUT;
     22 	LCD_RS = 0;
     23 	LCD_RW = 0;
     24 	LCD_EN = 0;
     25 	
     26 	lcd_cmd(LCD_MODE);
     27 	tmr0_delay_ms(LCD_DELAY_STARTUP);
     28 	lcd_cmd(LCD_CURS_ROW1);
     29 	lcd_cmd(LCD_CURS_OFF);
     30 	lcd_cmd(LCD_CURS_INC);
     31 	lcd_cmd(LCD_CLEAR);
     32 }
     33 
     34 void
     35 lcd_data(uint8_t c, uint8_t rs)
     36 {
     37 	LCD_RS = rs;
     38 	LCD_RW = 0;
     39 	LCD_PORT_DATA = c;
     40 	LCD_EN = 1;
     41 	tmr0_delay_ms(LCD_DELAY_CMD);
     42 	LCD_EN = 0;
     43 }
     44 
     45 void
     46 lcd_puts(const char *str)
     47 {
     48 	while (*str != '\0')
     49 		lcd_putc(*str++);
     50 }