Apply VSC auto format to the code and indent macros for readability
This commit is contained in:
1 parent
f7ec81ffaa
commit
7f9d8d18da
26 files changed
+4512
-3692
No files matched your search
+32
-23
@@ -30,36 +30,45 @@
|
||||
|
||||
#ifdef ZsensorHCSR501
|
||||
|
||||
void setupHCSR501() {
|
||||
pinMode(HCSR501_PIN, INPUT); // declare HC SR-501 pin as input
|
||||
void setupHCSR501()
|
||||
{
|
||||
pinMode(HCSR501_PIN, INPUT); // declare HC SR-501 pin as input
|
||||
}
|
||||
|
||||
void MeasureHCSR501(){
|
||||
if (millis() > TimeBeforeStartHCSR501) {//let time to init the PIR sensor
|
||||
void MeasureHCSR501()
|
||||
{
|
||||
if (millis() > TimeBeforeStartHCSR501)
|
||||
{ //let time to init the PIR sensor
|
||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(1);
|
||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||
JsonObject& HCSR501data = jsonBuffer.createObject();
|
||||
static int pirState = LOW;
|
||||
int PresenceValue = digitalRead(HCSR501_PIN);
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
JsonObject &HCSR501data = jsonBuffer.createObject();
|
||||
static int pirState = LOW;
|
||||
int PresenceValue = digitalRead(HCSR501_PIN);
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
yield();
|
||||
#endif
|
||||
if (PresenceValue == HIGH) {
|
||||
if (pirState == LOW) {
|
||||
//turned on
|
||||
HCSR501data.set("hcsr501", "true");
|
||||
trc(F("HC SR501 Motion started"));
|
||||
pirState = HIGH;
|
||||
}
|
||||
} else {
|
||||
if (pirState == HIGH){
|
||||
// turned off
|
||||
HCSR501data.set("hcsr501", "false");
|
||||
trc(F("HC SR501 Motion ended"));
|
||||
pirState = LOW;
|
||||
#endif
|
||||
if (PresenceValue == HIGH)
|
||||
{
|
||||
if (pirState == LOW)
|
||||
{
|
||||
//turned on
|
||||
HCSR501data.set("hcsr501", "true");
|
||||
trc(F("HC SR501 Motion started"));
|
||||
pirState = HIGH;
|
||||
}
|
||||
}
|
||||
if(HCSR501data.size()>0) pub(subjectHCSR501toMQTT,HCSR501data);
|
||||
else
|
||||
{
|
||||
if (pirState == HIGH)
|
||||
{
|
||||
// turned off
|
||||
HCSR501data.set("hcsr501", "false");
|
||||
trc(F("HC SR501 Motion ended"));
|
||||
pirState = LOW;
|
||||
}
|
||||
}
|
||||
if (HCSR501data.size() > 0)
|
||||
pub(subjectHCSR501toMQTT, HCSR501data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user