Add minuts run
This commit is contained in:
@@ -7,18 +7,16 @@
|
||||
#define MY_DEFAULT_ERR_LED_PIN (4) // Error led pin
|
||||
#define MY_DEFAULT_RX_LED_PIN (5) // Receive led pin
|
||||
#define MY_DEFAULT_TX_LED_PIN (6) // the PCB, on board LED
|
||||
#define MY_DEFAULT_LED_BLINK_PERIOD 100
|
||||
#define BUTT1 2
|
||||
#define BUTT2 3
|
||||
#define TIME_SLEEP 5 //Minutes
|
||||
|
||||
#include <MySensors.h>
|
||||
//#include <Bounce2.h>
|
||||
|
||||
|
||||
// #undef MY_NODE_ID
|
||||
// #define MY_NODE_ID 14
|
||||
int8_t buttWU = MY_WAKE_UP_BY_TIMER;
|
||||
uint16_t workMins = 0;
|
||||
uint32_t minRun;
|
||||
|
||||
void presentation();
|
||||
void sendDataI(MyMessage msg, uint32_t status);
|
||||
@@ -35,6 +33,7 @@ void setup() {
|
||||
analogReference(INTERNAL);
|
||||
pinMode(BUTT1, INPUT_PULLUP);
|
||||
pinMode(BUTT2, INPUT_PULLUP);
|
||||
minRun = 0;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -42,16 +41,21 @@ void loop() {
|
||||
float v = sensorValue * 0.0039561775471698;
|
||||
if(buttWU == digitalPinToInterrupt(BUTT1)){
|
||||
sendDataI(msgLamp1, (uint8_t)1);
|
||||
wait(30);
|
||||
Serial.println(F("Pressed: 1"));
|
||||
sleep(1000);
|
||||
//wait(100);
|
||||
//Serial.println(F("Pressed: 1"));
|
||||
}
|
||||
if(buttWU == digitalPinToInterrupt(BUTT2)){
|
||||
sendDataI(msgLamp2, (uint8_t)1);
|
||||
wait(30);
|
||||
Serial.println(F("Pressed: 2"));
|
||||
sleep(1000);
|
||||
//wait(100);
|
||||
//Serial.println(F("Pressed: 2"));
|
||||
}
|
||||
if(buttWU == MY_WAKE_UP_BY_TIMER){
|
||||
sendDataF(msgVoltage, v);
|
||||
buttWU = sleep(digitalPinToInterrupt(BUTT1), FALLING, digitalPinToInterrupt(BUTT2), FALLING, TIME_SLEEP * 60000);
|
||||
sendDataI(msgMillis, minRun++ * TIME_SLEEP);
|
||||
}
|
||||
buttWU = sleep(digitalPinToInterrupt(BUTT1), FALLING, digitalPinToInterrupt(BUTT2), FALLING, TIME_SLEEP * 60000 - 1000);
|
||||
}
|
||||
|
||||
void presentation()
|
||||
|
||||
Reference in New Issue
Block a user