#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 PS2_PORT0_CLK GPIO_NUM_26
#define PS2_PORT0_DAT GPIO_NUM_27
int indicatorX = 300;
int indicatorY = 170;
int cursor = 0;
void showCursorPos(MouseStatus const & status)
{
Canvas.
drawTextFmt(indicatorX, indicatorY,
" %d %d ", status.X, status.Y);
}
void setup()
{
Serial.begin(115200); delay(500); Serial.write("\n\n\n");
#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
Mouse.
begin(PS2_PORT0_CLK, PS2_PORT0_DAT);
showCursorPos(Mouse.
status());
}
void loop()
{
if (status.buttons.left) {
Canvas.
moveTo(status.X, status.Y);
}
if (status.buttons.right) {
}
if (status.buttons.middle) {
}
if (status.wheelDelta != 0) {
indicatorY = fabgl::tclamp(indicatorY + status.wheelDelta, 0, Canvas.
getHeight() - 16);
}
showCursorPos(status);
}