mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-25 18:29:26 +08:00
feat(osal): enable linux specific features with os_none (#8989)
This commit is contained in:
@@ -230,6 +230,7 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
|
||||
#if LV_USE_SYSMON == 0
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_SYSMON_PROC_IDLE_AVAILABLE 0
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
#if LV_USE_PERF_MONITOR == 0
|
||||
|
||||
@@ -35,10 +35,6 @@ extern "C" {
|
||||
#include "../font/lv_font_fmt_txt_private.h"
|
||||
#endif
|
||||
|
||||
#if LV_USE_OS != LV_OS_NONE && defined(__linux__)
|
||||
#include "../osal/lv_linux_private.h"
|
||||
#endif
|
||||
|
||||
#include "../tick/lv_tick.h"
|
||||
#include "../layouts/lv_layout.h"
|
||||
|
||||
@@ -257,12 +253,13 @@ typedef struct _lv_global_t {
|
||||
|
||||
#if LV_USE_OS != LV_OS_NONE
|
||||
lv_mutex_t lv_general_mutex;
|
||||
#if defined(__linux__)
|
||||
lv_proc_stat_t linux_last_proc_stat;
|
||||
#if defined LV_SYSMON_PROC_IDLE_AVAILABLE
|
||||
uint64_t linux_last_self_proc_time_ticks;
|
||||
lv_proc_stat_t linux_last_system_total_ticks_stat;
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
lv_linux_proc_stat_t linux_last_proc_stat;
|
||||
#if LV_SYSMON_PROC_IDLE_AVAILABLE
|
||||
uint64_t linux_last_self_proc_time_ticks;
|
||||
lv_linux_proc_stat_t linux_last_system_total_ticks_stat;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4733,6 +4733,7 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
|
||||
#if LV_USE_SYSMON == 0
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_SYSMON_PROC_IDLE_AVAILABLE 0
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
#if LV_USE_PERF_MONITOR == 0
|
||||
|
||||
+10
-9
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "lv_os_private.h"
|
||||
|
||||
#if LV_USE_OS != LV_OS_NONE && defined(__linux__)
|
||||
#if defined(__linux__)
|
||||
|
||||
#include "../core/lv_global.h"
|
||||
#include "../misc/lv_log.h"
|
||||
#include "lv_linux_private.h"
|
||||
#include "lv_linux.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static lv_result_t lv_read_proc_stat(lv_proc_stat_t * result);
|
||||
static uint32_t lv_proc_stat_get_total(const lv_proc_stat_t * p);
|
||||
static lv_result_t lv_read_proc_stat(lv_linux_proc_stat_t * result);
|
||||
static uint32_t lv_proc_stat_get_total(const lv_linux_proc_stat_t * p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -59,7 +59,7 @@ static uint32_t lv_proc_stat_get_total(const lv_proc_stat_t * p);
|
||||
|
||||
uint32_t lv_os_get_idle_percent(void)
|
||||
{
|
||||
lv_proc_stat_t proc_stat;
|
||||
lv_linux_proc_stat_t proc_stat;
|
||||
{
|
||||
lv_result_t err = lv_read_proc_stat(&proc_stat);
|
||||
|
||||
@@ -92,8 +92,8 @@ uint32_t lv_os_get_idle_percent(void)
|
||||
uint32_t lv_os_get_proc_idle_percent(void)
|
||||
{
|
||||
uint64_t self_current_time_ticks = 0;
|
||||
lv_proc_stat_t stat_current_system_total_ticks;
|
||||
lv_proc_stat_t stat_delta_system_ticks;
|
||||
lv_linux_proc_stat_t stat_current_system_total_ticks;
|
||||
lv_linux_proc_stat_t stat_delta_system_ticks;
|
||||
|
||||
FILE * self = fopen(LV_UPTIME_MONITOR_SELF_FILE, "r");
|
||||
if(!self) {
|
||||
@@ -181,7 +181,7 @@ uint32_t lv_os_get_proc_idle_percent(void)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static lv_result_t lv_read_proc_stat(lv_proc_stat_t * result)
|
||||
static lv_result_t lv_read_proc_stat(lv_linux_proc_stat_t * result)
|
||||
{
|
||||
FILE * fp = fopen(LV_UPTIME_MONITOR_FILE, "r");
|
||||
|
||||
@@ -207,7 +207,8 @@ static lv_result_t lv_read_proc_stat(lv_proc_stat_t * result)
|
||||
}
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
static uint32_t lv_proc_stat_get_total(const lv_proc_stat_t * p)
|
||||
|
||||
static uint32_t lv_proc_stat_get_total(const lv_linux_proc_stat_t * p)
|
||||
{
|
||||
uint32_t sum = 0;
|
||||
for(size_t i = 0; i < LV_PROC_STAT_PARAMS_LEN; ++i) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
/**
|
||||
* @file lv_linux_private.h
|
||||
* @file lv_linux.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LINUX_PRIVATE_H
|
||||
#define LV_LINUX_PRIVATE_H
|
||||
#ifndef LV_LINUX_H
|
||||
#define LV_LINUX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -15,8 +14,8 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../misc/lv_types.h"
|
||||
|
||||
#include "lv_os.h"
|
||||
#ifdef __linux__
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -27,7 +26,6 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
/*
|
||||
@@ -39,23 +37,20 @@ typedef union {
|
||||
steal /*, guest, guest_nice*/;
|
||||
} fields;
|
||||
uint32_t buffer[LV_PROC_STAT_PARAMS_LEN];
|
||||
} lv_proc_stat_t;
|
||||
} lv_linux_proc_stat_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
#if LV_SYSMON_PROC_IDLE_AVAILABLE
|
||||
|
||||
uint32_t lv_os_get_proc_idle_percent(void);
|
||||
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*__linux__*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_LINUX_PRIVATE_H*/
|
||||
#endif /*LV_LINUX_H*/
|
||||
@@ -37,10 +37,12 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#ifndef __linux__
|
||||
uint32_t lv_os_get_idle_percent(void)
|
||||
{
|
||||
return lv_timer_get_idle();
|
||||
}
|
||||
#endif /*__linux__*/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
||||
@@ -22,6 +22,10 @@ extern "C" {
|
||||
#include "lv_os.h"
|
||||
#include "../misc/lv_types.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include "lv_linux.h"
|
||||
#endif
|
||||
|
||||
#if LV_USE_OS == LV_OS_NONE
|
||||
#include "lv_os_none.h"
|
||||
#elif LV_USE_OS == LV_OS_PTHREAD
|
||||
@@ -72,6 +76,12 @@ void lv_os_init(void);
|
||||
*/
|
||||
uint32_t lv_os_get_idle_percent(void);
|
||||
|
||||
#if LV_SYSMON_PROC_IDLE_AVAILABLE
|
||||
|
||||
uint32_t lv_os_get_proc_idle_percent(void);
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_USE_OS != LV_OS_NONE
|
||||
|
||||
/*----------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user