This commit is contained in:
2024-01-26 12:10:20 +01:00
parent 19ca511a53
commit 956e9fc41a

View File

@ -64,7 +64,7 @@ uint8_t appPort = 2;
*/
uint8_t confirmedNbTrials = 4;
typedef enum { off_e, red_e, green_e, yellow_e, blue_e } color_t;
typedef enum { off_e, red_e, green_e, yellow_e, blue_e, white_e } color_t;
static void led(color_t color) {
switch (color) {
@ -83,6 +83,9 @@ static void led(color_t color) {
case blue_e:
pixels.setPixelColor(0, pixels.Color(0,0,50));
break;
case white_e:
pixels.setPixelColor(0, pixels.Color(255,255,255));
break;
}
pixels.show();
}
@ -127,6 +130,9 @@ static void prepareTxFrame( uint8_t port )
*the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h".
*/
led(white_e);
struct __attribute__((__packed__)) {
uint8_t status;
int32_t co2con;
@ -177,7 +183,6 @@ static void prepareTxFrame( uint8_t port )
Serial.println(errorMessage);
}
calibrationMode = HIGH;
led(off_e);
} else {
Serial.print("Waiting for calibration: ");
Serial.print(waitTimeForCalibration);
@ -185,13 +190,23 @@ static void prepareTxFrame( uint8_t port )
}
}
#define TONECNTMAX 10
static int toneCnt = TONECNTMAX;
if (calibrationMode == HIGH) {
if (co2con < 1100) {
led(green_e);
toneCnt = TONECNTMAX;
} else if (co2con < 2000) {
led(yellow_e);
if (toneCnt >= TONECNTMAX) {
tone(7, 500, 250);
toneCnt = 0;
}
toneCnt++;
} else {
led(red_e);
tone(7, 1000, 250);
toneCnt = TONECNTMAX;
}
}
@ -226,6 +241,9 @@ void setup() {
led(off_e);
}
pinMode(7, OUTPUT);
tone(7, 1000, 500);
Wire1.begin(41, 42, 10000);
//sensor.begin(Wire, SCD30_I2C_ADDR_61);
sensor.begin(Wire1, 0x61);