School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
lcd_functions.h
- Committer:
- tuxx0046
- Date:
- 2021-01-13
- Revision:
- 3:02e7aac23ff9
- Child:
- 4:1a12157689a7
File content as of revision 3:02e7aac23ff9:
/** @file lcd_functions.h @brief This file contains functions for graphicall dividing screen and outputting specific information to the display. LCD size is (480, 272) Available font sizes Font8, Font12, Font16, Font20 or Font24 @author Tu Tri Huynh @date 1/13/2021 */ #include "stm32746g_discovery_lcd.h" // Initializes the LCD for use void lcd_initialize() { BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); // Initialize LCD layers BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); // Select the LCD Layer } // Runs the startup screen with name and project name void lcd_show_startup_screen() { // Startup screen BSP_LCD_Clear(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_BLACK); BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Light Control System", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, 200, (uint8_t *)"by Tu Tri Huynh", CENTER_MODE); HAL_Delay(3000); } /* Screen is divided into four parts equal in size */ // Sets up the upper left part of screen void lcd_upper_left() { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, 240, 136); } void lcd_upper_left_smiley() { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, 240, 136); BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); // Create yellow circle in the middle of field BSP_LCD_FillCircle(120, 68, 50); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_FillCircle(120, 90, 15); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillCircle(100, 58, 10); BSP_LCD_FillCircle(140, 58, 10); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_FillCircle(100, 58, 3); BSP_LCD_FillCircle(140, 58, 3); } // Sets up the upper right part of screen void lcd_upper_right() { BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(240, 0, 240, 136); } // Sets up the lower left part of screen void lcd_lower_left() { BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_FillRect(0, 136, 240, 136); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); // Set font to be smaller for this part BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(5, 160, (uint8_t *)"Tu Tri Huynh", LEFT_MODE); BSP_LCD_DisplayStringAt(5, 180, (uint8_t *)"Embedded Programming", LEFT_MODE); BSP_LCD_DisplayStringAt(5, 200, (uint8_t *)"Light Control System", LEFT_MODE); // Reset fontsize BSP_LCD_SetFont(&Font16); } // Sets up the upper right part of screen void lcd_lower_right() { BSP_LCD_SetTextColor(LCD_COLOR_CYAN); BSP_LCD_FillRect(240, 136, 240, 136); } // Shows the main screen void lcd_show_main_screen() { BSP_LCD_Clear(LCD_COLOR_DARKBLUE); // Clear with color lcd_upper_left(); lcd_lower_left(); lcd_upper_right(); lcd_lower_right(); /******** DEMO CODE EXAMPLE *****/ /* BSP_LCD_Clear(LCD_COLOR_DARKBLUE); // Clear and set color BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 20, 50, 50); BSP_LCD_SetTextColor(LCD_COLOR_BROWN); BSP_LCD_FillCircle(80, 80, 50); BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); BSP_LCD_DrawEllipse(150, 150, 50, 100); BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_FillCircle(200, 200, 40); HAL_Delay(2000); BSP_LCD_SetBackColor(LCD_COLOR_DARKBLUE); BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); //BSP_LCD_DisplayStringAt(0, 6, (uint8_t *)output, RIGHT_MODE); //HAL_Delay(2000); */ }