add LV_VDB_SIZE_IN_BYTES to hide the compilacted expression

This commit is contained in:
Gabor Kiss-Vamosi
2018-09-14 07:33:22 +02:00
parent 5a301bff76
commit 1391df3948
2 changed files with 12 additions and 7 deletions

View File

@@ -39,7 +39,7 @@ typedef enum {
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE; static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
# if LV_VDB_ADR == 0 # if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/ /*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf[((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)]; static uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb = {.buf = (lv_color_t*)vdb_buf}; static lv_vdb_t vdb = {.buf = (lv_color_t*)vdb_buf};
# else /*LV_VDB_ADR != 0*/ # else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/ /*If the buffer address is specified use that address*/
@@ -50,8 +50,8 @@ static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE}; static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
# if LV_VDB_ADR == 0 # if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/ /*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf1[((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)]; static uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static uint8_t vdb_buf2[((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)]; static uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}}; static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}};
# else /*LV_VDB_ADR != 0*/ # else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/ /*If the buffer address is specified use that address*/
@@ -133,8 +133,7 @@ void lv_vdb_flush(void)
/** /**
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`. * Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
* It should be called before `lv_init()`. * It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
* The size of the buffer should be: `((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)`
* @param buf1 address of the VDB. * @param buf1 address of the VDB.
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0` * @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
*/ */

View File

@@ -34,6 +34,13 @@ extern "C" {
#warning "LV_VDB_PX_BPP is not specified in lv_conf.h. Use the default value (LV_COLOR_SIZE)" #warning "LV_VDB_PX_BPP is not specified in lv_conf.h. Use the default value (LV_COLOR_SIZE)"
#define LV_VDB_PX_BPP LV_COLOR_SIZE #define LV_VDB_PX_BPP LV_COLOR_SIZE
#endif #endif
/* The size of VDB in bytes.
* (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes
* (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up.
* E.g. if LV_VDB_SIZE = 10 and LV_VDB_PX_BPP = 1 -> 10 bits -> 2 bytes*/
#define LV_VDB_SIZE_IN_BYTES ((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
@@ -61,8 +68,7 @@ void lv_vdb_flush(void);
/** /**
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`. * Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
* It should be called before `lv_init()`. * It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
* The size of the buffer should be: `((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)`
* @param buf1 address of the VDB. * @param buf1 address of the VDB.
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0` * @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
*/ */