diff --git a/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.c b/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.c index b52f5f8..2654f28 100644 --- a/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.c +++ b/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.c @@ -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 ! diff --git a/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.h b/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.h index bd7180e..7dd4f24 100644 --- a/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.h +++ b/src/W800 SDK v1.00.08/app/app_drivers/lcd/lcd.h @@ -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 \ No newline at end of file