diff --git a/sys/pic32/st7781.c b/sys/pic32/st7781.c index 442a7e9..275fa21 100644 --- a/sys/pic32/st7781.c +++ b/sys/pic32/st7781.c @@ -97,6 +97,60 @@ static int _chip_id; #define RS_DATA() LAT_SET(LCD_RS_PORT) = 1<= WIDTH || y < 0 || y >= HEIGHT) return; CS_ACTIVE(); - writeReg(0x20, x); - writeReg(0x21, y); - writeReg(0x22, color); + writeReg(ST7781_DRAM_Horizontal_Address_Set, x); + writeReg(ST7781_DRAM_Vertical_Address_Set, y); + writeReg(ST7781_Write_Data_to_DRAM, color); CS_IDLE(); } @@ -370,8 +424,8 @@ static void flood(int color, int npixels) CS_ACTIVE(); RS_COMMAND(); - writeByte(0x00); // High byte of GRAM register... - writeByte(0x22); // Write data to GRAM + writeByte(0x00); /* High address byte */ + writeByte(ST7781_Write_Data_to_DRAM); /* Write first pixel normally, decrement counter by 1. */ RS_DATA(); @@ -460,8 +514,8 @@ static void drawImage(int x, int y, int width, int height, setAddrWindow(x, y, x + width - 1, y + height - 1); CS_ACTIVE(); RS_COMMAND(); - writeByte(0x00); - writeByte(0x22); + writeByte(0x00); /* High address byte */ + writeByte(ST7781_Write_Data_to_DRAM); RS_DATA(); while (cnt--) { color = *data++; @@ -599,8 +653,8 @@ static void drawGlyph(const struct gpanel_font_t *font, setAddrWindow(_col, _row, _col + width - 1, _row + font->height - 1); CS_ACTIVE(); RS_COMMAND(); - writeByte(0x00); - writeByte(0x22); + writeByte(0x00); /* High address byte */ + writeByte(ST7781_Write_Data_to_DRAM); RS_DATA(); /* Loop on each glyph row. */ @@ -742,8 +796,8 @@ int gpanel_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) struct gpanel_clear_t *param = (struct gpanel_clear_t*) addr; CS_ACTIVE(); - writeReg(0x20, 0); - writeReg(0x21, 0); + writeReg(ST7781_DRAM_Horizontal_Address_Set, 0); + writeReg(ST7781_DRAM_Vertical_Address_Set, 0); flood(param->color, WIDTH * HEIGHT); param->xsize = WIDTH; param->ysize = HEIGHT;