STM32-LTDC, LCD-TFT, LVGL(MCU3) Lecture 47| Testing exercise 001 : STM32F407x + External LCD

  • Post author:
  • Post category:Blog

 

Display VIBGYOR Bars on External LCD using STM32F407x

 

In this article, let’s discuss how to display VIBGYOR bars on an external LCD. 

The code for achieving this is shown in below. Initially, I set the background color to black (line 62). To display the VIBGYOR bars, you need to call the API bsp_lcd_fill_rect with the VIBGYOR color information, as well as the width and height information.

bsp_lcd_fill_rect(VIOLET, x_start, x_width, y_height*0, y_height);
bsp_lcd_fill_rect(INDIGO, x_start, x_width, y_height*1, y_height);
bsp_lcd_fill_rect(BLUE, x_start, x_width, y_height*2, y_height);
bsp_lcd_fill_rect(GREEN, x_start, x_width, y_height*3, y_height);
bsp_lcd_fill_rect(YELLOW, x_start, x_width, y_height*4, y_height);
bsp_lcd_fill_rect(ORANGE, x_start, x_width, y_height*5, y_height);
bsp_lcd_fill_rect(RED, x_start, x_width, y_height*6, y_height);
bsp_lcd_fill_rect(YELLOW, x_start, x_width, y_height*4, y_height);

 

First, try using the landscape orientation. Set it to landscape orientation, as illustrated in below code snippet.

/*Select orientation*/
#define PORTRAIT 0
#define LANDSCAPE 1
#define BSP_LCD_ORIENTATION LANDSCAPE

#if(BSP_LCD_ORIENTATION == PORTRAIT)
#define BSP_LCD_ACTIVE_WIDTH BSP_LCD_WIDTH
#define BSP_LCD_ACTIVE_HEIGHT BSP_LCD_HEIGHT
#elif(BSP_LCD_ORIENTATION == LANDSCAPE)
#define BSP_LCD_ACTIVE_WIDTH BSP_LCD_HEIGHT
#define BSP_LCD_ACTIVE_HEIGHT BSP_LCD_WIDTH
#endif

Once the landscape orientation is set, proceed with the execution. 

In Figure 1 you can observe that the external LCD is displayed in landscape orientation. All seven bars are displayed.

Display VIBGYOR Bars on External LCD using STM32F407x
Figure 1.VIBGYOR bars in landscape orientation

 

If you prefer the portrait orientation, simply select the orientation as PORTRAIT. 

The representation of VIBGYOR bars in portrait orientation is depicted in Figure 2.

Figure 4. VIBGYOR bars in Portrait orientation
Figure 2. VIBGYOR bars in Portrait orientation

 

 

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.

Leave a Reply