add water spill spot counting

This commit is contained in:
Yunhorn 2023-08-14 10:16:49 +08:00
parent e7df3cc465
commit 1b5c285fbe
2 changed files with 23 additions and 8 deletions

View File

@ -117,7 +117,7 @@ int main(void)
BSP_LCD_DisplayOn();
//APP_LOG(TS_OFF, VLEVEL_L, "BSP LCD TEST....\r\n");
BSP_LCD_Test();
//BSP_LCD_Test();
// BSP_LCD_DisplayOff();

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, waterTempThreshold=10, detectCycle=0;
volatile uint8_t draw_legend_once=0, normalPeopleTemp=30, blackOutTag=0, waterTempThreshold=10, detectCycle=0, v_water_cnt=0,h_water_cnt=0;
// start with some initial colors
float minTemp = 1.0f;
float maxTemp = 60.0f;
@ -151,7 +151,7 @@ static void drawLegend(void)
BSP_LCD_DisplayStringAt(20,ST7789V_LCD_PIXEL_HEIGHT+2,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_DARKBLUE);
memset(tempBuffer,0,sizeof(tempBuffer));
sprintf(tempBuffer,(char *)"F10.Male#1.Zone#1");
sprintf(tempBuffer,(char *)" F10.MWC#1.Z#1");
BSP_LCD_DisplayStringAt(22, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_DARKBLUE);
}
#if 0
@ -177,13 +177,17 @@ static void drawMeasurement(void ) {
// Measure and print center temperature
centerTemp = (tempValues[383 - 16] + tempValues[383 - 15] + tempValues[384 + 15] + tempValues[384 + 16]) / 4;
BSP_LCD_SetFont(&Font16);
memset(tempBuffer,0,sizeof(tempBuffer));
sprintf(tempBuffer,(char *)"%2d", (uint8_t)max(v_water_cnt, h_water_cnt));
BSP_LCD_DisplayStringAt(ST7789V_LCD_PIXEL_WIDTH-60, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_YELLOW);
}
static void drawPicture(void)
{
BSP_LCD_FillRect(0,2*16+6, ST7789V_LCD_PIXEL_WIDTH, ST7789V_LCD_PIXEL_HEIGHT-32, LCD_COLOR_BLACK);
uint8_t h_cnt[32]={0},v_cnt[24]={0}; //for horizon and vertical _water spill count
BSP_LCD_FillRect(0,2*16+6, ST7789V_LCD_PIXEL_WIDTH, ST7789V_LCD_PIXEL_HEIGHT-32, LCD_COLOR_BLACK);
// ignore edge of FOV
for (y=2; y<22; y++)
{
@ -193,12 +197,23 @@ static void drawPicture(void)
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+16, 4, 4, LCD_COLOR_GREEN);
h_cnt[x] =1;
v_cnt[y] =1;
}
}
}
v_water_cnt=0;
h_water_cnt=0;
for (y=2; y<23; y++) {
if ((1 == v_cnt[y]) && (0 == v_cnt[y-1])) {
v_water_cnt ++;
}
}
for (x=2; x<32; x++) {
if ((1 == h_cnt[x]) && (0 == h_cnt[x-1])) {
h_water_cnt ++;
}
}
}
// Read pixel data from MLX90640.