Jump to content

Driver for PCF8812 problem


pashamray

Recommended Posts

Hello and welcome to the community!

If it writes bytes directly through SPI, then everything is OK.

Could you please point directly to the working code and the not working board file? When I understand you correctly you already have a working driver and just porting it to uGFX does not work?

~ Tectu

Link to comment
Share on other sites

Thank you.

I found a bug, I'm ashamed.

I used to output data code:


unsigned int i;

for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) {
write_data(g, RAM(g) + i, 1);
}

as needed:


unsigned int i;

for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) {
write_data(g, RAM(g)[i], 1);
}

sorry.

uploaded working code repository.

Link to comment
Share on other sites

Does your display controller provide a native orientation mode? As in: Can you tell him to flip 90°?

If not, it's just a matter of doing some calculations for the pixel positions. The following is a code snipped from the framebuffer driver:


LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
unsigned pos;

#if GDISP_NEED_CONTROL
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
default:
pos = PIXIL_POS(g, g->p.x, g->p.y);
break;
case GDISP_ROTATE_90:
pos = PIXIL_POS(g, g->p.y, g->g.Width-g->p.x-1);
break;
case GDISP_ROTATE_180:
pos = PIXIL_POS(g, g->g.Width-g->p.x-1, g->g.Height-g->p.y-1);
break;
case GDISP_ROTATE_270:
pos = PIXIL_POS(g, g->g.Height-g->p.y-1, g->p.x);
break;
}
#else
pos = PIXIL_POS(g, g->p.x, g->p.y);
#endif
}

Sometimes it's also a good idea to take a look at already existing drivers.

~ Tectu

Link to comment
Share on other sites

There's one thing that inmarket and I recognized:

You are limiting the performance through the board file extremely. You're calling write_data(g, RAM(g), 1); in a for-loop but the function is actually meant to take the size of bytes so everything can be done in one call. The reason why this does/did not work for you is because in your board file you're using spiStartSend. However, that call is asynchronous so you have to wait for the completion of the transmission! You can use spiSend() instead as this is operation is synchronous.

Could you please try it this way so we can modify the driver to improve the performance?

~ Tectu

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...