update arduino/Betas/RGB_V1.1.1/main/main.ino.

master
慕炎 2022-01-09 08:21:57 +00:00 committed by Gitee
parent bfaec17bf6
commit 13a607e102
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 84 additions and 93 deletions

View File

@ -43,7 +43,7 @@ void OnSecond();
void StartWebServer();
#define ACTIVE_PIN 4 //状态灯
//#define BAT_VOLTAGE_SENSE_PIN 34 //电池电压检测ADC如果旧版PCB无电压检测电路则注释掉此行
#define BAT_VOLTAGE_SENSE_PIN 34 //电池电压检测ADC如果旧版PCB无电压检测电路则注释掉此行
const double R1_VOLTAGE = 68000; //68K
const double R2_VOLTAGE = 10000; //10K
const double min_voltage = 9.5; //电池检测最低电压
@ -827,33 +827,23 @@ void OnSecond()
}
#endif
if (touchDetected[1] > 0) { //检测到触摸中,一秒计数一次,未触摸则清零
touch_touching_time[1]++;
//Serial.print("\nLight1 touching ");
//Serial.println(touch_touching_time[1]);
for (byte i = 0; i < 3; i++) {
if (touchDetected[i] > 0) { //检测到触摸中,一秒计数一次,未触摸则清零
touch_touching_time[i]++;
//长按事件处理
if (touch_touching_time[1] % 2 == 0) { //按住大于2秒关灯或者开灯
touch_STATE[1] = !touch_STATE[1]; //灯光状态反处理
}
switch (i) {
case 0:
}
if (touchDetected[2] > 0) { //检测到触摸中,一秒计数一次,未触摸则清零
touch_touching_time[2]++;
//Serial.print("\nLight2 touching ");
//Serial.println(touch_touching_time[2]);
if (touch_touching_time[2] % 2 == 0) { //按住大于2秒事件处理
break;
case 1:
touch_STATE[i] = !touch_STATE[i]; //灯光状态反处理
break;
case 2:
break;
}
}
if (touchDetected[3] > 0) { //检测到触摸中,一秒计数一次,未触摸则清零
touch_touching_time[3]++;
//Serial.print("\nLight2 touching ");
//Serial.println(touch_touching_time[2]);
if (touch_touching_time[3] % 2 == 0) { //按住大于2秒事件处理
}
}
}
@ -1042,54 +1032,55 @@ void PocessControl(int DeviceType, int DeviceIndex, int Operation, float Operati
{
sprintf(do_commd, "%.2f", Operation2);
//Serial.println(do_commd);
if (DeviceIndex == 0) //期望角度TA
{
switch (DeviceIndex) {
case 0: //期望角度TA
do_TA(do_commd);
} else if (DeviceIndex == 1) //摇摆电压SV
{
break;
case 1: //摇摆电压SV
do_SV(do_commd);
} else if (DeviceIndex == 2) //摇摆角度SA
{
break;
case 2: //摇摆角度SA
do_SA(do_commd);
} else if (DeviceIndex == 3) //速度环P1
{
break;
case 3: //速度环P1
do_vp1(do_commd);
} else if (DeviceIndex == 4) //速度环I1
{
break;
case 4: //速度环I1
do_vi1(do_commd);
} else if (DeviceIndex == 5) //速度环P2
{
break;
case 5: //速度环P2
do_vp2(do_commd);
} else if (DeviceIndex == 6) //速度环I2
{
break;
case 6: //速度环I2
do_vi2(do_commd);
} else if (DeviceIndex == 7) //do_VQ
{
break;
case 7: //do_VQ
do_VQ(do_commd);
} else if (DeviceIndex == 8) //do_VV
{
break;
case 8: //do_VV
do_VV(do_commd);
} else if (DeviceIndex == 77) //TVQ
{
break;
case 77: //TVQ
do_TVQ(do_commd);
if (test_flag == 1)
ReturnString += "打开电机电压测试";
else
ReturnString += "关闭电机电压测试";
} else if (DeviceIndex == 88) //TVV
{
break;
case 88: //TVV
do_TVV(do_commd);
if (test_flag == 2)
ReturnString += "打开电机速度测试";
else
ReturnString += "关闭电机速度测试";
} else if (DeviceIndex == 99) //电机启停
{
break;
case 99: //电机启停
do_MOTOR(do_commd);
if (!Motor_enable_flag)
ReturnString += "电机启动...";
else
ReturnString += "电机停机...";
break;
}
EEPROM.commit();
}