restore back

This commit is contained in:
Yunhorn 2023-08-11 08:57:37 +08:00
parent e9596d0ab4
commit 6fee3af796
1 changed files with 62 additions and 33 deletions

View File

@ -19,7 +19,7 @@
paramsMLX90640 mlx90640;
static uint16_t eeMLX90640[832];
int status;
volatile uint8_t draw_legend_once=0, normalPeopleTemp=30, blackOutTag=0;
volatile uint8_t draw_legend_once=0, normalPeopleTemp=30, blackOutTag=0, waterTempThreshold=10, detectCycle=0;
// start with some initial colors
float minTemp = 1.0f;
float maxTemp = 60.0f;
@ -36,9 +36,9 @@ int x, y, i, j;
// array for the 32 x 24 measured tempValues
static float tempValues[32*24];
static uint8_t zoneMask[32*24]={0x0};
volatile uint8_t zoneMask[32*24]={0x0};
static uint8_t blackOutFilter(void);
void blackOutFilter(void);
static uint16_t TempToColor(float val);
static void setTempScale(void);
static void setAbcd(void);
@ -149,7 +149,7 @@ static void drawLegend(void)
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
#if 0
BSP_LCD_SetFont(&Font16);
DrawProp.BackColor = LCD_COLOR_BLACK;
memset(tempBuffer,0,sizeof(tempBuffer));
@ -204,34 +204,33 @@ static void drawMeasurement(void ) {
}
static void drawPicture(void) {
#if 0
float temp1=0.0;
uint8_t blackdot=0;
averageTemp = 0.0;
for (i=0; i<32*24; i++)
averageTemp += tempValues[i];
averageTemp /= 768;
#endif
BSP_LCD_FillRect(1,1,ST7789V_LCD_PIXEL_WIDTH-2, ST7789V_LCD_PIXEL_HEIGHT-16-16, LCD_COLOR_BLACK);
for (y=1; y<23; y++)
for (y=0; y<23; y++)
{
for (x=1; x<31; x++)
for (x=0; x<31; x++)
{
temp1 = tempValues[(x) + (y*32)];
if ((temp1+ 1.0) > averageTemp )
{
//BSP_LCD_FillRect(x*8, y*11, 7, 10, LCD_COLOR_BLACK);
temp1=0.0;
} else {
if (zoneMask[y*32+x] > 3) {
//APP_LOG(TS_OFF,VLEVEL_L,"\r\n X=%d Y=%d Count=%d\r\n",x,y,zoneMask[y*32+x]);
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;
}
}
}
}
}
// Read pixel data from MLX90640.
static void readTempValues(void) {
char buf[128];
static void readTempValues(void)
{
for (uint8_t x = 0 ; x < 2 ; x++) // Read both subpages
{
@ -259,32 +258,62 @@ static void readTempValues(void) {
}
#endif
}
static uint8_t blackOutFilter(void)
void blackOutFilter(void)
{
if (maxTemp < normalPeopleTemp) {
blackOutTag =0;
return 0;
} else {
blackOutTag =1;
return 1;
float averageTemp = 0.0, temp1=0.0;
for (i=0; i<32*24; i++) {
averageTemp += tempValues[i];
}
averageTemp /= 768;
if (maxTemp < normalPeopleTemp)
{
blackOutTag =0;
for (y=1; y<22; y++)
{
for (x=1; x<30; x++)
{
temp1 = (float)tempValues[(x) + (y*32)];
if ((temp1 + (float)(waterTempThreshold/10.0)) < averageTemp )
{
zoneMask[y*32+x] ++;
//APP_LOG(TS_OFF, VLEVEL_L, "Detect Zone X=%d Y=%d Count=%d T=%2.2f \r\n", x, y, zoneMask[y*32+x], (int)(temp1+waterTempThreshold/10.0));
}
}
}
blackOutTag =0;
} else
{
blackOutTag =1;
}
if (detectCycle ++ > 20)
{
detectCycle = 0;
memset(zoneMask,0,sizeof(zoneMask));
}
}
void mlx90640_display_process(void)
{
readTempValues();
setTempScale();
blackOutFilter();
if (blackOutTag == 0)
{
// APP_LOG(TS_OFF, VLEVEL_L, "DetectCycle=%d \r\n", detectCycle);
BSP_LCD_DisplayOn();
drawPicture();
drawMeasurement();
} else {
BSP_LCD_DisplayOff();
}
}
void mlx90640_display_init(void){