STM32-LTDC, LCD-TFT, LVGL(MCU3) Lecture 44| Testing exercise 001 in portrait mode

 

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.

Figure 2. Output
Figure 1. Output

 

However, it is actually happening in Portrait-2, not Portrait-1.

portrait mode
Figure 2. Direction of pixel display

 

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. 

portrait mode
Figure 3. BSP_LCD_Set_Orientation

 

After retesting the program, we can observe that the display is reversed.

portrait mode
Figure 4. Output

 

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

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.