Skip to content

Commit

Permalink
Fix incorrect use of an lv_task
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt authored Dec 4, 2019
1 parent 021f312 commit dd32300
Showing 1 changed file with 116 additions and 116 deletions.
232 changes: 116 additions & 116 deletions win_drv.c
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
/**
* @file win_drv.c
*
*/

/*********************
* INCLUDES
*********************/
#include "win_drv.h"
#if USE_WINDOWS

/**
* @file win_drv.c
*
*/

/*********************
* INCLUDES
*********************/
#include "win_drv.h"
#if USE_WINDOWS

#include <windows.h>
#include <windowsx.h>
#include "lvgl/lvgl.h"

#if LV_COLOR_DEPTH < 16
#error Windows driver only supports true RGB colors at this time
#endif


/**********************
* DEFINES
**********************/

#define WINDOW_STYLE (WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME))

/**********************
* TYPEDEFS
**********************/

/**********************
* STATIC PROTOTYPES

/**********************
* TYPEDEFS
**********************/

/**********************
* STATIC PROTOTYPES
**********************/
static void do_register(void);
static void win_drv_flush(lv_disp_t *drv, lv_area_t *area, const lv_color_t * color_p);
static void win_drv_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
static void win_drv_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
static void win_drv_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
static bool win_drv_read(lv_indev_t *drv, lv_indev_data_t * data);
static void msg_handler(void *param);

static COLORREF lv_color_to_colorref(const lv_color_t color);


static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);


/**********************
* GLOBAL VARIABLES
/**********************
* GLOBAL VARIABLES
**********************/

bool lv_win_exit_flag = false;
lv_disp_t *lv_windows_disp;

/**********************
* STATIC VARIABLES
**********************/

/**********************
* STATIC VARIABLES
**********************/
static HWND hwnd;
static uint32_t *fbp = NULL; /* Raw framebuffer memory */
static bool mouse_pressed;
static int mouse_x, mouse_y;


/**********************
* MACROS
**********************/

/**********************
* GLOBAL FUNCTIONS
**********************/

/**********************
* MACROS
**********************/

/**********************
* GLOBAL FUNCTIONS
**********************/
const char g_szClassName[] = "LittlevGL";

HWND windrv_init(void)

HWND windrv_init(void)
{
WNDCLASSEX wc;
RECT winrect;
Expand Down Expand Up @@ -123,58 +123,58 @@ HWND windrv_init(void)

lv_task_create(msg_handler, 0, LV_TASK_PRIO_HIGHEST, NULL);
lv_win_exit_flag = false;
do_register();
do_register();
}

/**********************
* STATIC FUNCTIONS

/**********************
* STATIC FUNCTIONS
**********************/

static void do_register(void)
{
/*-----------------------------
* Create a buffer for drawing
*----------------------------*/

/* LittlevGL requires a buffer where it draw the objects. The buffer's has to be greater than 1 display row
*
* There are three buffering configurations:
* 1. Create ONE buffer some rows: LittlevGL will draw the display's content here and writes it to your display
* 2. Create TWO buffer some rows: LittlevGL will draw the display's content to a buffer and writes it your display.
* You should use DMA to write the buffer's content to the display.
* It will enable LittlevGL to draw the next part of the screen to the other buffer while
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
* 3. Create TWO screen buffer: Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the
* whole frame to display. This way you only need to change the frame buffer's address instead of
* copying the pixels.
* */

/* Example for 1) */
static lv_disp_buf_t disp_buf_1;
static lv_color_t buf1_1[WINDOW_HOR_RES * 10]; /*A buffer for 10 rows*/
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, WINDOW_HOR_RES * 10); /*Initialize the display buffer*/


/*-----------------------------------
* Register the display in LittlevGL
*----------------------------------*/

lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/

/*Set up the functions to access to your display*/

/*Set the resolution of the display*/
disp_drv.hor_res = WINDOW_HOR_RES;
disp_drv.ver_res = WINDOW_VER_RES;

/*Used to copy the buffer's content to the display*/
disp_drv.flush_cb = win_drv_flush;

/*Set a display buffer*/
disp_drv.buffer = &disp_buf_1;

/*Finally register the driver*/
/*-----------------------------
* Create a buffer for drawing
*----------------------------*/

/* LittlevGL requires a buffer where it draw the objects. The buffer's has to be greater than 1 display row
*
* There are three buffering configurations:
* 1. Create ONE buffer some rows: LittlevGL will draw the display's content here and writes it to your display
* 2. Create TWO buffer some rows: LittlevGL will draw the display's content to a buffer and writes it your display.
* You should use DMA to write the buffer's content to the display.
* It will enable LittlevGL to draw the next part of the screen to the other buffer while
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
* 3. Create TWO screen buffer: Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the
* whole frame to display. This way you only need to change the frame buffer's address instead of
* copying the pixels.
* */

/* Example for 1) */
static lv_disp_buf_t disp_buf_1;
static lv_color_t buf1_1[WINDOW_HOR_RES * 10]; /*A buffer for 10 rows*/
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, WINDOW_HOR_RES * 10); /*Initialize the display buffer*/


/*-----------------------------------
* Register the display in LittlevGL
*----------------------------------*/

lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/

/*Set up the functions to access to your display*/

/*Set the resolution of the display*/
disp_drv.hor_res = WINDOW_HOR_RES;
disp_drv.ver_res = WINDOW_VER_RES;

/*Used to copy the buffer's content to the display*/
disp_drv.flush_cb = win_drv_flush;

/*Set a display buffer*/
disp_drv.buffer = &disp_buf_1;

/*Finally register the driver*/
lv_windows_disp = lv_disp_drv_register(&disp_drv);
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
Expand All @@ -189,7 +189,7 @@ static void msg_handler(void *param)

MSG msg;
BOOL bRet;
while( (bRet = PeekMessage( &msg, NULL, 0, 0, TRUE )) != 0)
if( (bRet = PeekMessage( &msg, NULL, 0, 0, TRUE )) != 0)
{
if (bRet == -1)
{
Expand Down Expand Up @@ -231,30 +231,30 @@ static void msg_handler(void *param)
EndPaint(hwnd, &ps);
DeleteObject(bmp);

}
/**
* Flush a buffer 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
*/
static void win_drv_flush(lv_disp_t *drv, lv_area_t *area, const lv_color_t * color_p)
{
win_drv_map(area->x1, area->y1, area->x2, area->y2, color_p);
lv_disp_flush_ready(drv);
}

/**
* 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
*/
static void win_drv_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
}
/**
* Flush a buffer 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
*/
static void win_drv_flush(lv_disp_t *drv, lv_area_t *area, const lv_color_t * color_p)
{
win_drv_map(area->x1, area->y1, area->x2, area->y2, color_p);
lv_disp_flush_ready(drv);
}

/**
* 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
*/
static void win_drv_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
{
for(int y = y1; y <= y2; y++)
{
Expand All @@ -265,9 +265,9 @@ static void win_drv_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv
}
}
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
UpdateWindow(hwnd);
}


static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
Expand Down Expand Up @@ -316,8 +316,8 @@ static COLORREF lv_color_to_colorref(const lv_color_t color)
tmp.full = raw_color;
uint32_t colorref = RGB(tmp.ch.red, tmp.ch.green, tmp.ch.blue);
return colorref;
}
#endif



}
#endif


0 comments on commit dd32300

Please sign in to comment.