1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4#include "slint-esp.h"
5#include "carousel_demo.h"
6#include <ctime>
7#include <memory>
8
9#include <slint-platform.h>
10
11#include <bsp/display.h>
12#include <bsp/esp-bsp.h>
13
14#if defined(BSP_LCD_DRAW_BUFF_SIZE)
15# define DRAW_BUF_SIZE BSP_LCD_DRAW_BUFF_SIZE
16#else
17# define DRAW_BUF_SIZE (BSP_LCD_H_RES * CONFIG_BSP_LCD_DRAW_BUF_HEIGHT)
18#endif
19
20#if defined(EXAMPLE_TARGET_S3_BOX)
21# include <bsp/touch.h>
22#endif
23#include <vector>
24
25extern "C" void app_main(void)
26{
27 /* Initialize I2C (for touch and audio) */
28#if defined(EXAMPLE_TARGET_S3_BOX)
29 bsp_i2c_init();
30#endif
31
32 /* Initialize display */
33 esp_lcd_panel_io_handle_t io_handle = NULL;
34 esp_lcd_panel_handle_t panel_handle = NULL;
35 const bsp_display_config_t bsp_disp_cfg = {
36 .max_transfer_sz = DRAW_BUF_SIZE * sizeof(uint16_t),
37 };
38 bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle);
39#if defined(EXAMPLE_TARGET_S3_BOX)
40 esp_lcd_touch_handle_t touch_handle = NULL;
41 const bsp_touch_config_t bsp_touch_cfg = {};
42 bsp_touch_new(&bsp_touch_cfg, &touch_handle);
43#else
44 std::optional<esp_lcd_touch_handle_t> touch_handle;
45#endif
46
47 /* Set display brightness to 100% */
48 bsp_display_backlight_on();
49
50 static std::vector<slint::platform::Rgb565Pixel> buffer(BSP_LCD_H_RES * BSP_LCD_V_RES);
51
52 slint_esp_init(slint::PhysicalSize({ BSP_LCD_H_RES, BSP_LCD_V_RES }), panel_handle,
53 touch_handle, buffer);
54
55 auto carousel_demo = MainWindow::create();
56
57 carousel_demo->run();
58}
59

source code of slint/examples/carousel/esp-idf/main.cpp