2018-01-16 22:35:55 +01:00
|
|
|
/****************************************************************************
|
2021-02-15 10:05:04 +01:00
|
|
|
* apps/examples/lvgldemo/lvgldemo.c
|
2018-01-16 22:35:55 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2018-01-16 22:35:55 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-01-16 22:35:55 +01:00
|
|
|
*
|
2021-06-15 09:09:58 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2018-01-16 22:35:55 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <unistd.h>
|
2024-02-09 06:18:23 +01:00
|
|
|
#include <sys/boardctl.h>
|
2018-01-16 22:35:55 +01:00
|
|
|
|
2020-07-15 14:33:00 +02:00
|
|
|
#include <lvgl/lvgl.h>
|
2022-10-08 11:03:06 +02:00
|
|
|
#include <lvgl/demos/lv_demos.h>
|
2024-02-09 06:18:23 +01:00
|
|
|
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
|
|
|
#include <uv.h>
|
2023-02-22 09:00:41 +01:00
|
|
|
#endif
|
|
|
|
|
2018-01-18 14:12:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
/* Should we perform board-specific driver initialization? There are two
|
2018-01-18 14:12:31 +01:00
|
|
|
* ways that board initialization can occur: 1) automatically via
|
2020-04-15 12:17:45 +02:00
|
|
|
* board_late_initialize() during bootupif CONFIG_BOARD_LATE_INITIALIZE
|
|
|
|
* or 2).
|
|
|
|
* via a call to boardctl() if the interface is enabled
|
2021-08-01 08:59:37 +02:00
|
|
|
* (CONFIG_BOARDCTL=y).
|
2018-01-18 14:12:31 +01:00
|
|
|
* If this task is running as an NSH built-in application, then that
|
|
|
|
* initialization has probably already been performed otherwise we do it
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef NEED_BOARDINIT
|
|
|
|
|
2021-08-01 08:59:37 +02:00
|
|
|
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
|
2018-01-18 14:12:31 +01:00
|
|
|
# define NEED_BOARDINIT 1
|
|
|
|
#endif
|
|
|
|
|
2022-10-08 11:03:06 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Type Declarations
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-06-17 10:50:05 +02:00
|
|
|
/****************************************************************************
|
2022-10-08 11:03:06 +02:00
|
|
|
* Private Data
|
2020-06-17 10:50:05 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2018-01-16 22:35:55 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
|
|
|
static void lv_nuttx_uv_loop(uv_loop_t *loop, lv_nuttx_result_t *result)
|
2021-02-15 10:05:04 +01:00
|
|
|
{
|
2024-02-09 06:18:23 +01:00
|
|
|
lv_nuttx_uv_t uv_info;
|
|
|
|
void *data;
|
2022-10-08 11:03:06 +02:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
uv_loop_init(loop);
|
2022-10-08 11:03:06 +02:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
lv_memset(&uv_info, 0, sizeof(uv_info));
|
|
|
|
uv_info.loop = loop;
|
|
|
|
uv_info.disp = result->disp;
|
|
|
|
uv_info.indev = result->indev;
|
|
|
|
#ifdef CONFIG_UINPUT_TOUCH
|
|
|
|
uv_info.uindev = result->utouch_indev;
|
|
|
|
#endif
|
2022-10-08 11:03:06 +02:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
data = lv_nuttx_uv_init(&uv_info);
|
|
|
|
uv_run(loop, UV_RUN_DEFAULT);
|
|
|
|
lv_nuttx_uv_deinit(&data);
|
2022-10-08 11:03:06 +02:00
|
|
|
}
|
2024-02-09 06:18:23 +01:00
|
|
|
#endif
|
2021-02-15 10:05:04 +01:00
|
|
|
|
2018-01-16 22:35:55 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2024-02-09 06:18:23 +01:00
|
|
|
* Name: main or lv_demos_main
|
2018-01-16 22:35:55 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* Standard argc and argv
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on success; a positive, non-zero value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int main(int argc, FAR char *argv[])
|
|
|
|
{
|
2024-02-09 06:18:23 +01:00
|
|
|
lv_nuttx_dsc_t info;
|
|
|
|
lv_nuttx_result_t result;
|
2020-06-10 05:12:59 +02:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
2023-02-22 09:00:41 +01:00
|
|
|
uv_loop_t ui_loop;
|
2024-03-22 10:27:05 +01:00
|
|
|
lv_memzero(&ui_loop, sizeof(ui_loop));
|
2023-02-22 09:00:41 +01:00
|
|
|
#endif
|
|
|
|
|
2018-01-18 14:12:31 +01:00
|
|
|
#ifdef NEED_BOARDINIT
|
|
|
|
/* Perform board-specific driver initialization */
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
boardctl(BOARDIOC_INIT, 0);
|
2018-08-28 23:44:03 +02:00
|
|
|
|
2018-01-18 14:12:31 +01:00
|
|
|
#endif
|
|
|
|
|
2018-01-16 22:35:55 +01:00
|
|
|
lv_init();
|
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
lv_nuttx_dsc_init(&info);
|
2021-02-15 10:05:04 +01:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
#ifdef CONFIG_LV_USE_NUTTX_LCD
|
|
|
|
info.fb_path = "/dev/lcd0";
|
|
|
|
#endif
|
2021-02-15 10:05:04 +01:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
lv_nuttx_init(&info, &result);
|
2021-02-15 10:05:04 +01:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
if (result.disp == NULL)
|
|
|
|
{
|
|
|
|
LV_LOG_ERROR("lv_demos initialization failure!");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lv_demos_create(&argv[1], argc - 1))
|
|
|
|
{
|
|
|
|
lv_demos_show_help();
|
2021-03-31 20:19:47 +02:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
/* we can add custom demos here */
|
2018-01-16 22:35:55 +01:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
goto demo_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
|
|
|
lv_nuttx_uv_loop(&ui_loop, &result);
|
2023-02-22 09:00:41 +01:00
|
|
|
#else
|
2018-01-16 22:35:55 +01:00
|
|
|
while (1)
|
|
|
|
{
|
2022-10-08 11:03:06 +02:00
|
|
|
uint32_t idle;
|
|
|
|
idle = lv_timer_handler();
|
|
|
|
|
|
|
|
/* Minimum sleep of 1ms */
|
|
|
|
|
|
|
|
idle = idle ? idle : 1;
|
|
|
|
usleep(idle * 1000);
|
2018-01-16 22:35:55 +01:00
|
|
|
}
|
2023-02-22 09:00:41 +01:00
|
|
|
#endif
|
2018-01-16 22:35:55 +01:00
|
|
|
|
2024-02-09 06:18:23 +01:00
|
|
|
demo_end:
|
|
|
|
lv_disp_remove(result.disp);
|
|
|
|
lv_deinit();
|
|
|
|
|
|
|
|
return 0;
|
2018-01-16 22:35:55 +01:00
|
|
|
}
|