add calibrateWaterTemp for reference later

This commit is contained in:
Yunhorn 2023-08-24 13:16:36 +08:00
parent d9bd3566fb
commit 25c2638ac4
1 changed files with 25 additions and 4 deletions

View File

@ -24,7 +24,7 @@ volatile uint8_t draw_legend_once=0, normalPeopleTemp=32, blackOutTag=0, waterTe
// start with some initial colors
float minTemp = 1.0f;
float maxTemp = 60.0f;
float centerTemp=0.0f;
volatile float centerTemp=0.0f, calibrationWaterTemp=0.0f;
float averageTemp=0.0f;
volatile uint16_t waterSpillLevel=0, waterSpillSpotCount=0;
static uint16_t lastWaterSpillSpotCount=0;
@ -39,7 +39,7 @@ int x, y, i, j;
// array for the 32 x 24 measured tempValues
static float tempValues[32*24];
volatile uint8_t zoneMask[32*24]={0x0}, edgeMask[32*24]={0x0};
void setCalibrationWaterTemp(void);
void blackOutFilter(void);
static uint16_t TempToColor(float val);
static void setTempScale(void);
@ -48,6 +48,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)
{
@ -89,8 +90,20 @@ static uint16_t TempToColor(float val)
// use the displays color mapping function to get 5-6-5 color palette (R=5 bits, G=6 bits, B-5 bits)
return BSP_LCD_GetColor565(red, green, blue);
}
void setCalibrationWaterTemp(void)
{
char tempbuf[128]="";
readTempValues();
setTempScale();
calibrationWaterTemp = centerTemp;
memset(tempbuf,0x0,sizeof(tempbuf));
sprintf(tempbuf,(char *)"Calibration Water Temp =%2.2f \r\n", calibrationWaterTemp);
APP_LOG(TS_OFF,VLEVEL_L,"%s\r\n",tempbuf);
}
static void setTempScale(void) {
char tempbuf[250]="";
minTemp = 255;
maxTemp = 0;
averageTemp =0.0;
@ -103,6 +116,12 @@ static void setTempScale(void) {
}
averageTemp /= 768;
centerTemp = (tempValues[383 - 16] + tempValues[383 - 15] + tempValues[384 + 15] + tempValues[384 + 16]) / 4;
memset(tempbuf,0x0,sizeof(tempbuf));
sprintf(tempbuf,(char *)"AVG Temp=%2.2f CenterTemp=%2.2f normalWaterTemp=%2.2f CalibratedWaterTemp=%2.2f\r\n", (float)averageTemp, (float)centerTemp, (float)normalWaterTemp, (float)calibrationWaterTemp);
APP_LOG(TS_OFF,VLEVEL_L,"%s\r\n",tempbuf);
if (maxTemp > normalPeopleTemp)
{
blackOutTag = 1;
@ -182,7 +201,6 @@ static void drawMeasurement(void ) {
memset(tempBuffer,0,sizeof(tempBuffer));
sprintf(tempBuffer,(char *)"%2d", waterSpillSpotCount);
BSP_LCD_DisplayStringAt(ST7789V_LCD_PIXEL_WIDTH-60, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_YELLOW);
//APP_LOG(TS_OFF, VLEVEL_L, "%s\r\n",tempBuffer);
}
@ -295,8 +313,11 @@ void blackOutFilter(void)
//simple edge finding --end
if (calibrationWaterTemp > 0.0f) { // we have calibrated water temp process done)
if ((temp1 + (float)(waterTempThreshold / 10.0)) < max(averageTemp, normalWaterTemp))
normalWaterTemp = calibrationWaterTemp;
}
if ((temp1 + (float)(waterTempThreshold / 10.0)) < min(averageTemp, normalWaterTemp))
{
if (blackOutTag == 0) {