remove useless code
This commit is contained in:
parent
db309c84f7
commit
e98af7458f
|
@ -57,60 +57,15 @@ static float tempValues[COL*ROW];
|
|||
volatile uint16_t zoneMask[ROW*COL]={0x0}, edgeMask[ROW*COL]={0x0}, upMask[ROW/3][COL/3]={0x0}, order[(ROW/3)*(COL/3)]={0x0};
|
||||
volatile STS_M1A_SensorDataTypeDef m1a_data;
|
||||
void blackOutFilter(void);
|
||||
static uint16_t TempToColor(float val);
|
||||
|
||||
static void setTempScale(void);
|
||||
static void setAbcd(void);
|
||||
static void drawLegend(void);
|
||||
static void drawMeasurement(void);
|
||||
static void drawPicture(void);
|
||||
static void findFocusArea(void);
|
||||
static void readTempValues(void);
|
||||
static void sortFocusAreas(void);
|
||||
static void bubbleSort(uint16_t arr[], uint16_t len, uint16_t order[]);
|
||||
|
||||
extern LCD_DrawPropTypeDef DrawProp;
|
||||
/*
|
||||
static uint16_t TempToColor(float val)
|
||||
{
|
||||
|
||||
//pass in value and figure out R G B
|
||||
//several published ways to do this I basically graphed R G B and developed simple linear equations
|
||||
//again a 5-6-5 color display will not need accurate temp to R G B color calculation
|
||||
|
||||
//equations based on
|
||||
//http://web-tech.ga-usa.com/2012/05/creating-a-custom-hot-to-cold-temperature-color-gradient-for-use-with-rrdtool/index.html
|
||||
|
||||
|
||||
|
||||
red = constrain(255.0f / (c - b) * val - ((b * 255.0f) / (c - b)), 0, 255);
|
||||
|
||||
if ((val > minTemp) & (val < a)) {
|
||||
green = constrain(255.0f / (a - minTemp) * val - (255.0f * minTemp) / (a - minTemp), 0, 255);
|
||||
}
|
||||
else if ((val >= a) & (val <= c)) {
|
||||
green = 255;
|
||||
}
|
||||
else if (val > c) {
|
||||
green = constrain(255.0f / (c - d) * val - (d * 255.0f) / (c - d), 0, 255);
|
||||
}
|
||||
else if ((val > d) | (val < a)) {
|
||||
green = 0;
|
||||
}
|
||||
|
||||
if (val <= b) {
|
||||
blue = constrain(255.0f / (a - b) * val - (255.0f * b) / (a - b), 0, 255);
|
||||
}
|
||||
else if ((val > b) & (val <= d)) {
|
||||
blue = 0;
|
||||
}
|
||||
else if (val > d) {
|
||||
blue = constrain(240.0f / (maxTemp - d) * val - (d * 240.0f) / (maxTemp - d), 0, 240);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
*/
|
||||
|
||||
static void setTempScale(void) {
|
||||
minTemp = 255;
|
||||
|
@ -147,9 +102,6 @@ static void setTempScale(void) {
|
|||
|
||||
|
||||
setAbcd();
|
||||
#if 0
|
||||
drawLegend();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,74 +114,6 @@ static void setAbcd(void) {
|
|||
}
|
||||
|
||||
|
||||
// Draw a legend.
|
||||
static void drawLegend(void)
|
||||
{
|
||||
if (draw_legend_once ==0)
|
||||
{
|
||||
#if 0
|
||||
float inc = (maxTemp - minTemp) / 224.0f;
|
||||
j = 0;
|
||||
for (ii = minTemp; ii < maxTemp; ii += inc) {
|
||||
BSP_LCD_DrawVLine(8+ + j++, 260, 20, TempToColor(ii));
|
||||
}
|
||||
|
||||
//BSP_LCD_FillRect(0,240,240, 320, LCD_COLOR_BLACK);
|
||||
BSP_LCD_Clear(LCD_COLOR_BLACK);
|
||||
draw_legend_once =1;
|
||||
|
||||
//BSP_LCD_DrawHLine(0,ST7789V_LCD_PIXEL_HEIGHT-16-1,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_LIGHTBLUE);
|
||||
BSP_LCD_DrawHLine(0,15,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_BRRED);
|
||||
BSP_LCD_DrawHLine(0,ST7789V_LCD_PIXEL_HEIGHT-16-1,ST7789V_LCD_PIXEL_WIDTH, LCD_COLOR_BRRED);
|
||||
|
||||
|
||||
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+2,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_DARKBLUE);
|
||||
|
||||
memset(tempBuffer,0,sizeof(tempBuffer));
|
||||
sprintf(tempBuffer,(char *)" F10.MWC#1.Z#1");
|
||||
BSP_LCD_DisplayStringAt(22, 15,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_DARKBLUE);
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
BSP_LCD_SetFont(&Font16);
|
||||
DrawProp.BackColor = LCD_COLOR_BLACK;
|
||||
memset(tempBuffer,0,sizeof(tempBuffer));
|
||||
sprintf(tempBuffer,(char *)"%2.1f",minTemp);
|
||||
BSP_LCD_DisplayStringAt(8,ST7789V_LCD_PIXEL_HEIGHT-16,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_BLUE);
|
||||
|
||||
memset(tempBuffer,0,sizeof(tempBuffer));
|
||||
sprintf(tempBuffer,(char *)"%2.1f",maxTemp);
|
||||
BSP_LCD_DisplayStringAt(190,ST7789V_LCD_PIXEL_HEIGHT-16,(uint8_t *)tempBuffer,LEFT_MODE,LCD_COLOR_RED);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// Draw a circle + measured value.
|
||||
static void drawMeasurement(void ) {
|
||||
|
||||
// Mark center measurement
|
||||
#if 0
|
||||
BSP_LCD_DrawCircle(120, 8+84, 10, LCD_COLOR_WHITE);
|
||||
#endif
|
||||
// Measure and print center temperature
|
||||
centerTemp = (tempValues[383 - 16] + tempValues[383 - 15] + tempValues[384 + 15] + tempValues[384 + 16]) / 4;
|
||||
#if 0
|
||||
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);
|
||||
#endif
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "WaterSpillCount= %s\r\n",tempBuffer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void findFocusArea(void)
|
||||
{
|
||||
uint16_t h_cnt[COL]={0},v_cnt[ROW]={0}; //for horizon and vertical _water spill count
|
||||
|
@ -240,10 +124,7 @@ static void findFocusArea(void)
|
|||
{
|
||||
|
||||
if (zoneMask[y*COL+x] > 3) {
|
||||
// APP_LOG(TS_OFF,VLEVEL_L,"\r\n X=%d Y=%d Count=%d\r\n",x,y,zoneMask[y*32+x]);
|
||||
//upMask[(x/3)*(y/3)] ++;
|
||||
upMask[(uint8_t)(y/3)][(uint8_t)(x/3)] ++; //translate to 11*8 matrix for upload
|
||||
|
||||
h_cnt[x] =1;
|
||||
v_cnt[y] =1;
|
||||
}
|
||||
|
@ -283,75 +164,6 @@ static void findFocusArea(void)
|
|||
|
||||
}
|
||||
|
||||
static void drawPicture(void)
|
||||
{
|
||||
uint8_t h_cnt[COL]={0},v_cnt[ROW]={0}; //for horizon and vertical _water spill count
|
||||
// start from 2, ignore edge of FOV
|
||||
for (y=1; y<ROW-1; y++)
|
||||
{
|
||||
#if 0
|
||||
BSP_LCD_FillRect(0, y*11+16, ST7789V_LCD_PIXEL_WIDTH, 4, LCD_COLOR_BLACK);
|
||||
#endif
|
||||
for (x=1; x<COL-1; x++) // Start from 2, ignore edge of FOV
|
||||
{
|
||||
|
||||
if (zoneMask[y*COL+x] > 3) {
|
||||
// APP_LOG(TS_OFF,VLEVEL_L,"\r\n X=%d Y=%d Count=%d\r\n",x,y,zoneMask[y*32+x]);
|
||||
|
||||
|
||||
#if 0
|
||||
BSP_LCD_FillRect(x*8, y*11+16, 4, 4, LCD_COLOR_GREEN);
|
||||
#endif
|
||||
//upMask[(x/3)*(y/3)] ++;
|
||||
upMask[(uint8_t)(y/3)][(uint8_t)(x/3)] ++; //translate to 11*8 matrix for upload
|
||||
|
||||
h_cnt[x] =1;
|
||||
v_cnt[y] =1;
|
||||
} else if (edgeMask[y*COL+x] > 3) {
|
||||
#if 0
|
||||
BSP_LCD_FillRect(x*8, y*11+16, 2, 2, LCD_COLOR_GRAY);
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
#if 0
|
||||
BSP_LCD_FillRect(x*8, y*11+16, 2, 2, LCD_COLOR_BLACK);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
// simple count of water spill point cloud
|
||||
v_water_cnt=0;
|
||||
h_water_cnt=0;
|
||||
uint8_t v_1=0, v_2=0,h_1=0,h_2=0;
|
||||
|
||||
for (y=1; y<ROW/2; y++) {
|
||||
if ((1 == v_cnt[y]) && (0 == v_cnt[y-1])) {
|
||||
v_1++;
|
||||
}
|
||||
}
|
||||
for (y=12; y<ROW; y++) {
|
||||
if ((1 == v_cnt[y]) && (0 == v_cnt[y-1])) {
|
||||
v_2++;
|
||||
}
|
||||
}
|
||||
v_water_cnt= v_1 + v_2;
|
||||
|
||||
for (x=1; x<COL/2; x++) {
|
||||
if ((1 == h_cnt[x]) && (0 == h_cnt[x-1])) {
|
||||
h_1 ++;
|
||||
}
|
||||
}
|
||||
for (x=16; x<COL; x++) {
|
||||
if ((1 == h_cnt[x]) && (0 == h_cnt[x-1])) {
|
||||
h_2 ++;
|
||||
}
|
||||
}
|
||||
h_water_cnt = h_1 + h_2;
|
||||
|
||||
spot_cnt = max(h_water_cnt, v_water_cnt);
|
||||
// APP_LOG(TS_OFF, VLEVEL_L, " H cnt = %2u V cnt =%2u Spot Cnt=%2u \r\n", h_water_cnt, v_water_cnt, spot_cnt);
|
||||
|
||||
}
|
||||
|
||||
// Read pixel data from MLX90640.
|
||||
static void readTempValues(void)
|
||||
|
@ -376,68 +188,10 @@ static void readTempValues(void)
|
|||
MLX90640_CalculateTo(mlx90640Frame, &mlx90640, (float)(emmisivityThreshold/100.0), tr, tempValues);
|
||||
}
|
||||
}
|
||||
void blackOutFilter(void)
|
||||
{
|
||||
float temp1=0.0, temph1=0.0, tempv1=0.0;
|
||||
|
||||
if (maxTemp > humanTempThreshold)
|
||||
{
|
||||
blackOutTag =1;
|
||||
} else
|
||||
{
|
||||
blackOutTag =0;
|
||||
}
|
||||
|
||||
// ignore edge of FOV
|
||||
waterSpillCount =0;
|
||||
detectCycle = 0;
|
||||
do
|
||||
{
|
||||
for (y=1; y<ROW; y++)
|
||||
{
|
||||
for (x=1; x<COL; x++)
|
||||
{
|
||||
temp1 = (float)tempValues[(x) + (y*COL)];
|
||||
temph1 = (float)tempValues[(x) + (y-1)*COL];
|
||||
tempv1 = (float)tempValues[(x) + (y+1)*COL];
|
||||
|
||||
//simple edge finding --begin
|
||||
//if (((fabs(temp1 - temph1)> 0.3)) && (fabs(temp1 - tempv1)> 0.3))
|
||||
if ((fabs(temp1 - temph1)> 0.2) && (fabs(temp1 - tempv1)> 0.2))
|
||||
//if (((temp1 > temph1)) && ((temp1 > tempv1)))
|
||||
{ // vertical find and horizontal find
|
||||
edgeMask[x+y*COL]++;
|
||||
} else {
|
||||
//edgeMask[x+y*COL] = 0;
|
||||
}
|
||||
|
||||
//simple edge finding --end
|
||||
|
||||
|
||||
if ((temp1 + (float)(waterTempThreshold / 10.0)) < averageTemp ) // was max(averageTemp, normalWaterTemp))
|
||||
{
|
||||
if (blackOutTag == 0) {
|
||||
|
||||
zoneMask[y*COL+x] ++;
|
||||
//upMask[(uint8_t)(x/3)*(uint8_t)(y/3)] ++; //translate to 11*8 matrix for upload
|
||||
upMask[(uint8_t)(y/3)][(uint8_t)(x/3)] ++; //translate to 11*8 matrix for upload
|
||||
waterSpillCount ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
detectCycle ++;
|
||||
|
||||
} while (detectCycle <DetectCycleCount);
|
||||
|
||||
waterSpillCount /=DetectCycleCount;
|
||||
|
||||
}
|
||||
|
||||
static void sortFocusAreas(void)
|
||||
{
|
||||
float temp1=0.0, temph1=0.0, tempv1=0.0;
|
||||
float temp1=0.0;
|
||||
|
||||
if (maxTemp > humanTempThreshold)
|
||||
{
|
||||
|
@ -455,21 +209,6 @@ static void sortFocusAreas(void)
|
|||
{
|
||||
temp1 = (float)tempValues[(x) + (y*COL)];
|
||||
|
||||
#if 0
|
||||
temph1 = (float)tempValues[(x) + (y-1)*COL];
|
||||
tempv1 = (float)tempValues[(x) + (y+1)*COL];
|
||||
//simple edge finding --begin
|
||||
//if (((fabs(temp1 - temph1)> 0.3)) && (fabs(temp1 - tempv1)> 0.3))
|
||||
if ((fabs(temp1 - temph1)> 0.2) && (fabs(temp1 - tempv1)> 0.2))
|
||||
//if (((temp1 > temph1)) && ((temp1 > tempv1)))
|
||||
{ // vertical find and horizontal find
|
||||
edgeMask[x+y*COL]++;
|
||||
} else {
|
||||
//edgeMask[x+y*COL] = 0;
|
||||
}
|
||||
//simple edge finding --end
|
||||
#endif
|
||||
|
||||
if ((temp1 + (float)(waterTempThreshold / 10.0)) < averageTemp ) // was max(averageTemp, normalWaterTemp))
|
||||
{
|
||||
if (blackOutTag == 0) {
|
||||
|
@ -500,7 +239,6 @@ void STS_M1A_SENSOR_Read(STS_M1A_SensorDataTypeDef *m1a_data)
|
|||
m1a_data->h_water_cnt = h_water_cnt;
|
||||
m1a_data->spot_cnt = blackOutTag ==0? spot_cnt:0; //max(v_water_cnt, h_water_cnt);
|
||||
|
||||
//memcpy((void *)m1a_data->waterSpillMatrix,(const void *) zoneMask,sizeof(zoneMask));
|
||||
uint8_t i=0;
|
||||
if ((spot_cnt != 0) && (blackOutTag == 0)) {
|
||||
//bubbleSort((uint8_t*)upMask, (ROW/3)*(COL/3), (uint8_t*)order);
|
||||
|
@ -516,18 +254,13 @@ void STS_M1A_SENSOR_Read(STS_M1A_SensorDataTypeDef *m1a_data)
|
|||
}
|
||||
}
|
||||
|
||||
// memset((void*)m1a_data->order, 0x0, sizeof(m1a_data->order));
|
||||
memcpy((void *)m1a_data->order, (const void *)order, sizeof(order));
|
||||
|
||||
//memset(order + m1a_data->spot_cnt, 0x0, sizeof(tempBuffer)-m1a_data->spot_cnt); // fill non-spot position to zero
|
||||
|
||||
memset(tempBuffer,0x0,sizeof(tempBuffer));
|
||||
|
||||
sprintf(tempBuffer,(char *)"\r\n## Blackout=%u ######\n##Read Sensor Spot CNT=%4d (areas) \r\n## V_cnt=%2d (lane) H_cnt=%2d (lane) \r\n## Spillage Level =%02.2f%% \r\n## averageTempInner=%02.2f C averageTemp=%02.2f C centerTemp=%.2f C MinTemp=%02.2f C maxTemp=%02.2f C \r\n ######## Gap_Average= %02.2f Gap_Inner = %02.2f \r\n",
|
||||
(uint8_t)blackOutTag, (int)m1a_data->waterSpillCount, (int)v_water_cnt, (int)h_water_cnt, (float)(m1a_data->spillage_level), (float)averageTempInner, (float)averageTemp, (float)centerTemp, (float)minTemp, (float)maxTemp, (float)(averageTemp - minTemp),(float)(averageTempInner - minTemp));
|
||||
APP_LOG(TS_OFF, VLEVEL_H,(char *)tempBuffer);
|
||||
|
||||
|
||||
if ((m1a_data->spot_cnt !=0 ) && (blackOutTag == 0))
|
||||
{
|
||||
for (uint8_t i=0; i< 4; i++) {
|
||||
|
|
Loading…
Reference in New Issue