So after a complete rewrite of the render function i split the display buffer in two.
One "Displaybuffer" which buffers everything on screen. A interrupt task which shifts out this buffer on the screen every x-milliseconds.
Via TWI we can write into an, i call it, "shadowbuffer". Only after we give a command to copy the shadowbuffer into the displaybuffer we can see what we send over. This reduces flickering by A LOT.
To write a pixel we simply send the X, Y and color value via TWI. While this is comparably awfully slow its incredibly easy to use.
So a write pixel function on an Arduino looks like this:
void Scr_DrawPixel(char x, char y, char col){
Wire.beginTransmission(0x41);
Wire.write(2);
Wire.write(x);
Wire.write(y);
Wire.write(col);
Wire.endTransmission();
}
So lets test the possible refresh rate with a simple arduino program:
for(int c=0; c<8; c++){
for(int x=0; x<64; x++){
for(int y=0; y<64; y++){
Scr_DrawPixel(y,x,c); // Write pixel
}
}
Scr_CopyBuf(); //copy shadow buffer into screenbuffer
}
Increasing the TWI speed of the Arduino up to 700Khz we can reach up to 365ms/frame in 64x64 mode.
Decreasing the resolution down to a 32x32 screen we can get 90ms (~10FPS)
While this is not very much and pretty slow/unusable for video playback...... IT IS NOT THE INTENDED PURPOSE.
Goal is to make it as easy as possible. This way the TWI master is free to do whatever and does not have to render every frame.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.