Add millis
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#define MY_BAUD_RATE 38400
|
#define MY_BAUD_RATE 38400
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_DEFAULT_LED_BLINK_PERIOD 300
|
#define MY_DEFAULT_LED_BLINK_PERIOD 100
|
||||||
#define MY_WITH_LEDS_BLINKING_INVERSE
|
#define MY_WITH_LEDS_BLINKING_INVERSE
|
||||||
#define MY_DEFAULT_ERR_LED_PIN 2 // Error led pin
|
#define MY_DEFAULT_ERR_LED_PIN 2 // Error led pin
|
||||||
#define MY_DEFAULT_TX_LED_PIN 3 // the PCB, on board LED
|
#define MY_DEFAULT_TX_LED_PIN 3 // the PCB, on board LED
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#define DOWN_LOCK_ID 2
|
#define DOWN_LOCK_ID 2
|
||||||
#define SMALL_LOCK_ID 3
|
#define SMALL_LOCK_ID 3
|
||||||
#define DOOR_ID 4
|
#define DOOR_ID 4
|
||||||
|
#define CUSTOM_ID 5
|
||||||
|
|
||||||
bool bpTop, bpInt, bpDown, bpSmall, bpDoor;
|
bool bpTop, bpInt, bpDown, bpSmall, bpDoor;
|
||||||
|
|
||||||
@@ -35,24 +36,37 @@ MyMessage msgInt(INT_LOCK_ID, V_LOCK_STATUS);
|
|||||||
MyMessage msgDown(DOWN_LOCK_ID, V_LOCK_STATUS);
|
MyMessage msgDown(DOWN_LOCK_ID, V_LOCK_STATUS);
|
||||||
MyMessage msgSmall(SMALL_LOCK_ID, V_LOCK_STATUS);
|
MyMessage msgSmall(SMALL_LOCK_ID, V_LOCK_STATUS);
|
||||||
MyMessage msgDoor(DOOR_ID, V_LOCK_STATUS);
|
MyMessage msgDoor(DOOR_ID, V_LOCK_STATUS);
|
||||||
|
MyMessage msgCust(CUSTOM_ID, V_VAR1);
|
||||||
|
void sendData(MyMessage msg, bool status);
|
||||||
|
|
||||||
void before()
|
void before()
|
||||||
{
|
{
|
||||||
pinMode(TOP_LOCK, INPUT);
|
pinMode(TOP_LOCK, INPUT_PULLUP);
|
||||||
pinMode(INT_LOCK, INPUT);
|
pinMode(INT_LOCK, INPUT_PULLUP);
|
||||||
pinMode(DOWN_LOCK, INPUT);
|
pinMode(DOWN_LOCK, INPUT_PULLUP);
|
||||||
pinMode(SMALL_LOCK, INPUT);
|
pinMode(SMALL_LOCK, INPUT_PULLUP);
|
||||||
|
pinMode(DOOR, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void presentation()
|
void presentation()
|
||||||
{
|
{
|
||||||
// Send the sketch version information to the gateway and Controller
|
// Send the sketch version information to the gateway and Controller
|
||||||
sendSketchInfo("Main Door", "1.0");
|
sendSketchInfo("Main Door", "1.0");
|
||||||
present(0, S_LOCK, "Top");
|
present(TOP_LOCK_ID, S_LOCK, "Top");
|
||||||
present(1, S_LOCK, "Int");
|
present(INT_LOCK_ID, S_LOCK, "Int");
|
||||||
present(2, S_LOCK, "Down");
|
present(DOWN_LOCK_ID, S_LOCK, "Down");
|
||||||
present(3, S_LOCK, "Small");
|
present(SMALL_LOCK_ID, S_LOCK, "Small");
|
||||||
present(4, S_LOCK, "Door");
|
present(DOOR_ID, S_LOCK, "Door");
|
||||||
|
present(CUSTOM_ID, S_CUSTOM);
|
||||||
|
sendData(msgDoor, digitalRead(DOOR));
|
||||||
|
wait(100);
|
||||||
|
sendData(msgTop, digitalRead(TOP_LOCK));
|
||||||
|
wait(100);
|
||||||
|
sendData(msgInt, digitalRead(INT_LOCK));
|
||||||
|
wait(100);
|
||||||
|
sendData(msgDown, digitalRead(DOWN_LOCK));
|
||||||
|
wait(100);
|
||||||
|
sendData(msgSmall, digitalRead(SMALL_LOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@@ -60,6 +74,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
static uint32_t cRun = millis();
|
||||||
bool bTop, bInt, bDown, bSmall, bDoor;
|
bool bTop, bInt, bDown, bSmall, bDoor;
|
||||||
bTop = digitalRead(TOP_LOCK);
|
bTop = digitalRead(TOP_LOCK);
|
||||||
bInt = digitalRead(INT_LOCK);
|
bInt = digitalRead(INT_LOCK);
|
||||||
@@ -86,6 +101,10 @@ void loop() {
|
|||||||
bpDoor = bDoor;
|
bpDoor = bDoor;
|
||||||
sendData(msgDoor, bDoor);
|
sendData(msgDoor, bDoor);
|
||||||
}
|
}
|
||||||
|
if((cRun + 29999) < millis()){
|
||||||
|
cRun = millis();
|
||||||
|
send(msgCust.set(cRun));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendData(MyMessage msg, bool status)
|
void sendData(MyMessage msg, bool status)
|
||||||
|
|||||||
Reference in New Issue
Block a user