Hello all, I am having a hard time finding the best way of optimising a function as some of the things I have tried do not behave as expected and I am struggling to understand why?
This is the fastest performing version so far :-
if (_UTFT->_transparent==0) {
if (!(_UTFT->orient == LANDSCAPE && _UTFT->display_model == CPLD)) {
setXY(X, Y, X + Image_Width - 1, Y + Image_Height - 1, 1);
CD_DATA;
for (x_1 = 0; x_1 < Image_Height; x_1++) {
_SPIread(databyte, (im2));
for (y_1 = 0; y_1 < im2; y_1+=2) {
write16((databyte[y_1 ] << 8 | databyte[y_1 + 1]));
}
}
}
else { // CPLD PORTRAIT
for (y_1 = 0; y_1 < Image_Height; y_1++) {
_SPIread(databyte, im2);
setXY(X, Y + y_1, X + Image_Width, Y + y_1, 1);
CD_DATA;
for(x_1=im2-2;x_1>0;x_1-=2) {
write16((databyte[x_1 ] << 8 | databyte[x_1 + 1]));
}
}
}
}
else
{ // Transparent
for (y_1 = 0; y_1 < Image_Height; y_1++) {
_SPIread(databyte, im2);
for (x_1 = 0; x_1 < im2; x_1+=2) {
if (((databyte[x_1] << 8) + databyte[x_1 + 1]) != 0) {
setXY(x_1 + X, y_1 + Y, x_1 + X, y_1 + Y, 0);
WriteData((databyte[x_1] << 8 | databyte[x_1 + 1]));
}
}
}
}
if (result < flash1) sbi(P_F_CS, B_F_CS);
else if (result >= flash1 && (result < (flash1 + flash2))) sbi(P_F_CS2, B_F_CS2);
else sbi(P_F_CS3, B_F_CS3);
Here are the performance figures for the function shown above for an image size of 320x180
425 frames drawn in 18067.91ms =23.52 FPS
425 frames drawn in 18067.94ms =23.52 FPS
425 frames drawn in 18067.94ms =23.52 FPS
425 frames drawn in 18067.94ms =23.52 FPS
425 frames drawn in 18067.94ms =23.52 FPS
But, none of the images I wish to draw in the current test uses transparent images, so you might assume that by removing all of the transparency conditions it would speed things up like this, but this has the effect of slowing it down dramatically, why ?
if (!(_UTFT->orient == LANDSCAPE && _UTFT->display_model == CPLD)) {
setXY(X, Y, X + Image_Width - 1, Y + Image_Height - 1, 1);
CD_DATA;
for (x_1 = 0; x_1 < Image_Height; x_1++) {
_SPIread(databyte, (im2));
for (y_1 = 0; y_1 < im2; y_1+=2) {
write16((databyte[y_1 ] << 8 | databyte[y_1 + 1]));
}
}
}
else { // CPLD PORTRAIT
for (y_1 = 0; y_1 < Image_Height; y_1++) {
_SPIread(databyte, im2);
setXY(X, Y + y_1, X + Image_Width, Y + y_1, 1);
CD_DATA;
for(x_1=im2-2;x_1>0;x_1-=2) {
write16((databyte[x_1 ] << 8 | databyte[x_1 + 1]));
}
}
}
if (result < flash1) sbi(P_F_CS, B_F_CS);
else if (result >= flash1 && (result < (flash1 + flash2))) sbi(P_F_CS2, B_F_CS2);
else sbi(P_F_CS3, B_F_CS3);
Here are the performance figures for the function shown above for an image size of 320x180
425 frames drawn in 22707.50ms =18.72 FPS
425 frames drawn in 22707.48ms =18.72 FPS
425 frames drawn in 22707.48ms =18.72 FPS
425 frames drawn in 22707.48ms =18.72 FPS
425 frames drawn in 22707.48ms =18.72 FPS
Regards,
Graham