mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #17930 from aabadie/pr/drivers/lcd_rotation_rework
drivers/lcd: rework rotation management and enable it for st7735
This commit is contained in:
commit
56359d6fb1
@ -107,7 +107,7 @@ 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_VERT) /**< Rotation mode */
|
#define ILI9341_PARAM_ROTATION (ILI9341_ROTATION_VERT) /**< Rotation mode */
|
||||||
#define ILI9341_PARAM_OFFSET_X (80) /**< Vertical rotation requires a 80 pixel offset */
|
#define ILI9341_PARAM_OFFSET_X (80) /**< Vertical rotation requires a 80 pixel offset */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ extern "C" {
|
|||||||
#define ST7735_PARAM_RGB_CHANNELS (128U) /**< Number of screen rgb channel (height) */
|
#define ST7735_PARAM_RGB_CHANNELS (128U) /**< Number of screen rgb channel (height) */
|
||||||
#define ST7735_PARAM_RGB (1) /**< RGB configuration */
|
#define ST7735_PARAM_RGB (1) /**< RGB configuration */
|
||||||
#define ST7735_PARAM_INVERTED (0) /**< Inversion configuration */
|
#define ST7735_PARAM_INVERTED (0) /**< Inversion configuration */
|
||||||
|
#define ST7735_PARAM_ROTATION (ST7735_ROTATION_HORZ_FLIP) /**< Rotation mode */
|
||||||
#define LCD_SCREEN_WIDTH (ST7735_PARAM_NUM_LINES) /**< LCD screen width */
|
#define LCD_SCREEN_WIDTH (ST7735_PARAM_NUM_LINES) /**< LCD screen width */
|
||||||
#define LCD_SCREEN_HEIGHT (ST7735_PARAM_RGB_CHANNELS) /**< LCD screen height */
|
#define LCD_SCREEN_HEIGHT (ST7735_PARAM_RGB_CHANNELS) /**< LCD screen height */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
#define ILI9341_PARAM_RST LCD_RST
|
#define ILI9341_PARAM_RST LCD_RST
|
||||||
#define ILi9341_PARAM_RGB 0
|
#define ILi9341_PARAM_RGB 0
|
||||||
#define ILI9341_PARAM_INVERTED 0
|
#define ILI9341_PARAM_INVERTED 0
|
||||||
#define ILI9341_PARAM_ROTATION LCD_ROTATION_HORZ_FLIP
|
#define ILI9341_PARAM_ROTATION ILI9341_ROTATION_HORZ_FLIP
|
||||||
#endif
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ extern "C" {
|
|||||||
#define ILI9341_PARAM_RGB 1
|
#define ILI9341_PARAM_RGB 1
|
||||||
#define ILI9341_PARAM_INVERTED 1
|
#define ILI9341_PARAM_INVERTED 1
|
||||||
#define ILI9341_PARAM_NUM_LINES 240U
|
#define ILI9341_PARAM_NUM_LINES 240U
|
||||||
#define ILI9341_PARAM_ROTATION LCD_ROTATION_HORZ_FLIP
|
#define ILI9341_PARAM_ROTATION ILI9341_ROTATION_HORZ_FLIP
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,7 @@ extern "C" {
|
|||||||
#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 ILI9341_ROTATION_HORZ_FLIP
|
||||||
#endif
|
#endif
|
||||||
#ifndef ILI9341_PARAM_OFFSET_X
|
#ifndef ILI9341_PARAM_OFFSET_X
|
||||||
#define ILI9341_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
#define ILI9341_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
||||||
|
@ -76,6 +76,19 @@ extern "C" {
|
|||||||
#define CONFIG_ILI9341_VCOML -2000
|
#define CONFIG_ILI9341_VCOML -2000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ILI9341 display rotation modes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ILI9341_ROTATION_VERT LCD_MADCTL_MX /**< Vertical mode */
|
||||||
|
#define ILI9341_ROTATION_VERT_FLIP LCD_MADCTL_MY /**< Flipped vertical */
|
||||||
|
#define ILI9341_ROTATION_HORZ LCD_MADCTL_MV /**< Horizontal mode */
|
||||||
|
#define ILI9341_ROTATION_HORZ_FLIP LCD_MADCTL_MV | \
|
||||||
|
LCD_MADCTL_MY | \
|
||||||
|
LCD_MADCTL_MX /**< Horizontal flipped */
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Device descriptor for a ili9341
|
* @brief Device descriptor for a ili9341
|
||||||
*/
|
*/
|
||||||
|
@ -68,29 +68,6 @@ extern "C" {
|
|||||||
#define LCD_MADCTL_MH 0x04 /**< Horizontal refresh direction */
|
#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 */
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Display rotation mode
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
LCD_ROTATION_VERT = LCD_MADCTL_VERT, /**< Vertical mode */
|
|
||||||
LCD_ROTATION_VERT_FLIP = LCD_MADCTL_VERT_FLIP, /**< Vertical flipped mode */
|
|
||||||
LCD_ROTATION_HORZ = LCD_MADCTL_HORZ, /**< Horizontal mode */
|
|
||||||
LCD_ROTATION_HORZ_FLIP = LCD_MADCTL_HORZ_FLIP, /**< Horizontal flipped mode */
|
|
||||||
} lcd_rotation_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Device initialization parameters
|
* @brief Device initialization parameters
|
||||||
*/
|
*/
|
||||||
@ -106,7 +83,7 @@ typedef struct {
|
|||||||
bool inverted; /**< Display works in inverted color mode */
|
bool inverted; /**< Display works in inverted color mode */
|
||||||
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 */
|
uint8_t rotation; /**< Display rotation mode */
|
||||||
uint8_t offset_x; /**< LCD offset to apply on x axis. */
|
uint8_t offset_x; /**< LCD offset to apply on x axis. */
|
||||||
uint8_t offset_y; /**< LCD offset to apply on y axis. */
|
uint8_t offset_y; /**< LCD offset to apply on y axis. */
|
||||||
} lcd_params_t;
|
} lcd_params_t;
|
||||||
|
@ -78,6 +78,19 @@ extern "C" {
|
|||||||
#define CONFIG_ST7735_VCOML -2000
|
#define CONFIG_ST7735_VCOML -2000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ILI9341 display rotation modes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ST7735_ROTATION_VERT 0 /**< Vertical mode */
|
||||||
|
#define ST7735_ROTATION_VERT_FLIP LCD_MADCTL_MX | \
|
||||||
|
LCD_MADCTL_MY /**< Flipped vertical */
|
||||||
|
#define ST7735_ROTATION_HORZ LCD_MADCTL_MV | \
|
||||||
|
LCD_MADCTL_MX /**< Horizontal mode */
|
||||||
|
#define ST7735_ROTATION_HORZ_FLIP LCD_MADCTL_MV | \
|
||||||
|
LCD_MADCTL_MY /**< Horizontal flipped */
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Device descriptor for a st7735
|
* @brief Device descriptor for a st7735
|
||||||
*
|
*
|
||||||
|
@ -64,7 +64,7 @@ extern "C" {
|
|||||||
#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_PARAM_ROTATION
|
#ifndef ST7735_PARAM_ROTATION
|
||||||
#define ST7735_PARAM_ROTATION LCD_ROTATION_HORZ /**< Rotation mode (unused) */
|
#define ST7735_PARAM_ROTATION ST7735_ROTATION_HORZ /**< Rotation mode */
|
||||||
#endif
|
#endif
|
||||||
#ifndef ST7735_PARAM_OFFSET_X
|
#ifndef ST7735_PARAM_OFFSET_X
|
||||||
#define ST7735_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
#define ST7735_PARAM_OFFSET_X 0 /**< Horizontal offset */
|
||||||
@ -87,7 +87,7 @@ extern "C" {
|
|||||||
.inverted = ST7735_PARAM_INVERTED, \
|
.inverted = ST7735_PARAM_INVERTED, \
|
||||||
.lines = ST7735_PARAM_NUM_LINES, \
|
.lines = ST7735_PARAM_NUM_LINES, \
|
||||||
.rgb_channels = ST7735_PARAM_RGB_CHANNELS, \
|
.rgb_channels = ST7735_PARAM_RGB_CHANNELS, \
|
||||||
.rotation = LCD_ROTATION_HORZ, \
|
.rotation = ST7735_PARAM_ROTATION, \
|
||||||
.offset_x = ST7735_PARAM_OFFSET_X, \
|
.offset_x = ST7735_PARAM_OFFSET_X, \
|
||||||
.offset_y = ST7735_PARAM_OFFSET_Y, \
|
.offset_y = ST7735_PARAM_OFFSET_Y, \
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ static int _init(lcd_t *dev, const lcd_params_t *params)
|
|||||||
_write_cmd(dev, LCD_CMD_VMCTRL2, command_params, 1);
|
_write_cmd(dev, LCD_CMD_VMCTRL2, command_params, 1);
|
||||||
|
|
||||||
/* Memory access CTL */
|
/* Memory access CTL */
|
||||||
command_params[0] = LCD_MADCTL_MY | LCD_MADCTL_MV;
|
command_params[0] = dev->params->rotation;
|
||||||
command_params[0] |= dev->params->rgb ? 0 : LCD_MADCTL_BGR;
|
command_params[0] |= dev->params->rgb ? 0 : LCD_MADCTL_BGR;
|
||||||
_write_cmd(dev, LCD_CMD_MADCTL, command_params, 1);
|
_write_cmd(dev, LCD_CMD_MADCTL, command_params, 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user