Light Control Adjustments
This commit is contained in:
@@ -27,6 +27,8 @@ void configSave() {
|
||||
i+=sizeof(invertMotor[0]);
|
||||
EEPROM.put(i,oldBrightness);
|
||||
i+=sizeof(oldBrightness);
|
||||
EEPROM.put(i,oldPWMBrightness);
|
||||
i+=sizeof(oldPWMBrightness);
|
||||
EEPROM.commit();
|
||||
Serial.println("Config Saved");
|
||||
}
|
||||
@@ -47,6 +49,8 @@ void configLoad() {
|
||||
i+=sizeof(invertMotor);
|
||||
EEPROM.get(i,oldBrightness);
|
||||
i+=sizeof(oldBrightness);
|
||||
EEPROM.get(i,oldPWMBrightness);
|
||||
i+=sizeof(oldPWMBrightness);
|
||||
delay(20);
|
||||
Serial.print("Config Loaded | Version "); Serial.println(returnConfigVersion());
|
||||
Serial.print("Stepper: Speed|"); Serial.print(stepperSpeed[2]); Serial.print(" Accel:"); Serial.println(stepperAccel);
|
||||
|
||||
@@ -28,12 +28,35 @@ void lightControl() {
|
||||
if (lightMode == 0) {
|
||||
if (pwmOn == false || pwmBrightness == 0) {
|
||||
pwmBrightnessOut = 0;
|
||||
analogWrite(PWM_PIN,pwmBrightnessOut);
|
||||
}
|
||||
if (pwmOn == true && pwmBrightness != pwmBrightnessOut) {
|
||||
pwmBrightnessOut = pwmBrightness;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (pwmOn == true && pwmBrightness != pwmBrightnessOut) {
|
||||
pwmBrightnessOut = pwmBrightness;
|
||||
analogWrite(PWM_PIN,pwmBrightnessOut);
|
||||
}
|
||||
|
||||
//------LED Strip
|
||||
if (pwmOn == false && pwmBrightness != oldPWMBrightness) { //If brightness is adjusted when light is turned off, turn it on.
|
||||
pwmOn = true;
|
||||
}
|
||||
|
||||
if (pwmOn == true && pwmBrightness == 0) { //If slider is turned to 0, turn off the light button.
|
||||
pwmOn = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (lightMode == 0) {
|
||||
if (pwmBrightness != pwmBrightnessOut) {
|
||||
analogWrite(PWM_PIN,pwmBrightnessOut);
|
||||
//oldBrightness = pwmBrightnessOut;
|
||||
}
|
||||
}
|
||||
|
||||
//------LED Strip
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
//version 2.5.0
|
||||
//Latest tested :
|
||||
const byte configVersion = 1; //This will prevent loading an old config from EEPROM
|
||||
const byte configVersion = 2; //This will prevent loading an old config from EEPROM
|
||||
|
||||
#include <AccelStepper.h>
|
||||
#include <EEPROM.h>
|
||||
@@ -87,6 +87,7 @@ bool pwmOld = false;
|
||||
int oldBrightness = ledBrightness;
|
||||
int pwmBrightness = 0;
|
||||
int pwmBrightnessOut = 0;
|
||||
int oldPWMBrightness = 0;
|
||||
|
||||
|
||||
|
||||
@@ -245,6 +246,7 @@ void loop() {
|
||||
|
||||
|
||||
oldBrightness = ledBrightness;
|
||||
oldPWMBrightness = pwmBrightness;
|
||||
currentDistance = stepper.distanceToGo();
|
||||
checkInvert();
|
||||
ArduinoOTA.handle();
|
||||
@@ -284,12 +286,6 @@ void loop() {
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
if (lightMode == 0) {
|
||||
if (pwmBrightness != oldBrightness) {
|
||||
analogWrite(PWM_PIN,pwmBrightnessOut);
|
||||
oldBrightness = pwmBrightnessOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef stepperNema
|
||||
|
||||
Reference in New Issue
Block a user