#include #include "app/input/obb_touch_gt911.h" #include "app/ui/obb_tiles_dashboard.h" namespace { lgfx::LGFX_Device *s_display = nullptr; constexpr uint16_t kBufferHeight = 24; constexpr uint16_t kBufferWidth = 320; static lv_disp_draw_buf_t s_draw_buf; static lv_color_t s_buf[kBufferWidth * kBufferHeight]; void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { static uint32_t flush_count = 0; if ((flush_count++ % 50U) == 0U) { Serial.println("[Station S] LVGL flush"); } if (!s_display) { lv_disp_flush_ready(drv); return; } uint32_t w = area->x2 - area->x1 + 1; uint32_t h = area->y2 - area->y1 + 1; s_display->startWrite(); s_display->setAddrWindow(area->x1, area->y1, w, h); s_display->writePixels(reinterpret_cast(color_p), w * h, true); s_display->endWrite(); lv_disp_flush_ready(drv); } } // namespace namespace obb { void gui_core_init(l"> #include #include "app/input/obb_touch_gt911.h" #include "app/ui/obb_tiles_dashboard.h" namespace { lgfx::LGFX_Device *s_display = nullptr; constexpr uint16_t kBufferHeight = 24; constexpr uint16_t kBufferWidth = 320; static lv_disp_draw_buf_t s_draw_buf; static lv_color_t s_buf[kBufferWidth * kBufferHeight]; void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { static uint32_t flush_count = 0; if ((flush_count++ % 50U) == 0U) { Serial.println("[Station S] LVGL flush"); } if (!s_display) { lv_disp_flush_ready(drv); return; } uint32_t w = area->x2 - area->x1 + 1; uint32_t h = area->y2 - area->y1 + 1; s_display->startWrite(); s_display->setAddrWindow(area->x1, area->y1, w, h); s_display->writePixels(reinterpret_cast(color_p), w * h, true); s_display->endWrite(); lv_disp_flush_ready(drv); } } // namespace namespace obb { void gui_core_init(l"> #include #include "app/input/obb_touch_gt911.h" #include "app/ui/obb_tiles_dashboard.h" namespace { lgfx::LGFX_Device *s_display = nullptr; constexpr uint16_t kBufferHeight = 24; constexpr uint16_t kBufferWidth = 320; static lv_disp_draw_buf_t s_draw_buf; static lv_color_t s_buf[kBufferWidth * kBufferHeight]; void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) { static uint32_t flush_count = 0; if ((flush_count++ % 50U) == 0U) { Serial.println("[Station S] LVGL flush"); } if (!s_display) { lv_disp_flush_ready(drv); return; } uint32_t w = area->x2 - area->x1 + 1; uint32_t h = area->y2 - area->y1 + 1; s_display->startWrite(); s_display->setAddrWindow(area->x1, area->y1, w, h); s_display->writePixels(reinterpret_cast(color_p), w * h, true); s_display->endWrite(); lv_disp_flush_ready(drv); } } // namespace namespace obb { void gui_core_init(l">
#include "app/core/gui_core.h"

#include <Arduino.h>
#include <lvgl.h>

#include "app/input/obb_touch_gt911.h"
#include "app/ui/obb_tiles_dashboard.h"

namespace {
lgfx::LGFX_Device *s_display = nullptr;
constexpr uint16_t kBufferHeight = 24;
constexpr uint16_t kBufferWidth = 320;
static lv_disp_draw_buf_t s_draw_buf;
static lv_color_t s_buf[kBufferWidth * kBufferHeight];

void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) {
  static uint32_t flush_count = 0;
  if ((flush_count++ % 50U) == 0U) {
    Serial.println("[Station S] LVGL flush");
  }
  if (!s_display) {
    lv_disp_flush_ready(drv);
    return;
  }

  uint32_t w = area->x2 - area->x1 + 1;
  uint32_t h = area->y2 - area->y1 + 1;

  s_display->startWrite();
  s_display->setAddrWindow(area->x1, area->y1, w, h);
  s_display->writePixels(reinterpret_cast<uint16_t *>(color_p), w * h, true);
  s_display->endWrite();

  lv_disp_flush_ready(drv);
}
}  // namespace

namespace obb {

void gui_core_init(lgfx::LGFX_Device &display) {
  s_display = &display;
  s_display->init();
  s_display->setRotation(0);
  s_display->setColorDepth(16);
  s_display->setBrightness(200);
  s_display->fillScreen(0x0000);

  lv_init();
  lv_disp_draw_buf_init(&s_draw_buf, s_buf, nullptr, kBufferWidth * kBufferHeight);

  static lv_disp_drv_t disp_drv;
  lv_disp_drv_init(&disp_drv);
  disp_drv.hor_res = kBufferWidth;
  disp_drv.ver_res = 480;
  disp_drv.flush_cb = lvgl_flush_cb;
  disp_drv.draw_buf = &s_draw_buf;
  lv_disp_drv_register(&disp_drv);

  obb_touch_gt911_init();
  obb_touch_gt911_attach_lvgl();
  obb_tiles_dashboard_init(lv_scr_act());
}

void gui_core_loop() {
  static uint32_t last_tick = millis();
  uint32_t now = millis();
  lv_tick_inc(now - last_tick);
  last_tick = now;

  lv_timer_handler();
  obb_touch_poll();
  delay(5);
}

}  // namespace obb