Skip to content

Commit

Permalink
indev/disp cb: pass driver as first argument
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Feb 24, 2019
1 parent 9264cd9 commit 054e43e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
8 changes: 4 additions & 4 deletions lv_core/lv_refr.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)

/*The area is truncated to the screen*/
if(suc != false) {
if(disp->driver.rounder_cb) disp->driver.rounder_cb(disp_refr, &com_area);
if(disp->driver.rounder_cb) disp->driver.rounder_cb(&disp_refr->driver, &com_area);

/*Save only if this area is not in one of the saved areas*/
uint16_t i;
Expand Down Expand Up @@ -192,7 +192,7 @@ static void lv_refr_task(void * param)

/*Call monitor cb if present*/
if(disp_refr->driver.monitor_cb) {
disp_refr->driver.monitor_cb(disp_refr, lv_tick_elaps(start), px_num);
disp_refr->driver.monitor_cb(&disp_refr->driver, lv_tick_elaps(start), px_num);
}
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ static void lv_refr_area(const lv_area_t * area_p)
lv_coord_t y_tmp = max_row;
do {
tmp.y2 = y_tmp;
disp_refr->driver.rounder_cb(disp_refr, &tmp);
disp_refr->driver.rounder_cb(&disp_refr->driver, &tmp);
y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */
} while(lv_area_get_height(&tmp) > max_row && y_tmp != 0);

Expand Down Expand Up @@ -539,7 +539,7 @@ static void lv_refr_vdb_flush(void)

/*Flush the rendered content to the display*/
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.flush_cb) disp->driver.flush_cb(disp, &vdb->area, vdb->buf_act);
if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act);


if(vdb->buf1 && vdb->buf2) {
Expand Down
12 changes: 6 additions & 6 deletions lv_draw/lv_draw_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t
y -= vdb->area.y1;

if(disp->driver.set_px_cb) {
disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa);
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa);
} else {
lv_color_t * vdb_px_p = vdb->buf_act;
vdb_px_p += y * vdb_width + x;
Expand Down Expand Up @@ -336,7 +336,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
}

if(disp->driver.set_px_cb) {
disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width,
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
(col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1,
color, px_opa);
} else {
Expand Down Expand Up @@ -434,7 +434,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa);
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
}
Expand Down Expand Up @@ -497,7 +497,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
}
/*Handle custom VDB write is present*/
if(disp->driver.set_px_cb) {
disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
}
/*Normal native VDB write*/
else {
Expand All @@ -507,7 +507,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
} else {
/*Handle custom VDB write is present*/
if(disp->driver.set_px_cb) {
disp->driver.set_px_cb(disp, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result);
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result);
}
/*Normal native VDB write*/
else {
Expand Down Expand Up @@ -571,7 +571,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
if(disp->driver.set_px_cb) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.set_px_cb(disp, (uint8_t *)mem, mem_width, col, row, color, opa);
disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, opa);
}
}
} else {
Expand Down
7 changes: 4 additions & 3 deletions lv_hal/lv_hal_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
}

/**
* Call in the display driver's `flush` function when the flushing is finished
* Call in the display driver's `flush_cb` function when the flushing is finished
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
*/
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp)
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv)
{
disp->driver.buffer->flushing = 0;
disp_drv->buffer->flushing = 0;

/*If the screen is transparent initialize it when the flushing is ready*/
#if LV_COLOR_SCREEN_TRANSP
Expand Down
16 changes: 9 additions & 7 deletions lv_hal/lv_hal_disp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern "C" {
**********************/

struct _disp_t;
struct _disp_drv_t;


typedef struct
Expand Down Expand Up @@ -67,22 +68,22 @@ typedef struct _disp_drv_t {
lv_disp_buf_t * buffer;

/* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */
void (*flush_cb)(struct _disp_t * disp, const lv_area_t * area, lv_color_t * color_p);
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
lv_disp_user_data_t flush_user_data;

/* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements
* E.g. round `y` to, 8, 16 ..) on a monochrome display*/
void (*rounder_cb)(struct _disp_t * disp, lv_area_t * area);
void (*rounder_cb)(struct _disp_drv_t * disp_drv, lv_area_t * area);
lv_disp_user_data_t rounder_user_data;

/* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display
* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales
* Note: Much slower then drawing with supported color formats. */
void (*set_px_cb)(struct _disp_t * disp, 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 (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
lv_disp_user_data_t set_px_user_data;

/* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
void (*monitor_cb)(struct _disp_t * disp, uint32_t time, uint32_t px);
/* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px);
lv_disp_user_data_t monitor_user_data;

#if USE_LV_GPU
Expand Down Expand Up @@ -178,9 +179,10 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp);
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp);

/**
* Call in the display driver's `flush` function when the flushing is finished
* Call in the display driver's `flush_cb` function when the flushing is finished
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
*/
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_t * disp);
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv);


/**
Expand Down
2 changes: 1 addition & 1 deletion lv_hal/lv_hal_indev.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
if(indev->driver.read_cb) {

LV_LOG_TRACE("idnev read started");
cont = indev->driver.read_cb(indev, data);
cont = indev->driver.read_cb(&indev->driver, data);
LV_LOG_TRACE("idnev read finished");
} else {
LV_LOG_WARN("indev function registered");
Expand Down
13 changes: 7 additions & 6 deletions lv_hal/lv_hal_indev.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ extern "C" {
* TYPEDEFS
**********************/

struct _lv_obj_t;
struct _disp_t;
struct _lv_indev_t;
struct _lv_indev_drv_t;

/*Possible input device types*/
enum {
Expand Down Expand Up @@ -67,14 +69,13 @@ typedef struct {
} lv_indev_data_t;

/*Initialized by the user and registered by 'lv_indev_add()'*/
typedef struct {
lv_hal_indev_type_t type; /*Input device type*/
bool (*read_cb)(struct _lv_indev_t * indev, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
struct _disp_t * disp;
typedef struct _lv_indev_drv_t {
lv_hal_indev_type_t type; /*Input device type*/
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
lv_indev_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
struct _disp_t * disp; /*Pointer to the assigned display*/
} lv_indev_drv_t;

struct _lv_obj_t;

/*Run time data of input devices*/
typedef struct _lv_indev_proc_t {
Expand Down

0 comments on commit 054e43e

Please sign in to comment.