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