Prep for LED strip support.
This commit is contained in:
@@ -42,8 +42,8 @@ const int stepPerRev = 4096; //Steps needed to make 1 revolution
|
||||
#define buttonPin A0 //Analog pin for buttons
|
||||
|
||||
//AnalogRead values for buttons
|
||||
#define upVal 964
|
||||
#define dnVal 875
|
||||
#define upVal 895
|
||||
#define dnVal 980
|
||||
#define rsVal 1024
|
||||
|
||||
/* The margin that analogButtons uses to determine
|
||||
@@ -57,8 +57,7 @@ const int stepPerRev = 4096; //Steps needed to make 1 revolution
|
||||
#define ANALOGBUTTONS_SAMPLING_INTERVAL 10
|
||||
|
||||
//Feedback for button presses
|
||||
#define lightEnable true //Allow control of LED
|
||||
#define ledPin D4 //Feedback LED
|
||||
#define ledPin D3 //Feedback LED
|
||||
|
||||
/* This will allow control of an accessory light via
|
||||
* PWM or FastLED.
|
||||
@@ -74,7 +73,7 @@ const int stepPerRev = 4096; //Steps needed to make 1 revolution
|
||||
* The data pin for the WS2812 is set in the main ino
|
||||
* around line 31
|
||||
*/
|
||||
int ledBrightness = 2; //Starting brightness
|
||||
int ledBrightness = 0; //Starting brightness
|
||||
int ledButtonBrightness = 50; //Brightness to use when using rst button to turn on light.
|
||||
int pulseMax = 250; //Max brightness for pulse mode. Max 250 or it will loop to near 0
|
||||
//Can be set in Blynk
|
||||
|
||||
@@ -144,7 +144,9 @@ int pulseSpeed = 2;
|
||||
|
||||
|
||||
void setup() {
|
||||
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS);//.setCorrection(TypicalLEDStrip);
|
||||
if (lightMode == 1) { //Use FastLED if selected
|
||||
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS);
|
||||
}
|
||||
|
||||
pinMode(ledPin,OUTPUT);
|
||||
digitalWrite(ledPin,LOW);
|
||||
@@ -193,9 +195,9 @@ void setup() {
|
||||
|
||||
|
||||
Serial.print(F("Loaded | Position S|C : ")); Serial.print(savedPosition); Serial.print("|"); Serial.println(stepper.currentPosition());
|
||||
|
||||
FastLED.setBrightness(ledBrightness);
|
||||
|
||||
if (lightMode == 1) { //Use FastLED if selected
|
||||
FastLED.setBrightness(ledBrightness);
|
||||
}
|
||||
} //END SETUP
|
||||
|
||||
|
||||
@@ -226,12 +228,14 @@ void loop() {
|
||||
}
|
||||
|
||||
lightControl();
|
||||
|
||||
if (ledBrightness != oldBrightness) {
|
||||
FastLED.setBrightness(ledBrightness);
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
if (lightMode == 1) { //Use FastLED if selected
|
||||
if (ledBrightness != oldBrightness) {
|
||||
FastLED.setBrightness(ledBrightness);
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -245,28 +249,31 @@ void loop() {
|
||||
|
||||
void lightControl() {
|
||||
|
||||
if (lightOn == true) {
|
||||
fill_solid(leds,NUM_LEDS,CRGB(currentColor[0],currentColor[1],currentColor[2]));
|
||||
}
|
||||
|
||||
if (lightOn == false && lightOld != lightOn) {
|
||||
fill_solid(leds,NUM_LEDS,CRGB(0,0,0));
|
||||
}
|
||||
lightOld = lightOn;
|
||||
|
||||
static bool _direction = false; //Flag for fade direction
|
||||
|
||||
if (pulse == true) {
|
||||
if (timerFunc(pulseSpeed)) {
|
||||
if (_direction == true) {
|
||||
if (ledBrightness < pulseMax) { ledBrightness+=2; } else {_direction = false;}
|
||||
if (lightMode == 1) { //Use FastLED if selected
|
||||
if (lightOn == true) {
|
||||
fill_solid(leds,NUM_LEDS,CRGB(currentColor[0],currentColor[1],currentColor[2]));
|
||||
}
|
||||
|
||||
if (lightOn == false && lightOld != lightOn) {
|
||||
fill_solid(leds,NUM_LEDS,CRGB(0,0,0));
|
||||
}
|
||||
lightOld = lightOn;
|
||||
|
||||
static bool _direction = false; //Flag for fade direction
|
||||
|
||||
if (pulse == true) {
|
||||
if (timerFunc(pulseSpeed)) {
|
||||
if (_direction == true) {
|
||||
if (ledBrightness < pulseMax) { ledBrightness+=2; } else {_direction = false;}
|
||||
}
|
||||
|
||||
if (_direction == false) {
|
||||
if (ledBrightness > 5) { ledBrightness-=2; } else {_direction = true;}
|
||||
}
|
||||
}
|
||||
|
||||
if (_direction == false) {
|
||||
if (ledBrightness > 5) { ledBrightness-=2; } else {_direction = true;}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------LED Strip
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user