zephyr/lib/gui/lvgl/lvgl.c
Patrik Flykt 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00

90 lines
1.7 KiB
C

/*
* Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <zephyr.h>
#include <lvgl.h>
#include <lv_core/lv_refr.h>
#include "lvgl_color.h"
#include "lvgl_fs.h"
#define LOG_LEVEL CONFIG_LVGL_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(lvgl);
struct device *lvgl_display_dev;
#if CONFIG_LVGL_LOG_LEVEL != 0
static void lvgl_log(lv_log_level_t level, const char *file, uint32_t line,
const char *dsc)
{
/* Convert LVGL log level to Zephyr log lvel
*
* LVGL log level mapping:
* * LV_LOG_LEVEL_TRACE 0
* * LV_LOG_LEVEL_INFO 1
* * LV_LOG_LEVEL_WARN 2
* * LV_LOG_LEVEL_ERROR 3
* * LV_LOG_LEVEL_NUM 4
*
* Zephyr log level mapping:
* * LOG_LEVEL_NONE 0
* * LOG_LEVEL_ERR 1
* * LOG_LEVEL_WRN 2
* * LOG_LEVEL_INF 3
* * LOG_LEVEL_DBG 4
*/
u8_t zephyr_level = LOG_LEVEL_DBG - level;
ARG_UNUSED(file);
ARG_UNUSED(line);
Z_LOG(zephyr_level, "%s", dsc);
}
#endif
static int lvgl_init(struct device *dev)
{
lv_disp_drv_t disp_drv;
ARG_UNUSED(dev);
lvgl_display_dev = device_get_binding(CONFIG_LVGL_DISPLAY_DEV_NAME);
if (lvgl_display_dev == NULL) {
LOG_ERR("Display device not found.");
return -ENODEV;
}
#if CONFIG_LVGL_LOG_LEVEL != 0
lv_log_register_print(lvgl_log);
#endif
lv_init();
#ifdef CONFIG_LVGL_FILESYSTEM
lvgl_fs_init();
#endif
lv_refr_set_round_cb(get_round_func());
lv_disp_drv_init(&disp_drv);
disp_drv.disp_flush = get_disp_flush();
#if CONFIG_LVGL_VDB_SIZE != 0
disp_drv.vdb_wr = get_vdb_write();
#endif
if (lv_disp_drv_register(&disp_drv) == NULL) {
LOG_ERR("Failed to register display device.");
return -EPERM;
}
return 0;
}
SYS_INIT(lvgl_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);