From f1389eda5d125a3e383343f09cc919ee233b0d6f Mon Sep 17 00:00:00 2001 From: panigrc Date: Mon, 25 Jun 2018 08:17:07 +0200 Subject: [PATCH] Initial commit --- LEDWolke.ino | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 LEDWolke.ino diff --git a/LEDWolke.ino b/LEDWolke.ino new file mode 100644 index 0000000..25a45f1 --- /dev/null +++ b/LEDWolke.ino @@ -0,0 +1,103 @@ +/* + ESP8266 BlinkWithoutDelay by Simon Peter + Blink the blue LED on the ESP-01 module + Based on the Arduino Blink without Delay example + This example code is in the public domain + + The blue LED on the ESP-01 module is connected to GPIO1 + (which is also the TXD pin; so we cannot use Serial.print() at the same time) + + Note that this sketch uses LED_BUILTIN to find the pin with the internal LED +*/ + +class RgbLed { + int ledRedPin; + int ledGreenPin; + int ledBluePin; + + byte ledRedIntensity; + byte ledGreenIntensity; + byte ledBlueIntensity; + + byte ledRedIntensityTo; + byte ledGreenIntensityTo; + byte ledBlueIntensityTo; + + long durationLeft; + long currentMillis; + + public: + RgbLed(int redPin, int greenPin, int bluePin) + { + ledRedPin = redPin; + ledGreenPin = greenPin; + ledBluePin = bluePin; + + pinMode(ledRedPin, OUTPUT); + pinMode(ledGreenPin, OUTPUT); + pinMode(ledBluePin, OUTPUT); + + ledRedIntensity = 0; + ledGreenIntensity = 0; + ledBlueIntensity = 0; + + ledRedIntensityTo = ledRedIntensity; + ledGreenIntensityTo = ledGreenIntensity; + ledBlueIntensityTo = ledBlueIntensity; + + durationLeft = 0; + currentMillis = 0; + } + + public: + void ChangeColor(int redIntesity, int greenIntensity, int blueIntensity, long duration) + { + if (ledRedIntensityTo == ledRedIntensity && ledGreenIntensityTo == ledGreenIntensity && ledBlueIntensityTo == ledBlueIntensity + && ledRedIntensity != redIntesity && ledGreenIntensity != greenIntensity && ledBlueIntensity != blueIntensity) { + durationLeft = duration; + ledRedIntensityTo = ledRedIntensity; + ledGreenIntensityTo = ledGreenIntensity; + ledBlueIntensityTo = ledBlueIntensity; + } + + } + + public: + void Update(long currentMillis) + { + // if(currentMillis - this->currentMillis >= interval) { + // this->currentMillis = currentMillis; + // digitalWrite(led, intensity); + // } + // if (ledRedIntensityTo != ledRedIntensity && ledGreenIntensityTo != ledGreenIntensity && ledBlueIntensityTo != ledBlueIntensity) { + // ledRedIntensity = ; + // ledGreenIntensity = ; + // ledBlueIntensity = ; + // } + } + + byte lerp(byte from, byte to, long t) { + return from + t * (to - from); + } +}; + + +RgbLed ledStripe(5, 4, 0); + +void setup() { +} + +void loop() +{ + ledStripe.ChangeColor(30, 200, 255, 1000); + ledStripe.Update(millis()); +} + + +//void led_blink(int led, byte intensity, long interval) { +// unsigned long currentMillis = millis(); +// if(currentMillis - previousMillis >= interval) { +// previousMillis = currentMillis; +// digitalWrite(led, intensity); +// } +//}