Skip to content

Commit 740db4e

Browse files
committed
Fix for LAMP_PIN undefined
1 parent 9c96ded commit 740db4e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

esp32-cam-webserver.ino

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void handleSerial() {
253253

254254
// Notification LED
255255
void flashLED(int flashtime) {
256-
#ifdef LED_PIN // If we have it; flash it.
256+
#if defined(LED_PIN) // If we have it; flash it.
257257
digitalWrite(LED_PIN, LED_ON); // On at full power.
258258
delay(flashtime); // delay
259259
digitalWrite(LED_PIN, LED_OFF); // turn Off
@@ -264,6 +264,7 @@ void flashLED(int flashtime) {
264264

265265
// Lamp Control
266266
void setLamp(int newVal) {
267+
#if defined(LAMP_PIN)
267268
if (newVal != -1) {
268269
// Apply a logarithmic function to the scale.
269270
int brightness = round((pow(2,(1+(newVal*0.02)))-2)/6*pwmMax);
@@ -273,6 +274,7 @@ void setLamp(int newVal) {
273274
Serial.print("%, pwm = ");
274275
Serial.println(brightness);
275276
}
277+
#endif
276278
}
277279

278280
void printLocalTime(bool extraData=false) {
@@ -763,10 +765,12 @@ void setup() {
763765

764766
// Initialise and set the lamp
765767
if (lampVal != -1) {
766-
ledcSetup(lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
767-
ledcAttachPin(LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
768-
if (autoLamp) setLamp(0); // set default value
769-
else setLamp(lampVal);
768+
#if defined(LAMP_PIN)
769+
ledcSetup(lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
770+
ledcAttachPin(LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
771+
if (autoLamp) setLamp(0); // set default value
772+
else setLamp(lampVal);
773+
#endif
770774
} else {
771775
Serial.println("No lamp, or lamp disabled in config");
772776
}

storage.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ void loadPrefs(fs::FS &fs){
9191
sensor_t * s = esp_camera_sensor_get();
9292

9393
// process local settings
94-
lampVal = jsonExtract(prefs, "lamp").toInt();
94+
if (lampVal >= 0) {
95+
int lampValPref = jsonExtract(prefs, "lamp").toInt();
96+
if (lampValPref >= 0) lampVal = lampValPref;
97+
}
9598
minFrameTime = jsonExtract(prefs, "min_frame_time").toInt();
9699
if (jsonExtract(prefs, "autolamp").toInt() == 0) autoLamp = false; else autoLamp = true;
97100
int xclkPref = jsonExtract(prefs, "xclk").toInt();
98-
if (xclkPref != 0) xclk = xclkPref;
101+
if (xclkPref >= 2) xclk = xclkPref;
99102
myRotation = jsonExtract(prefs, "rotate").toInt();
100103

101104
// process camera settings

0 commit comments

Comments
 (0)