| 53 | } |
| 54 | |
| 55 | std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { |
| 56 | // Initialize PWM backlight |
| 57 | if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 5000, LEDC_TIMER_1, LEDC_CHANNEL_0)) { |
| 58 | LOGGER.warn("Failed to initialize backlight"); |
| 59 | } |
| 60 | |
| 61 | Tab5Variant variant = detectVariant(); |
| 62 | |
| 63 | std::shared_ptr<tt::hal::touch::TouchDevice> touch; |
| 64 | |
| 65 | if (variant == Tab5Variant::St7123) { |
| 66 | touch = createSt7123Touch(); |
| 67 | } else { |
| 68 | touch = createGt911Touch(); |
| 69 | |
| 70 | // Work-around to init GT911 touch: interrupt pin must be set to low |
| 71 | // Note: There is a resistor to 3V3 on interrupt pin which is blocking GT911 touch |
| 72 | // See https://github.com/espressif/esp-bsp/blob/ad668c765cbad177495a122181df0a70ff9f8f61/bsp/m5stack_tab5/src/m5stack_tab5.c#L777 |
| 73 | tt::hal::gpio::configure(23, tt::hal::gpio::Mode::Output, true, false); |
| 74 | tt::hal::gpio::setLevel(23, false); |
| 75 | } |
| 76 | |
| 77 | auto configuration = std::make_shared<EspLcdConfiguration>(EspLcdConfiguration { |
| 78 | .horizontalResolution = 720, |
| 79 | .verticalResolution = 1280, |
| 80 | .gapX = 0, |
| 81 | .gapY = 0, |
| 82 | .monochrome = false, |
| 83 | .swapXY = false, |
| 84 | .mirrorX = false, |
| 85 | .mirrorY = false, |
| 86 | .invertColor = false, |
| 87 | .bufferSize = 0, // 0 = default (1/10 of screen) |
| 88 | .swRotate = true, |
| 89 | .buffSpiram = true, |
| 90 | .touch = touch, |
| 91 | .backlightDutyFunction = driver::pwmbacklight::setBacklightDuty, |
| 92 | .resetPin = LCD_PIN_RESET, |
| 93 | .lvglColorFormat = LV_COLOR_FORMAT_RGB565, |
| 94 | .lvglSwapBytes = false, |
| 95 | .rgbElementOrder = LCD_RGB_ELEMENT_ORDER_RGB, |
| 96 | .bitsPerPixel = 16 |
| 97 | }); |
| 98 | |
| 99 | if (variant == Tab5Variant::St7123) { |
| 100 | return std::static_pointer_cast<tt::hal::display::DisplayDevice>( |
| 101 | std::make_shared<St7123Display>(configuration) |
| 102 | ); |
| 103 | } else { |
| 104 | return std::static_pointer_cast<tt::hal::display::DisplayDevice>( |
| 105 | std::make_shared<Ili9881cDisplay>(configuration) |
| 106 | ); |
| 107 | } |
| 108 | } |
no test coverage detected