School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
lcd_functions.h
- Committer:
- tuxx0046
- Date:
- 2021-01-13
- Revision:
- 4:1a12157689a7
- Parent:
- 3:02e7aac23ff9
- Child:
- 6:aecab8e3acad
File content as of revision 4:1a12157689a7:
/** @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" /** This function will initialize the LCD for use @date 1/13/2021 */ void lcd_initialize() { BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); } /** This function will print LCD size in console terminal */ void lcd_get_screen_size() { printf("LCD X size : %zu\n\r",BSP_LCD_GetXSize()); //result: 480 printf("LCD Y size : %zu\n\r",BSP_LCD_GetYSize()); //result: 272 } /** This function will run a screen that tells user to input building and room for the unit @date 1/13/2021 */ void lcd_show_setup_screen() { /// Clears the LCD with specified color BSP_LCD_Clear(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_BLACK); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 50, (uint8_t *)"SETUP", CENTER_MODE); BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(0, 200, (uint8_t *)"Please set the building and room", CENTER_MODE); } /** This function will runs the startup screen with project- and developer-name @date 1/13/2021 */ void lcd_show_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); } /** 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); } // 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(char building[], char room[]) { BSP_LCD_Clear(LCD_COLOR_DARKBLUE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_FillRect(0, 136, 240, 136); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(5, 160, (uint8_t *)"Current location", LEFT_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(5, 200, (uint8_t *)building, LEFT_MODE); BSP_LCD_DisplayStringAt(5, 210, (uint8_t *)room, 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); */ }