Added a function to set the orientation of the screen
This commit is contained in:
parent
7148e76115
commit
562114814e
@ -222,6 +222,7 @@ void lcd_config_init(LCDConfig_t * const LCDConfig)
|
||||
LCDConfig->LCDChipSelectPin = -1;
|
||||
LCDConfig->LCDDataCommandPin = -1;
|
||||
LCDConfig->LCDResetPin = -1;
|
||||
LCDConfig->LCDOrientation = LCD_ORIENTATION_DEFAULT;
|
||||
|
||||
}
|
||||
|
||||
@ -415,6 +416,41 @@ void lcd_sleep(LCDConfig_t *const LCDConfig, bool state)
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
|
||||
void lcd_orientation(LCDConfig_t *const LCDConfig, LCDOrientation_t orientation)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
//No need to apply the same config again
|
||||
if(orientation == LCDConfig->LCDOrientation || orientation > LCD_ORIENTATION_270) return;
|
||||
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x36);
|
||||
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
|
||||
LCDConfig->LCDOrientation = orientation;
|
||||
|
||||
switch(orientation)
|
||||
{
|
||||
case LCD_ORIENTATION_90:
|
||||
mmc_sdio_driver_write_one(0xE8);
|
||||
break;
|
||||
case LCD_ORIENTATION_180:
|
||||
mmc_sdio_driver_write_one(0x48);
|
||||
break;
|
||||
case LCD_ORIENTATION_270:
|
||||
mmc_sdio_driver_write_one(0x28);
|
||||
break;
|
||||
default: //Is default orientation eg : 0
|
||||
mmc_sdio_driver_write_one(0x88);
|
||||
}
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
|
||||
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes)
|
||||
{
|
||||
// Select the slave CS line and tell him that he will receive a command !
|
||||
|
@ -35,6 +35,19 @@ typedef enum LCDSelect
|
||||
*/
|
||||
typedef void (*DrawFinishedCb_t)(void *arg);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef enum LCDOrientation
|
||||
{
|
||||
LCD_ORIENTATION_0 = 0,
|
||||
LCD_ORIENTATION_DEFAULT = LCD_ORIENTATION_0,
|
||||
LCD_ORIENTATION_90,
|
||||
LCD_ORIENTATION_180,
|
||||
LCD_ORIENTATION_270,
|
||||
} LCDOrientation_t;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@ -49,6 +62,7 @@ typedef struct LCDConfig
|
||||
enum tls_io_name LCDResetPin;
|
||||
DrawFinishedCb_t drawFinishedCb;
|
||||
void *cbArg;
|
||||
LCDOrientation_t LCDOrientation;
|
||||
} LCDConfig_t;
|
||||
|
||||
/**
|
||||
@ -121,4 +135,12 @@ void lcd_on(LCDConfig_t * const LCDConfig, bool state);
|
||||
*/
|
||||
void lcd_sleep(LCDConfig_t * const LCDConfig, bool state);
|
||||
|
||||
/**
|
||||
* @brief Sets the LCD orientation.
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
* @param orientation the value of the orientation to set
|
||||
*/
|
||||
void lcd_orientation(LCDConfig_t * const LCDConfig, LCDOrientation_t orientation);
|
||||
|
||||
#endif //LCD_H
|
Loading…
Reference in New Issue
Block a user