uint8_t lcd_waitbusy() { __IO uint8_t c; //wait until the DB7 signal is gone while( (c=lcd_read(0)) & (1<<LCD_BUSY)); Delay(16); //return address counter return lcd_read(0); }
/************************************************************************* loops while lcd is busy, returns address counter *************************************************************************/ static uint8_t lcd_waitbusy(void) { register uint8_t c; /* wait until busy flag is cleared */ while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {} /* the address counter is updated 4us after the busy flag is cleared */ delay(2); /* now read the address counter */ return (lcd_read(0)); // return address counter }/* lcd_waitbusy */
void lcd_plotpixel(unsigned char rx, unsigned char ry) { unsigned char data; _lcd_waitbusy(); // select the correct side if (rx & 64) lcd_selectside(RIGHT); else lcd_selectside(LEFT); lcd_setpage( ry >> 3); lcd_setxaddr( rx & 0b00111111); data = lcd_read(); // dummy read needed here data = lcd_read(); lcd_setxaddr( rx & 0b00111111); lcd_write (data | (1 << (ry & 0b111))); }
static void lcd_waitbusy(void) { register uint8_t c; unsigned int ul1=0; // Wait Until Busy Flag is Cleared while ( ((c=lcd_read(0)) & (1<<LCD_BUSY)) && ul1<((F_CPU/16384>=16)?F_CPU/16384:16)) ul1++; }
uint8_t lcd_state_read(uint8_t chip) { wait_while_busy(chip); uint8_t temp_state; HIGH(RW_PORT, RW_PIN); LOW(RS_PORT, RS_PIN); temp_state = lcd_read(); return temp_state; }
uint8_t lcd_data_read(uint8_t chip) { wait_while_busy(chip); uint8_t data; HIGH(RW_PORT, RW_PIN);//read HIGH(RS_PORT, RS_PIN);//data data = lcd_read(); return data; }
static uint16_t LCD_ReadDat(){ cs::set( 0 ); rs::set( 1 ); wr::set( 1 ); rd::set( 0 ); int temp = lcd_read(); rd::set( 1 ); cs::set( 1 ); return temp; }
static inline unsigned short rd_dat (void) { unsigned short val = 0; LCD_RS(1) LCD_WR(1) //LCD_RD(0); val = lcd_read(); //LCD_RD(1); return val; }
// wait for busy flag to go away void lcd_busy_wait(void) { lcd_set_instruction(); lcd_set_port_read(); lcd_set_read(); lcd_set_enable_on(); LCD_DELAY; while (lcd_read() & LCD_GET_BF) { lcd_set_enable_off(); LCD_DELAY; LCD_DELAY; lcd_set_enable_on(); LCD_DELAY; LCD_DELAY; } lcd_set_enable_off(); }
// generic get uint8_t lcd_get(uint8_t type) { uint8_t data; lcd_busy_wait(); lcd_set_port_read(); lcd_write(0xFF); if (type) { lcd_set_data(); } else { lcd_set_instruction(); } lcd_set_read(); lcd_set_enable_on(); LCD_DELAY; LCD_DELAY; data = lcd_read(); lcd_set_enable_off(); return data; }
/* waits until busy flag is not set, i.e. the next instruction can be sent */ static void waitbusy(void) { while (lcd_read(0) & BF_MASK) ; }
uint8_t lcd_getc(void) { return lcd_read(1); }
uint8_t lcd_status() { return lcd_read(LCD_RS_COMMAND); }
void lcd_sendstat(u8_t *x){ for(int i = 0; x[i] != '\0'; i++){ RS(1); // Rs = 1 lcd_read(x[i]); } }
void lcd_senddata(unsigned char cmd){ RS(1); // Rs = 1 lcd_read(cmd); }
void lcd_sendcmd(unsigned char cmd){ RS(0); // Rs = 0 lcd_read(cmd); }
static uint8_t lcd_read_cmd( void ) { RS_DISABLE; return lcd_read(); }
static uint8_t lcd_read_data( void ) { RS_ENABLE; return lcd_read(); }