School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
Diff: lcd_functions.h
- Revision:
- 13:41debc0b9063
- Parent:
- 10:137cf2c92871
- Child:
- 15:638e65c37d58
--- a/lcd_functions.h Mon Jan 18 07:41:31 2021 +0000 +++ b/lcd_functions.h Mon Jan 18 13:39:58 2021 +0000 @@ -2,7 +2,7 @@ @file lcd_functions.h @author Tu Tri Huynh @date January 13, 2021 -@brief This file contains functions for the LCD display. +@brief This file contains functions for the LCD display. The display is visually divided into four equal parts to output different things. @section Useful information LCD size is (480, 272) Available font sizes are Font8, Font12, Font16, Font20 or Font24 @@ -12,7 +12,7 @@ /** This function will initialize the LCD for use -@date 1/13/2021 +1/13/2021 */ void lcd_initialize() { @@ -21,18 +21,11 @@ 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 +This function will run a screen that tells user to configure the unit +1/13/2021 */ void lcd_show_setup_screen() { @@ -48,7 +41,7 @@ /** This function will runs the startup screen with project- and developer-name -@date 1/13/2021 +1/13/2021 */ void lcd_show_startup_screen() { @@ -63,14 +56,28 @@ /** Sets up the upper left part of screen +1/18/2021 */ void lcd_upper_left() { - BSP_LCD_SetTextColor(LCD_COLOR_BLUE); + BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); BSP_LCD_FillRect(0, 0, 240, 136); } -// Sets up the upper right part of screen +/** +Update the content of the upper left part of display. +1/18/2021 +*/ +void lcd_update_upper_left() +{ + BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); + BSP_LCD_FillRect(0, 0, 240, 136); +} + +/** +Sets up the upper right part of display +1/18/2021 +*/ void lcd_upper_right() { BSP_LCD_SetBackColor(LCD_COLOR_WHITE); @@ -78,29 +85,83 @@ BSP_LCD_FillRect(240, 0, 240, 136); } -// Sets up the lower left part of screen -void lcd_lower_left(char building[], char room[]) +/** Update the content of the upper right part of display. +@light_reading The intensity level of registered light in percentage +@rotary_reading The current position of rotary sensor in percentage +1/18/2021 +*/ +void lcd_update_upper_right(int light_reading, int rotary_reading) { - BSP_LCD_Clear(LCD_COLOR_DARKBLUE); - - BSP_LCD_SetTextColor(LCD_COLOR_BLACK); - BSP_LCD_FillRect(0, 136, 240, 136); + BSP_LCD_SetBackColor(LCD_COLOR_BLUE); 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); + BSP_LCD_DisplayStringAt(35, 200, (uint8_t *)"TIME HERE", LEFT_MODE); +} + +/** +Sets up the lower left part of display +1/13/2021 +*/ +void lcd_lower_left() +{ + BSP_LCD_SetBackColor(LCD_COLOR_DARKMAGENTA); + BSP_LCD_SetTextColor(LCD_COLOR_DARKMAGENTA); + BSP_LCD_FillRect(0, 136, 240, 136); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&Font20); + BSP_LCD_DisplayStringAt(5, 160, (uint8_t *)"Location", LEFT_MODE); } -// Sets up the upper right part of screen +/** +Updates the content of the lower left area of the display +@building[] Name of the building +@room[] Name of the room +1/18/2021 +*/ +void lcd_update_lower_left(char building[], char room[]) +{ + BSP_LCD_SetBackColor(LCD_COLOR_DARKMAGENTA); + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&Font12); + BSP_LCD_DisplayStringAt(35, 200, (uint8_t *)building, LEFT_MODE); + BSP_LCD_DisplayStringAt(35, 220, (uint8_t *)room, LEFT_MODE); +} + +/** +Sets up the lower right part of display +1/18/2021 +*/ void lcd_lower_right() { BSP_LCD_SetTextColor(LCD_COLOR_CYAN); BSP_LCD_FillRect(240, 136, 240, 136); + BSP_LCD_SetBackColor(LCD_COLOR_CYAN); + BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); + BSP_LCD_SetFont(&Font20); + BSP_LCD_DisplayStringAt(5, 160, (uint8_t *)"Temperature", RIGHT_MODE); +} + +/** Update the content of the lower right part of display. +@temp The temperature reading from the thermal sensor +1/18/2021 +*/ +void lcd_update_lower_right(float temp, bool is_fahrenheit) +{ + char temp_text[30]; + if (is_fahrenheit == true) + { + float fahrenheit = helper_convert_celsius_to_fahrenheit(temp); + sprintf(temp_text, "%3.0f F", fahrenheit); + } + else + { + sprintf(temp_text, "%2.0f C", temp); + } + BSP_LCD_SetBackColor(LCD_COLOR_CYAN); + BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); + BSP_LCD_SetFont(&Font24); + BSP_LCD_DisplayStringAt(35, 210, (uint8_t *)temp_text, RIGHT_MODE); + BSP_LCD_DrawCircle(421, 214, 3); } // Shows the main screen @@ -109,7 +170,7 @@ BSP_LCD_Clear(LCD_COLOR_DARKBLUE); // Clear with color lcd_upper_left(); //lcd_lower_left(); - lcd_upper_right(); + //lcd_upper_right(); lcd_lower_right(); @@ -132,4 +193,14 @@ //BSP_LCD_DisplayStringAt(0, 6, (uint8_t *)output, RIGHT_MODE); //HAL_Delay(2000); */ +} + +/** +This function will print LCD size in console terminal +@date 1/13/2021 +*/ +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 } \ No newline at end of file