Import app manager, samples and test-tools
This commit is contained in:
143
samples/littlevgl/vgl-native-ui-app/CMakeLists.txt
Normal file
143
samples/littlevgl/vgl-native-ui-app/CMakeLists.txt
Normal file
@ -0,0 +1,143 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.2)
|
||||
message ("vgl_native_ui_app...")
|
||||
project (vgl_native_ui_app)
|
||||
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -g -DLV_CONF_INCLUDE_SIMPLE -DPLATFORM_NATIVE_LINUX -DUSE_MONITOR -DUSE_MOUSE=1")
|
||||
|
||||
set(lv_name lvgl)
|
||||
set(LVGL_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/${lv_name})
|
||||
set(LVGL_DRIVER_DIR ${CMAKE_CURRENT_LIST_DIR}/lv-drivers)
|
||||
|
||||
message(${LVGL_SOURCE_DIR})
|
||||
include( ExternalProject )
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl/CMakeLists.txt)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for lvgl failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for lvgl failed: ${result}")
|
||||
endif()
|
||||
SET (LVGL_SOURCES
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_group.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_indev.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_lang.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_obj.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_refr.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_style.c
|
||||
${LVGL_SOURCE_DIR}/lv_core/lv_vdb.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_arc.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_img.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_label.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_line.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_rbasic.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_rect.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_triangle.c
|
||||
${LVGL_SOURCE_DIR}/lv_draw/lv_draw_vbasic.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_hal/lv_hal_disp.c
|
||||
${LVGL_SOURCE_DIR}/lv_hal/lv_hal_indev.c
|
||||
${LVGL_SOURCE_DIR}/lv_hal/lv_hal_tick.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_anim.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_area.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_circ.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_color.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_font.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_fs.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_gc.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_ll.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_log.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_math.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_mem.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_task.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_templ.c
|
||||
${LVGL_SOURCE_DIR}/lv_misc/lv_txt.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_arc.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_bar.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_btn.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_btnm.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_calendar.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_canvas.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_cb.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_chart.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_cont.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_ddlist.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_gauge.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_img.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_imgbtn.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_kb.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_label.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_led.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_line.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_list.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_lmeter.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_mbox.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_objx_templ.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_page.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_preload.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_roller.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_slider.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_spinbox.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_sw.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_ta.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_table.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_tabview.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_tileview.c
|
||||
${LVGL_SOURCE_DIR}/lv_objx/lv_win.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_alien.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_default.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_material.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_mono.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_nemo.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_night.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_templ.c
|
||||
${LVGL_SOURCE_DIR}/lv_themes/lv_theme_zen.c
|
||||
|
||||
${LVGL_SOURCE_DIR}/lv_fonts/lv_font_builtin.c
|
||||
${LVGL_SOURCE_DIR}/lv_fonts/lv_font_dejavu_20.c
|
||||
${LVGL_DRIVER_DIR}/linux_display_indev.c
|
||||
${LVGL_DRIVER_DIR}/indev/mouse.c
|
||||
|
||||
)
|
||||
SET(SOURCES
|
||||
${LVGL_SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.c
|
||||
)
|
||||
include_directories(
|
||||
${LVGL_DRIVER_DIR}
|
||||
${LVGL_DRIVER_DIR}/display
|
||||
${LVGL_DRIVER_DIR}/indev
|
||||
${LVGL_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
add_executable(vgl_native_ui_app ${SOURCES} )
|
||||
target_link_libraries( vgl_native_ui_app -lSDL2)
|
||||
29
samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in
Normal file
29
samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.2)
|
||||
|
||||
project(lvgl_download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(${lv_name}
|
||||
GIT_REPOSITORY https://github.com/littlevgl/lvgl.git
|
||||
GIT_TAG v5.3
|
||||
BINARY_DIR ""
|
||||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/lvgl"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
1
samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore
vendored
Normal file
1
samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
**/*.o
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_INDEV_H_
|
||||
#define DISPLAY_INDEV_H_
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "mouse.h"
|
||||
#include "lvgl/lv_misc/lv_color.h"
|
||||
#include "lvgl/lv_hal/lv_hal_indev.h"
|
||||
extern void display_init(void);
|
||||
extern void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p);
|
||||
extern bool display_input_read(lv_indev_data_t * data);
|
||||
extern void display_deinit(void);
|
||||
extern void display_vdb_write(void *buf, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, lv_color_t *color, lv_opa_t opa);
|
||||
extern int time_get_ms();
|
||||
|
||||
#endif
|
||||
95
samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c
Normal file
95
samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file mouse.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "mouse.h"
|
||||
#if USE_MOUSE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static bool left_button_down = false;
|
||||
static int16_t last_x = 0;
|
||||
static int16_t last_y = 0;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current position and state of the mouse
|
||||
* @param data store the mouse data here
|
||||
* @return false: because the points are not buffered, so no more data to be read
|
||||
*/
|
||||
bool mouse_read(lv_indev_data_t * data)
|
||||
{
|
||||
/*Store the collected data*/
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = left_button_down ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
void mouse_handler(SDL_Event * event)
|
||||
{
|
||||
switch (event->type) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (event->button.button == SDL_BUTTON_LEFT)
|
||||
left_button_down = false;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (event->button.button == SDL_BUTTON_LEFT) {
|
||||
left_button_down = true;
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
72
samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h
Normal file
72
samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @file mouse.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MOUSE_H
|
||||
#define MOUSE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
//#include "lv_drv_conf.h"
|
||||
#else
|
||||
#include "../../lv_drv_conf.h"
|
||||
#endif
|
||||
|
||||
#if USE_MOUSE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lvgl/lv_hal/lv_hal_indev.h"
|
||||
|
||||
#ifndef MONITOR_SDL_INCLUDE_PATH
|
||||
#define MONITOR_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
#endif
|
||||
|
||||
#include MONITOR_SDL_INCLUDE_PATH
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void);
|
||||
/**
|
||||
* Get the current position and state of the mouse
|
||||
* @param data store the mouse data here
|
||||
* @return false: because the points are not buffered, so no more data to be read
|
||||
*/
|
||||
bool mouse_read(lv_indev_data_t * data);
|
||||
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
void mouse_handler(SDL_Event *event);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* USE_MOUSE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* MOUSE_H */
|
||||
@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "display_indev.h"
|
||||
#include "sys/time.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#define MONITOR_HOR_RES 320
|
||||
#define MONITOR_VER_RES 240
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
#define SDL_REFR_PERIOD 50
|
||||
void monitor_sdl_init(void);
|
||||
void monitor_sdl_refr_core(void);
|
||||
void monitor_sdl_clean_up(void);
|
||||
static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
|
||||
|
||||
void display_vdb_write(void *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t *color, lv_opa_t opa)
|
||||
{
|
||||
unsigned char *buf_xy = buf + 4 * x + 4 * y * buf_w;
|
||||
lv_color_t * temp = (lv_color_t *) buf_xy;
|
||||
*temp = *color;
|
||||
/*
|
||||
if (opa != LV_OPA_COVER) {
|
||||
lv_color_t mix_color;
|
||||
|
||||
mix_color.red = *buf_xy;
|
||||
mix_color.green = *(buf_xy+1);
|
||||
mix_color.blue = *(buf_xy+2);
|
||||
color = lv_color_mix(color, mix_color, opa);
|
||||
}
|
||||
*/
|
||||
}
|
||||
int time_get_ms()
|
||||
{
|
||||
static struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
long long time_in_mill = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
|
||||
|
||||
return (int) time_in_mill;
|
||||
}
|
||||
|
||||
SDL_Window * window;
|
||||
SDL_Renderer * renderer;
|
||||
SDL_Texture * texture;
|
||||
static volatile bool sdl_inited = false;
|
||||
static volatile bool sdl_refr_qry = false;
|
||||
static volatile bool sdl_quit_qry = false;
|
||||
|
||||
void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0 || y2 < 0 || x1 > MONITOR_HOR_RES - 1
|
||||
|| y1 > MONITOR_VER_RES - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t y;
|
||||
uint32_t w = x2 - x1 + 1;
|
||||
for (y = y1; y <= y2; y++) {
|
||||
memcpy(&tft_fb[y * MONITOR_HOR_RES + x1], color_p,
|
||||
w * sizeof(lv_color_t));
|
||||
|
||||
color_p += w;
|
||||
}
|
||||
sdl_refr_qry = true;
|
||||
|
||||
/*IMPORTANT! It must be called to tell the system the flush is ready*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill out the marked area with a color
|
||||
* @param x1 left coordinate
|
||||
* @param y1 top coordinate
|
||||
* @param x2 right coordinate
|
||||
* @param y2 bottom coordinate
|
||||
* @param color fill color
|
||||
*/
|
||||
void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
return;
|
||||
if (y2 < 0)
|
||||
return;
|
||||
if (x1 > MONITOR_HOR_RES - 1)
|
||||
return;
|
||||
if (y1 > MONITOR_VER_RES - 1)
|
||||
return;
|
||||
|
||||
/*Truncate the area to the screen*/
|
||||
int32_t act_x1 = x1 < 0 ? 0 : x1;
|
||||
int32_t act_y1 = y1 < 0 ? 0 : y1;
|
||||
int32_t act_x2 = x2 > MONITOR_HOR_RES - 1 ? MONITOR_HOR_RES - 1 : x2;
|
||||
int32_t act_y2 = y2 > MONITOR_VER_RES - 1 ? MONITOR_VER_RES - 1 : y2;
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
uint32_t color32 = color.full; //lv_color_to32(color);
|
||||
|
||||
for (x = act_x1; x <= act_x2; x++) {
|
||||
for (y = act_y1; y <= act_y2; y++) {
|
||||
tft_fb[y * MONITOR_HOR_RES + x] = color32;
|
||||
}
|
||||
}
|
||||
|
||||
sdl_refr_qry = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a color map to the marked area
|
||||
* @param x1 left coordinate
|
||||
* @param y1 top coordinate
|
||||
* @param x2 right coordinate
|
||||
* @param y2 bottom coordinate
|
||||
* @param color_p an array of colors
|
||||
*/
|
||||
void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
return;
|
||||
if (y2 < 0)
|
||||
return;
|
||||
if (x1 > MONITOR_HOR_RES - 1)
|
||||
return;
|
||||
if (y1 > MONITOR_VER_RES - 1)
|
||||
return;
|
||||
|
||||
/*Truncate the area to the screen*/
|
||||
int32_t act_x1 = x1 < 0 ? 0 : x1;
|
||||
int32_t act_y1 = y1 < 0 ? 0 : y1;
|
||||
int32_t act_x2 = x2 > MONITOR_HOR_RES - 1 ? MONITOR_HOR_RES - 1 : x2;
|
||||
int32_t act_y2 = y2 > MONITOR_VER_RES - 1 ? MONITOR_VER_RES - 1 : y2;
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
for (y = act_y1; y <= act_y2; y++) {
|
||||
for (x = act_x1; x <= act_x2; x++) {
|
||||
tft_fb[y * MONITOR_HOR_RES + x] = color_p->full; //lv_color_to32(*color_p);
|
||||
color_p++;
|
||||
}
|
||||
|
||||
color_p += x2 - act_x2;
|
||||
}
|
||||
|
||||
sdl_refr_qry = true;
|
||||
}
|
||||
|
||||
void display_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
monitor_flush(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p)
|
||||
{
|
||||
monitor_fill(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
monitor_map(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
|
||||
bool display_input_read(lv_indev_data_t * data)
|
||||
{
|
||||
return mouse_read(data);
|
||||
}
|
||||
|
||||
void display_deinit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int monitor_sdl_refr_thread(void * param)
|
||||
{
|
||||
(void) param;
|
||||
|
||||
/*If not OSX initialize SDL in the Thread*/
|
||||
monitor_sdl_init();
|
||||
/*Run until quit event not arrives*/
|
||||
while (sdl_quit_qry == false) {
|
||||
/*Refresh handling*/
|
||||
monitor_sdl_refr_core();
|
||||
}
|
||||
|
||||
monitor_sdl_clean_up();
|
||||
exit(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void monitor_sdl_refr_core(void)
|
||||
{
|
||||
if (sdl_refr_qry != false) {
|
||||
sdl_refr_qry = false;
|
||||
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
SDL_RenderClear(renderer);
|
||||
/*Test: Draw a background to test transparent screens (LV_COLOR_SCREEN_TRANSP)*/
|
||||
// SDL_SetRenderDrawColor(renderer, 0xff, 0, 0, 0xff);
|
||||
// SDL_Rect r;
|
||||
// r.x = 0; r.y = 0; r.w = MONITOR_HOR_RES; r.w = MONITOR_VER_RES;
|
||||
// SDL_RenderDrawRect(renderer, &r);
|
||||
/*Update the renderer with the texture containing the rendered image*/
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
#if USE_MOUSE != 0
|
||||
mouse_handler(&event);
|
||||
#endif
|
||||
if ((&event)->type == SDL_WINDOWEVENT) {
|
||||
switch ((&event)->window.event) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
#endif
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Sleep some time*/
|
||||
SDL_Delay(SDL_REFR_PERIOD);
|
||||
|
||||
}
|
||||
int quit_filter(void * userdata, SDL_Event * event)
|
||||
{
|
||||
(void) userdata;
|
||||
|
||||
if (event->type == SDL_QUIT) {
|
||||
sdl_quit_qry = true;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void monitor_sdl_clean_up(void)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void monitor_sdl_init(void)
|
||||
{
|
||||
/*Initialize the SDL*/
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
SDL_SetEventFilter(quit_filter, NULL);
|
||||
|
||||
window = SDL_CreateWindow("TFT Simulator", SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
MONITOR_HOR_RES * MONITOR_ZOOM, MONITOR_VER_RES * MONITOR_ZOOM, 0); /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STATIC, MONITOR_HOR_RES, MONITOR_VER_RES);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
/*Initialize the frame buffer to gray (77 is an empirical value) */
|
||||
memset(tft_fb, 0x44, MONITOR_HOR_RES * MONITOR_VER_RES * sizeof(uint32_t));
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
sdl_refr_qry = true;
|
||||
sdl_inited = true;
|
||||
}
|
||||
|
||||
void display_SDL_init()
|
||||
{
|
||||
SDL_CreateThread(monitor_sdl_refr_thread, "sdl_refr", NULL);
|
||||
while (sdl_inited == false)
|
||||
; /*Wait until 'sdl_refr' initializes the SDL*/
|
||||
}
|
||||
|
||||
389
samples/littlevgl/vgl-native-ui-app/lv-drivers/lv_conf.h
Normal file
389
samples/littlevgl/vgl-native-ui-app/lv-drivers/lv_conf.h
Normal file
@ -0,0 +1,389 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#if 1 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
/*===================
|
||||
Dynamic memory
|
||||
*===================*/
|
||||
|
||||
/* Memory size which will be used by the library
|
||||
* to store the graphical objects and other data */
|
||||
#define LV_MEM_CUSTOM 1 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_ATTR /*Complier prefix for big array declaration*/
|
||||
# define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
|
||||
# define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
# define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||
# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
|
||||
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Garbage Collector settings
|
||||
* Used if lvgl is binded to higher language and the memory is managed by that language */
|
||||
#define LV_ENABLE_GC 0
|
||||
#if LV_ENABLE_GC != 0
|
||||
# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/
|
||||
# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/
|
||||
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*===================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#define LV_HOR_RES (320)
|
||||
#define LV_VER_RES (240)
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI 100
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#define LV_ANTIALIAS 0 /*1: Enable anti-aliasing*/
|
||||
|
||||
/*Screen refresh period in milliseconds*/
|
||||
#define LV_REFR_PERIOD 30
|
||||
|
||||
/*-----------------
|
||||
* VDB settings
|
||||
*----------------*/
|
||||
|
||||
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
|
||||
* The GUI will be drawn into this buffer first and then
|
||||
* the buffer will be passed to your `disp_drv.disp_flush` function to
|
||||
* copy it to your frame buffer.
|
||||
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
|
||||
* Learn more: https://docs.littlevgl.com/#Drawing*/
|
||||
|
||||
/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES
|
||||
* Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions
|
||||
* will be called to draw to the frame buffer directly*/
|
||||
#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10)
|
||||
|
||||
/* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays.
|
||||
* Special formats are handled with `disp_drv.vdb_wr`)*/
|
||||
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */
|
||||
|
||||
/* Place VDB to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#define LV_VDB_ADR 0
|
||||
|
||||
/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
|
||||
* The flushing should use DMA to write the frame buffer in the background */
|
||||
#define LV_VDB_DOUBLE 0
|
||||
|
||||
/* Place VDB2 to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#define LV_VDB2_ADR 0
|
||||
|
||||
/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen.
|
||||
* Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display.
|
||||
* The best if you do in the blank period of you display to avoid tearing effect.
|
||||
* Requires:
|
||||
* - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES
|
||||
* - LV_VDB_DOUBLE = 1
|
||||
*/
|
||||
#define LV_VDB_TRUE_DOUBLE_BUFFERED 0
|
||||
|
||||
/*=================
|
||||
Misc. setting
|
||||
*=================*/
|
||||
|
||||
/*Input device settings*/
|
||||
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
|
||||
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
|
||||
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
|
||||
/*Color settings*/
|
||||
#define LV_COLOR_DEPTH 32 /*Color depth: 1/8/16/32*/
|
||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
|
||||
/*Text settings*/
|
||||
#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
|
||||
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
|
||||
|
||||
/*Feature usage*/
|
||||
#define USE_LV_ANIMATION 1 /*1: Enable all animations*/
|
||||
#define USE_LV_SHADOW 1 /*1: Enable shadows*/
|
||||
#define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/
|
||||
#define USE_LV_GPU 0 /*1: Enable GPU interface*/
|
||||
#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/
|
||||
#define USE_LV_FILESYSTEM 0 /*1: Enable file system (might be required for images*/
|
||||
#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/
|
||||
|
||||
/*Compiler settings*/
|
||||
#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */
|
||||
#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */
|
||||
#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/
|
||||
#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 1 /* 1: Initialization with non constant values are supported */
|
||||
|
||||
/*HAL settings*/
|
||||
#define LV_TICK_CUSTOM 1 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
|
||||
#if LV_TICK_CUSTOM == 1
|
||||
#define LV_TICK_CUSTOM_INCLUDE "system_header.h" /*Header for the sys time function*/
|
||||
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (time_get_ms()) /*Expression evaluating to current systime in ms*/
|
||||
#endif /*LV_TICK_CUSTOM*/
|
||||
|
||||
/*Log settings*/
|
||||
#define USE_LV_LOG 1 /*Enable/disable the log module*/
|
||||
#if USE_LV_LOG
|
||||
/* How important log should be added:
|
||||
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
|
||||
* LV_LOG_LEVEL_INFO Log important events
|
||||
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem
|
||||
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*/
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
|
||||
|
||||
# define LV_LOG_PRINTF 0
|
||||
#endif /*USE_LV_LOG*/
|
||||
|
||||
/*================
|
||||
* THEME USAGE
|
||||
*================*/
|
||||
#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
|
||||
#define USE_LV_THEME_TEMPL 0 /*Just for test*/
|
||||
#define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/
|
||||
#define USE_LV_THEME_ALIEN 0 /*Dark futuristic theme*/
|
||||
#define USE_LV_THEME_NIGHT 0 /*Dark elegant theme*/
|
||||
#define USE_LV_THEME_MONO 0 /*Mono color theme for monochrome displays*/
|
||||
#define USE_LV_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/
|
||||
#define USE_LV_THEME_ZEN 0 /*Peaceful, mainly light theme */
|
||||
#define USE_LV_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
*===================*/
|
||||
|
||||
/* More info about fonts: https://docs.littlevgl.com/#Fonts
|
||||
* To enable a built-in font use 1,2,4 or 8 values
|
||||
* which will determine the bit-per-pixel. Higher value means smoother fonts */
|
||||
#define USE_LV_FONT_DEJAVU_10 0
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_10 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_20 4
|
||||
#define USE_LV_FONT_DEJAVU_20_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_20 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_30 0
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_30 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_40 0
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_40 0
|
||||
|
||||
#define USE_LV_FONT_MONOSPACE_8 1
|
||||
|
||||
/* Optionally declare your custom fonts here.
|
||||
* You can use these fonts as default font too
|
||||
* and they will be available globally. E.g.
|
||||
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
|
||||
* LV_FONT_DECLARE(my_font_2) \
|
||||
*/
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
|
||||
|
||||
/*===================
|
||||
* LV_OBJ SETTINGS
|
||||
*==================*/
|
||||
#define LV_OBJ_FREE_NUM_TYPE uint32_t /*Type of free number attribute (comment out disable free number)*/
|
||||
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
|
||||
#define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
|
||||
|
||||
/*==================
|
||||
* LV OBJ X USAGE
|
||||
*================*/
|
||||
/*
|
||||
* Documentation of the object types: https://docs.littlevgl.com/#Object-types
|
||||
*/
|
||||
|
||||
/*****************
|
||||
* Simple object
|
||||
*****************/
|
||||
|
||||
/*Label (dependencies: -*/
|
||||
#define USE_LV_LABEL 1
|
||||
#if USE_LV_LABEL != 0
|
||||
# define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
|
||||
#endif
|
||||
|
||||
/*Image (dependencies: lv_label*/
|
||||
#define USE_LV_IMG 1
|
||||
#if USE_LV_IMG != 0
|
||||
# define LV_IMG_CF_INDEXED 1 /*Enable indexed (palette) images*/
|
||||
# define LV_IMG_CF_ALPHA 1 /*Enable alpha indexed images*/
|
||||
#endif
|
||||
|
||||
/*Line (dependencies: -*/
|
||||
#define USE_LV_LINE 1
|
||||
|
||||
/*Arc (dependencies: -)*/
|
||||
#define USE_LV_ARC 1
|
||||
|
||||
/*******************
|
||||
* Container objects
|
||||
*******************/
|
||||
|
||||
/*Container (dependencies: -*/
|
||||
#define USE_LV_CONT 1
|
||||
|
||||
/*Page (dependencies: lv_cont)*/
|
||||
#define USE_LV_PAGE 1
|
||||
|
||||
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define USE_LV_WIN 1
|
||||
|
||||
/*Tab (dependencies: lv_page, lv_btnm)*/
|
||||
#define USE_LV_TABVIEW 1
|
||||
# if USE_LV_TABVIEW != 0
|
||||
# define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*Tileview (dependencies: lv_page) */
|
||||
#define USE_LV_TILEVIEW 1
|
||||
#if USE_LV_TILEVIEW
|
||||
# define LV_TILEVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
* Data visualizer objects
|
||||
*************************/
|
||||
|
||||
/*Bar (dependencies: -)*/
|
||||
#define USE_LV_BAR 1
|
||||
|
||||
/*Line meter (dependencies: *;)*/
|
||||
#define USE_LV_LMETER 1
|
||||
|
||||
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
|
||||
#define USE_LV_GAUGE 1
|
||||
|
||||
/*Chart (dependencies: -)*/
|
||||
#define USE_LV_CHART 1
|
||||
|
||||
/*Table (dependencies: lv_label)*/
|
||||
#define USE_LV_TABLE 1
|
||||
#if USE_LV_TABLE
|
||||
# define LV_TABLE_COL_MAX 12
|
||||
#endif
|
||||
|
||||
/*LED (dependencies: -)*/
|
||||
#define USE_LV_LED 1
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
|
||||
#define USE_LV_MBOX 1
|
||||
|
||||
/*Text area (dependencies: lv_label, lv_page)*/
|
||||
#define USE_LV_TA 1
|
||||
#if USE_LV_TA != 0
|
||||
# define LV_TA_CURSOR_BLINK_TIME 400 /*ms*/
|
||||
# define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
/*Spinbox (dependencies: lv_ta)*/
|
||||
#define USE_LV_SPINBOX 1
|
||||
|
||||
/*Calendar (dependencies: -)*/
|
||||
#define USE_LV_CALENDAR 1
|
||||
|
||||
/*Preload (dependencies: lv_arc)*/
|
||||
#define USE_LV_PRELOAD 1
|
||||
#if USE_LV_PRELOAD != 0
|
||||
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
|
||||
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
|
||||
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
|
||||
#endif
|
||||
|
||||
/*Canvas (dependencies: lv_img)*/
|
||||
#define USE_LV_CANVAS 1
|
||||
/*************************
|
||||
* User input objects
|
||||
*************************/
|
||||
|
||||
/*Button (dependencies: lv_cont*/
|
||||
#define USE_LV_BTN 1
|
||||
#if USE_LV_BTN != 0
|
||||
# define LV_BTN_INK_EFFECT 1 /*Enable button-state animations - draw a circle on click (dependencies: USE_LV_ANIMATION)*/
|
||||
#endif
|
||||
|
||||
/*Image Button (dependencies: lv_btn*/
|
||||
#define USE_LV_IMGBTN 1
|
||||
#if USE_LV_IMGBTN
|
||||
# define LV_IMGBTN_TILED 0 /*1: The imgbtn requires left, mid and right parts and the width can be set freely*/
|
||||
#endif
|
||||
|
||||
/*Button matrix (dependencies: -)*/
|
||||
#define USE_LV_BTNM 1
|
||||
|
||||
/*Keyboard (dependencies: lv_btnm)*/
|
||||
#define USE_LV_KB 1
|
||||
|
||||
/*Check box (dependencies: lv_btn, lv_label)*/
|
||||
#define USE_LV_CB 1
|
||||
|
||||
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
|
||||
#define USE_LV_LIST 1
|
||||
#if USE_LV_LIST != 0
|
||||
# define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
|
||||
#endif
|
||||
|
||||
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
|
||||
#define USE_LV_DDLIST 1
|
||||
#if USE_LV_DDLIST != 0
|
||||
# define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*Roller (dependencies: lv_ddlist)*/
|
||||
#define USE_LV_ROLLER 1
|
||||
#if USE_LV_ROLLER != 0
|
||||
# define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*Slider (dependencies: lv_bar)*/
|
||||
#define USE_LV_SLIDER 1
|
||||
|
||||
/*Switch (dependencies: lv_slider)*/
|
||||
#define USE_LV_SW 1
|
||||
|
||||
/*************************
|
||||
* Non-user section
|
||||
*************************/
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
/*Be sure every define has a default value*/
|
||||
#include "lvgl/lv_conf_checker.h"
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int time_get_ms();
|
||||
165
samples/littlevgl/vgl-native-ui-app/main.c
Normal file
165
samples/littlevgl/vgl-native-ui-app/main.c
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file main
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "display_indev.h"
|
||||
#include <unistd.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void hal_init(void);
|
||||
//static int tick_thread(void * data);
|
||||
//static void memory_monitor(void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
uint32_t count = 0;
|
||||
char count_str[11] = { 0 };
|
||||
lv_obj_t *hello_world_label;
|
||||
lv_obj_t *count_label;
|
||||
lv_obj_t * btn1;
|
||||
|
||||
lv_obj_t * label_count1;
|
||||
int label_count1_value = 0;
|
||||
char label_count1_str[11] = { 0 };
|
||||
static lv_res_t btn_rel_action(lv_obj_t * btn)
|
||||
{
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
void display_SDL_init();
|
||||
display_SDL_init();
|
||||
|
||||
/*Initialize LittlevGL*/
|
||||
lv_init();
|
||||
|
||||
/*Initialize the HAL (display, input devices, tick) for LittlevGL*/
|
||||
hal_init();
|
||||
|
||||
hello_world_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(hello_world_label, "Hello world!");
|
||||
lv_obj_align(hello_world_label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
count_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(count_label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a button on the currently loaded screen*/
|
||||
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK, btn_rel_action); /*Set function to be called when the button is released*/
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 20); /*Align below the label*/
|
||||
|
||||
/*Create a label on the button*/
|
||||
lv_obj_t * btn_label = lv_label_create(btn1, NULL);
|
||||
lv_label_set_text(btn_label, "Click ++");
|
||||
|
||||
label_count1 = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_count1, "0");
|
||||
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
|
||||
while(1) {
|
||||
/* Periodically call the lv_task handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count/ 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
lv_task_handler();
|
||||
++count;
|
||||
usleep(10 * 1000); /*Just to let the system breath*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
|
||||
*/
|
||||
void display_flush_wrapper(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
display_flush(x1, y1, x2, y2, color_p);
|
||||
lv_flush_ready();
|
||||
}
|
||||
void display_vdb_write_wrapper(uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
display_vdb_write(buf, buf_w, x, y, &color, opa);
|
||||
}
|
||||
extern void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p);
|
||||
extern void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p);
|
||||
static void hal_init(void)
|
||||
{
|
||||
/* Add a display*/
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.disp_flush = display_flush_wrapper; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/
|
||||
disp_drv.disp_fill = display_fill; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
||||
disp_drv.disp_map = display_map; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
||||
#if LV_VDB_SIZE != 0
|
||||
disp_drv.vdb_wr = display_vdb_write_wrapper;
|
||||
#endif
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Add the mouse as input device
|
||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||
// mouse_init();
|
||||
lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read = display_input_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
|
||||
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user