mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17921 from aabadie/pr/drivers/disp_dev_coordinates
drivers/disp_dev: use struct to store display area coordinates
This commit is contained in:
commit
63b25483c9
@ -212,11 +212,10 @@ void ltdc_fill(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const uint16_
|
||||
}
|
||||
|
||||
#if IS_USED(MODULE_DISP_DEV)
|
||||
static void _ltdc_map(const disp_dev_t *disp_dev, uint16_t x1, uint16_t x2,
|
||||
uint16_t y1, uint16_t y2, const uint16_t *color)
|
||||
static void _ltdc_map(const disp_dev_t *disp_dev, const disp_dev_area_t *area, const uint16_t *color)
|
||||
{
|
||||
(void)disp_dev;
|
||||
ltdc_map(x1, x2, y1, y2, color);
|
||||
ltdc_map(area->x1, area->x2, area->y1, area->y2, color);
|
||||
}
|
||||
|
||||
static uint16_t _ltdc_height(const disp_dev_t *disp_dev)
|
||||
|
@ -63,12 +63,12 @@ disp_dev_reg_t *disp_dev_reg_find_screen(uint8_t screen_id)
|
||||
}
|
||||
|
||||
void disp_dev_map(const disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const disp_dev_area_t *area,
|
||||
const uint16_t *color)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
dev->driver->map(dev, x1, x2, y1, y2, color);
|
||||
dev->driver->map(dev, area, color);
|
||||
}
|
||||
|
||||
uint16_t disp_dev_height(const disp_dev_t *dev)
|
||||
|
@ -42,6 +42,16 @@ extern "C" {
|
||||
*/
|
||||
typedef struct disp_dev disp_dev_t;
|
||||
|
||||
/**
|
||||
* @brief Display area coordinates
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t x1; /**< Horizontal start position (included) */
|
||||
uint16_t x2; /**< Horizontal end position (included) */
|
||||
uint16_t y1; /**< Vertical start position (included) */
|
||||
uint16_t y2; /**< Vertical end position (included) */
|
||||
} disp_dev_area_t;
|
||||
|
||||
/**
|
||||
* @brief Generic type for a display driver
|
||||
*/
|
||||
@ -50,14 +60,11 @@ typedef struct {
|
||||
* @brief Map an area to display on the device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
* @param[in] x1 Left coordinate
|
||||
* @param[in] x2 Right coordinate
|
||||
* @param[in] y1 Top coordinate
|
||||
* @param[in] y2 Bottom coordinate
|
||||
* @param[in] area Coordinates of display area
|
||||
* @param[in] color Array of color to map to the display
|
||||
*/
|
||||
void (*map)(const disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const disp_dev_area_t *area,
|
||||
const uint16_t *color);
|
||||
|
||||
/**
|
||||
@ -139,14 +146,11 @@ disp_dev_reg_t *disp_dev_reg_find_screen(uint8_t screen_id);
|
||||
* @brief Map an area to display on the device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
* @param[in] x1 Left coordinate
|
||||
* @param[in] x2 Right coordinate
|
||||
* @param[in] y1 Top coordinate
|
||||
* @param[in] y2 Bottom coordinate
|
||||
* @param[in] area Coordinates of display area
|
||||
* @param[in] color Array of color to map to the display
|
||||
*/
|
||||
void disp_dev_map(const disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const disp_dev_area_t *area,
|
||||
const uint16_t *color);
|
||||
|
||||
/**
|
||||
|
@ -27,11 +27,10 @@
|
||||
#define LCD_DISP_COLOR_DEPTH (16U)
|
||||
#endif
|
||||
|
||||
static void _lcd_map(const disp_dev_t *dev, uint16_t x1, uint16_t x2,
|
||||
uint16_t y1, uint16_t y2, const uint16_t *color)
|
||||
static void _lcd_map(const disp_dev_t *dev, const disp_dev_area_t *area, const uint16_t *color)
|
||||
{
|
||||
lcd_t *lcd = (lcd_t *)dev;
|
||||
lcd_pixmap(lcd, x1, x2, y1, y2, color);
|
||||
lcd_pixmap(lcd, area->x1, area->x2, area->y1, area->y2, color);
|
||||
}
|
||||
|
||||
static uint16_t _lcd_height(const disp_dev_t *disp_dev)
|
||||
|
@ -76,8 +76,10 @@ static void _disp_map(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *col
|
||||
return;
|
||||
}
|
||||
|
||||
disp_dev_map(_screen_dev->display, area->x1, area->x2, area->y1, area->y2,
|
||||
(const uint16_t *)color_p);
|
||||
const disp_dev_area_t disp_area = {
|
||||
area->x1, area->x2, area->y1, area->y2
|
||||
};
|
||||
disp_dev_map(_screen_dev->display, &disp_area, (const uint16_t *)color_p);
|
||||
|
||||
LOG_DEBUG("[lvgl] flush display\n");
|
||||
|
||||
|
@ -60,8 +60,10 @@ static void _disp_map(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *col
|
||||
return;
|
||||
}
|
||||
|
||||
disp_dev_map(_screen_dev->display, area->x1, area->x2, area->y1, area->y2,
|
||||
(const uint16_t *)color_p);
|
||||
const disp_dev_area_t disp_area = {
|
||||
area->x1, area->x2, area->y1, area->y2
|
||||
};
|
||||
disp_dev_map(_screen_dev->display, &disp_area, (const uint16_t *)color_p);
|
||||
|
||||
LOG_DEBUG("[lvgl] flush display\n");
|
||||
|
||||
|
@ -60,16 +60,20 @@ int main(void)
|
||||
expect(max_height == 240);
|
||||
#endif
|
||||
|
||||
disp_dev_area_t area;
|
||||
for (uint16_t y = 0; y < max_height; ++y) {
|
||||
disp_dev_map(disp_dev->dev, 0, max_width - 1, y, y, display_buffer);
|
||||
area.x1 = 0;
|
||||
area.x2 = max_width - 1;
|
||||
area.y1 = y;
|
||||
area.y2 = y;
|
||||
disp_dev_map(disp_dev->dev, &area, display_buffer);
|
||||
}
|
||||
|
||||
disp_dev_map(
|
||||
disp_dev->dev,
|
||||
((max_width - RIOT_LOGO_WIDTH) >> 1), ((max_width + RIOT_LOGO_WIDTH) >> 1) - 1,
|
||||
((max_height - RIOT_LOGO_HEIGHT) >> 1), ((max_height + RIOT_LOGO_HEIGHT) >> 1) - 1,
|
||||
(const uint16_t *)picture
|
||||
);
|
||||
area.x1 = ((max_width - RIOT_LOGO_WIDTH) >> 1);
|
||||
area.x2 = ((max_width + RIOT_LOGO_WIDTH) >> 1);
|
||||
area.y1 = ((max_height - RIOT_LOGO_HEIGHT) >> 1);
|
||||
area.y2 = ((max_height + RIOT_LOGO_HEIGHT) >> 1);
|
||||
disp_dev_map(disp_dev->dev, &area, (const uint16_t *)picture);
|
||||
|
||||
puts("SUCCESS");
|
||||
|
||||
|
@ -79,8 +79,12 @@ int main(void)
|
||||
const uint8_t h_offset = (disp_dev_height(disp_dev->dev) - (size * scale)) / 2;
|
||||
|
||||
/* Clear the screen */
|
||||
disp_dev_area_t area;
|
||||
for (uint16_t y = 0; y < disp_dev_height(disp_dev->dev); y ++) {
|
||||
disp_dev_map(disp_dev->dev, 0, disp_dev_width(disp_dev->dev) - 1, y, y, display_buffer);
|
||||
area.x1 = 0;
|
||||
area.x2 = disp_dev_width(disp_dev->dev) - 1;
|
||||
area.y1 = area.y2 = y;
|
||||
disp_dev_map(disp_dev->dev, &area, display_buffer);
|
||||
}
|
||||
|
||||
/* Prepare a subset of the display buffer for white tiles */
|
||||
@ -95,10 +99,11 @@ int main(void)
|
||||
for (int x = 0; x < size; x++) {
|
||||
#ifdef MODULE_DISP_DEV
|
||||
if (qrcodegen_getModule(qr0, x, y)) {
|
||||
disp_dev_map(disp_dev->dev,
|
||||
w_offset + (x * scale), w_offset + ((x + 1)* scale) - 1,
|
||||
h_offset + (y * scale), h_offset + ((y + 1)* scale) - 1,
|
||||
display_buffer);
|
||||
area.x1 = w_offset + (x * scale);
|
||||
area.x2 = w_offset + ((x + 1)* scale) - 1;
|
||||
area.y1 = h_offset + (y * scale);
|
||||
area.y2 = h_offset + ((y + 1)* scale) - 1;
|
||||
disp_dev_map(disp_dev->dev, &area, display_buffer);
|
||||
}
|
||||
#endif
|
||||
printf("%s", qrcodegen_getModule(qr0, x, y) ? "██" : " ");
|
||||
|
Loading…
Reference in New Issue
Block a user