/******************************************************************************* * 获取温度 ********************************************************************************/ void getTempture() { uint16 voltageRawCount;//电平值得统计 ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT); /* 等待温度转换完成 */ voltageRawCount = ADC_DelSig_1_GetResult32(); /* 得到转换后的值 GetResult16 最大值是32767 */ tempture = 1.024*voltageRawCount/65536*1000; /* 根据公式进行转换 */ if (voltageRawCount <= 0) { errorDisplay();/* 处理错误数据或是零下的温度 */ UART_PutString("sl0e"); } else if(tempture > highTempture ) { char tem[6]; tem[0] = 's'; tem[1] = 'h'; tem[2] = '0'; tem[3] = 'e'; tem[4] = '\0'; UART_PutString(tem); LCD_Char_1_PrintNumber(highTempture); } else if(tempture < lowTempture)//防止温度值溢出 { char tem[6]; tem[0] = 's'; tem[1] = 'l'; tem[2] = '0'; tem[3] = 'e'; tem[4] = '\0'; UART_PutString(tem); LCD_Char_1_PrintNumber(lowTempture); } else { char tem[9]; tem[0] = 's'; tem[1] = 't'; tem[2] = '0'; tem[3] = tempture/100 + 48; tem[4] = (tempture%100)/10 + 48; tem[5] = tempture%10 + 48; tem[6] = 'e'; tem[7] = '\0'; UART_PutString(tem); } //LCD_Char_1_PrintString(" tempture "); //LCD_Char_1_PrintNumber(tempture/10); /* 打印小数点前面的数据 */ //LCD_Char_1_PrintNumber(tempture%10); /* 打印小数点后面的数据 */ //LCD_Char_1_PrintNumber(tempture); //updateDisplay(tempture); /* 打印数据到LCD */ }
void *handleHttpRequest(void *acceptedConn){ httpState = 200; int sock = *(int*)acceptedConn; char buffer[maxBuffer]; /* Empties the buffer memory */ bzero(buffer,maxBuffer); int i; do { /*********************************************************************/ /* STEP : Accept a HTTP request */ acceptAndParseHttpRequest(sock); /*********************************************************************/ /* STEP : Get requested file from the server */ if ( httpState == 200 ) { getRequestedFile(sock); } /*********************************************************************/ /* STEP : Create and send the HTTP response */ if ( httpState == 200 ) { sendHttpResponse(sock); } /* else display the error */ if (httpState == 400 || httpState == 404 ) { errorDisplay(sock); } } while((!strcmp(connectionStatus,"Connection: keep-alive"))&&(!strcmp(httpVersion,"1.1"))); free(acceptedConn); /* enable terminating option on the pthreads */ i = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); i = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); /* Should get canceled while we sleep */ sleep(300); return NULL; }