@@ -666,24 +666,13 @@ void setup() {
666666 * Camera setup complete; initialise the rest of the hardware.
667667 */
668668
669- // Initialise and set the lamp
670- if (lampVal != -1 ) {
671- ledcSetup (lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
672- if (autoLamp) setLamp (0 ); // set default value
673- else setLamp (lampVal);
674- #if defined(LAMP_PIN)
675- ledcAttachPin (LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
676- #endif
677- } else {
678- Serial.println (" No lamp, or lamp disabled in config" );
679- }
680-
681- // Having got this far; start Wifi and loop until we are connected or have started an AccessPoint
669+ // Start Wifi and loop until we are connected or have started an AccessPoint
682670 while ((WiFi.status () != WL_CONNECTED) && !accesspoint) {
683671 WifiSetup ();
684672 delay (1000 );
685673 }
686674
675+ // Set up OTA
687676 if (otaEnabled) {
688677 // Start OTA once connected
689678 Serial.println (" Setting up OTA" );
@@ -736,7 +725,22 @@ void setup() {
736725 Serial.println (" Time functions disabled" );
737726 }
738727
739- // Now we have a network we can start the two http handlers for the UI and Stream.
728+ // Gather static values used when dumping status; these are slow functions, so just do them once during startup
729+ sketchSize = ESP.getSketchSize ();
730+ sketchSpace = ESP.getFreeSketchSpace ();
731+ sketchMD5 = ESP.getSketchMD5 ();
732+
733+ // Initialise and set the lamp
734+ if (lampVal != -1 ) {
735+ ledcSetup (lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
736+ ledcAttachPin (LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
737+ if (autoLamp) setLamp (0 ); // set default value
738+ else setLamp (lampVal);
739+ } else {
740+ Serial.println (" No lamp, or lamp disabled in config" );
741+ }
742+
743+ // Start the camera server
740744 startCameraServer (httpPort, streamPort);
741745
742746 if (critERR.length () == 0 ) {
@@ -752,16 +756,11 @@ void setup() {
752756 Serial.printf (" \r\n Camera unavailable due to initialisation errors.\r\n\r\n " );
753757 }
754758
755- // Used when dumping status; these are slow functions, so just do them once during startup
756- sketchSize = ESP.getSketchSize ();
757- sketchSpace = ESP.getFreeSketchSpace ();
758- sketchMD5 = ESP.getSketchMD5 ();
759+ // Info line; use for Info messages; eg 'This is a Beta!' warnings, etc. as necesscary
760+ // Serial.print("\r\nThis is the 4.1 beta\r\n");
759761
760762 // As a final init step chomp out the serial buffer in case we have recieved mis-keys or garbage during startup
761763 while (Serial.available ()) Serial.read ();
762-
763- // Info line; use for Info messages; eg 'This is a Beta!' warnings, etc. as necesscary
764- // Serial.print("\r\nThis is the 4.1 beta\r\n");
765764}
766765
767766void loop () {
0 commit comments