Light can be turned on via RST button

To turn on the light hold the rst button for 250-500ms, to reset position hold for 2.5+ seconds
This commit is contained in:
mrcory
2019-05-21 14:13:44 -04:00
parent 7b3c22ea53
commit 0443cd92f4
2 changed files with 21 additions and 16 deletions
+14 -13
View File
@@ -1,12 +1,13 @@
//Config stuff
//Set positions 1-4 in steps for stop locations. Scaled is figured for 10 positions between 1 and 4
//Set positions 1-4 in steps for stop locations.
//Scaled is figured for 10 positions between 1 and 4
//Position: 1 2 3 4 Scaled
long shade[5] = {0,20500,41000,61500,0};
long shade[5] = {0,20500,41000,60000,0};
//Speed Settings in Steps/Second
#define stepperSpeed 1000.0 //Max Speed
#define stepperAccel 212.0 //Acceleration Rate
#define stepperSpeed 950.0 //Max Speed
#define stepperAccel 200.0 //Acceleration Rate
int connectTimeout = 100; // How many attempts can we make before giving up on Blynk
#define blynkRtcInterval = 30; //How often to sync the time
@@ -24,18 +25,18 @@ const int eepromSize = 512;
const int stepPerRev = 4096;
//Declare motor pins
#define mtrPin1 D5
#define mtrPin2 D7
#define mtrPin3 D6
#define mtrPin4 D8
#define mtrPin1 D8//D5
#define mtrPin2 D6//D7
#define mtrPin3 D7//D6
#define mtrPin4 D5//D8
//Button Config
#define buttonEnable true //True to enable button controls
#define buttonPin A0 //Analog pin for buttons
//AnalogRead values for buttons
#define upVal 990
#define dnVal 903
#define upVal 964
#define dnVal 875
#define rsVal 1024
#define ANALOGBUTTONS_SAMPLING_INTERVAL 10
@@ -45,15 +46,15 @@ const int stepPerRev = 4096;
#define lightMode 1 //0-PWM 1-FastLED
#define ledPin D1 //Feedback LED
#define alternateFunction false //Enable alternate use of the reset button
int ledBrightness = 2;
int ledButtonBrightness = 50; //Brightness to use when using rst button to turn on light.
int ledBrightness = 2; //Not used yet
//Extra Stuff
#define alternateFunction false //Enable alternate use of the reset button
#define rtcBlynk false
#define cmds true //After setting up positions, cmdArduino can be disabled
+7 -3
View File
@@ -115,6 +115,9 @@ int oldBrightness = ledBrightness;
void resetClick() {
Serial.println("Rst Click");
lightOn = !lightOn;
ledBrightness = ledButtonBrightness;
ledTurn(1);
}
void resetHold() {
@@ -123,10 +126,10 @@ int oldBrightness = ledBrightness;
ledTurn(1);
}
AnalogButtons buttons(buttonPin, INPUT);
AnalogButtons buttons(buttonPin, INPUT,4,30);
Button up = Button(upVal, &upClick, &upHold, 1000, 5000);
Button down = Button(dnVal, &downClick, &downHold, 1000, 5000);
Button rst = Button(rsVal, &resetClick, &resetHold, 1000, 5000);
Button rst = Button(rsVal, &resetClick, &resetHold, 2500, 5000);
#endif
@@ -193,12 +196,13 @@ void setup() {
Serial.print(F("Loaded | Position S|C : ")); Serial.print(savedPosition); Serial.print("|"); Serial.println(stepper.currentPosition());
FastLED.setBrightness(ledBrightness);
FastLED.setDither(1);
}
void loop() {
oldBrightness = ledBrightness;
if (ledFeedback == true) {