Skip to content

Commit 091bead

Browse files
committed
rework xymap
1 parent ce2bff0 commit 091bead

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void loop()
9696
}
9797

9898
// run a fade effect too if the confetti or myConfetti is running:
99-
if (effectList[currentEffect] == confetti or myConfetti) fadeAll(1);
99+
if (effectList[currentEffect] == confetti || effectList[currentEffect] == myConfetti) fadeAll(1);
100100

101101
FastLED.show(); // send the contents of the led memory to the LEDs
102102
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <FastLED.h>
2+
#include "XYmap.h"
3+
4+
CRGB leds[ NUM_LEDS ];
5+
6+
#define LAST_VISIBLE_LED 119
7+
uint16_t XY(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
8+
{
9+
(void)width;
10+
(void)height;
11+
// any out of bounds address maps to the first hidden pixel
12+
if( (x >= kMatrixWidth) || (y >= kMatrixHeight) ) {
13+
return (LAST_VISIBLE_LED + 1);
14+
}
15+
16+
// On the visual left of DiscoBandCamp, wearers right
17+
// +------------------------------------------
18+
// | 10 9 8 7 6 5 4 3 2 1 0
19+
// | . 20 19 18 17 16 15 14 13 12 11
20+
// | . . 29 28 27 26 25 24 23 22 21
21+
// | . . . 37 36 35 34 33 32 31 30
22+
// | . . . . 44 43 42 41 40 39 38
23+
// | . . . . . 50 49 48 47 46 45
24+
// | . . . . . . 55 54 53 52 51
25+
// | . . . . . . . 59 58 57 56
26+
27+
//this is how DiscoBandCamp works
28+
const uint8_t JacketTable[] = {
29+
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 145,
30+
153,60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
31+
120,11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 146,
32+
154,80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 182,
33+
121,127,21, 22, 23, 24, 25, 26, 27, 28, 29, 147,
34+
155,89, 88, 87, 86, 85, 84, 83, 82, 81, 176,183,
35+
122,128,133,30, 31, 32, 33, 34, 35, 36, 37, 148,
36+
156,97, 96, 95, 94, 93, 92, 91, 90, 171,177,184,
37+
123,129,134,135,38, 39, 40, 41, 42, 43, 44, 149,
38+
157,104,103,102,101,100,99, 98, 167,172,178,185,
39+
124,130,134,136,139,45, 46, 47, 48, 49, 50, 150,
40+
158,110,109,108,107,106,105,164,168,173,179,186,
41+
125,131,134,137,140,142,51, 52, 53, 54, 55, 151,
42+
159,115,114,113,112,111,162,165,169,174,180,187,
43+
126,132,134,138,141,143,144,56, 57, 58, 59, 152,
44+
160,119,118,117,116,161,163,166,170,175,181,188,
45+
};
46+
47+
uint8_t i = (y * kMatrixWidth) + x;
48+
uint8_t j = JacketTable[i];
49+
return j;
50+
}
51+
52+
// Instantiate an XYMap object
53+
XYMap myXYMap = XYMap::constructWithUserFunction(kMatrixWidth, kMatrixHeight, XY);

GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,34 @@
2323
// XY(x,y) takes x and y coordinates and returns an LED index number,
2424
// for use like this: leds[ XY(x,y) ] == CRGB::Red;
2525

26+
#ifndef XYMAP_H
27+
#define XYMAP_H
28+
2629
#include <FastLED.h>
2730

31+
// Parameters for width and height
32+
const uint8_t kMatrixWidth = 24;
33+
const uint8_t kMatrixHeight = 8;
34+
const uint8_t kBorderWidth = 2;
35+
36+
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
37+
extern CRGB leds[NUM_LEDS];
38+
39+
// XY Function
40+
uint16_t XY(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
41+
42+
// Declare XYMap
43+
extern XYMap myXYMap;
44+
45+
#endif // XYMAP_H
46+
2847
// Parameters for width and height
2948
const uint8_t kMatrixWidth = 24;
3049
const uint8_t kMatrixHeight = 8;
3150
const uint8_t kBorderWidth = 2; //for swirly
3251

3352
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
34-
CRGB leds[ NUM_LEDS ];
53+
extern CRGB leds[ NUM_LEDS ];
3554

3655
// This function will return the right 'led index number' for
3756
// a given set of X and Y coordinates on DiscoBandCamp

0 commit comments

Comments
 (0)