Added Clock screen.
This commit is contained in:
parent
d2faa6c421
commit
0d4f5e58fe
|
@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
project(SystemAgent)
|
project(SystemAgent)
|
||||||
|
|
||||||
set(ST7789_LCD_DEFINES "ST7789_PANEL_ZJY_320")
|
set(ST7789_LCD_DEFINES "ST7789_PANEL_ZJY_320")
|
||||||
set(LVGL_DEFINES "LV_CONF_INCLUDE_SIMPLE")
|
set(LVGL_DEFINES
|
||||||
|
"LV_CONF_INCLUDE_SIMPLE"
|
||||||
|
)
|
||||||
|
|
||||||
set(C_SOURCES
|
set(C_SOURCES
|
||||||
"src/main.c"
|
"src/main.c"
|
||||||
|
@ -15,7 +17,12 @@ set(C_SOURCES
|
||||||
"src/impl/user_stick_impl.c"
|
"src/impl/user_stick_impl.c"
|
||||||
"src/tasks/user_lvgl_task.c"
|
"src/tasks/user_lvgl_task.c"
|
||||||
"src/tasks/user_clock_task.c"
|
"src/tasks/user_clock_task.c"
|
||||||
|
"src/tasks/user_base_task.c"
|
||||||
"src/utils/user_log_util.c"
|
"src/utils/user_log_util.c"
|
||||||
|
"src/assets/encode_sans_sc_light_24.c"
|
||||||
|
"src/assets/encode_sans_sc_regular_32.c"
|
||||||
|
"src/assets/encode_sans_sc_bold_48.c"
|
||||||
|
"src/assets/encode_sans_sc_regular_64.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(C_INCLUDES
|
set(C_INCLUDES
|
||||||
|
@ -26,6 +33,7 @@ set(C_INCLUDES
|
||||||
|
|
||||||
set(C_DEFINES
|
set(C_DEFINES
|
||||||
"_GNU_SOURCE"
|
"_GNU_SOURCE"
|
||||||
|
"LV_LVGL_H_INCLUDE_SIMPLE"
|
||||||
${ST7789_LCD_DEFINES}
|
${ST7789_LCD_DEFINES}
|
||||||
${LVGL_DEFINES}
|
${LVGL_DEFINES}
|
||||||
)
|
)
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
|
*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
|
||||||
*However the opened images might consume additional RAM.
|
*However the opened images might consume additional RAM.
|
||||||
*0: to disable caching*/
|
*0: to disable caching*/
|
||||||
#define LV_IMG_CACHE_DEF_SIZE 0
|
#define LV_IMG_CACHE_DEF_SIZE (48*1024)
|
||||||
|
|
||||||
/*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/
|
/*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/
|
||||||
#define LV_DISP_ROT_MAX_BUF (10*1024)
|
#define LV_DISP_ROT_MAX_BUF (10*1024)
|
||||||
|
@ -297,7 +297,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||||
/*Optionally declare custom fonts here.
|
/*Optionally declare custom fonts here.
|
||||||
*You can use these fonts as default font too and they will be available globally.
|
*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)*/
|
*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_CUSTOM_DECLARE LV_FONT_DECLARE(encode_sans_sc_light_24) \
|
||||||
|
LV_FONT_DECLARE(encode_sans_sc_regular_32) \
|
||||||
|
LV_FONT_DECLARE(encode_sans_sc_bold_48) \
|
||||||
|
LV_FONT_DECLARE(encode_sans_sc_regular_64)
|
||||||
|
|
||||||
/*Always set a default font*/
|
/*Always set a default font*/
|
||||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||||
|
@ -308,10 +311,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||||
#define LV_FONT_FMT_TXT_LARGE 0
|
#define LV_FONT_FMT_TXT_LARGE 0
|
||||||
|
|
||||||
/*Enables/disables support for compressed fonts.*/
|
/*Enables/disables support for compressed fonts.*/
|
||||||
#define LV_USE_FONT_COMPRESSED 0
|
#define LV_USE_FONT_COMPRESSED 1
|
||||||
|
|
||||||
/*Enable subpixel rendering*/
|
/*Enable subpixel rendering*/
|
||||||
#define LV_USE_FONT_SUBPX 0
|
#define LV_USE_FONT_SUBPX 1
|
||||||
#if LV_USE_FONT_SUBPX
|
#if LV_USE_FONT_SUBPX
|
||||||
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
|
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
|
||||||
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
|
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef USER_TASK_LVGL_COMMON_H
|
||||||
|
#define USER_TASK_LVGL_COMMON_H
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "lvgl.h"
|
||||||
|
|
||||||
|
#include "drivers/user_config_driver.h"
|
||||||
|
|
||||||
|
#include "utils/user_log_util.h"
|
||||||
|
|
||||||
|
extern uint8_t g_running;
|
||||||
|
extern uint8_t g_lvgl_ready;
|
||||||
|
extern user_config_t g_config;
|
||||||
|
|
||||||
|
extern pthread_mutex_t g_lvgl_mutex;
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __USER_TASKS_H
|
#ifndef USER_TASKS_H
|
||||||
#define __USER_TASKS_H
|
#define USER_TASKS_H
|
||||||
|
|
||||||
int user_lvgl_task_init(void);
|
int user_lvgl_task_init(void);
|
||||||
int user_lvgl_task_deinit(void);
|
int user_lvgl_task_deinit(void);
|
||||||
|
@ -7,4 +7,7 @@ int user_lvgl_task_deinit(void);
|
||||||
int user_clock_task_init(void);
|
int user_clock_task_init(void);
|
||||||
int user_clock_task_deinit(void);
|
int user_clock_task_deinit(void);
|
||||||
|
|
||||||
#endif
|
int user_base_task_init(void);
|
||||||
|
int user_base_task_deinit(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
Copyright 2020 The Encode Project Authors (https://github.com/thundernixon/Encode-Sans), with Reserved Font Name "Encode Sans”.
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -60,10 +60,10 @@ void user_lvgl_impl_indev_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
|
||||||
}
|
}
|
||||||
switch(key_to_determine) {
|
switch(key_to_determine) {
|
||||||
case USER_STICK_LEFT:
|
case USER_STICK_LEFT:
|
||||||
data->key = LV_KEY_LEFT;
|
data->key = LV_KEY_PREV;
|
||||||
break;
|
break;
|
||||||
case USER_STICK_RIGHT:
|
case USER_STICK_RIGHT:
|
||||||
data->key = LV_KEY_RIGHT;
|
data->key = LV_KEY_NEXT;
|
||||||
break;
|
break;
|
||||||
case USER_STICK_UP:
|
case USER_STICK_UP:
|
||||||
data->key = LV_KEY_UP;
|
data->key = LV_KEY_UP;
|
||||||
|
|
|
@ -39,6 +39,7 @@ int main(int argc, const char *argv[]) {
|
||||||
user_log_set_level(log_level);
|
user_log_set_level(log_level);
|
||||||
|
|
||||||
user_lvgl_task_init();
|
user_lvgl_task_init();
|
||||||
|
user_base_task_init();
|
||||||
user_clock_task_init();
|
user_clock_task_init();
|
||||||
|
|
||||||
USER_LOG(USER_LOG_INFO, "Initialized, main thread sleeping.");
|
USER_LOG(USER_LOG_INFO, "Initialized, main thread sleeping.");
|
||||||
|
@ -47,6 +48,7 @@ int main(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
user_clock_task_deinit();
|
user_clock_task_deinit();
|
||||||
|
user_base_task_deinit();
|
||||||
user_lvgl_task_deinit();
|
user_lvgl_task_deinit();
|
||||||
|
|
||||||
user_config_deinit(&g_config);
|
user_config_deinit(&g_config);
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include "tasks/user_task_lvgl_common.h"
|
||||||
|
|
||||||
|
pthread_t user_base_task_thread;
|
||||||
|
|
||||||
|
void *user_base_task(void *arguments);
|
||||||
|
|
||||||
|
int user_base_task_init(void) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = pthread_create(&user_base_task_thread, NULL, user_base_task, NULL);
|
||||||
|
if(ret) return ret;
|
||||||
|
|
||||||
|
pthread_setname_np(user_base_task_thread, "BASE");
|
||||||
|
|
||||||
|
USER_LOG(USER_LOG_INFO, "BASE thread created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int user_base_task_deinit(void) {
|
||||||
|
USER_LOG(USER_LOG_INFO, "BASE task_deinit() called.");
|
||||||
|
|
||||||
|
pthread_join(user_base_task_thread, NULL);
|
||||||
|
|
||||||
|
USER_LOG(USER_LOG_INFO, "BASE tasks joined.");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void event_handler(lv_event_t * e)
|
||||||
|
{
|
||||||
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
|
||||||
|
if(code == LV_EVENT_CLICKED) {
|
||||||
|
LV_LOG_USER("Clicked");
|
||||||
|
}
|
||||||
|
else if(code == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
LV_LOG_USER("Toggled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *user_base_task(void *arguments) {
|
||||||
|
while(g_running && !g_lvgl_ready) {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
|
|
||||||
|
lv_style_t background_style;
|
||||||
|
lv_style_init(&background_style);
|
||||||
|
lv_style_set_opa(&background_style, LV_OPA_30);
|
||||||
|
|
||||||
|
char *background_path = user_config_lookup_string(&g_config, "agent.theme.background");
|
||||||
|
lv_obj_t * background_image = lv_img_create(lv_scr_act());
|
||||||
|
if(background_path != NULL) {
|
||||||
|
lv_img_set_src(background_image, background_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_move_background(background_image);
|
||||||
|
lv_obj_add_style(background_image, &background_style, 0);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
|
|
||||||
|
while(g_running) {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +1,11 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include "tasks/user_task_lvgl_common.h"
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "lvgl.h"
|
|
||||||
|
|
||||||
#include "drivers/user_config_driver.h"
|
|
||||||
|
|
||||||
#include "utils/user_log_util.h"
|
|
||||||
|
|
||||||
extern uint8_t g_running;
|
|
||||||
extern uint8_t g_lvgl_ready;
|
|
||||||
extern user_config_t g_config;
|
|
||||||
|
|
||||||
pthread_t user_clock_task_thread;
|
pthread_t user_clock_task_thread;
|
||||||
|
|
||||||
|
static char *s_wday[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||||
|
|
||||||
void *user_clock_task(void *arguments);
|
void *user_clock_task(void *arguments);
|
||||||
|
|
||||||
int user_clock_task_init(void) {
|
int user_clock_task_init(void) {
|
||||||
|
@ -25,7 +16,7 @@ int user_clock_task_init(void) {
|
||||||
|
|
||||||
pthread_setname_np(user_clock_task_thread, "CLOCK");
|
pthread_setname_np(user_clock_task_thread, "CLOCK");
|
||||||
|
|
||||||
USER_LOG(USER_LOG_INFO, "Clock thread created.");
|
USER_LOG(USER_LOG_INFO, "CLOCK thread created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int user_clock_task_deinit(void) {
|
int user_clock_task_deinit(void) {
|
||||||
|
@ -43,14 +34,48 @@ void *user_clock_task(void *arguments) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *background_path = user_config_lookup_string(&g_config, "agent.theme.background");
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
|
|
||||||
|
lv_style_t label_clock_time_style;
|
||||||
|
lv_style_init(&label_clock_time_style);
|
||||||
|
|
||||||
|
lv_style_set_text_font(&label_clock_time_style, &encode_sans_sc_bold_48);
|
||||||
|
lv_style_set_text_color(&label_clock_time_style,
|
||||||
|
lv_palette_main(LV_PALETTE_PINK));
|
||||||
|
|
||||||
|
lv_style_t label_clock_date_style;
|
||||||
|
lv_style_init(&label_clock_date_style);
|
||||||
|
lv_style_set_text_font(&label_clock_date_style, &encode_sans_sc_regular_32);
|
||||||
|
lv_style_set_text_color(&label_clock_date_style,
|
||||||
|
lv_palette_main(LV_PALETTE_PINK));
|
||||||
|
|
||||||
|
lv_obj_t *label_clock_time = lv_label_create(lv_scr_act());
|
||||||
|
lv_obj_t *label_clock_date = lv_label_create(lv_scr_act());
|
||||||
|
|
||||||
|
lv_obj_add_style(label_clock_time, &label_clock_time_style, 0);
|
||||||
|
lv_obj_add_style(label_clock_date, &label_clock_date_style, 0);
|
||||||
|
|
||||||
|
lv_label_set_text(label_clock_date, "--- ----/--/--");
|
||||||
|
lv_label_set_text(label_clock_time, "--:--:--");
|
||||||
|
|
||||||
|
lv_obj_align(label_clock_time, LV_ALIGN_CENTER, 0, -24);
|
||||||
|
lv_obj_align(label_clock_date, LV_ALIGN_CENTER, 0, 24);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
|
|
||||||
|
struct tm *cur_tm;
|
||||||
|
time_t cur_time;
|
||||||
|
|
||||||
lv_obj_t * bg_image = lv_img_create(lv_scr_act());
|
|
||||||
if(background_path != NULL) {
|
|
||||||
lv_img_set_src(bg_image, background_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(g_running) {
|
while(g_running) {
|
||||||
sleep(1);
|
time(&cur_time);
|
||||||
|
cur_tm = localtime(&cur_time);
|
||||||
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
|
lv_label_set_text_fmt(label_clock_date, "%s %04d/%02d/%02d",
|
||||||
|
s_wday[cur_tm->tm_wday], cur_tm->tm_year + 1900,
|
||||||
|
cur_tm->tm_mon + 1, cur_tm->tm_mday);
|
||||||
|
lv_label_set_text_fmt(label_clock_time, "%02d:%02d:%02d",
|
||||||
|
cur_tm->tm_hour, cur_tm->tm_min, cur_tm->tm_sec);
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
|
usleep(200 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,19 +1,11 @@
|
||||||
#include <stdint.h>
|
#include "tasks/user_task_lvgl_common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "lvgl.h"
|
|
||||||
|
|
||||||
#include "utils/user_log_util.h"
|
|
||||||
#include "tasks/user_tasks.h"
|
|
||||||
#include "impl/user_lvgl_impl.h"
|
#include "impl/user_lvgl_impl.h"
|
||||||
|
|
||||||
#define PIXBUF_SIZE 320 * 10
|
#define PIXBUF_SIZE 320 * 20
|
||||||
|
|
||||||
extern uint8_t g_running;
|
|
||||||
|
|
||||||
uint8_t g_lvgl_ready = 0;
|
uint8_t g_lvgl_ready = 0;
|
||||||
|
pthread_mutex_t g_lvgl_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
pthread_t user_lv_task_thread;
|
pthread_t user_lv_task_thread;
|
||||||
pthread_t user_lv_tick_thread;
|
pthread_t user_lv_tick_thread;
|
||||||
|
@ -34,6 +26,8 @@ int user_lvgl_task_init(void) {
|
||||||
|
|
||||||
USER_LOG(USER_LOG_INFO, "lv_init() called.");
|
USER_LOG(USER_LOG_INFO, "lv_init() called.");
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
|
|
||||||
lv_init();
|
lv_init();
|
||||||
|
|
||||||
lv_log_register_print_cb(user_lvgl_impl_log_cb);
|
lv_log_register_print_cb(user_lvgl_impl_log_cb);
|
||||||
|
@ -53,6 +47,8 @@ int user_lvgl_task_init(void) {
|
||||||
lv_indev_t *indev = lv_indev_drv_register(&s_indev_drv);
|
lv_indev_t *indev = lv_indev_drv_register(&s_indev_drv);
|
||||||
|
|
||||||
lv_group_t *indev_group = lv_group_create();
|
lv_group_t *indev_group = lv_group_create();
|
||||||
|
lv_group_set_default(indev_group);
|
||||||
|
lv_indev_set_group(indev, indev_group);
|
||||||
|
|
||||||
lv_fs_drv_init(&s_fs_drv);
|
lv_fs_drv_init(&s_fs_drv);
|
||||||
s_fs_drv.letter = 'A';
|
s_fs_drv.letter = 'A';
|
||||||
|
@ -65,6 +61,8 @@ int user_lvgl_task_init(void) {
|
||||||
|
|
||||||
lv_fs_drv_register(&s_fs_drv);
|
lv_fs_drv_register(&s_fs_drv);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
|
|
||||||
ret = pthread_create(&user_lv_task_thread, NULL, user_lv_task, NULL);
|
ret = pthread_create(&user_lv_task_thread, NULL, user_lv_task, NULL);
|
||||||
if(ret) return ret;
|
if(ret) return ret;
|
||||||
ret = pthread_create(&user_lv_tick_thread, NULL, user_lv_tick, NULL);
|
ret = pthread_create(&user_lv_tick_thread, NULL, user_lv_tick, NULL);
|
||||||
|
@ -94,7 +92,9 @@ void *user_lv_task(void *arguments) {
|
||||||
|
|
||||||
while(g_running) {
|
while(g_running) {
|
||||||
usleep(30 * 1000);
|
usleep(30 * 1000);
|
||||||
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -103,7 +103,9 @@ void *user_lv_task(void *arguments) {
|
||||||
void *user_lv_tick(void *arguments) {
|
void *user_lv_tick(void *arguments) {
|
||||||
while(g_running) {
|
while(g_running) {
|
||||||
usleep(30 * 1000);
|
usleep(30 * 1000);
|
||||||
|
pthread_mutex_lock(&g_lvgl_mutex);
|
||||||
lv_tick_inc(30);
|
lv_tick_inc(30);
|
||||||
|
pthread_mutex_unlock(&g_lvgl_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue