MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / createPanelHandle

Method createPanelHandle

Drivers/ST7735/Source/St7735Display.cpp:47–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool St7735Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
48
49 const esp_lcd_panel_dev_config_t panel_config = {
50 .reset_gpio_num = configuration->resetPin,
51 .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
52 .data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
53 .bits_per_pixel = 16,
54 .flags = {
55 .reset_active_high = false
56 },
57 .vendor_config = nullptr
58 };
59
60 if (esp_lcd_new_panel_st7735(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
61 LOGGER.error("Failed to create panel");
62 return false;
63 }
64
65 if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
66 LOGGER.error("Failed to reset panel");
67 return false;
68 }
69
70 if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
71 LOGGER.error("Failed to init panel");
72 return false;
73 }
74
75 if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
76 LOGGER.error("Failed to set panel to invert");
77 return false;
78 }
79
80 // Warning: it looks like LVGL rotation is broken when "gap" is set and the screen is moved to a non-default orientation
81 int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX;
82 int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
83 if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
84 LOGGER.error("Failed to set panel gap");
85 return false;
86 }
87
88 if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
89 LOGGER.error("Failed to swap XY ");
90 return false;
91 }
92
93 if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
94 LOGGER.error("Failed to set panel to mirror");
95 return false;
96 }
97
98 if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
99 LOGGER.error("Failed to turn display on");
100 return false;
101 }
102
103 return true;
104}

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected