static void lcd_data_bus_test(void) { unsigned short temp1; unsigned short temp2; /* wirte */ lcd_SetCursor(0,0); rw_data_prepare(); write_data(0x5555); lcd_SetCursor(1,0); rw_data_prepare(); write_data(0xAAAA); /* read */ lcd_SetCursor(0,0); temp1 = lcd_read_gram(0,0); temp2 = lcd_read_gram(1,0); if( (temp1 == 0x5555) && (temp2 == 0xAAAA) ) { //printf(" data bus test pass!\r\n"); } else { //printf(" data bus test error: %04X %04X\r\n",temp1,temp2); } }
static void lcd_data_bus_test(void) { unsigned short temp1; unsigned short temp2; // /* [5:4]-ID~ID0 [3]-AM-1垂直-0水平 */ // write_reg(0x0003,(1<<12)|(1<<5)|(1<<4) | (0<<3) ); /* wirte */ lcd_SetCursor(0,0); rw_data_prepare(); write_data(0x5555); lcd_SetCursor(1,0); rw_data_prepare(); write_data(0xAAAA); /* read */ lcd_SetCursor(0,0); temp1 = lcd_read_gram(0,0); temp2 = lcd_read_gram(1,0); if( (temp1 == 0x5555) && (temp2 == 0xAAAA) ) { printf(" data bus test pass!\r\n"); } else { printf(" data bus test error: %04X %04X\r\n",temp1,temp2); } }
/* 设置像素点 颜色,X,Y */ void ssd1289_lcd_set_pixel(const char* pixel, int x, int y) { lcd_SetCursor(x,y); rw_data_prepare(); write_data(*(rt_uint16_t*)pixel); }
/* 读取指定地址的GRAM */ static unsigned short lcd_read_gram(unsigned int x,unsigned int y) { unsigned short temp; lcd_SetCursor(x,y); rw_data_prepare(); /* dummy read */ temp = read_data(); temp = read_data(); return temp; }
void lcd_clear(unsigned short Color) { unsigned int index=0; lcd_SetCursor(0,0); rw_data_prepare(); /* Prepare to write GRAM */ for (index=0; index<(LCD_WIDTH*LCD_HEIGHT); index++) { write_data(Color); } }
/* 垂直线 */ void ssd1289_lcd_draw_vline(const char* pixel, int x, int y1, int y2) { /* [5:4]-ID~ID0 [3]-AM-1垂直-0水平 */ write_reg(0x0011,0x6070 | (1<<3)); // AM=0 vline lcd_SetCursor(x, y1); rw_data_prepare(); /* Prepare to write GRAM */ while (y1 < y2) { write_data(*(rt_uint16_t*)pixel); y1++; } }
/* 画水平线 */ void ssd1289_lcd_draw_hline(const char* pixel, int x1, int x2, int y) { /* [5:4]-ID~ID0 [3]-AM-1垂直-0水平 */ write_reg(0x0011,0x6030 | (0<<3)); // AM=0 hline lcd_SetCursor(x1, y); rw_data_prepare(); /* Prepare to write GRAM */ while (x1 < x2) { write_data(*(rt_uint16_t*)pixel); x1++; } }
/* blit a line */ void ssd1289_lcd_blit_line(const char* pixels, int x, int y, rt_size_t size) { rt_uint16_t *ptr; ptr = (rt_uint16_t*)pixels; /* [5:4]-ID~ID0 [3]-AM-1垂直-0水平 */ write_reg(0x0011,0x6070 | (0<<3)); // AM=0 hline lcd_SetCursor(x, y); rw_data_prepare(); /* Prepare to write GRAM */ while (size) { write_data(*ptr ++); size --; } }
void LCD_write_english(uint16_t x,uint16_t y,uint8_t str,unsigned int color,unsigned int xcolor)//д×Ö·û { uint16_t xpos = x; uint16_t ypos = y; unsigned char avl,i,n; for(i=0; i<16; i++) //16ÐÐ { avl= (english[str-32][i]); lcd_SetCursor(xpos,ypos); ypos++; rw_data_prepare(); for(n=0; n<8; n++) //8ÁÐ { if(avl&0x80) write_data(color); else write_data(xcolor); avl<<=1; } } }