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);
14 SDL_RenderSetLogicalSize(this->renderer_, this->width_, this->height_);
16 SDL_CreateTexture(this->renderer_, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, this->width_, this->height_);
17 SDL_SetTextureBlendMode(this->
texture_, SDL_BLENDMODE_BLEND);
18 ESP_LOGD(TAG,
"Setup Complete");
22 if ((this->x_high_ < this->
x_low_) || (this->y_high_ < this->
y_low_))
25 this->x_low_ = this->
width_;
39 SDL_Rect rect{x_start, y_start, w, h};
41 Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
43 auto stride = x_offset + w + x_pad;
44 auto data = ptr + (stride * y_offset + x_offset) * 2;
45 SDL_UpdateTexture(this->
texture_, &rect, data, stride * 2);
51 SDL_Rect rect{
x,
y, 1, 1};
53 SDL_UpdateTexture(this->
texture_, &rect, &data, 2);
66 if (SDL_PollEvent(&e)) {
71 case SDL_MOUSEBUTTONDOWN:
72 case SDL_MOUSEBUTTONUP:
73 if (e.button.button == 1) {
81 if (e.motion.state & 1) {
91 switch (e.window.event) {
92 case SDL_WINDOWEVENT_SIZE_CHANGED:
93 case SDL_WINDOWEVENT_EXPOSED:
94 case SDL_WINDOWEVENT_RESIZED: {
105 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
void redraw_(SDL_Rect &rect)
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.