mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17925 from aabadie/pr/drivers/lcd_params_rework
drivers/lcd: slightly rework params to expose offset values to ili9341 driver
This commit is contained in:
commit
646fb1135a
@ -107,7 +107,8 @@ extern "C" {
|
|||||||
#define ILI9341_PARAM_NUM_LINES (240U) /**< Number of screen lines */
|
#define ILI9341_PARAM_NUM_LINES (240U) /**< Number of screen lines */
|
||||||
#define ILI9341_PARAM_RGB (1) /**< RGB configuration */
|
#define ILI9341_PARAM_RGB (1) /**< RGB configuration */
|
||||||
#define ILI9341_PARAM_INVERTED (1) /**< Inversion configuration */
|
#define ILI9341_PARAM_INVERTED (1) /**< Inversion configuration */
|
||||||
#define ILI9341_PARAM_ROTATION (LCD_ROTATION_HORZ_FLIP) /**< Rotation mode */
|
#define ILI9341_PARAM_ROTATION (LCD_ROTATION_VERT) /**< Rotation mode */
|
||||||
|
#define ILI9341_PARAM_OFFSET_X (80) /**< Vertical rotation requires a 80 pixel offset */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -168,6 +168,11 @@ static void _set_area(const lcd_t *dev, uint16_t x1, uint16_t x2,
|
|||||||
{
|
{
|
||||||
be_uint16_t params[2];
|
be_uint16_t params[2];
|
||||||
|
|
||||||
|
x1 += dev->params->offset_x;
|
||||||
|
x2 += dev->params->offset_x;
|
||||||
|
y1 += dev->params->offset_y;
|
||||||
|
y2 += dev->params->offset_y;
|
||||||
|
|
||||||
params[0] = byteorder_htons(x1);
|
params[0] = byteorder_htons(x1);
|
||||||
params[1] = byteorder_htons(x2);
|
params[1] = byteorder_htons(x2);
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#define ILI9341_PARAMS_H
|
#define ILI9341_PARAMS_H
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -60,9 +61,14 @@ extern "C" {
|
|||||||
#ifndef ILI9341_PARAM_RGB_CHANNELS
|
#ifndef ILI9341_PARAM_RGB_CHANNELS
|
||||||
#define ILI9341_PARAM_RGB_CHANNELS 240U /**< Number of RGB channels (e.g. columns) */
|
#define ILI9341_PARAM_RGB_CHANNELS 240U /**< Number of RGB channels (e.g. columns) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ILI9341_PARAM_ROTATION
|
#ifndef ILI9341_PARAM_ROTATION
|
||||||
#define ILI9341_PARAM_ROTATION LCD_ROTATION_HORZ_FLIP
|
#define ILI9341_PARAM_ROTATION LCD_ROTATION_HORZ_FLIP
|
||||||
|
#endif
|
||||||
|
#ifndef ILI9341_PARAM_OFFSET_X
|
||||||
|
#define ILI9341_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
||||||
|
#endif
|
||||||
|
#ifndef ILI9341_PARAM_OFFSET_Y
|
||||||
|
#define ILI9341_PARAM_OFFSET_Y 0 /**< Vertival offset */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,8 +84,10 @@ extern "C" {
|
|||||||
.rgb = ILI9341_PARAM_RGB, \
|
.rgb = ILI9341_PARAM_RGB, \
|
||||||
.inverted = ILI9341_PARAM_INVERTED, \
|
.inverted = ILI9341_PARAM_INVERTED, \
|
||||||
.lines = ILI9341_PARAM_NUM_LINES, \
|
.lines = ILI9341_PARAM_NUM_LINES, \
|
||||||
.rotation = ILI9341_PARAM_ROTATION, \
|
|
||||||
.rgb_channels = ILI9341_PARAM_RGB_CHANNELS, \
|
.rgb_channels = ILI9341_PARAM_RGB_CHANNELS, \
|
||||||
|
.rotation = ILI9341_PARAM_ROTATION, \
|
||||||
|
.offset_x = ILI9341_PARAM_OFFSET_X, \
|
||||||
|
.offset_y = ILI9341_PARAM_OFFSET_Y, \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -107,6 +107,8 @@ typedef struct {
|
|||||||
uint16_t lines; /**< Number of lines, from 16 to 320 in 8 line steps */
|
uint16_t lines; /**< Number of lines, from 16 to 320 in 8 line steps */
|
||||||
uint16_t rgb_channels; /**< Display rgb channels */
|
uint16_t rgb_channels; /**< Display rgb channels */
|
||||||
lcd_rotation_t rotation; /**< Display rotation mode */
|
lcd_rotation_t rotation; /**< Display rotation mode */
|
||||||
|
uint8_t offset_x; /**< LCD offset to apply on x axis. */
|
||||||
|
uint8_t offset_y; /**< LCD offset to apply on y axis. */
|
||||||
} lcd_params_t;
|
} lcd_params_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,15 +86,6 @@ typedef struct {
|
|||||||
lcd_t dev; /**< Pointer to the common lcd device */
|
lcd_t dev; /**< Pointer to the common lcd device */
|
||||||
} st7735_t;
|
} st7735_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Device initialization parameters
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
lcd_params_t params; /**< LCD struct params */
|
|
||||||
uint8_t offset_x; /**< LCD offset to apply on x axis. */
|
|
||||||
uint8_t offset_y; /**< LCD offset to apply on y axis. */
|
|
||||||
} st7735_params_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LCD device operations table
|
* @brief LCD device operations table
|
||||||
*/
|
*/
|
||||||
|
@ -68,30 +68,6 @@ extern "C" {
|
|||||||
#define LCD_CMD_IFCTL 0xf6 /**< Interface control */
|
#define LCD_CMD_IFCTL 0xf6 /**< Interface control */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
|
||||||
* @name Memory access control bits
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define LCD_MADCTL_MY 0x80 /**< Row address order */
|
|
||||||
#define LCD_MADCTL_MX 0x40 /**< Column access order */
|
|
||||||
#define LCD_MADCTL_MV 0x20 /**< Row column exchange */
|
|
||||||
#define LCD_MADCTL_ML 0x10 /**< Vertical refresh order */
|
|
||||||
#define LCD_MADCTL_BGR 0x08 /**< Color selector switch control */
|
|
||||||
#define LCD_MADCTL_MH 0x04 /**< Horizontal refresh direction */
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name Display rotation modes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define LCD_MADCTL_VERT LCD_MADCTL_MX /**< Vertical mode */
|
|
||||||
#define LCD_MADCTL_VERT_FLIP LCD_MADCTL_MY /**< Flipped vertical */
|
|
||||||
#define LCD_MADCTL_HORZ LCD_MADCTL_MV /**< Horizontal mode */
|
|
||||||
#define LCD_MADCTL_HORZ_FLIP LCD_MADCTL_MV | \
|
|
||||||
LCD_MADCTL_MY | \
|
|
||||||
LCD_MADCTL_MX /**< Horizontal flipped */
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
#define LCD_PIXSET_16BIT 0x55 /**< MCU and RGB 16 bit interface */
|
#define LCD_PIXSET_16BIT 0x55 /**< MCU and RGB 16 bit interface */
|
||||||
#define LCD_PIXSET_18BIT 0x66 /**< MCU and RGB 18 bit interface (not implemented) */
|
#define LCD_PIXSET_18BIT 0x66 /**< MCU and RGB 18 bit interface (not implemented) */
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#define ST7735_PARAMS_H
|
#define ST7735_PARAMS_H
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -62,29 +63,33 @@ extern "C" {
|
|||||||
#ifndef ST7735_PARAM_RGB_CHANNELS
|
#ifndef ST7735_PARAM_RGB_CHANNELS
|
||||||
#define ST7735_PARAM_RGB_CHANNELS 128U /**< Number of RGB channels (e.g. columns) */
|
#define ST7735_PARAM_RGB_CHANNELS 128U /**< Number of RGB channels (e.g. columns) */
|
||||||
#endif
|
#endif
|
||||||
#ifndef ST7735_OFFSET_X
|
#ifndef ST7735_PARAM_ROTATION
|
||||||
#define ST7735_OFFSET_X 0 /**< Horizontal offset */
|
#define ST7735_PARAM_ROTATION LCD_ROTATION_HORZ /**< Rotation mode (unused) */
|
||||||
#endif
|
#endif
|
||||||
#ifndef ST7735_OFFSET_Y
|
#ifndef ST7735_PARAM_OFFSET_X
|
||||||
#define ST7735_OFFSET_Y 0 /**< Vertival offset */
|
#define ST7735_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
||||||
|
#endif
|
||||||
|
#ifndef ST7735_PARAM_OFFSET_Y
|
||||||
|
#define ST7735_PARAM_OFFSET_Y 0 /**< Vertival offset */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default params
|
* @brief Default params
|
||||||
*/
|
*/
|
||||||
#ifndef ST7735_PARAMS
|
#ifndef ST7735_PARAMS
|
||||||
#define ST7735_PARAMS { .params.spi = ST7735_PARAM_SPI, \
|
#define ST7735_PARAMS { .spi = ST7735_PARAM_SPI, \
|
||||||
.params.spi_clk = ST7735_PARAM_SPI_CLK, \
|
.spi_clk = ST7735_PARAM_SPI_CLK, \
|
||||||
.params.spi_mode = ST7735_PARAM_SPI_MODE, \
|
.spi_mode = ST7735_PARAM_SPI_MODE, \
|
||||||
.params.cs_pin = ST7735_PARAM_CS, \
|
.cs_pin = ST7735_PARAM_CS, \
|
||||||
.params.dcx_pin = ST7735_PARAM_DCX, \
|
.dcx_pin = ST7735_PARAM_DCX, \
|
||||||
.params.rst_pin = ST7735_PARAM_RST, \
|
.rst_pin = ST7735_PARAM_RST, \
|
||||||
.params.rgb = ST7735_PARAM_RGB, \
|
.rgb = ST7735_PARAM_RGB, \
|
||||||
.params.inverted = ST7735_PARAM_INVERTED, \
|
.inverted = ST7735_PARAM_INVERTED, \
|
||||||
.params.lines = ST7735_PARAM_NUM_LINES, \
|
.lines = ST7735_PARAM_NUM_LINES, \
|
||||||
.params.rgb_channels = ST7735_PARAM_RGB_CHANNELS, \
|
.rgb_channels = ST7735_PARAM_RGB_CHANNELS, \
|
||||||
.offset_x = ST7735_OFFSET_X, \
|
.rotation = LCD_ROTATION_HORZ, \
|
||||||
.offset_y = ST7735_OFFSET_Y, \
|
.offset_x = ST7735_PARAM_OFFSET_X, \
|
||||||
|
.offset_y = ST7735_PARAM_OFFSET_Y, \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
@ -99,7 +104,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief Configure LCD
|
* @brief Configure LCD
|
||||||
*/
|
*/
|
||||||
static const st7735_params_t st7735_params[] =
|
static const lcd_params_t st7735_params[] =
|
||||||
{
|
{
|
||||||
ST7735_PARAMS,
|
ST7735_PARAMS,
|
||||||
};
|
};
|
||||||
|
@ -192,14 +192,12 @@ static int _init(lcd_t *dev, const lcd_params_t *params)
|
|||||||
static void _set_area(const lcd_t *dev, uint16_t x1, uint16_t x2,
|
static void _set_area(const lcd_t *dev, uint16_t x1, uint16_t x2,
|
||||||
uint16_t y1, uint16_t y2)
|
uint16_t y1, uint16_t y2)
|
||||||
{
|
{
|
||||||
st7735_params_t *st7735_params = (st7735_params_t *)dev->params;
|
|
||||||
|
|
||||||
be_uint16_t params[2];
|
be_uint16_t params[2];
|
||||||
|
|
||||||
x1 += st7735_params->offset_x;
|
x1 += dev->params->offset_x;
|
||||||
x2 += st7735_params->offset_x;
|
x2 += dev->params->offset_x;
|
||||||
y1 += st7735_params->offset_y;
|
y1 += dev->params->offset_y;
|
||||||
y2 += st7735_params->offset_y;
|
y2 += dev->params->offset_y;
|
||||||
|
|
||||||
params[0] = byteorder_htons(x1);
|
params[0] = byteorder_htons(x1);
|
||||||
params[1] = byteorder_htons(x2);
|
params[1] = byteorder_htons(x2);
|
||||||
|
@ -47,7 +47,7 @@ void auto_init_st7735(void)
|
|||||||
for (size_t i = 0; i < ST7735_NUMOF; i++) {
|
for (size_t i = 0; i < ST7735_NUMOF; i++) {
|
||||||
st7735_devs[i].dev.driver = &lcd_st7735_driver;
|
st7735_devs[i].dev.driver = &lcd_st7735_driver;
|
||||||
LOG_DEBUG("[auto_init_screen] initializing st7735 #%u\n", i);
|
LOG_DEBUG("[auto_init_screen] initializing st7735 #%u\n", i);
|
||||||
if (lcd_init(&st7735_devs[i].dev, &st7735_params[i].params) < 0) {
|
if (lcd_init(&st7735_devs[i].dev, &st7735_params[i]) < 0) {
|
||||||
LOG_ERROR("[auto_init_screen] error initializing st7735 #%u\n", i);
|
LOG_ERROR("[auto_init_screen] error initializing st7735 #%u\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ int main(void)
|
|||||||
BACKLIGHT_ON;
|
BACKLIGHT_ON;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lcd_init(&dev, &st7735_params[0].params) == 0) {
|
if (lcd_init(&dev, &st7735_params[0]) == 0) {
|
||||||
puts("[OK]");
|
puts("[OK]");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user