TinyGPU
Loading...
Searching...
No Matches
LCDBoardsSDL.h
Go to the documentation of this file.
1#pragma once
2/**
3 * @file LCDBoardsSDL.h
4 * @brief LCDBoard for the SDL2 desktop backend - renders to a window via
5 * DisplayDriverSDL and maps the mouse to touch via TouchDriverSDL, so
6 * sketches written against the LCDBoard interface can run unmodified on a
7 * desktop for testing/debugging without any physical hardware.
8 *
9 * See LCDBoardsCommon.h for the platform-independent LCDBoard interface this
10 * implements, and LCDBoardsESP32.h for the ESP32 hardware boards.
11 */
12#include "TinyGPU/Boards/LCDBoardsCommon.h"
13#include "TinyGPU/Drivers/DisplayDriverSDL.h"
14#include "TinyGPU/Input/TouchDriverSDL.h"
15
16namespace tinygpu {
17
18/**
19 * @brief Desktop SDL2 window standing in for a physical LCD board. Window
20 * size is set at construction time (default 320x240) since - unlike the
21 * hardware boards in LCDBoardsESP32.h - there is no fixed panel to match.
22 *
23 * The left mouse button stands in for a finger (see TouchDriverSDL).
24 * There is no backlight/I2S/LED hardware on this backend, so i2s()/led()
25 * report "not present" (every field -1) and backlightPin() is -1.
26 */
28 public:
29 LCDBoardDesktopSDL(size_t width = 320, size_t height = 240)
31
32 /// Opens the SDL window and starts mouse-as-touch tracking.
33 bool begin() override {
34 if (!display_.begin()) return false;
35 return touch_.begin();
36 }
37
38 /// Window width in pixels.
39 size_t width() const override { return width_; }
40 /// Window height in pixels.
41 size_t height() const override { return height_; }
42
43 /// The board's display driver.
44 DisplayDriverSDL<RGB565>& display() override { return display_; }
45 /// The board's touch controller (mouse-mapped).
46 TouchDriver* touch() override { return &touch_; }
47 /// No I2S bus on this backend - every field is -1.
48 const I2SPins& i2s() const override { return i2s_; }
49 /// No LED on this backend - every field is -1.
50 const LEDPins& led() const override { return led_; }
51
52 private:
53 size_t width_;
54 size_t height_;
55 DisplayDriverSDL<RGB565> display_;
56 TouchDriverSDL touch_;
57 I2SPins i2s_{};
58 LEDPins led_{};
59};
60
61using DesktopSDL = LCDBoardDesktopSDL;
62
63} // namespace tinygpu
Display class for rendering a Surface<RGB565> using the SDL2 library. This class can be used to displ...
Definition: DisplayDriverSDL.h:26
Desktop SDL2 window standing in for a physical LCD board. Window size is set at construction time (de...
Definition: LCDBoardsSDL.h:27
DisplayDriverSDL< RGB565 > & display() override
The board's display driver.
Definition: LCDBoardsSDL.h:44
size_t height() const override
Window height in pixels.
Definition: LCDBoardsSDL.h:41
const I2SPins & i2s() const override
No I2S bus on this backend - every field is -1.
Definition: LCDBoardsSDL.h:48
TouchDriver * touch() override
The board's touch controller (mouse-mapped).
Definition: LCDBoardsSDL.h:46
size_t width() const override
Window width in pixels.
Definition: LCDBoardsSDL.h:39
bool begin() override
Opens the SDL window and starts mouse-as-touch tracking.
Definition: LCDBoardsSDL.h:33
const LEDPins & led() const override
No LED on this backend - every field is -1.
Definition: LCDBoardsSDL.h:50
LCDBoardDesktopSDL(size_t width=320, size_t height=240)
Definition: LCDBoardsSDL.h:29
Definition: LCDBoardsCommon.h:62
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout.
Definition: RGB565.h:24
Maps the desktop mouse to a TouchDriver, for exercising touch-driven UI (buttons, sliders,...
Definition: TouchDriverSDL.h:25
bool begin() override
Initialize the controller.
Definition: TouchDriverSDL.h:29
Base class for touch controllers.
Definition: TouchDriverCommon.h:72
Definition: DSIBusESP32.h:19
Definition: LCDBoardsCommon.h:28
Definition: LCDBoardsCommon.h:49