mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-10 05:05:27 +00:00
@ -50,68 +50,6 @@ static char SUBMIT_AND_END_FORM[] = "<br><input type=\"submit\" value=\"Submit\"
|
||||
#if defined(PLATFORM_BK7231T) || defined(PLATFORM_BK7231N)
|
||||
int tuya_os_adapt_wifi_all_ap_scan(AP_IF_S** ap_ary, unsigned int* num);
|
||||
int tuya_os_adapt_wifi_release_ap(AP_IF_S* ap);
|
||||
#elif PLATFORM_BL602
|
||||
/// Read the Internal Temperature Sensor as Float. Returns 0 if successful.
|
||||
/// Based on bl_tsen_adc_get in https://github.com/lupyuen/bl_iot_sdk/blob/master/components/hal_drv/bl602_hal/bl_adc.c#L224-L282
|
||||
static int get_tsen_adc(
|
||||
float *temp, // Pointer to float to store the temperature
|
||||
uint8_t log_flag // 0 to disable logging, 1 to enable logging
|
||||
) {
|
||||
static uint16_t tsen_offset = 0xFFFF;
|
||||
float val = 0.0;
|
||||
|
||||
// If the offset has not been fetched...
|
||||
if (0xFFFF == tsen_offset) {
|
||||
// Define the ADC configuration
|
||||
tsen_offset = 0;
|
||||
ADC_CFG_Type adcCfg = {
|
||||
.v18Sel=ADC_V18_SEL_1P82V, /*!< ADC 1.8V select */
|
||||
.v11Sel=ADC_V11_SEL_1P1V, /*!< ADC 1.1V select */
|
||||
.clkDiv=ADC_CLK_DIV_32, /*!< Clock divider */
|
||||
.gain1=ADC_PGA_GAIN_1, /*!< PGA gain 1 */
|
||||
.gain2=ADC_PGA_GAIN_1, /*!< PGA gain 2 */
|
||||
.chopMode=ADC_CHOP_MOD_AZ_PGA_ON, /*!< ADC chop mode select */
|
||||
.biasSel=ADC_BIAS_SEL_MAIN_BANDGAP, /*!< ADC current form main bandgap or aon bandgap */
|
||||
.vcm=ADC_PGA_VCM_1V, /*!< ADC VCM value */
|
||||
.vref=ADC_VREF_2V, /*!< ADC voltage reference */
|
||||
.inputMode=ADC_INPUT_SINGLE_END, /*!< ADC input signal type */
|
||||
.resWidth=ADC_DATA_WIDTH_16_WITH_256_AVERAGE, /*!< ADC resolution and oversample rate */
|
||||
.offsetCalibEn=0, /*!< Offset calibration enable */
|
||||
.offsetCalibVal=0, /*!< Offset calibration value */
|
||||
};
|
||||
ADC_FIFO_Cfg_Type adcFifoCfg = {
|
||||
.fifoThreshold = ADC_FIFO_THRESHOLD_1,
|
||||
.dmaEn = DISABLE,
|
||||
};
|
||||
|
||||
// Enable and reset the ADC
|
||||
GLB_Set_ADC_CLK(ENABLE,GLB_ADC_CLK_96M, 7);
|
||||
ADC_Disable();
|
||||
ADC_Enable();
|
||||
ADC_Reset();
|
||||
|
||||
// Configure the ADC and Internal Temperature Sensor
|
||||
ADC_Init(&adcCfg);
|
||||
ADC_Channel_Config(ADC_CHAN_TSEN_P, ADC_CHAN_GND, 0);
|
||||
ADC_Tsen_Init(ADC_TSEN_MOD_INTERNAL_DIODE);
|
||||
ADC_FIFO_Cfg(&adcFifoCfg);
|
||||
|
||||
// Fetch the offset
|
||||
BL_Err_Type rc = ADC_Trim_TSEN(&tsen_offset);
|
||||
|
||||
// Must wait 100 milliseconds or returned temperature will be negative
|
||||
rtos_delay_milliseconds(100);
|
||||
}
|
||||
// Read the temperature based on the offset
|
||||
val = TSEN_Get_Temp(tsen_offset);
|
||||
if (log_flag) {
|
||||
printf("offset = %d\r\n", tsen_offset);
|
||||
printf("temperature = %f Celsius\r\n", val);
|
||||
}
|
||||
// Return the temperature
|
||||
*temp = val;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned char hexdigit(char hex) {
|
||||
@ -818,27 +756,11 @@ int http_fn_index(http_request_t* request) {
|
||||
|
||||
// display temperature - thanks to giedriuslt
|
||||
// only in Normal mode, and if boot is not failing
|
||||
if(!bSafeMode && g_bootFailures <= 1)
|
||||
{
|
||||
#if PLATFORM_BEKEN
|
||||
UINT32 temperature;
|
||||
temp_single_get_current_temperature(&temperature);
|
||||
hprintf255(request, "<h5>Internal temperature: %.1f°C</h5>",
|
||||
temperature/10.0f);
|
||||
#elif PLATFORM_BL602
|
||||
float wifi_temperature;
|
||||
get_tsen_adc(&wifi_temperature, 0);
|
||||
hprintf255(request, "<h5>Internal Temperature: %.1f°C</h5>",
|
||||
wifi_temperature);
|
||||
#elif PLATFORM_LN882H
|
||||
// Quick hack to display LN-only temperature,
|
||||
// we may improve it in the future
|
||||
extern float g_wifi_temperature;
|
||||
|
||||
hprintf255(request, "<h5>Internal temperature: %.1f°C</h5>",
|
||||
g_wifi_temperature);
|
||||
#if PLATFORM_BK7231T
|
||||
hprintf255(request, "<h5>Internal temperature: [IGNORE IT - yet to be calibrated] %.1f°C</h5>", g_wifi_temperature);
|
||||
#else
|
||||
hprintf255(request, "<h5>Internal temperature: %.1f°C</h5>", g_wifi_temperature);
|
||||
#endif
|
||||
}
|
||||
|
||||
inputName = CFG_GetPingHost();
|
||||
if (inputName && *inputName && CFG_GetPingDisconnectedSecondsToRestart()) {
|
||||
|
||||
Reference in New Issue
Block a user