9 ESP_LOGD(TAG,
"Starting setup");
10 SDL_Init(SDL_INIT_VIDEO);
11 this->
window_ = SDL_CreateWindow(
App.
get_name().c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
13 this->
renderer_ = SDL_CreateRenderer(this->
window_, -1, SDL_RENDERER_SOFTWARE);
15 SDL_CreateTexture(this->renderer_, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, this->width_, this->height_);
16 SDL_SetTextureBlendMode(this->
texture_, SDL_BLENDMODE_BLEND);
17 ESP_LOGD(TAG,
"Setup Complete");
21 if ((this->x_high_ < this->
x_low_) || (this->y_high_ < this->
y_low_))
24 this->x_low_ = this->
width_;
34 SDL_Rect rect{x_start, y_start, w, h};
36 display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset,
39 auto stride = x_offset + w + x_pad;
40 auto data = ptr + (stride * y_offset + x_offset) * 2;
41 SDL_UpdateTexture(this->
texture_, &rect, data, stride * 2);
48 SDL_Rect rect{
x,
y, 1, 1};
50 SDL_UpdateTexture(this->
texture_, &rect, &data, 2);
63 if (SDL_PollEvent(&e)) {
68 case SDL_MOUSEBUTTONDOWN:
69 case SDL_MOUSEBUTTONUP:
70 if (e.button.button == 1) {
78 if (e.motion.state & 1) {
88 ESP_LOGV(TAG,
"Event %d", e.type);
static uint16_t color_to_565(Color color, ColorOrder color_order=ColorOrder::COLOR_ORDER_RGB)
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
Application App
Global storage of Application pointer - only one Application can exist.
const std::string & get_name() const
Get the name of this Application set by pre_setup().
DisplayRotation rotation_
void draw_pixel_at(int x, int y, Color color) override
Implementation of SPI Controller mode.
virtual void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order, ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad)
Given an array of pixels encoded in the nominated format, draw these into the display's buffer...