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.
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.
FastBit Embedded Brain Academy courses
https://fastbitlab.com/course1