diff --git a/mlx90640/hx8347d.c b/mlx90640/hx8347d.c index c23eb66..2e54fb9 100644 --- a/mlx90640/hx8347d.c +++ b/mlx90640/hx8347d.c @@ -67,7 +67,7 @@ static uint8_t Is_hx8347d_Initialized = 0; uint16_t _width = 240; uint16_t _height = 320; -uint8_t _rotation = 0; +uint8_t _rotation = 1; /** * @} @@ -440,7 +440,7 @@ void hx8347d_WriteColor(uint16_t color, uint32_t len){ /** * @brief Set the Rotation. -* @param rotation: 0(0¡ã), 1(90¡ã), 2(180¡ã), 3(270¡ã) +* @param rotation: 0(0��), 1(90��), 2(180��), 3(270��) * @retval None */ void hx8347d_SetRotation(uint8_t rotation) diff --git a/mlx90640/mlx90640_lcd_display.c b/mlx90640/mlx90640_lcd_display.c index 1723529..27e7e5c 100644 --- a/mlx90640/mlx90640_lcd_display.c +++ b/mlx90640/mlx90640_lcd_display.c @@ -4,6 +4,7 @@ #include "MLX90640_API.h" #include "MLX90640_I2C_Driver.h" #include "sys_app.h" +#include "bmp.h" #define FPS2HZ 0x02 #define FPS4HZ 0x03 #define FPS8HZ 0x04 @@ -20,9 +21,10 @@ static uint16_t eeMLX90640[832]; int status; // start with some initial colors -float minTemp = 20.0f; -float maxTemp = 40.0f; +float minTemp = 1.0f; +float maxTemp = 60.0f; float centerTemp; +float averageTemp; char tempBuffer[6]; // variables for interpolated colors @@ -34,7 +36,8 @@ int x, y, i, j; // array for the 32 x 24 measured tempValues static float tempValues[32*24]; -static float ColorValues[32*24]; +static uint8_t zoneMask[32*24]={0x0}; + static uint16_t TempToColor(float val); static void setTempScale(void); @@ -43,7 +46,7 @@ static void drawLegend(void); static void drawMeasurement(void); static void drawPicture(void); static void readTempValues(void); - +extern LCD_DrawPropTypeDef DrawProp; static uint16_t TempToColor(float val){ /* pass in value and figure out R G B @@ -95,6 +98,7 @@ static void setTempScale(void) { setAbcd(); drawLegend(); + } @@ -109,15 +113,16 @@ static void setAbcd(void) { // Draw a legend. static void drawLegend(void) { - float inc = (maxTemp - minTemp) / 224.0f; - +#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)); - } - +#endif BSP_LCD_SetFont(&Font16); + DrawProp.BackColor = LCD_COLOR_BLACK; memset(tempBuffer,0,sizeof(tempBuffer)); sprintf(tempBuffer,(char *)"%2.1f",minTemp); BSP_LCD_DisplayStringAt(8,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); @@ -132,26 +137,53 @@ static void drawLegend(void) { static void drawMeasurement(void ) { // Mark center measurement - BSP_LCD_DrawCircle(120, 8+84, 3, LCD_COLOR_WHITE); + //BSP_LCD_DrawCircle(120, 8+84, 10, LCD_COLOR_WHITE); // Measure and print center temperature centerTemp = (tempValues[383 - 16] + tempValues[383 - 15] + tempValues[384 + 15] + tempValues[384 + 16]) / 4; + averageTemp = 0.0; + for (i=0; i<32*24; i++) + averageTemp += tempValues[i]; + averageTemp /= 768; 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); + memset(tempBuffer,0,sizeof(tempBuffer)); sprintf(tempBuffer,(char *)"%2.2f ",centerTemp); - BSP_LCD_DisplayStringAt(88,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_RED); + BSP_LCD_DisplayStringAt(60,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_RED); + + memset(tempBuffer,0,sizeof(tempBuffer)); + sprintf(tempBuffer,(char *)"%2.2f ",averageTemp); + BSP_LCD_DisplayStringAt(120,260,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE); + } static void drawPicture(void) { - for (y=0; y<768; y++) { - ColorValues[y] = TempToColor(tempValues[y]); - } - - for (y=0; y<24; y++) { - for (x=0; x<32; x++) { - //BSP_LCD_FillRect(x*8, y*11, 8, 11, TempToColor(tempValues[(x) + (y*32)])); - BSP_LCD_FillRect(x*8, y*11, 8, 11, ColorValues[(x) + (y*32)]); +float temp1=0.0; +uint8_t blackdot=0; +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++) + { + for (x=2; x<31; x++) + { + temp1 = tempValues[(x) + (y*32)]; + if ((temp1+ 1.5) > 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); + zoneMask[y*32+x]=0x57; + } } } } @@ -188,11 +220,13 @@ static void readTempValues(void) { } void mlx90640_display_process(void){ - //APP_LOG(TS_OFF, VLEVEL_L, "Read value.\r\n"); + readTempValues(); - setTempScale(); - drawPicture(); - drawMeasurement(); + setTempScale(); + + drawPicture(); + drawMeasurement(); + } void mlx90640_display_init(void){ diff --git a/mlx90640/mlx90640_user.h b/mlx90640/mlx90640_user.h index b03ff68..f78a871 100644 --- a/mlx90640/mlx90640_user.h +++ b/mlx90640/mlx90640_user.h @@ -13,7 +13,7 @@ #define FPS32HZ 0x06 #define MLX90640_ADDR 0x33 -#define RefreshRate FPS16HZ +#define RefreshRate FPS4HZ #define TA_SHIFT 8 //Default shift for MLX90640 in open air static uint16_t eeMLX90640[832]; diff --git a/mlx90640/stm32_hx8347d_lcd.c b/mlx90640/stm32_hx8347d_lcd.c index 7985a95..ce2dc75 100644 --- a/mlx90640/stm32_hx8347d_lcd.c +++ b/mlx90640/stm32_hx8347d_lcd.c @@ -114,7 +114,8 @@ static uint8_t _rotation = 0; * @{ */ static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c, uint16_t RGBCode); -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); +//static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); +void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); /** * @} */ @@ -1052,7 +1053,8 @@ static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *pChar, uint16_ * @param Height: LCD window height * @retval None */ -static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) +//static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) +void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) { if(lcd_drv->SetDisplayWindow != NULL) { @@ -1337,23 +1339,20 @@ void LCD_Delay(uint32_t Delay) */ void BSP_LCD_Test(void) { - BSP_LCD_Clear(LCD_COLOR_WHITE); - HAL_Delay(200); - APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with red...........\r\n"); - BSP_LCD_Clear(LCD_COLOR_RED); + 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); - HAL_Delay(200); - BSP_LCD_Clear(LCD_COLOR_RED); - APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with blue...........\r\n"); - BSP_LCD_Clear(LCD_COLOR_BLUE); - HAL_Delay(200); + 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); + HAL_Delay(2500); - APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with YELLOW...........\r\n"); - BSP_LCD_Clear(LCD_COLOR_YELLOW); - HAL_Delay(200); - APP_LOG(TS_OFF,VLEVEL_L,"\r\n Clear with GREEN...........\r\n"); - BSP_LCD_Clear(LCD_COLOR_GREEN); - HAL_Delay(200); #if 0 BSP_LCD_FillRect(0,0,ST7789V_LCD_PIXEL_WIDTH,ST7789V_LCD_PIXEL_HEIGHT,LCD_COLOR_WHITE); HAL_Delay(500); diff --git a/mlx90640/stm32_hx8347d_lcd.h b/mlx90640/stm32_hx8347d_lcd.h index 85f971a..c8cf053 100644 --- a/mlx90640/stm32_hx8347d_lcd.h +++ b/mlx90640/stm32_hx8347d_lcd.h @@ -234,7 +234,7 @@ void BSP_LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1 void BSP_LCD_DisplayOff(void); void BSP_LCD_DisplayOn(void); - +void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); uint16_t BSP_LCD_GetColor565(uint8_t red, uint8_t green, uint8_t blue); void BSP_LCD_Test(void);