mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
Merge pull request #16773 from jeandudey/ili9341-flip
drivers/ili9341: add rotation mode to ili9341_params_t
This commit is contained in:
commit
719a18ca8b
@ -105,6 +105,7 @@ extern "C" {
|
||||
#define ILI9341_PARAM_NUM_LINES (240U)
|
||||
#define ILI9341_PARAM_RGB (1)
|
||||
#define ILI9341_PARAM_INVERTED (1)
|
||||
#define ILI9341_PARAM_ROTATION (ILI9341_ROTATION_HORZ_FLIP)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -119,6 +119,7 @@
|
||||
#define ILI9341_PARAM_RST LCD_RST
|
||||
#define ILi9341_PARAM_RGB 0
|
||||
#define ILI9341_PARAM_INVERTED 0
|
||||
#define ILI9341_PARAM_ROTATION ILI9341_ROTATION_HORZ_FLIP
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -76,6 +76,7 @@ extern "C" {
|
||||
#define ILI9341_PARAM_RGB 1
|
||||
#define ILI9341_PARAM_INVERTED 1
|
||||
#define ILI9341_PARAM_NUM_LINES 240U
|
||||
#define ILI9341_PARAM_ROTATION ILI9341_ROTATION_HORZ_FLIP
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -131,7 +131,7 @@ int ili9341_init(ili9341_t *dev, const ili9341_params_t *params)
|
||||
_write_cmd(dev, ILI9341_CMD_VMCTRL2, command_params, 1);
|
||||
|
||||
/* Memory access CTL */
|
||||
command_params[0] = ILI9341_MADCTL_HORZ_FLIP;
|
||||
command_params[0] = dev->params->rotation;
|
||||
command_params[0] |= dev->params->rgb ? 0 : ILI9341_MADCTL_BGR;
|
||||
_write_cmd(dev, ILI9341_CMD_MADCTL, command_params, 1);
|
||||
|
||||
|
@ -65,30 +65,6 @@ extern "C" {
|
||||
#define ILI9341_CMD_IFCTL 0xf6 /**< Interface control */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Memory access control bits
|
||||
* @{
|
||||
*/
|
||||
#define ILI9341_MADCTL_MY 0x80 /**< Row address order */
|
||||
#define ILI9341_MADCTL_MX 0x40 /**< Column access order */
|
||||
#define ILI9341_MADCTL_MV 0x20 /**< Row column exchange */
|
||||
#define ILI9341_MADCTL_ML 0x10 /**< Vertical refresh order */
|
||||
#define ILI9341_MADCTL_BGR 0x08 /**< Color selector switch control */
|
||||
#define ILI9341_MADCTL_MH 0x04 /**< Horizontal refresh direction */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Display rotation modes
|
||||
* @{
|
||||
*/
|
||||
#define ILI9341_MADCTL_VERT ILI9341_MADCTL_MX /**< Vertical mode */
|
||||
#define ILI9341_MADCTL_VERT_FLIP ILI9341_MADCTL_MY /**< Flipped vertical */
|
||||
#define ILI9341_MADCTL_HORZ ILI9341_MADCTL_MV /**< Horizontal mode */
|
||||
#define ILI9341_MADCTL_HORZ_FLIP ILI9341_MADCTL_MV | \
|
||||
ILI9341_MADCTL_MY | \
|
||||
ILI9341_MADCTL_MX /**< Horizontal flipped */
|
||||
/** @} */
|
||||
|
||||
#define ILI9341_PIXSET_16BIT 0x55 /**< MCU and RGB 16 bit interface */
|
||||
#define ILI9341_PIXSET_18BIT 0x66 /**< MCU and RGB 18 bit interface (not implemented) */
|
||||
|
||||
|
@ -59,6 +59,10 @@ extern "C" {
|
||||
#define ILI9341_PARAM_NUM_LINES 320U
|
||||
#endif
|
||||
|
||||
#ifndef ILI9341_PARAM_ROTATION
|
||||
#define ILI9341_PARAM_ROTATION ILI9341_ROTATION_HORZ_FLIP
|
||||
#endif
|
||||
|
||||
#ifndef ILI9341_PARAMS
|
||||
#define ILI9341_PARAMS { .spi = ILI9341_PARAM_SPI, \
|
||||
.spi_clk = ILI9341_PARAM_SPI_CLK, \
|
||||
@ -69,6 +73,7 @@ extern "C" {
|
||||
.rgb = ILI9341_PARAM_RGB, \
|
||||
.inverted = ILI9341_PARAM_INVERTED, \
|
||||
.lines = ILI9341_PARAM_NUM_LINES, \
|
||||
.rotation = ILI9341_PARAM_ROTATION, \
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
|
@ -93,20 +93,55 @@ extern "C" {
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Memory access control bits
|
||||
* @{
|
||||
*/
|
||||
#define ILI9341_MADCTL_MY 0x80 /**< Row address order */
|
||||
#define ILI9341_MADCTL_MX 0x40 /**< Column access order */
|
||||
#define ILI9341_MADCTL_MV 0x20 /**< Row column exchange */
|
||||
#define ILI9341_MADCTL_ML 0x10 /**< Vertical refresh order */
|
||||
#define ILI9341_MADCTL_BGR 0x08 /**< Color selector switch control */
|
||||
#define ILI9341_MADCTL_MH 0x04 /**< Horizontal refresh direction */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Display rotation modes
|
||||
* @{
|
||||
*/
|
||||
#define ILI9341_MADCTL_VERT ILI9341_MADCTL_MX /**< Vertical mode */
|
||||
#define ILI9341_MADCTL_VERT_FLIP ILI9341_MADCTL_MY /**< Flipped vertical */
|
||||
#define ILI9341_MADCTL_HORZ ILI9341_MADCTL_MV /**< Horizontal mode */
|
||||
#define ILI9341_MADCTL_HORZ_FLIP ILI9341_MADCTL_MV | \
|
||||
ILI9341_MADCTL_MY | \
|
||||
ILI9341_MADCTL_MX /**< Horizontal flipped */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Display rotation mode
|
||||
*/
|
||||
typedef enum {
|
||||
ILI9341_ROTATION_VERT = ILI9341_MADCTL_VERT, /**< Vertical mode */
|
||||
ILI9341_ROTATION_VERT_FLIP = ILI9341_MADCTL_VERT_FLIP, /**< Vertical flipped mode */
|
||||
ILI9341_ROTATION_HORZ = ILI9341_MADCTL_HORZ, /**< Horizontal mode */
|
||||
ILI9341_ROTATION_HORZ_FLIP = ILI9341_MADCTL_HORZ_FLIP, /**< Horizontal flipped mode */
|
||||
} ili9341_rotation_t;
|
||||
|
||||
/**
|
||||
* @brief Device initialization parameters
|
||||
*/
|
||||
typedef struct {
|
||||
spi_t spi; /**< SPI device that the display is connected to */
|
||||
spi_clk_t spi_clk; /**< SPI clock speed to use */
|
||||
spi_mode_t spi_mode;/**< SPI mode */
|
||||
gpio_t cs_pin; /**< pin connected to the CHIP SELECT line */
|
||||
gpio_t dcx_pin; /**< pin connected to the DC line */
|
||||
gpio_t rst_pin; /**< pin connected to the reset line */
|
||||
bool rgb; /**< True when display is connected in RGB mode
|
||||
* False when display is connected in BGR mode */
|
||||
bool inverted; /**< Display works in inverted color mode */
|
||||
uint16_t lines; /**< Number of lines, from 16 to 320 in 8 line steps */
|
||||
spi_t spi; /**< SPI device that the display is connected to */
|
||||
spi_clk_t spi_clk; /**< SPI clock speed to use */
|
||||
spi_mode_t spi_mode; /**< SPI mode */
|
||||
gpio_t cs_pin; /**< pin connected to the CHIP SELECT line */
|
||||
gpio_t dcx_pin; /**< pin connected to the DC line */
|
||||
gpio_t rst_pin; /**< pin connected to the reset line */
|
||||
bool rgb; /**< True when display is connected in RGB mode
|
||||
* False when display is connected in BGR mode */
|
||||
bool inverted; /**< Display works in inverted color mode */
|
||||
uint16_t lines; /**< Number of lines, from 16 to 320 in 8 line steps */
|
||||
ili9341_rotation_t rotation; /**< Display rotation mode */
|
||||
} ili9341_params_t;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user