#define USE_8_COLORS 0
#define USE_64_COLORS 1
#if USE_8_COLORS
#define VGA_RED GPIO_NUM_22
#define VGA_GREEN GPIO_NUM_21
#define VGA_BLUE GPIO_NUM_19
#define VGA_HSYNC GPIO_NUM_18
#define VGA_VSYNC GPIO_NUM_5
#elif USE_64_COLORS
#define VGA_RED1 GPIO_NUM_22
#define VGA_RED0 GPIO_NUM_21
#define VGA_GREEN1 GPIO_NUM_19
#define VGA_GREEN0 GPIO_NUM_18
#define VGA_BLUE1 GPIO_NUM_5
#define VGA_BLUE0 GPIO_NUM_4
#define VGA_HSYNC GPIO_NUM_23
#define VGA_VSYNC GPIO_NUM_15
#endif
#define DOUBLEBUFFERING 1
struct Test {
virtual ~Test() { };
virtual void update() = 0;
virtual bool nextState() = 0;
virtual int testState() = 0;
virtual char const * name() = 0;
};
#include "ballstest.h"
#include "polygonstest.h"
#include "spritestest.h"
void setup()
{
#if USE_8_COLORS
VGAController.
begin(VGA_RED, VGA_GREEN, VGA_BLUE, VGA_HSYNC, VGA_VSYNC);
#elif USE_64_COLORS
VGAController.
begin(VGA_RED1, VGA_RED0, VGA_GREEN1, VGA_GREEN0, VGA_BLUE1, VGA_BLUE0, VGA_HSYNC, VGA_VSYNC);
#endif
}
void loop()
{
static int64_t stime = esp_timer_get_time();
static int FPS = 0;
static int FPSCounter = 0;
static int testIndex = 0;
static Test * test = new BallsTest;
if (test->nextState() == false) {
delete test;
++testIndex;
switch (testIndex) {
case 1:
test = new PolygonsTest;
break;
case 2:
test = new SpritesTest;
break;
default:
testIndex = 0;
test = new BallsTest;
break;
}
}
if (esp_timer_get_time() - stime > 1000000) {
FPS = FPSCounter;
stime = esp_timer_get_time();
FPSCounter = 0;
}
++FPSCounter;
test->update();
Canvas.
drawTextFmt(80, 5,
" %d %s at %d FPS ", test->testState(), test->name(), FPS);
if (DOUBLEBUFFERING)
}