Browse Source

Different heart colors for yin/yang

master
The Dod 1 year ago
parent
commit
42a54610c4
1 changed files with 23 additions and 21 deletions
  1. 23
    21
      blinkinlove-materix.ino

+ 23
- 21
blinkinlove-materix.ino View File

@@ -30,23 +30,24 @@ Adafruit_NeoPixel strip(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
30 30
 
31 31
 #include <PGMWrap.h>
32 32
 
33
-int8_p heart0[8 * 4 * 3] PROGMEM = {
34
-  0, 0, 0,    16, 0, 0,    64, 0, 0,    0, 0, 0,    116, 0, 0,    16, 0, 0,    0, 0, 0,    0, 0, 0,
35
-  0, 0, 0,    64, 0, 0,    32, 0, 0,    60, 0, 0,    29, 0, 0,    145, 0, 0,    0, 0, 0,    0, 0, 0,
36
-  0, 0, 0,    0, 0, 0,    125, 1, 1,    48, 0, 0,    126, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0,
37
-  0, 0, 0,    0, 0, 0,    0, 0, 0,    134, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0
33
+int8_p heart0[8 * 4] PROGMEM = {
34
+  0,   16,   64,     0,   116,    16,   0,   0,
35
+  0,   64,   32,    64,    32,   144,   0,   0,
36
+  0,   0,   128,    48,   128,     0,   0,   0,
37
+  0,   0,     0,   128,     0,     0,   0,   0
38 38
 };
39 39
 
40
-int8_p heart1[8 * 4 * 3] PROGMEM = {
41
-  0, 0, 0,    32, 0, 0,    160, 0, 0,    0, 0, 0,    185, 0, 0,    32, 0, 0,    0, 0, 0,   0, 0, 0,
42
-  0, 0, 0,    160, 0, 0,    64, 0, 0,    120, 0, 0,    58, 0, 0,    200, 0, 0,    0, 0, 0,    0, 0, 0,
43
-  0, 0, 0,    0, 0, 0,    190, 1, 1,    96, 0, 0,    190, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0,
44
-  0, 0, 0,    0, 0, 0,    0, 0, 0,    194, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0,    0, 0, 0
40
+int8_p heart1[8 * 4] PROGMEM = {
41
+  0,    32,   160,     0,   160,    32,   0,  0,
42
+  0,   192,    64,   128,    64,   192,   0,   0,
43
+  0,     0,   192,    96,   192,     0,   0,   0,
44
+  0,     0,     0,   192,     0,     0,   0,   0
45 45
 };
46 46
 
47
-void drawImage(int8_p *img) {
47
+void drawImage(int8_p *img, int rscale, int gscale, int bscale) {
48 48
   for (int i = 0; i < 8 * 4; i++) {
49
-    strip.setPixelColor(i, strip.Color(img[i * 3], img[i * 3 + 1], img[i * 3 + 2]));
49
+    int level = img[i];
50
+    strip.setPixelColor(i, strip.Color((level * rscale) / 100, (level * gscale) / 100, (level * bscale) / 100));
50 51
   }
51 52
   strip.show();
52 53
 }
@@ -65,10 +66,10 @@ int current_frame = 0;
65 66
 unsigned long last_flip = 0;
66 67
 
67 68
 #define SCAN_FRAME_DURATION 200
68
-#define SCAN_COMMON_COLOR_YANG strip.Color(16, 32, 64)
69
-#define SCAN_ANIM_COLOR_YANG strip.Color(16, 32, 128)
70
-#define SCAN_COMMON_COLOR_YIN strip.Color(64, 32, 16)
71
-#define SCAN_ANIM_COLOR_YIN strip.Color(128, 32, 16)
69
+#define SCAN_COMMON_COLOR_YANG strip.Color(16, 0, 64)
70
+#define SCAN_ANIM_COLOR_YANG strip.Color(16, 0, 128)
71
+#define SCAN_COMMON_COLOR_YIN strip.Color(64, 0, 16)
72
+#define SCAN_ANIM_COLOR_YIN strip.Color(128, 0, 16)
72 73
 
73 74
 #define NUM_SCAN_ANIM_FRAMES 4
74 75
 
@@ -172,17 +173,18 @@ void checkScanResult(int numResults) {
172 173
 // Show heart animation frame according to rssi)
173 174
 // If scanning: indicate that (animation if no rssi, single pixel otherwise)
174 175
 void animate(int rssi, bool scanning, unsigned long nowmillis) {
176
+  int rscale = is_yang ? 50 : 100, gscale = 0, bscale = is_yang ? 100 : 75;
175 177
   if (rssi) {
176 178
     int duration = constrain(
177 179
                      map(rssi, RSSI_NEAR, RSSI_FAR, DURATION_FAST, DURATION_SLOW),
178 180
                      DURATION_FAST, DURATION_SLOW);
179 181
     if ((nowmillis - last_flip) > duration || nowmillis < last_flip) {
180
-      drawImage(frames[current_frame]);
182
+      drawImage(frames[current_frame], rscale, gscale, bscale);
181 183
       current_frame = (current_frame + 1) % NUM_FRAMES;
182 184
       last_flip = nowmillis;
183 185
     }
184 186
   } else {
185
-    drawImage(heart0);
187
+    drawImage(heart0, rscale, gscale, bscale);
186 188
     current_frame = 0;
187 189
   }
188 190
   if (scanning) {
@@ -212,7 +214,7 @@ void setup()
212 214
   digitalWrite(PSEUDO_GND, LOW);
213 215
 
214 216
   strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
215
-  strip.setBrightness(16); // (max = 255)
217
+  strip.setBrightness(32); // (max = 255)
216 218
   strip.show();            // Turn OFF all pixels ASAP
217 219
 
218 220
   for (int offs = -23 ; offs < 25; offs++) {
@@ -246,8 +248,8 @@ void loop()
246 248
       Serial.println(is_active);
247 249
     }
248 250
     if (!is_active) {
249
-      for (int i = 0; i<NEOPIXEL_COUNT; i++) {
250
-        strip.setPixelColor(i,strip.Color(0,0,0));
251
+      for (int i = 0; i < NEOPIXEL_COUNT; i++) {
252
+        strip.setPixelColor(i, strip.Color(0, 0, 0));
251 253
       }
252 254
       strip.show();
253 255
     }

Loading…
Cancel
Save