One day, One problem.
Today I look for writing a Gfx driver for my ssd1322 Oled display.
May be I say bullshit but this is what I have understand about the display :
- The display have a 4 bpp depth, so I need to have 2 pixels for sending one data byte.
- Worst : Columns are addressing 4 by 4 (May be it is configurable at init ?), so I need to have 4 pixels for sending.
This is what I have written for testing the 2 pixels 'frame buffer' :
Code: Select all
void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
//We need to send 2 pixel at a time for 4 bpp depth
//So impair pixel must be kept for sending with the next one (the pair pixel associate with this one)
static waiting_pixel;
static waiting_pixel_x;
static waiting_pixel_y;
static waiting_pixel_color;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
#endif
//if imppair pixel
if ( x&0x01 )
{
acquire_bus();
setviewport(x, y, 1, 1);
if (!waiting_pixel)
waiting_pixel_color = 0;
write_cmd1(RAMWR, ( (waiting_pixel_color<<4) & 0xF0) | ( color & 0x0F) );
release_bus();
waiting_pixel = 0;
}
else //else impair pixel
{
//if we have one pixel waiting but actuel pixel is not the pair
// we send the last pixel with a black associated impair pixel
if (waiting_pixel)
gdisp_lld_draw_pixel(waiting_pixel_x + 1, waiting_pixel_y, 0);
//Store the new impair pixel
waiting_pixel = 1;
waiting_pixel_x = x;
waiting_pixel_y = y;
waiting_pixel_color = color;
}
}
I can have a problem and erase some pixels with this algorithm.
For 4 pixels, it will be more compicated and the possiblity of losing of pixels grown.
The only way I see is to store ALL unfinished group of 4 pixels. and flush them at the end. It is a fractionned frame buffer. In the worst case, I will use a complete frame buffer of 8ko (256x64/2)
I heard about ccm Ram, can I store this to ccm ? Is ChibiOs use ccm ?
Do you see another method ?