Commit d74a4e84c8a4a2412065abaf2199da7f49634d9f

Authored by Thomas R. Koll
1 parent b9b7a60b4d
Exists in master

Light more pixels and give them a fading trail

Showing 1 changed file with 20 additions and 17 deletions Side-by-side Diff

regal-uhr/regal-uhr.ino
1   - /*
  1 +/*
2 2  
3 3 Clock using NTP on an ESP8266 show the time on a 7-segment display
4 4 and a 60 pixel led strip.
5 5  
6 6  
... ... @@ -37,14 +37,12 @@
37 37  
38 38 Adafruit_7segment matrix = Adafruit_7segment();
39 39  
  40 +// set up led strip
40 41 #include "FastLED.h"
41 42  
42   -// How many leds in your strip?
43   -#define NUM_LEDS 60
44 43 #define FASTLED_ESP8266_RAW_PIN_ORDER
45   -#define DATA_PIN D6
46   -
47   -// Define the array of leds
  44 +#define DATA_PIN D7
  45 +#define NUM_LEDS 60
48 46 CRGB leds[NUM_LEDS];
49 47  
50 48 #define LED_SPEED 10 // steps per second
51 49  
52 50  
... ... @@ -83,21 +81,26 @@
83 81 static int pos = 0;
84 82 static int pos_20 = 20;
85 83 static int pos_40 = 40;
86   - // show leds for second, minute and hour, send them around the strip
87   - setLEDcolor(pos, CHSV(second(local_time) * 4.25, 255, 255), 5);
88   - setLEDcolor(pos_40, CHSV(minute(local_time) * 4.25, 255, 255), 3);
89   - setLEDcolor(pos_20, CHSV(hour(local_time) * 10.625, 255, 255), 2);
90   - FastLED.show();
91 84  
92   - // Only turn off the last LED, the rest was overwritten anyways
93   - leds[pos] = CRGB::Black;
94   - leds[pos_20] = CRGB::Black;
95   - leds[pos_40] = CRGB::Black;
96   - FastLED.show();
  85 + leds[pos].fadeLightBy(190);
  86 + leds[(pos + (NUM_LEDS - 1)) % NUM_LEDS].fadeLightBy(200);
  87 + leds[(pos + (NUM_LEDS - 2)) % NUM_LEDS].fadeLightBy(255);
  88 + leds[pos_20].fadeLightBy(190);
  89 + leds[(pos_20 + (NUM_LEDS - 1)) % NUM_LEDS].fadeLightBy(200);
  90 + leds[(pos_20 + (NUM_LEDS - 2)) % NUM_LEDS].fadeLightBy(255);
  91 + leds[pos_40].fadeLightBy(190);
  92 + leds[(pos_40 + (NUM_LEDS - 1)) % NUM_LEDS].fadeLightBy(200);
  93 + leds[(pos_40 + (NUM_LEDS - 2)) % NUM_LEDS].fadeLightBy(255);
97 94  
98 95 pos = (pos + 1) % NUM_LEDS;
99 96 pos_20 = (pos_20 + 1) % NUM_LEDS;
100 97 pos_40 = (pos_40 + 1) % NUM_LEDS;
  98 +
  99 + // show leds for second, minute and hour, send them around the strip
  100 + setLEDcolor(pos, CHSV(second(local_time) * 4.25, 255, 255), 5);
  101 + setLEDcolor(pos_40, CHSV(minute(local_time) * 4.25, 255, 255), 3);
  102 + setLEDcolor(pos_20, CHSV(hour(local_time) * 10.625, 255, 255), 2);
  103 + FastLED.show();
101 104 }
102 105  
103 106 void loop() {
... ... @@ -112,7 +115,7 @@
112 115  
113 116 static unsigned long next_led_update = 0;
114 117 if (next_led_update < millis()) {
115   - next_led_update = millis() + (LED_SPEED / 1000);
  118 + next_led_update = millis() + (1000 / LED_SPEED);
116 119 displayTimeOnLEDs();
117 120 }
118 121 }