Thomas Buck пре 4 година
родитељ
комит
5a4c6eb48d
1 измењених фајлова са 12 додато и 10 уклоњено
  1. 12
    10
      src/main.cpp

+ 12
- 10
src/main.cpp Прегледај датотеку

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

Loading…
Откажи
Сачувај