From e72f20c5e3d5f0b844e1edcecf83a4097fe8bf2c Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 9 Aug 2023 17:29:26 +0800 Subject: [PATCH] add maxTemp blackOutFilter to avoid people in/out impact to average temperature. --- mlx90640/hx8347d.h | 2 +- mlx90640/mlx90640_lcd_display.c | 91 +++++++++++++++++++++++++-------- mlx90640/stm32_hx8347d_lcd.c | 11 ++-- 3 files changed, 76 insertions(+), 28 deletions(-) diff --git a/mlx90640/hx8347d.h b/mlx90640/hx8347d.h index 3c54825..e571ae2 100644 --- a/mlx90640/hx8347d.h +++ b/mlx90640/hx8347d.h @@ -62,7 +62,7 @@ SOFTWARE. * @brief HX8347D Size */ #define HX8347D_LCD_PIXEL_WIDTH ((uint16_t)240) -#define HX8347D_LCD_PIXEL_HEIGHT ((uint16_t)320) +#define HX8347D_LCD_PIXEL_HEIGHT ((uint16_t)280) #define TFT_MAX_PIXELS_AT_ONCE 32 /** * @brief HX8347D Registers diff --git a/mlx90640/mlx90640_lcd_display.c b/mlx90640/mlx90640_lcd_display.c index 27e7e5c..22fb43b 100644 --- a/mlx90640/mlx90640_lcd_display.c +++ b/mlx90640/mlx90640_lcd_display.c @@ -19,14 +19,14 @@ paramsMLX90640 mlx90640; static uint16_t eeMLX90640[832]; int status; - +volatile uint8_t draw_legend_once=0, normalPeopleTemp=30, blackOutTag=0; // start with some initial colors float minTemp = 1.0f; float maxTemp = 60.0f; float centerTemp; float averageTemp; -char tempBuffer[6]; +char tempBuffer[128]; // variables for interpolated colors uint8_t red, green, blue; @@ -38,7 +38,7 @@ int x, y, i, j; static float tempValues[32*24]; static uint8_t zoneMask[32*24]={0x0}; - +static uint8_t blackOutFilter(void); static uint16_t TempToColor(float val); static void setTempScale(void); static void setAbcd(void); @@ -95,7 +95,12 @@ static void setTempScale(void) { minTemp = min(minTemp, tempValues[i]); maxTemp = max(maxTemp, tempValues[i]); } - + if (maxTemp > normalPeopleTemp) + { + blackOutTag = 1; + } else { + blackOutTag = 0; + } setAbcd(); drawLegend(); @@ -112,15 +117,34 @@ static void setAbcd(void) { // Draw a legend. -static void drawLegend(void) { +static void drawLegend(void) +{ + if (draw_legend_once ==0) + { #if 0 - //float inc = (maxTemp - minTemp) / 224.0f; - float inc = (maxTemp - minTemp) / 224.0f; - j = 0; - for (ii = minTemp; ii < maxTemp; ii += inc) { - BSP_LCD_DrawVLine(8+ + j++, 260, 20, TempToColor(ii)); - } + float inc = (maxTemp - minTemp) / 224.0f; + j = 0; + for (ii = minTemp; ii < maxTemp; ii += inc) { + BSP_LCD_DrawVLine(8+ + j++, 260, 20, TempToColor(ii)); + } #endif + BSP_LCD_FillRect(0,240,240, 300, LCD_COLOR_BLACK); + draw_legend_once =1; + + BSP_LCD_DrawHLine(0,246,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_LIGHTBLUE); + BSP_LCD_DrawHLine(0,245,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_LIGHTBLUE); + + BSP_LCD_SetFont(&Font16); + memset(tempBuffer,0,sizeof(tempBuffer)); + DrawProp.BackColor = LCD_COLOR_BLACK; + sprintf(tempBuffer,(char *)"Yunhorn Technology"); + BSP_LCD_DisplayStringAt(20,ST7789V_LCD_PIXEL_HEIGHT,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); + + memset(tempBuffer,0,sizeof(tempBuffer)); + sprintf(tempBuffer,(char *)"F10.Male#1.WashBasin",centerTemp); + BSP_LCD_DisplayStringAt(8, ST7789V_LCD_PIXEL_HEIGHT-16,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_WHITE); + } +#if 1 BSP_LCD_SetFont(&Font16); DrawProp.BackColor = LCD_COLOR_BLACK; memset(tempBuffer,0,sizeof(tempBuffer)); @@ -130,6 +154,7 @@ static void drawLegend(void) { memset(tempBuffer,0,sizeof(tempBuffer)); sprintf(tempBuffer,(char *)"%2.1f",maxTemp); BSP_LCD_DisplayStringAt(190,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_RED); +#endif } @@ -146,12 +171,22 @@ static void drawMeasurement(void ) { averageTemp += tempValues[i]; averageTemp /= 768; +#if 0 + BSP_LCD_DrawHLine(0,246,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_LIGHTBLUE); + BSP_LCD_DrawHLine(0,245,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_LIGHTBLUE); + BSP_LCD_SetFont(&Font16); memset(tempBuffer,0,sizeof(tempBuffer)); DrawProp.BackColor = LCD_COLOR_BLACK; sprintf(tempBuffer,(char *)"Yunhorn Technology"); - BSP_LCD_DisplayStringAt(18,240,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); + BSP_LCD_DisplayStringAt(20,ST7789V_LCD_PIXEL_HEIGHT,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); + memset(tempBuffer,0,sizeof(tempBuffer)); + sprintf(tempBuffer,(char *)"F10.Male#1.WashBasin",centerTemp); + BSP_LCD_DisplayStringAt(8, ST7789V_LCD_PIXEL_HEIGHT-16,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_WHITE); +#endif + +#if 0 memset(tempBuffer,0,sizeof(tempBuffer)); sprintf(tempBuffer,(char *)"%2.2f ",centerTemp); BSP_LCD_DisplayStringAt(60,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_RED); @@ -159,6 +194,7 @@ static void drawMeasurement(void ) { memset(tempBuffer,0,sizeof(tempBuffer)); sprintf(tempBuffer,(char *)"%2.2f ",averageTemp); BSP_LCD_DisplayStringAt(120,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); +#endif } @@ -169,19 +205,19 @@ averageTemp = 0.0; for (i=0; i<32*24; i++) averageTemp += tempValues[i]; averageTemp /= 768; - BSP_LCD_FillRect(0,0,240, 240, LCD_COLOR_BLACK); - for (y=2; y<23; y++) + BSP_LCD_FillRect(0,0,ST7789V_LCD_PIXEL_WIDTH, ST7789V_LCD_PIXEL_HEIGHT-16, LCD_COLOR_BLACK); + for (y=1; y<23; y++) { - for (x=2; x<31; x++) + for (x=1; x<31; x++) { temp1 = tempValues[(x) + (y*32)]; - if ((temp1+ 1.5) > averageTemp ) + if ((temp1+ 1.0) > averageTemp ) { //BSP_LCD_FillRect(x*8, y*11, 7, 10, LCD_COLOR_BLACK); temp1=0.0; } else { - BSP_LCD_FillRect(x*8, y*11, 7, 11, LCD_COLOR_YELLOW); - BSP_LCD_DrawCircle(x*8, y*11, 20, LCD_COLOR_RED); + BSP_LCD_FillRect(x*8, y*11, 4, 4, LCD_COLOR_GREEN); + //BSP_LCD_DrawCircle((x)*8, (y-2)*11, 10, LCD_COLOR_BLUE); zoneMask[y*32+x]=0x57; } } @@ -218,14 +254,25 @@ static void readTempValues(void) { } #endif } - -void mlx90640_display_process(void){ +static uint8_t blackOutFilter(void) +{ + if (maxTemp < normalPeopleTemp) { + return 1; + } else { + return 0; + } +} +void mlx90640_display_process(void) +{ readTempValues(); setTempScale(); - drawPicture(); - drawMeasurement(); + if (blackOutTag == 0) + { + drawPicture(); + drawMeasurement(); + } } diff --git a/mlx90640/stm32_hx8347d_lcd.c b/mlx90640/stm32_hx8347d_lcd.c index ce2dc75..f8c9dc5 100644 --- a/mlx90640/stm32_hx8347d_lcd.c +++ b/mlx90640/stm32_hx8347d_lcd.c @@ -1339,18 +1339,19 @@ void LCD_Delay(uint32_t Delay) */ void BSP_LCD_Test(void) { - APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with rainbow...........\r\n"); + APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with rainbow...........\r\n"); BSP_LCD_FillRect(0,0,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_RED); BSP_LCD_FillRect(0,1*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_GREEN); BSP_LCD_FillRect(0,2*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_BLUE); BSP_LCD_FillRect(0,3*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_WHITE); BSP_LCD_FillRect(0,4*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_YELLOW); BSP_LCD_FillRect(0,5*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_MAGENTA); - BSP_LCD_FillRect(0,6*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_BLACK); - BSP_LCD_FillRect(0,7*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_LIGHTBLUE); + BSP_LCD_FillRect(0,6*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_LIGHTBLUE); + BSP_LCD_FillRect(0,7*ST7789V_LCD_PIXEL_HEIGHT/7,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT/7,LCD_COLOR_BLACK); - BSP_LCD_DisplayStringAt(10, 3*ST7789V_LCD_PIXEL_HEIGHT/7, "Yunhorn Technology", LEFT_MODE, LCD_COLOR_BLUE); - BSP_LCD_DisplayStringAt(10, 20+3*ST7789V_LCD_PIXEL_HEIGHT/7, "SmarToilets", LEFT_MODE, LCD_COLOR_BLUE); + + BSP_LCD_DisplayStringAt(30, 3*ST7789V_LCD_PIXEL_HEIGHT/7, "SmarToilets", LEFT_MODE, LCD_COLOR_BLUE); + BSP_LCD_DisplayStringAt(10, 20+3*ST7789V_LCD_PIXEL_HEIGHT/7,"Yunhorn Technology", LEFT_MODE, LCD_COLOR_BLUE); HAL_Delay(2500); #if 0