Skip to content

Commit

Permalink
Remove Green GPIO pin platformio.ini. Add conditionals to include fun…
Browse files Browse the repository at this point in the history
…ctionality at compile time
  • Loading branch information
melkati committed Feb 20, 2024
1 parent 06654e8 commit 621e5f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 14 additions & 4 deletions CO2_Gadget.ino
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ void processPendingCommands() {
}

void initGPIO() {
#ifdef GREEN_PIN
pinMode(GREEN_PIN, OUTPUT);
digitalWrite(GREEN_PIN, LOW);
#endif
pinMode(BLUE_PIN, OUTPUT);
digitalWrite(BLUE_PIN, LOW);
pinMode(RED_PIN, OUTPUT);
Expand All @@ -333,12 +335,14 @@ void initGPIO() {

void outputsRelays() {
if ((!outputsModeRelay) || (co2 == 0)) return; // Don't turn on relays until there is CO2 Data
#ifdef GREEN_PIN
if (co2 >= co2OrangeRange) {
digitalWrite(GREEN_PIN, GREEN_PIN_LOW);
}
if (co2 < co2OrangeRange) {
digitalWrite(GREEN_PIN, GREEN_PIN_HIGH);
}
#endif
if (co2 >= co2OrangeRange) {
digitalWrite(BLUE_PIN, BLUE_PIN_HIGH);
}
Expand All @@ -356,20 +360,26 @@ void outputsRelays() {
void outputsRGBLeds() {
if ((outputsModeRelay) || (co2 == 0)) return; // Don't turn on led until there is CO2 Data
if (co2 > co2RedRange) {
digitalWrite(RED_PIN, RED_PIN_HIGH);
#ifdef GREEN_PIN
digitalWrite(GREEN_PIN, GREEN_PIN_LOW);
#endif
digitalWrite(RED_PIN, RED_PIN_HIGH);
digitalWrite(BLUE_PIN, BLUE_PIN_LOW);
return;
}
if (co2 >= co2OrangeRange) {
digitalWrite(BLUE_PIN, BLUE_PIN_LOW);
#ifdef GREEN_PIN
digitalWrite(GREEN_PIN, GREEN_PIN_HIGH);
#endif
digitalWrite(BLUE_PIN, BLUE_PIN_LOW);
digitalWrite(RED_PIN, RED_PIN_HIGH);
return;
}
#ifdef GREEN_PIN
digitalWrite(GREEN_PIN, GREEN_PIN_HIGH);
digitalWrite(BLUE_PIN, GREEN_PIN_LOW);
digitalWrite(RED_PIN, GREEN_PIN_LOW);
#endif
digitalWrite(BLUE_PIN, BLUE_PIN_LOW);
digitalWrite(RED_PIN, RED_PIN_LOW);
}

void outputsLoop() {
Expand Down
6 changes: 1 addition & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ build_flags =

-D MQTT_BROKER_SERVER="\"192.168.1.145"\"
-D CO2_GADGET_VERSION="\"0.10."\"
-D CO2_GADGET_REV="\"003-development"\"
-D CO2_GADGET_REV="\"005-development"\"
-D CORE_DEBUG_LEVEL=0
-DCACHE_DIR=".pio/build"
-DBUZZER_PIN=2 ; ESP32 pin GPIO13 connected to piezo buzzer
Expand All @@ -76,9 +76,6 @@ build_flags =
-DRED_PIN=33 ; GPIO to go HIGH on red color range
-DRED_PIN_LOW=0
-DRED_PIN_HIGH=1 ; Should the RED_PIN_HIGH go high or low at threshold
-DGREEN_PIN=25 ; GPIO to go HIGH bellow range (goes LOW at orange range)
-DGREEN_PIN_LOW=0
-DGREEN_PIN_HIGH=1 ; Should the GREEN_PIN_HIGH go high or low bellow orange threshold
-DPIN_HYSTERESIS=100 ; Hysteresis PPM to avoid pins going ON and OFF continuously. TODO : Minimum time to switch
-DBUZZER_HYSTERESIS=50 ; Hysteresis PPM to avoid BUZZER ON and OFF
-DWIFI_PRIVACY ; Comment to show WiFi password in serial and the menu (intended for debugging)
Expand Down Expand Up @@ -266,7 +263,6 @@ build_flags =
-UENABLE_PIN ; ENABLE_PIN not supported in T-Display S3
-UENABLE_PIN_HIGH ; ENABLE_PIN not supported in T-Display S3
-DRED_PIN=01 ; GPIO to go HIGH on red color range
-DGREEN_PIN=02 ; GPIO to go HIGH bellow range (goes LOW at orange range)
-DBLUE_PIN=03 ; GPIO to go HIGH on orange color range
-DSUPPORT_TFT
-DLV_LVGL_H_INCLUDE_SIMPLE
Expand Down

0 comments on commit 621e5f2

Please sign in to comment.