added short distance warning + increased priority of heavy warning
This commit is contained in:
@@ -14,8 +14,8 @@ board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
#; upload_port = COM[6]
|
||||
#upload_protocol = espota
|
||||
upload_port = 192.168.2.92
|
||||
; upload_protocol = espota
|
||||
upload_port = 192.168.2.136
|
||||
;board_build.partitions = huge_app.csv
|
||||
board_build.partitions = min_spiffs.csv
|
||||
|
||||
|
||||
32
src/main.cpp
32
src/main.cpp
@@ -56,6 +56,7 @@ class MyServerCallbacks : public BLEServerCallbacks {
|
||||
uint8_t alarmFired_1km = 0;
|
||||
uint8_t alarmFired_500m = 0;
|
||||
uint8_t alarmFired_300m = 0;
|
||||
uint8_t alarmFired_100m = 0;
|
||||
int state = 0;
|
||||
class MyAlarmCallback : public BLECharacteristicCallbacks {
|
||||
void onWrite(BLECharacteristic * pCharacteristic) {
|
||||
@@ -76,6 +77,11 @@ class MyAlarmCallback : public BLECharacteristicCallbacks {
|
||||
alarmFired_300m = 1;
|
||||
state = 0;
|
||||
}
|
||||
else if (value.compare("XXXX") == 0) {
|
||||
Serial.println("found XXXX");
|
||||
alarmFired_100m = 1;
|
||||
state = 0;
|
||||
}
|
||||
else if (value.compare("U") == 0) {
|
||||
// reboot in WifiMode
|
||||
Serial.println("Found U");
|
||||
@@ -252,8 +258,14 @@ void loop() {
|
||||
}
|
||||
state++;
|
||||
#else
|
||||
if (alarmFired_1km) {
|
||||
if (state % 4 == 0) {
|
||||
if (alarmFired_100m) {
|
||||
// if (state % 2 == 0) {
|
||||
stateLED = togglePin(ALARM_LED, stateLED);
|
||||
// }
|
||||
state++;
|
||||
}
|
||||
else if (alarmFired_300m) {
|
||||
if (state % 2 == 0) {
|
||||
stateLED = togglePin(ALARM_LED, stateLED);
|
||||
}
|
||||
state++;
|
||||
@@ -264,12 +276,13 @@ void loop() {
|
||||
}
|
||||
state++;
|
||||
}
|
||||
else if (alarmFired_300m) {
|
||||
if (state % 2 == 0) {
|
||||
else if (alarmFired_1km) {
|
||||
if (state % 4 == 0) {
|
||||
stateLED = togglePin(ALARM_LED, stateLED);
|
||||
}
|
||||
state++;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (state == 50) {
|
||||
state = 0;
|
||||
@@ -281,6 +294,7 @@ void loop() {
|
||||
alarmFired_1km = 0;
|
||||
alarmFired_500m = 0;
|
||||
alarmFired_300m = 0;
|
||||
alarmFired_100m = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +305,7 @@ void loop() {
|
||||
// value++;
|
||||
delay(10); // bluetooth stack will go into congestion, if too many packets are sent, in
|
||||
// 6 hours test i was able to go as low as 3ms
|
||||
|
||||
}
|
||||
// disconnecting
|
||||
if (!deviceConnected && oldDeviceConnected) {
|
||||
@@ -304,6 +319,15 @@ void loop() {
|
||||
if (deviceConnected && !oldDeviceConnected) {
|
||||
// do stuff here on connecting
|
||||
oldDeviceConnected = deviceConnected;
|
||||
|
||||
digitalWrite(ALARM_LED, HIGH);
|
||||
delay(200);
|
||||
digitalWrite(ALARM_LED, LOW);
|
||||
delay(200);
|
||||
digitalWrite(ALARM_LED, HIGH);
|
||||
delay(200);
|
||||
digitalWrite(ALARM_LED, LOW);
|
||||
|
||||
}
|
||||
|
||||
// delay(500);
|
||||
|
||||
Reference in New Issue
Block a user