Testing exercise 001 in portrait mode
In the main.c file, I have chosen a width of 239 instead of 320 for the portrait mode. Additionally, I have modified the height of each color bar accordingly.
void SystemClock_Setup(void); void LTDC_Pin_Init(void); void LTDC_Init(void); void LTDC_Layer_Init(LTDC_Layer_TypeDef *pLayer); int main(void) { SystemClock_Setup(); BSP_LCD_Init(); BSP_LCD_Set_Orientation(PORTRAIT); LTDC_Pin_Init(); LTDC_Init(); LTDC_Layer_Init(LTDC_Layer1); bsp_lcd_set_fb_background_color(BLACK); #if(BSP_LCD_ORIENTATION == LANDSCAPE) bsp_lcd_fill_rect(VIOLET, 0, 320, 34*0, 34); bsp_lcd_fill_rect(INDIGO, 0, 320, 34*1, 34); bsp_lcd_fill_rect(BLUE, 0, 320, 34*2, 34); bsp_lcd_fill_rect(GREEN, 0, 320, 34*3, 34); bsp_lcd_fill_rect(YELLOW, 0, 320, 34*4, 34); bsp_lcd_fill_rect(ORANGE, 0, 320, 34*5, 34); bsp_lcd_fill_rect(RED, 0, 320, 34*6, 34); #elif(BSP_LCD_ORIENTATION == PORTRAIT) bsp_lcd_fill_rect(VIOLET, 0, 239, 46*0, 46); bsp_lcd_fill_rect(INDIGO, 0, 239, 46*1, 46); bsp_lcd_fill_rect(BLUE, 0, 239, 46*2, 46); bsp_lcd_fill_rect(GREEN, 0, 239, 46*3, 46); bsp_lcd_fill_rect(YELLOW, 0, 239, 46*4, 46); bsp_lcd_fill_rect(ORANGE, 0, 239, 46*5, 46); bsp_lcd_fill_rect(RED, 0, 239, 46*6, 44); #endif /* Loop forever */ for(;;); }
As a result, the output is displayed in portrait mode.
However, it is actually happening in Portrait-2, not Portrait-1.
If you want to achieve Portrait-1, you need to set MX to 1 and MY to 1. Let’s make those changes.
In the BSP_LCD_Set_Orientation function, when it is set to portrait mode, let’s add the MY and MX components as shown in Figure 3.
After retesting the program, we can observe that the display is reversed.
If you need more information about the LCD’s commands, please refer to the datasheet. You can simply search for the desired command code in the datasheet.
Fastbit Embedded Brain Academy Courses
https://fastbitlab.com/course1