mirror of
https://github.com/easytarget/esp32-cam-webserver.git
synced 2024-02-16 18:18:24 +08:00
Move flashLED & setLamp to start of file (#41)
Fix builds on PlatformIO (and other Development Environments too, I suspect)
This commit is contained in:
@ -109,6 +109,29 @@ const int pwmMax = pow(2,pwmresolution)-1;
|
||||
int8_t recognition_enabled = 0;
|
||||
#endif
|
||||
|
||||
// Notification LED
|
||||
void flashLED(int flashtime) {
|
||||
#ifdef LED_PIN // If we have it; flash it.
|
||||
digitalWrite(LED_PIN, LED_ON); // On at full power.
|
||||
delay(flashtime); // delay
|
||||
digitalWrite(LED_PIN, LED_OFF); // turn Off
|
||||
#else
|
||||
return; // No notifcation LED, do nothing, no delay
|
||||
#endif
|
||||
}
|
||||
|
||||
// Lamp Control
|
||||
void setLamp(int newVal) {
|
||||
if (newVal != -1) {
|
||||
// Apply a logarithmic function to the scale.
|
||||
int brightness = round((pow(2,(1+(newVal*0.02)))-2)/6*pwmMax);
|
||||
ledcWrite(lampChannel, brightness);
|
||||
Serial.print("Lamp: ");
|
||||
Serial.print(newVal);
|
||||
Serial.print("%, pwm = ");
|
||||
Serial.println(brightness);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@ -320,30 +343,6 @@ void setup() {
|
||||
Serial.printf("\nCamera Ready!\nUse '%s' to connect\n\n", httpURL);
|
||||
}
|
||||
|
||||
// Notification LED
|
||||
void flashLED(int flashtime) {
|
||||
#ifdef LED_PIN // If we have it; flash it.
|
||||
digitalWrite(LED_PIN, LED_ON); // On at full power.
|
||||
delay(flashtime); // delay
|
||||
digitalWrite(LED_PIN, LED_OFF); // turn Off
|
||||
#else
|
||||
return; // No notifcation LED, do nothing, no delay
|
||||
#endif
|
||||
}
|
||||
|
||||
// Lamp Control
|
||||
void setLamp(int newVal) {
|
||||
if (newVal != -1) {
|
||||
// Apply a logarithmic function to the scale.
|
||||
int brightness = round((pow(2,(1+(newVal*0.02)))-2)/6*pwmMax);
|
||||
ledcWrite(lampChannel, brightness);
|
||||
Serial.print("Lamp: ");
|
||||
Serial.print(newVal);
|
||||
Serial.print("%, pwm = ");
|
||||
Serial.println(brightness);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Just loop forever.
|
||||
// The stream and URI handler processes initiated by the startCameraServer() call at the
|
||||
|
Reference in New Issue
Block a user