Browse Source

make led pin a define

Thomas Buck 4 years ago
parent
commit
5a4c6eb48d
1 changed files with 12 additions and 10 deletions
  1. 12
    10
      src/main.cpp

+ 12
- 10
src/main.cpp View File

13
 Influxdb influx(INFLUXDB_HOST, INFLUXDB_PORT);
13
 Influxdb influx(INFLUXDB_HOST, INFLUXDB_PORT);
14
 #endif // ENABLE_DATABASE_WRITES
14
 #endif // ENABLE_DATABASE_WRITES
15
 
15
 
16
+#define BUILTIN_LED_PIN 1
17
+
16
 ESP8266WebServer server(80);
18
 ESP8266WebServer server(80);
17
 ESP8266HTTPUpdateServer updater;
19
 ESP8266HTTPUpdateServer updater;
18
 
20
 
102
 }
104
 }
103
 
105
 
104
 void setup() {
106
 void setup() {
105
-    pinMode(1, OUTPUT);
107
+    pinMode(BUILTIN_LED_PIN, OUTPUT);
106
 
108
 
107
     // Blink LED for init
109
     // Blink LED for init
108
     for (int i = 0; i < 2; i++) {
110
     for (int i = 0; i < 2; i++) {
109
-        digitalWrite(1, LOW); // LED on
111
+        digitalWrite(BUILTIN_LED_PIN, LOW); // LED on
110
         delay(LED_INIT_BLINK_INTERVAL);
112
         delay(LED_INIT_BLINK_INTERVAL);
111
-        digitalWrite(1, HIGH); // LED off
113
+        digitalWrite(BUILTIN_LED_PIN, HIGH); // LED off
112
         delay(LED_INIT_BLINK_INTERVAL);
114
         delay(LED_INIT_BLINK_INTERVAL);
113
     }
115
     }
114
 
116
 
121
     if ((!found_bme) && (!found_sht)) {
123
     if ((!found_bme) && (!found_sht)) {
122
         // no sensor available
124
         // no sensor available
123
         while (1) {
125
         while (1) {
124
-            digitalWrite(1, !digitalRead(1));
126
+            digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
125
             delay(LED_ERROR_BLINK_INTERVAL);
127
             delay(LED_ERROR_BLINK_INTERVAL);
126
         }
128
         }
127
     }
129
     }
137
     WiFi.begin(ssid, password);
139
     WiFi.begin(ssid, password);
138
     while (WiFi.status() != WL_CONNECTED) {
140
     while (WiFi.status() != WL_CONNECTED) {
139
         delay(LED_CONNECT_BLINK_INTERVAL);
141
         delay(LED_CONNECT_BLINK_INTERVAL);
140
-        digitalWrite(1, !digitalRead(1));
142
+        digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
141
     }
143
     }
142
 
144
 
143
 #ifdef ENABLE_DATABASE_WRITES
145
 #ifdef ENABLE_DATABASE_WRITES
173
         boolean success = influx.write(measurement);
175
         boolean success = influx.write(measurement);
174
         if (!success) {
176
         if (!success) {
175
             for (int i = 0; i < 10; i++) {
177
             for (int i = 0; i < 10; i++) {
176
-                digitalWrite(1, LOW); // LED on
178
+                digitalWrite(BUILTIN_LED_PIN, LOW); // LED on
177
                 delay(LED_ERROR_BLINK_INTERVAL);
179
                 delay(LED_ERROR_BLINK_INTERVAL);
178
-                digitalWrite(1, HIGH); // LED off
180
+                digitalWrite(BUILTIN_LED_PIN, HIGH); // LED off
179
                 delay(LED_ERROR_BLINK_INTERVAL);
181
                 delay(LED_ERROR_BLINK_INTERVAL);
180
             }
182
             }
181
         }
183
         }
193
         boolean success = influx.write(measurement);
195
         boolean success = influx.write(measurement);
194
         if (!success) {
196
         if (!success) {
195
             for (int i = 0; i < 10; i++) {
197
             for (int i = 0; i < 10; i++) {
196
-                digitalWrite(1, LOW); // LED on
198
+                digitalWrite(BUILTIN_LED_PIN, LOW); // LED on
197
                 delay(LED_ERROR_BLINK_INTERVAL);
199
                 delay(LED_ERROR_BLINK_INTERVAL);
198
-                digitalWrite(1, HIGH); // LED off
200
+                digitalWrite(BUILTIN_LED_PIN, HIGH); // LED off
199
                 delay(LED_ERROR_BLINK_INTERVAL);
201
                 delay(LED_ERROR_BLINK_INTERVAL);
200
             }
202
             }
201
         }
203
         }
221
 #ifdef ENABLE_LED_HEARTBEAT_BLINK
223
 #ifdef ENABLE_LED_HEARTBEAT_BLINK
222
     if ((time - last_led_blink_time) >= LED_BLINK_INTERVAL) {
224
     if ((time - last_led_blink_time) >= LED_BLINK_INTERVAL) {
223
         last_led_blink_time = time;
225
         last_led_blink_time = time;
224
-        digitalWrite(1, !digitalRead(1));
226
+        digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
225
     }
227
     }
226
 #endif // ENABLE_LED_HEARTBEAT_BLINK
228
 #endif // ENABLE_LED_HEARTBEAT_BLINK
227
 }
229
 }

Loading…
Cancel
Save