update esp32_air_pump/esp32_air_pump_main.h.

修正按键判断错误的bug
master
慕炎 2022-01-13 12:59:24 +00:00 committed by Gitee
parent fc06da73f2
commit e7d210c8cc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 6 additions and 6 deletions

View File

@ -42,12 +42,12 @@ double return_voltage_value(int pin_no)
double ADCVoltage = 0;
double inputVoltage = 0;
double avg = 0;
for (int i = 0; i < 150; i++)
for (int i = 0; i < 50; i++)
{
tmp = tmp + analogRead(pin_no);
}
avg = tmp / 150;
ADCVoltage = ((avg * 3.3) / (4095)) + 0.112;
avg = tmp / 50;
ADCVoltage = ((avg * 3.3) / (4095)) + 0.225;
inputVoltage = ADCVoltage / (R2_VOLTAGE / (R1_VOLTAGE + R2_VOLTAGE)); // formula for calculating voltage in i.e. GND
return inputVoltage;
}
@ -285,7 +285,7 @@ void loop()
if (touch_touched[i]) {
Serial.print(i);
Serial.print(" control touched\t");
running_type = touch_touched_times[i] % 6;
running_type = touch_touched_times[1] % 6;
Serial.println(running_type);
switch (i) {
@ -396,7 +396,7 @@ void TenthSecondsSinceStartTask() //100ms
bool battery_low = 0;
void OnSecond()
{
#if defined(BAT_VOLTAGE_SENSE_PIN) //电池电压检测
#if defined(INPUT_VOLTAGE_SENSE_PIN) //电池电压检测
bat_voltage = return_voltage_value(INPUT_VOLTAGE_SENSE_PIN);
if (bat_voltage < min_voltage && !battery_low) {
battery_low = 1;
@ -594,4 +594,4 @@ void StartWebServer()
{
ESP32Server.begin();
ESP32Server.onNotFound(handleNotFound);//将所有请求导向自己处理的代码
}
}