add water spill level out of 32*24

This commit is contained in:
Yunhorn 2023-08-11 17:08:45 +08:00
parent 211c62c184
commit 81c3189ecd
2 changed files with 20 additions and 53 deletions

View File

@ -25,6 +25,7 @@ float minTemp = 1.0f;
float maxTemp = 60.0f;
float centerTemp=0.0f;
float averageTemp=0.0f;
volatile uint16_t waterSpillCount=0;
char tempBuffer[128];
// variables for interpolated colors
@ -147,11 +148,11 @@ static void drawLegend(void)
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_DARKBLUE);
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.WashBasin");
BSP_LCD_DisplayStringAt(8, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_WHITE);
sprintf(tempBuffer,(char *)"F10.Male#1.Zone#1");
BSP_LCD_DisplayStringAt(22, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_DARKBLUE);
}
#if 0
BSP_LCD_SetFont(&Font16);
@ -176,42 +177,11 @@ static void drawMeasurement(void ) {
// Measure and print center temperature
centerTemp = (tempValues[383 - 16] + tempValues[383 - 15] + tempValues[384 + 15] + tempValues[384 + 16]) / 4;
#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(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);
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
}
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
static void drawPicture(void)
{
BSP_LCD_FillRect(0,2*16+6, ST7789V_LCD_PIXEL_WIDTH, ST7789V_LCD_PIXEL_HEIGHT-32, LCD_COLOR_BLACK);
// ignore edge of FOV
@ -223,6 +193,7 @@ averageTemp = 0.0;
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);
}
}
}
@ -250,15 +221,6 @@ static void readTempValues(void)
MLX90640_CalculateTo(mlx90640Frame, &mlx90640, EMMISIVITY, tr, tempValues);
}
#if 0
APP_LOG(TS_OFF,VLEVEL_L, "\r\n\n\n");
for (uint8_t y=0; y < 24; y++) {
for (uint8_t x=0; x<32; x++) {
APP_LOG(TS_OFF, VLEVEL_L, "%c ", (uint8_t)((((float)tempValues[y*32+x]- 25.0)) + 0x30));
}
APP_LOG(TS_OFF,VLEVEL_L, "\r\n");
}
#endif
}
void blackOutFilter(void)
{
@ -268,6 +230,7 @@ void blackOutFilter(void)
{
blackOutTag =0;
// ignore edge of FOV
waterSpillCount =0;
for (y=2; y<22; y++)
{
for (x=2; x<30; x++)
@ -277,6 +240,7 @@ void blackOutFilter(void)
{
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));
waterSpillCount ++;
}
}
}
@ -291,6 +255,7 @@ void blackOutFilter(void)
if (detectCycle ++ > 20)
{
detectCycle = 0;
memset((void *)zoneMask,0,sizeof(zoneMask));
}
@ -316,6 +281,8 @@ void mlx90640_display_process(void)
LCD_BL_OFF();
// BSP_LCD_DisplayOff();
}
APP_LOG(TS_OFF, VLEVEL_L, "Water Spill Detected Level = %d of %d, \r\n", waterSpillCount, 30*20);
}
void mlx90640_display_init(void){

View File

@ -212,14 +212,14 @@ void st7789v_Init(void)
*/
void st7789v_DisplayOn(void)
{
//uint8_t data = 0;
uint8_t data = 0;
LCD_IO_WriteReg(0x13);/* Partial off (Normal): NORON */
LCD_Delay(10);
LCD_IO_WriteReg(0x29);/* Display on: DISPON */
LCD_Delay(10);
// LCD_IO_WriteReg(0x36);/* Memory data access control: MADCTL */
// data = 0xC0;
// LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteReg(0x36);/* Memory data access control: MADCTL */
data = 0xC0;
LCD_IO_WriteMultipleData(&data, 1);
}
/**
@ -229,14 +229,14 @@ void st7789v_DisplayOn(void)
*/
void st7789v_DisplayOff(void)
{
// uint8_t data = 0;
uint8_t data = 0;
LCD_IO_WriteReg(0x13);/* Partial off (Normal): NORON */
LCD_Delay(10);
LCD_IO_WriteReg(0x28);/* Display off: DISPOFF */
LCD_Delay(10);
// LCD_IO_WriteReg(0x36);/* Memory data access control: MADCTL */
// data = 0xC0;
// LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteReg(0x36);/* Memory data access control: MADCTL */
data = 0xC0;
LCD_IO_WriteMultipleData(&data, 1);
}
/**