Fix Calibration Routines

This commit is contained in:
seiichiro 2021-03-31 20:15:13 +02:00
parent c455a7c7a7
commit b02df7d69b
9 changed files with 15 additions and 5 deletions

View file

@ -40,8 +40,8 @@ class AttSensor {
// Return the number of Bytes added to the Payload
virtual uint8_t numBytes(void) = 0;
// Calibrate a Sensor. Needs to be Implemented in the Child Class if supported
void calibrate(void) {};
// Calibrate a Sensor. Needs to be Implemented in the Child Class
virtual void calibrate(void) = 0;
// Helper Functions to Put Values Into the Payload Array
static void int32ToPayload(int32_t value, char *payload, uint8_t startbyte) {

View file

@ -33,6 +33,7 @@ private:
public:
BME280(void);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void) {getCalData();};
uint8_t numBytes(void) {return 12;};
};

View file

@ -50,6 +50,7 @@ class DS18B20 : public AttSensor {
public:
DS18B20(uint8_t owpin, uint8_t resbits = 12, bool para = false);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void);
uint8_t numBytes(void);
};

View file

@ -85,7 +85,7 @@ uint8_t SCD30::getSensorData(char *payload, uint8_t startbyte) {
}
// Calibrate the Sensor to 400ppm (Outside Level)
void SCD30::calibrate() {
void SCD30::calibrate(void) {
sendCmd(SCD30_SET_RECALIB, 400);
}

View file

@ -61,9 +61,10 @@ class SCD30 : public AttSensor {
SCD30();
SCD30(uint8_t interval, bool selfcalib);
void initialize(void);
void calibrate(void);
uint8_t numBytes(void) {return 6;};
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate();
};
#endif

View file

@ -43,6 +43,7 @@ class SENSAIRS8 : public AttSensor {
public:
SENSAIRS8(void);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void) {};
uint8_t numBytes(void) {return 2;};
};

View file

@ -49,6 +49,7 @@ class SG112A : public AttSensor {
public:
SG112A(void);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void) {};
uint8_t numBytes(void) {return 2;};
};

View file

@ -44,6 +44,7 @@ class SHT21 : public AttSensor {
public:
SHT21(void);
uint8_t getSensorData(char *payload, uint8_t startbyte);
void calibrate(void) {};
void initialize(void) {};
uint8_t numBytes(void) {return 8;};
};

View file

@ -149,6 +149,7 @@ void onEvent(ev_t ev) {
case EV_JOINED:
// Disable LinkCheck
LMIC_setLinkCheckMode(0);
BLINK_LED(2);
WS2812B_BLINK(1,0,127,0,1000);
DEBUG_PRINTLN("OTAA Join Succeeded");
break;
@ -172,7 +173,7 @@ void onEvent(ev_t ev) {
for (uint16_t i = 0; i < sleep_time*2; i++) {
// Cancel sleep Cycle if Button was Pressed
#ifdef BTN_PIN
if (btn_pressed) {
if (btn_pressed && digitalRead(BTN_PIN) == HIGH) {
i = sleep_time*2;
btn_pressed = 0;
} else {
@ -370,8 +371,11 @@ void loop()
unsigned long loop_millis = millis();
if ((unsigned long)(loop_millis - btn_millis) >= 4000) {
WS2812B_SETLED(1,153,0,153);
BLINK_LED(3);
delay(1000);
for (uint8_t i=0; i<NUM_SENSORS; i++)
sensors[i]->calibrate();
BLINK_LED(1);
WS2812B_SETLED(1,0,0,0);
} else {
delay(500);