|
12 | 12 | * A camera name can now be configured, and wifi details can be stored in an optional |
13 | 13 | * header file to allow easier updated of the repo. |
14 | 14 | * |
15 | | - * The web UI has had minor changes to add the Lamp control when present, I have made the |
| 15 | + * The web UI has had minor changes to add the lamp control when present, I have made the |
16 | 16 | * 'Start Stream' controls more accessible, and add feedback of the camera name/firmware. |
17 | 17 | * |
18 | 18 | * |
19 | 19 | * note: Make sure that you have either selected ESP32 AI Thinker, |
20 | | - * or another board which has PSRAM enabled to use High resolution Modes |
| 20 | + * or another board which has PSRAM enabled to use high resolution camera modes |
21 | 21 | */ |
22 | 22 |
|
23 | 23 | // Select camera board model |
@@ -148,42 +148,54 @@ void setup() { |
148 | 148 | s->set_hmirror(s, 1); |
149 | 149 | #endif |
150 | 150 |
|
| 151 | + // Feedback that hardware init is complete and we are now attempting to connect |
| 152 | + Serial.println(""); |
| 153 | + Serial.print("Connecting to Wifi Netowrk: "); |
| 154 | + Serial.println(ssid); |
| 155 | + flashLED(400); |
| 156 | + delay(100); |
| 157 | + |
151 | 158 | WiFi.begin(ssid, password); |
152 | 159 |
|
153 | | - while (WiFi.status() != WL_CONNECTED) { // Owen, pulse LED for this. |
154 | | - delay(250); |
| 160 | + while (WiFi.status() != WL_CONNECTED) { |
| 161 | + delay(250); // Wait for Wifi to connect. If no wifi the code basically hangs here. |
| 162 | + // It would be good to do something else here as a future enhancement. |
| 163 | + // (eg: go to a captive AP config portal to configure the wifi) |
155 | 164 | } |
156 | 165 |
|
157 | 166 | // feedback that we are connected |
| 167 | + Serial.println(""); |
| 168 | + Serial.println("WiFi connected"); |
158 | 169 | flashLED(200); |
159 | 170 | delay(100); |
160 | 171 | flashLED(200); |
161 | 172 | delay(100); |
162 | 173 | flashLED(200); |
163 | | - |
164 | | - Serial.println(""); |
165 | | - Serial.println("WiFi connected"); |
166 | 174 |
|
| 175 | + // Start the Stream server, and the handler processes for the Web UI. |
167 | 176 | startCameraServer(); |
168 | 177 |
|
169 | 178 | Serial.print("Camera Ready! Use 'http://"); |
170 | 179 | Serial.print(WiFi.localIP()); |
171 | 180 | Serial.println("' to connect"); |
172 | 181 | } |
173 | 182 |
|
| 183 | +// Notification LED |
174 | 184 | void flashLED(int flashtime) |
175 | 185 | { |
176 | | -#ifdef LED_PIN // Notification LED; If we have it; flash it. |
177 | | - digitalWrite(LED_PIN, LED_ON); // On at full power. |
| 186 | +#ifdef LED_PIN // If we have it; flash it. |
| 187 | + digitalWrite(LED_PIN, LED_ON); // On at full power. |
178 | 188 | delay(flashtime); // delay |
179 | | - digitalWrite(LED_PIN, LED_OFF); // turn Off |
| 189 | + digitalWrite(LED_PIN, LED_OFF); // turn Off |
180 | 190 | #else |
181 | | - return; // No notifcation LED, do nothing |
| 191 | + return; // No notifcation LED, do nothing, no delay |
182 | 192 | #endif |
183 | 193 | } |
184 | 194 |
|
185 | 195 |
|
186 | 196 | void loop() { |
187 | | - // put your main code here, to run repeatedly: |
| 197 | + // Just loop forever. |
| 198 | + // The stream and URI handler processes initiated by the startCameraServer() call at the |
| 199 | + // end of setup() will handle the camera and UI processing from now on. |
188 | 200 | delay(10000); |
189 | 201 | } |
0 commit comments