Fix for LAMP_PIN undefined

This commit is contained in:
Owen
2022-03-11 12:01:23 +01:00
parent 9c96ded688
commit 740db4ea54
2 changed files with 14 additions and 7 deletions

View File

@ -253,7 +253,7 @@ void handleSerial() {
// Notification LED
void flashLED(int flashtime) {
#ifdef LED_PIN // If we have it; flash it.
#if defined(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
@ -264,6 +264,7 @@ void flashLED(int flashtime) {
// Lamp Control
void setLamp(int newVal) {
#if defined(LAMP_PIN)
if (newVal != -1) {
// Apply a logarithmic function to the scale.
int brightness = round((pow(2,(1+(newVal*0.02)))-2)/6*pwmMax);
@ -273,6 +274,7 @@ void setLamp(int newVal) {
Serial.print("%, pwm = ");
Serial.println(brightness);
}
#endif
}
void printLocalTime(bool extraData=false) {
@ -763,10 +765,12 @@ void setup() {
// Initialise and set the lamp
if (lampVal != -1) {
ledcSetup(lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
ledcAttachPin(LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
if (autoLamp) setLamp(0); // set default value
else setLamp(lampVal);
#if defined(LAMP_PIN)
ledcSetup(lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
ledcAttachPin(LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
if (autoLamp) setLamp(0); // set default value
else setLamp(lampVal);
#endif
} else {
Serial.println("No lamp, or lamp disabled in config");
}

View File

@ -91,11 +91,14 @@ void loadPrefs(fs::FS &fs){
sensor_t * s = esp_camera_sensor_get();
// process local settings
lampVal = jsonExtract(prefs, "lamp").toInt();
if (lampVal >= 0) {
int lampValPref = jsonExtract(prefs, "lamp").toInt();
if (lampValPref >= 0) lampVal = lampValPref;
}
minFrameTime = jsonExtract(prefs, "min_frame_time").toInt();
if (jsonExtract(prefs, "autolamp").toInt() == 0) autoLamp = false; else autoLamp = true;
int xclkPref = jsonExtract(prefs, "xclk").toInt();
if (xclkPref != 0) xclk = xclkPref;
if (xclkPref >= 2) xclk = xclkPref;
myRotation = jsonExtract(prefs, "rotate").toInt();
// process camera settings