Compare commits
No commits in common. "ac60546eabe2dd0dc6d6471e29a676ccf98ff266" and "b02df7d69bcc433e7e74a17971e0121c4ee31a51" have entirely different histories.
ac60546eab
...
b02df7d69b
4 changed files with 12 additions and 46 deletions
|
@ -53,7 +53,7 @@ void MHZ19C::calibrate(void) {
|
||||||
digitalWrite(calpin, LOW);
|
digitalWrite(calpin, LOW);
|
||||||
delay(7500);
|
delay(7500);
|
||||||
digitalWrite(calpin, HIGH);
|
digitalWrite(calpin, HIGH);
|
||||||
pinMode(calpin, INPUT_PULLUP);
|
pinMode(PIN_PB4, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t MHZ19C::getSensorData(char * payload, uint8_t startbyte) {
|
uint8_t MHZ19C::getSensorData(char * payload, uint8_t startbyte) {
|
||||||
|
|
|
@ -49,22 +49,6 @@ uint8_t SENSAIRS8::getSensorData(char *payload, uint8_t startbyte) {
|
||||||
return startbyte+2;
|
return startbyte+2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SENSAIRS8::calibrate(void) {
|
|
||||||
pinMode(calpin, OUTPUT);
|
|
||||||
digitalWrite(calpin, LOW);
|
|
||||||
delay(6000);
|
|
||||||
digitalWrite(calpin, HIGH);
|
|
||||||
pinMode(calpin, INPUT_PULLUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SENSAIRS8::initialize(void) {
|
|
||||||
// Disable Auto Background Calibration
|
|
||||||
uint8_t _cmd[8] = {0xFE, 0x06, 0x00, 0x01F, 0x00, 0x00, 0xAC, 0x03};
|
|
||||||
while (Serial.available() > 0) Serial.read();
|
|
||||||
Serial.write(_cmd, 8);
|
|
||||||
Serial.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read a Sensor Response
|
// Read a Sensor Response
|
||||||
uint8_t SENSAIRS8::read() {
|
uint8_t SENSAIRS8::read() {
|
||||||
// Number of returned Bytes
|
// Number of returned Bytes
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
class SENSAIRS8 : public AttSensor {
|
class SENSAIRS8 : public AttSensor {
|
||||||
private:
|
private:
|
||||||
uint8_t buffer[SER_BUF_LEN];
|
uint8_t buffer[SER_BUF_LEN];
|
||||||
pin_size_t calpin = PIN_PB4; // PB4 is the Calibration Pin on the Addon PCB
|
|
||||||
|
|
||||||
uint8_t read();
|
uint8_t read();
|
||||||
void zeroBuffer(void);
|
void zeroBuffer(void);
|
||||||
|
@ -44,8 +43,8 @@ class SENSAIRS8 : public AttSensor {
|
||||||
public:
|
public:
|
||||||
SENSAIRS8(void);
|
SENSAIRS8(void);
|
||||||
uint8_t getSensorData(char *payload, uint8_t startbyte);
|
uint8_t getSensorData(char *payload, uint8_t startbyte);
|
||||||
void calibrate(void);
|
void calibrate(void) {};
|
||||||
void initialize(void);
|
void initialize(void) {};
|
||||||
uint8_t numBytes(void) {return 2;};
|
uint8_t numBytes(void) {return 2;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
35
src/main.cpp
35
src/main.cpp
|
@ -157,32 +157,15 @@ void onEvent(ev_t ev) {
|
||||||
// Check for Downlink
|
// Check for Downlink
|
||||||
DEBUG_PRINTLN("LoRa Packet Sent");
|
DEBUG_PRINTLN("LoRa Packet Sent");
|
||||||
WS2812B_BLINK(1,0,127,0,1000);
|
WS2812B_BLINK(1,0,127,0,1000);
|
||||||
if ((int)LMIC.dataLen > 0) {
|
if ((int)LMIC.dataLen == 2) {
|
||||||
// Check for Downlinks
|
// We got a Packet with the right size - lets assemble it into a uint16_t
|
||||||
// Function based in Ports:
|
DEBUG_PRINTLN("Received Downlink")
|
||||||
// Port 1
|
uint16_t tmpslp = (LMIC.frame[LMIC.dataBeg] << 8) | LMIC.frame[LMIC.dataBeg+1];
|
||||||
// Set Sending Interval
|
DEBUG_PRINT("Setting Sleep Time to: ");
|
||||||
// Port 2
|
DEBUG_PRINTLN(tmpslp);
|
||||||
// Do Calibration
|
sleep_time = tmpslp;
|
||||||
switch((uint8_t)LMIC.frame[LMIC.dataBeg-1]) {
|
EEPROM.put(ADDR_SLP, tmpslp);
|
||||||
case 1:
|
WS2812B_BLINK(1,0,0,127,250);
|
||||||
if ((int)LMIC.dataLen == 2) {
|
|
||||||
// We got a Packet with the right size - lets assemble it into a uint16_t
|
|
||||||
DEBUG_PRINTLN("Received Downlink")
|
|
||||||
uint16_t tmpslp = (LMIC.frame[LMIC.dataBeg] << 8) | LMIC.frame[LMIC.dataBeg+1];
|
|
||||||
DEBUG_PRINT("Setting Sleep Time to: ");
|
|
||||||
DEBUG_PRINTLN(tmpslp);
|
|
||||||
sleep_time = tmpslp;
|
|
||||||
EEPROM.put(ADDR_SLP, tmpslp);
|
|
||||||
WS2812B_BLINK(1,0,0,127,250);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
for (uint8_t i=0; i<NUM_SENSORS; i++)
|
|
||||||
sensors[i]->calibrate();
|
|
||||||
BLINK_LED(3);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Got to sleep for specified Time
|
// Got to sleep for specified Time
|
||||||
|
|
Loading…
Reference in a new issue