mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
add lv_hal as normal folder (not from hal repo)
This commit is contained in:
parent
2b44c68794
commit
d9205adc60
1
lv_hal
1
lv_hal
@ -1 +0,0 @@
|
||||
Subproject commit f4c87207c2d93366e3a0615a499c063c48a6497f
|
41
lv_hal/lv_hal.h
Normal file
41
lv_hal/lv_hal.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file hal.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_H
|
||||
#define HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_hal_disp.h"
|
||||
#include "lv_hal_indev.h"
|
||||
#include <lvgl/lv_hal/lv_hal_tick.h>
|
||||
#include "lv_hal_indev_keycode.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
154
lv_hal/lv_hal_disp.c
Normal file
154
lv_hal/lv_hal_disp.c
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
/**
|
||||
* @file hal_disp.c
|
||||
*
|
||||
* @description HAL layer for display driver
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_disp_t *disp_list = NULL;
|
||||
static lv_disp_t *active;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register Display driver
|
||||
* @param driver Display driver structure
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_hal_disp_drv_t *driver)
|
||||
{
|
||||
lv_disp_t *node;
|
||||
|
||||
node = dm_alloc(sizeof(lv_disp_t));
|
||||
if (!node) return NULL;
|
||||
|
||||
memcpy(&node->drv,driver, sizeof(lv_hal_disp_drv_t));
|
||||
node->next = NULL;
|
||||
|
||||
/* Set first display as active by default */
|
||||
if (disp_list == NULL) {
|
||||
disp_list = node;
|
||||
active = node;
|
||||
} else {
|
||||
node->next = disp_list;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Active Display by ID
|
||||
*
|
||||
* @param id Display ID to set as active
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp)
|
||||
{
|
||||
active = disp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Active Display
|
||||
*
|
||||
* @return Active ID of display on success else -ve on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_next(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) {
|
||||
return disp_list;
|
||||
} else {
|
||||
if(disp_list->next == NULL) return NULL;
|
||||
else return disp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color fill color
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->drv.fill != NULL) active->drv.fill(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_map pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * color_map)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->drv.map != NULL) active->drv.map(x1, y1, x2, y2, color_map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity with GPU (hardware accelerator)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_copy(color_t * dest, const color_t * src, uint32_t length, opa_t opa)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->drv.copy != NULL) active->drv.copy(dest, src, length, opa);
|
||||
}
|
||||
|
||||
bool lv_disp_is_accelerated(void)
|
||||
{
|
||||
if(active->drv.copy) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
113
lv_hal/lv_hal_disp.h
Normal file
113
lv_hal/lv_hal_disp.h
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @file hal_disp.h
|
||||
*
|
||||
* @description Display Driver HAL interface header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_DISP_H
|
||||
#define HAL_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_hal.h"
|
||||
#include "misc/gfx/color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Display Driver structure to be registered by HAL
|
||||
*/
|
||||
typedef struct _disp_drv_t {
|
||||
const char *name;
|
||||
int32_t h_res;
|
||||
int32_t v_res;
|
||||
void (*fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color);
|
||||
void (*map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * color_p);
|
||||
void (*copy)(color_t * dest, const color_t * src, uint32_t length, opa_t opa);
|
||||
} lv_hal_disp_drv_t;
|
||||
|
||||
typedef struct _disp_drv_node_t {
|
||||
lv_hal_disp_drv_t drv;
|
||||
struct _disp_drv_node_t *next;
|
||||
} lv_disp_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register Display driver
|
||||
*
|
||||
* @param driver Display driver structure
|
||||
* @return 0 on success, -ve on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_hal_disp_drv_t *driver);
|
||||
|
||||
/**
|
||||
* Set Active Display by ID
|
||||
*
|
||||
* @param id Display ID to set as active
|
||||
* @return 0 on success, -ve on error
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Get Active Display
|
||||
*
|
||||
* @return Active ID of display on success else -ve on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void);
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color fill color
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, color_t color);
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const color_t * color_p);
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity with GPU (hardware accelerator)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_color_cpy(color_t * dest, const color_t * src, uint32_t length, opa_t opa);
|
||||
|
||||
bool lv_disp_is_accelerated(void);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
106
lv_hal/lv_hal_indev.c
Normal file
106
lv_hal/lv_hal_indev.c
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @file hal_indev.c
|
||||
*
|
||||
* @description Input device HAL interface
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_indev_t *indev_list = NULL;
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register Input Device driver
|
||||
*
|
||||
* @param driver Input Device driver structure
|
||||
* @return pointer to the new input device
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_hal_indev_drv_t *driver)
|
||||
{
|
||||
lv_indev_t *node;
|
||||
|
||||
node = dm_alloc(sizeof(lv_indev_t));
|
||||
if (!node) return NULL;
|
||||
|
||||
memcpy(&node->drv, driver, sizeof(lv_hal_indev_drv_t));
|
||||
|
||||
node->next = NULL;
|
||||
|
||||
if (indev_list == NULL) {
|
||||
indev_list = node;
|
||||
} else {
|
||||
lv_indev_t *last = indev_list;
|
||||
while (last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = node;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev)
|
||||
{
|
||||
|
||||
if(indev == NULL) {
|
||||
return indev_list;
|
||||
} else {
|
||||
if(indev_list->next == NULL) return NULL;
|
||||
else return indev_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an input device.
|
||||
* @param indev pointer to an input device
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool lv_indev_get(lv_indev_t * indev, lv_hal_indev_data_t *data)
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
if(indev->drv.get_data) {
|
||||
cont = indev->drv.get_data(data);
|
||||
} else {
|
||||
memset(data, 0, sizeof(lv_hal_indev_data_t));
|
||||
}
|
||||
|
||||
return cont;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
127
lv_hal/lv_hal_indev.h
Normal file
127
lv_hal/lv_hal_indev.h
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @file hal_indev.h
|
||||
*
|
||||
* @description Input Device HAL interface layer header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_INDEV_H
|
||||
#define HAL_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "misc/gfx/area.h"
|
||||
#include <lvgl/lv_hal/lv_hal.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Possible input device types*/
|
||||
typedef enum {
|
||||
LV_HAL_INDEV_TYPE_TOUCH, /*Touch pad*/
|
||||
LV_HAL_INDEV_TYPE_POINTER, /*Mouse or similar pointer device*/
|
||||
LV_HAL_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
|
||||
LV_HAL_INDEV_TYPE_BUTTON, /*Hardware button assigned to a point on the screen*/
|
||||
} lv_hal_indev_type_t;
|
||||
|
||||
/*State for input devices*/
|
||||
typedef enum {
|
||||
LV_HAL_INDEV_STATE_PRESS,
|
||||
LV_HAL_INDEV_STATE_RELEASE
|
||||
}lv_hal_indev_state_t;
|
||||
|
||||
/*Data read from an input device. */
|
||||
typedef struct {
|
||||
union {
|
||||
point_t point; /*For INDEV_TYPE_TOUCH, INDEV_TYPE_POINTER, INDEV_TYPE_BUTTON*/
|
||||
uint32_t key; /*For INDEV_TYPE_BUTTON*/
|
||||
};
|
||||
lv_hal_indev_state_t state;
|
||||
}lv_hal_indev_data_t;
|
||||
|
||||
/*Initialized by the user and registered by 'lv_hal_indev_drv_register'*/
|
||||
typedef struct {
|
||||
const char * name; /*Input device name*/
|
||||
lv_hal_indev_type_t type; /*Input device type*/
|
||||
bool (*get_data)(lv_hal_indev_data_t * data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
|
||||
}lv_hal_indev_drv_t;
|
||||
|
||||
struct __LV_OBJ_T;
|
||||
|
||||
typedef struct _lv_indev_state_t
|
||||
{
|
||||
bool pressed;
|
||||
point_t act_point;
|
||||
point_t last_point;
|
||||
point_t vect;
|
||||
point_t vect_sum;
|
||||
struct __LV_OBJ_T * act_obj;
|
||||
struct __LV_OBJ_T * last_obj;
|
||||
uint32_t press_time_stamp;
|
||||
uint32_t lpr_rep_time_stamp;
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_range_out :1;
|
||||
uint8_t drag_in_prog :1;
|
||||
uint8_t long_press_sent :1;
|
||||
uint8_t wait_release :1;
|
||||
uint8_t reset_qry :1;
|
||||
uint8_t disable :1;
|
||||
}lv_indev_state_t;
|
||||
|
||||
|
||||
typedef struct _lv_indev_t {
|
||||
lv_hal_indev_drv_t drv;
|
||||
lv_indev_state_t state;
|
||||
struct __LV_OBJ_T * cursor;
|
||||
struct _lv_indev_t *next;
|
||||
} lv_indev_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register Input Device driver
|
||||
*
|
||||
* @param driver Input Device driver structure
|
||||
* @return 0 on success, -ve on error
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_hal_indev_drv_t *driver);
|
||||
|
||||
|
||||
/**
|
||||
* Ask data fro man input device.
|
||||
* @param data input device data
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool lv_indev_get(lv_indev_t * indev, lv_hal_indev_data_t *data);
|
||||
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
174
lv_hal/lv_hal_indev_keycode.h
Normal file
174
lv_hal/lv_hal_indev_keycode.h
Normal file
@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @file hal_indev_keycode.h
|
||||
*
|
||||
* @description Input Device keycodes
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_INDEV_KEYCODE_H
|
||||
#define HAL_INDEV_KEYCODE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**
|
||||
* Common keycodes taken from Linux Source
|
||||
* include/uapi/linux/input-event-codes.h
|
||||
*/
|
||||
#define KEY_RESERVED 0
|
||||
#define KEY_ESC 1
|
||||
#define KEY_1 2
|
||||
#define KEY_2 3
|
||||
#define KEY_3 4
|
||||
#define KEY_4 5
|
||||
#define KEY_5 6
|
||||
#define KEY_6 7
|
||||
#define KEY_7 8
|
||||
#define KEY_8 9
|
||||
#define KEY_9 10
|
||||
#define KEY_0 11
|
||||
#define KEY_MINUS 12
|
||||
#define KEY_EQUAL 13
|
||||
#define KEY_BACKSPACE 14
|
||||
#define KEY_TAB 15
|
||||
#define KEY_Q 16
|
||||
#define KEY_W 17
|
||||
#define KEY_E 18
|
||||
#define KEY_R 19
|
||||
#define KEY_T 20
|
||||
#define KEY_Y 21
|
||||
#define KEY_U 22
|
||||
#define KEY_I 23
|
||||
#define KEY_O 24
|
||||
#define KEY_P 25
|
||||
#define KEY_LEFTBRACE 26
|
||||
#define KEY_RIGHTBRACE 27
|
||||
#define KEY_ENTER 28
|
||||
#define KEY_LEFTCTRL 29
|
||||
#define KEY_A 30
|
||||
#define KEY_S 31
|
||||
#define KEY_D 32
|
||||
#define KEY_F 33
|
||||
#define KEY_G 34
|
||||
#define KEY_H 35
|
||||
#define KEY_J 36
|
||||
#define KEY_K 37
|
||||
#define KEY_L 38
|
||||
#define KEY_SEMICOLON 39
|
||||
#define KEY_APOSTROPHE 40
|
||||
#define KEY_GRAVE 41
|
||||
#define KEY_LEFTSHIFT 42
|
||||
#define KEY_BACKSLASH 43
|
||||
#define KEY_Z 44
|
||||
#define KEY_X 45
|
||||
#define KEY_C 46
|
||||
#define KEY_V 47
|
||||
#define KEY_B 48
|
||||
#define KEY_N 49
|
||||
#define KEY_M 50
|
||||
#define KEY_COMMA 51
|
||||
#define KEY_DOT 52
|
||||
#define KEY_SLASH 53
|
||||
#define KEY_RIGHTSHIFT 54
|
||||
#define KEY_KPASTERISK 55
|
||||
#define KEY_LEFTALT 56
|
||||
#define KEY_SPACE 57
|
||||
#define KEY_CAPSLOCK 58
|
||||
#define KEY_F1 59
|
||||
#define KEY_F2 60
|
||||
#define KEY_F3 61
|
||||
#define KEY_F4 62
|
||||
#define KEY_F5 63
|
||||
#define KEY_F6 64
|
||||
#define KEY_F7 65
|
||||
#define KEY_F8 66
|
||||
#define KEY_F9 67
|
||||
#define KEY_F10 68
|
||||
#define KEY_NUMLOCK 69
|
||||
#define KEY_SCROLLLOCK 70
|
||||
#define KEY_KP7 71
|
||||
#define KEY_KP8 72
|
||||
#define KEY_KP9 73
|
||||
#define KEY_KPMINUS 74
|
||||
#define KEY_KP4 75
|
||||
#define KEY_KP5 76
|
||||
#define KEY_KP6 77
|
||||
#define KEY_KPPLUS 78
|
||||
#define KEY_KP1 79
|
||||
#define KEY_KP2 80
|
||||
#define KEY_KP3 81
|
||||
#define KEY_KP0 82
|
||||
#define KEY_KPDOT 83
|
||||
|
||||
#define KEY_ZENKAKUHANKAKU 85
|
||||
#define KEY_102ND 86
|
||||
#define KEY_F11 87
|
||||
#define KEY_F12 88
|
||||
#define KEY_RO 89
|
||||
#define KEY_KATAKANA 90
|
||||
#define KEY_HIRAGANA 91
|
||||
#define KEY_HENKAN 92
|
||||
#define KEY_KATAKANAHIRAGANA 93
|
||||
#define KEY_MUHENKAN 94
|
||||
#define KEY_KPJPCOMMA 95
|
||||
#define KEY_KPENTER 96
|
||||
#define KEY_RIGHTCTRL 97
|
||||
#define KEY_KPSLASH 98
|
||||
#define KEY_SYSRQ 99
|
||||
#define KEY_RIGHTALT 100
|
||||
#define KEY_LINEFEED 101
|
||||
#define KEY_HOME 102
|
||||
#define KEY_UP 103
|
||||
#define KEY_PAGEUP 104
|
||||
#define KEY_LEFT 105
|
||||
#define KEY_RIGHT 106
|
||||
#define KEY_END 107
|
||||
#define KEY_DOWN 108
|
||||
#define KEY_PAGEDOWN 109
|
||||
#define KEY_INSERT 110
|
||||
#define KEY_DELETE 111
|
||||
#define KEY_MACRO 112
|
||||
#define KEY_MUTE 113
|
||||
#define KEY_VOLUMEDOWN 114
|
||||
#define KEY_VOLUMEUP 115
|
||||
#define KEY_POWER 116 /* SC System Power Down */
|
||||
#define KEY_KPEQUAL 117
|
||||
#define KEY_KPPLUSMINUS 118
|
||||
#define KEY_PAUSE 119
|
||||
#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */
|
||||
|
||||
#define KEY_KPCOMMA 121
|
||||
#define KEY_HANGEUL 122
|
||||
#define KEY_HANGUEL KEY_HANGEUL
|
||||
#define KEY_HANJA 123
|
||||
#define KEY_YEN 124
|
||||
#define KEY_LEFTMETA 125
|
||||
#define KEY_RIGHTMETA 126
|
||||
#define KEY_COMPOSE 127
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
152
lv_hal/lv_hal_tick.c
Normal file
152
lv_hal/lv_hal_tick.c
Normal file
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* @file systick.c
|
||||
* Provide access to the system tick with 1 millisecond resolution
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_hal/lv_hal_tick.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_HAL_TICK_CALLBACK_NUM 32
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static uint32_t sys_time = 0;
|
||||
static volatile uint8_t tick_irq_flag;
|
||||
static volatile uint8_t tick_cb_sem; /*Semaphore for tick callbacks*/
|
||||
static void (*tick_callbacks[LV_HAL_TICK_CALLBACK_NUM])(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Call this function in every milliseconds
|
||||
*/
|
||||
void lv_tick_handler(void)
|
||||
{
|
||||
sys_time++;
|
||||
|
||||
/*Run the callback functions*/
|
||||
uint8_t i;
|
||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
||||
if (tick_callbacks[i] != NULL) {
|
||||
tick_callbacks[i]();
|
||||
}
|
||||
}
|
||||
tick_irq_flag = 0; /*lv_hal_systick_get set it to know there was an IRQ*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t lv_tick_get(void)
|
||||
{
|
||||
uint32_t result;
|
||||
do {
|
||||
tick_irq_flag = 1;
|
||||
result = sys_time;
|
||||
} while(!tick_irq_flag); /*Systick IRQ clears this flag. Continue until make a non interrupted cycle */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds science a previous time stamp
|
||||
* @param prev_tick a previous time stamp ( return value of systick_get() )
|
||||
* @return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick)
|
||||
{
|
||||
uint32_t act_time = lv_tick_get();
|
||||
|
||||
/*If there is no overflow in sys_time simple subtract*/
|
||||
if(act_time >= prev_tick) {
|
||||
prev_tick = act_time - prev_tick;
|
||||
} else {
|
||||
prev_tick = UINT32_MAX - prev_tick + 1;
|
||||
prev_tick += act_time;
|
||||
}
|
||||
|
||||
return prev_tick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a callback function to the systick interrupt
|
||||
* @param cb a function pointer
|
||||
* @return true: 'cb' added to the systick callbacks, false: 'cb' not added
|
||||
*/
|
||||
bool lv_tick_add_callback(void (*cb) (void))
|
||||
{
|
||||
bool suc = false;
|
||||
|
||||
/*Take the semaphore. Be sure it is set*/
|
||||
do {
|
||||
tick_cb_sem = 1;
|
||||
} while(!tick_cb_sem);
|
||||
|
||||
uint8_t i;
|
||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
||||
if (tick_callbacks[i] == NULL) {
|
||||
tick_callbacks[i] = cb;
|
||||
suc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Release the semaphore. Be sure it is cleared*/
|
||||
do {
|
||||
tick_cb_sem = 0;
|
||||
} while(tick_cb_sem);
|
||||
|
||||
return suc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a callback function from the tick callbacks
|
||||
* @param cb a function pointer (added with 'lv_hal_tick_add_callback')
|
||||
*/
|
||||
void lv_tick_rem_callback(void (*cb) (void))
|
||||
{
|
||||
/*Take the semaphore. Be sure it is set*/
|
||||
do {
|
||||
tick_cb_sem = 1;
|
||||
} while(!tick_cb_sem);
|
||||
|
||||
uint8_t i;
|
||||
for (i = 0; i < LV_HAL_TICK_CALLBACK_NUM; i++) {
|
||||
if (tick_callbacks[i] == cb) {
|
||||
tick_callbacks[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Release the semaphore. Be sure it is cleared*/
|
||||
do {
|
||||
tick_cb_sem = 0;
|
||||
} while(tick_cb_sem);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
69
lv_hal/lv_hal_tick.h
Normal file
69
lv_hal/lv_hal_tick.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file lv_hal_tick.h
|
||||
* Provide access to the system tick with 1 millisecond resolution
|
||||
*/
|
||||
|
||||
#ifndef LV_HAL_TICK_H
|
||||
#define LV_HAL_TICK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/**
|
||||
* Call this function every milliseconds
|
||||
*/
|
||||
void lv_tick_handler(void);
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t lv_tick_get(void);
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds science a previous time stamp
|
||||
* @param prev_tick a previous time stamp from 'systick_get'
|
||||
* @return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick);
|
||||
|
||||
/**
|
||||
* Add a callback function to the systick interrupt
|
||||
* @param cb a function pointer
|
||||
* @return true: 'cb' added to the systick callbacks, false: 'cb' not added
|
||||
*/
|
||||
bool lv_tick_add_callback(void (*cb) (void));
|
||||
|
||||
/**
|
||||
* Remove a callback function from the tick callbacks
|
||||
* @param cb a function pointer (added with 'lv_hal_tick_add_callback')
|
||||
*/
|
||||
void lv_tick_rem_callback(void (*cb) (void));
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_HAL_TICK_H*/
|
Loading…
x
Reference in New Issue
Block a user