I have fixed the performance problems in the automatic FPS counter. Now I did not notice any slowdown at all. The fps count is drawn once in 3 seconds.
Also added FPS counter support in some new modes. It is supported now in:
MODE_HI_4COLOR
MODE_FAST_16COLOR
MODE_HI_16COLOR
There are two defines for the FPS counter:
#define PROJ_SHOW_FPS_COUNTER ==> Takes FPS counter into use and shows it automatically. You do not have to do anything in your code. This is what you usually will use. It will look like this on HW and in Simulator:
#define PROJ_USE_FPS_COUNTER ==> Takes FPS counter into use but do not show it automatically. The game itself can read the fps value and and show it as follows:
Pokitto::Core mygame;
uint32_t fps= 0;
while (mygame.isRunning()) {
if (mygame.update()) {
mygame.display.print(0, 0, mygame.fps_counter);
// Draw screen...
}
}
}
Edit: there is an issue with the FPS counting. By using a GPIO pin toggle connected to an oscilloscope, I have verified its not showing the right amount.
We must look at this together
EDIT: just took a look at Pixonia. 33 FPS on the scope, 13 FPS on the FPS counter
I move the rect of 10x10 pixles to left 1 pixel per frame until the right edge reached the screen edge, i.e. 220-10 = 210 pixels. So that is 210 frames also.
If I measure the time it is about 10.5 seconds for the rectangle to go from left to right. So fps is 210/10.5 = 20 fps which matches to the fps counter visible.
The code:
#include "Pokitto.h" // include Pokitto library
Pokitto::Core mygame; //create Pokitto application instance
int main () {
mygame.begin(); // start the application
mygame.display.bgcolor=0; // set color 1
mygame.display.color=2;
Pokitto::Core::setFrameRate(100);
mygame.display.palette[0] = COLOR_BLACK;
mygame.display.palette[1] = COLOR_BLUE;
mygame.display.palette[2] = COLOR_RED;
mygame.display.palette[3] = COLOR_GREEN;
uint32_t x = 0;
while (mygame.isRunning()) {
/* mygame.update() is processed whenever it is time to update the screen */
if (mygame.update()) {
mygame.display.fillRect(x,0,10,10);
if(++x >= 210) x = 0;
}
}
return 0;
}