Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
This commit is contained in:
@ -10,13 +10,19 @@
|
||||
#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();
|
||||
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
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -42,17 +42,18 @@ static int16_t last_y = 0;
|
||||
/**
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
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
|
||||
* @return false: because the points are not buffered, so no more data to be
|
||||
* read
|
||||
*/
|
||||
bool mouse_read(lv_indev_data_t * data)
|
||||
bool
|
||||
mouse_read(lv_indev_data_t *data)
|
||||
{
|
||||
/*Store the collected data*/
|
||||
data->point.x = last_x;
|
||||
@ -65,27 +66,27 @@ bool mouse_read(lv_indev_data_t * data)
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
void mouse_handler(SDL_Event * event)
|
||||
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;
|
||||
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;
|
||||
case SDL_MOUSEMOTION:
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@ -43,18 +43,22 @@ extern "C" {
|
||||
/**
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void);
|
||||
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
|
||||
* @return false: because the points are not buffered, so no more data to be
|
||||
* read
|
||||
*/
|
||||
bool mouse_read(lv_indev_data_t * data);
|
||||
bool
|
||||
mouse_read(lv_indev_data_t *data);
|
||||
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
void mouse_handler(SDL_Event *event);
|
||||
void
|
||||
mouse_handler(SDL_Event *event);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@ -11,19 +11,23 @@
|
||||
#define MONITOR_HOR_RES 320
|
||||
#define MONITOR_VER_RES 240
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#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);
|
||||
#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)
|
||||
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;
|
||||
lv_color_t *temp = (lv_color_t *)buf_xy;
|
||||
*temp = *color;
|
||||
/*
|
||||
if (opa != LV_OPA_COVER) {
|
||||
@ -36,28 +40,30 @@ void display_vdb_write(void *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
}
|
||||
*/
|
||||
}
|
||||
int time_get_ms()
|
||||
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;
|
||||
return (int)time_in_mill;
|
||||
}
|
||||
|
||||
SDL_Window * window;
|
||||
SDL_Renderer * renderer;
|
||||
SDL_Texture * texture;
|
||||
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)
|
||||
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) {
|
||||
|| y1 > MONITOR_VER_RES - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,14 +71,13 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
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));
|
||||
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*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,8 +88,8 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @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)
|
||||
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)
|
||||
@ -104,7 +109,7 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
uint32_t color32 = color.full; //lv_color_to32(color);
|
||||
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++) {
|
||||
@ -123,8 +128,9 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @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)
|
||||
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)
|
||||
@ -147,7 +153,8 @@ void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
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);
|
||||
tft_fb[y * MONITOR_HOR_RES + x] =
|
||||
color_p->full; // lv_color_to32(*color_p);
|
||||
color_p++;
|
||||
}
|
||||
|
||||
@ -157,39 +164,42 @@ void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
sdl_refr_qry = true;
|
||||
}
|
||||
|
||||
void display_init(void)
|
||||
{
|
||||
}
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
bool
|
||||
display_input_read(lv_indev_data_t *data)
|
||||
{
|
||||
return mouse_read(data);
|
||||
}
|
||||
|
||||
void display_deinit(void)
|
||||
{
|
||||
void
|
||||
display_deinit(void)
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
int monitor_sdl_refr_thread(void * param)
|
||||
int
|
||||
monitor_sdl_refr_thread(void *param)
|
||||
{
|
||||
(void) param;
|
||||
(void)param;
|
||||
|
||||
/*If not OSX initialize SDL in the Thread*/
|
||||
monitor_sdl_init();
|
||||
@ -205,19 +215,21 @@ int monitor_sdl_refr_thread(void * param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void monitor_sdl_refr_core(void)
|
||||
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));
|
||||
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);
|
||||
/*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);
|
||||
@ -231,29 +243,29 @@ void monitor_sdl_refr_core(void)
|
||||
if ((&event)->type == SDL_WINDOWEVENT) {
|
||||
switch ((&event)->window.event) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
#endif
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
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;
|
||||
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)
|
||||
int
|
||||
quit_filter(void *userdata, SDL_Event *event)
|
||||
{
|
||||
(void) userdata;
|
||||
(void)userdata;
|
||||
|
||||
if (event->type == SDL_QUIT) {
|
||||
sdl_quit_qry = true;
|
||||
@ -262,7 +274,8 @@ int quit_filter(void * userdata, SDL_Event * event)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void monitor_sdl_clean_up(void)
|
||||
void
|
||||
monitor_sdl_clean_up(void)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
@ -270,34 +283,37 @@ void monitor_sdl_clean_up(void)
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void monitor_sdl_init(void)
|
||||
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*/
|
||||
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_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));
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
sdl_refr_qry = true;
|
||||
sdl_inited = true;
|
||||
}
|
||||
|
||||
void display_SDL_init()
|
||||
void
|
||||
display_SDL_init()
|
||||
{
|
||||
SDL_CreateThread(monitor_sdl_refr_thread, "sdl_refr", NULL);
|
||||
while (sdl_inited == false)
|
||||
; /*Wait until 'sdl_refr' initializes the SDL*/
|
||||
}
|
||||
|
||||
|
||||
@ -5,4 +5,5 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int time_get_ms();
|
||||
int
|
||||
time_get_ms();
|
||||
|
||||
@ -28,9 +28,10 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void hal_init(void);
|
||||
//static int tick_thread(void * data);
|
||||
//static void memory_monitor(void * param);
|
||||
static void
|
||||
hal_init(void);
|
||||
// static int tick_thread(void * data);
|
||||
// static void memory_monitor(void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -47,22 +48,23 @@ 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 *btn1;
|
||||
|
||||
lv_obj_t * label_count1;
|
||||
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)
|
||||
static lv_res_t
|
||||
btn_rel_action(lv_obj_t *btn)
|
||||
{
|
||||
label_count1_value++;
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str), "%d",
|
||||
label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
void display_SDL_init();
|
||||
display_SDL_init();
|
||||
@ -80,23 +82,26 @@ int main()
|
||||
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*/
|
||||
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_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) {
|
||||
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) {
|
||||
snprintf(count_str, sizeof(count_str), "%d", count/ 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
lv_task_handler();
|
||||
@ -112,31 +117,41 @@ int main()
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
|
||||
* 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)
|
||||
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)
|
||||
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)
|
||||
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)*/
|
||||
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
|
||||
@ -144,12 +159,12 @@ static void hal_init(void)
|
||||
|
||||
/* Add the mouse as input device
|
||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||
// mouse_init();
|
||||
// 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);
|
||||
|
||||
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