-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper.pde
167 lines (113 loc) · 4.11 KB
/
mapper.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//build a map of ledPos[logical led positions] = map of led positions on canvas
void mapper() {
int internalX = 0;
int internalY = 0;
// hardcode examples
int ledStripNo = 0;
for (int i = 5; i < canvasH; i+=(canvasH)/ledsH) {
internalX = i;
internalY = 5;//starting point on canvas
for (int x = 0; x < ledsW; x++) {//start and number of pixels on strip
//v strip #
ledPos[xyPixels(x, ledStripNo, ledsW)] = xyPixels(internalX, internalY, canvasW);
//internalX++;//direction
internalX++;
}
ledStripNo++;
}
internalX = 1;
internalY = 10;//starting point on canvas
for (int x = 0; x < ledsW; x++) {//start and number of pixels on strip
//v strip #
ledPos[xyPixels(x, 0, ledsW)] = xyPixels(internalX, internalY, canvasW);
//internalX++;//direction
internalX++;
}
internalX = 1;
internalY = 15;//starting point on canvas
for (int x = 0; x < ledsW; x++) {//start and number of pixels on strip
//v strip #
ledPos[xyPixels(x, 1, ledsW)] = xyPixels(internalX, internalY, canvasW);
//internalX++;//direction
internalX++;
}
internalX = 1;
internalY = 20;//starting point on canvas
for (int x = 115; x < ledsW; x++) {//start and number of pixels on strip
//v strip #
ledPos[xyPixels(x, 2, ledsW)] = xyPixels(internalX, internalY, canvasW);
//internalX++;//direction
internalX++;
}
internalX = 1;
internalY = 25;//starting point on canvas
for (int x = 0; x < ledsW; x++) {//start and number of pixels on strip
//v strip #
ledPos[xyPixels(x, 3, ledsW)] = xyPixels(internalX, internalY, canvasW);
//internalX++;//direction
internalX++;
}
}
int xyPixels(int x, int y, int yScale) {
return(x+(y*yScale));
}
int xPixels(int pxN, int yScale) {
return(pxN % yScale);
}
int yPixels(int pxN, int yScale) {
return(pxN / yScale);
}
void setupPixelPusher() {
ledPos = new int[ledsW*ledsH]; //create array of positions of leds on canvas
mapper();
registry = new DeviceRegistry();
testObserver = new TestObserver();
registry.addObserver(testObserver);
background(0);
}
void drawPixelPusher() {
loadPixels();
// Pixel blackP = new Pixel((byte)0, (byte)0, (byte)0);
if (testObserver.hasStrips) {
registry.startPushing();
List<Strip> strips = registry.getStrips( );
// List<Strip> strips1 = registry.getStrips(1);
// strips1.addAll(registry.getStrips(2));
// strips1.addAll(registry.getStrips(3));
//List<Strip> strips2 = registry.getStrips(2);
colorMode(HSB, 255);
for (int y = 0; y < ledsH; y++) {
for (int x = 0; x < ledsW; x++) {
thisLedPos = ledPos[xyPixels(x, y, ledsW)];
// int lX = xPixels(thisLedPos, ledsW);
// int lY = yPixels(thisLedPos, ledsW);
// pixels[xyPixels(x,y,canvasW)] = color(r, g, b);
color c = pixels[thisLedPos];
/*
c = color(hue(c), saturation(c), brightness(c) - dimmer1);
if (y >= 0 && y <= 23) //bookshelves
c = color(hue(c), saturation(c), brightness(c) - dimmer2);
if (y >= 24 && y <= 38) //glass shelves
c = color(hue(c), saturation(c), brightness(c) - dimmer3);
if (y >= 48 && y <= 53) //banquettes
c = color(hue(c), saturation(c), brightness(c) - dimmer4);
if (y >= 54 && y <= 71) //soffit
c = color(hue(c), saturation(c), brightness(c) - dimmer6);
if ((y >= 72 && y <= 78) || y == 83) //vip shelves, soffit
c = color(hue(c), saturation(c), brightness(c) - dimmer5);
if (y >= 80 && y <= 88) //vip bar
c = color(hue(c), saturation(c), brightness(c) - dimmer5);
*/
Pixel p = new Pixel((byte)red(c), (byte)green(c), (byte)blue(c));
if (y < strips.size()) {
//if (y < strips1.size() && y!=34) {
//if (y < strips1.size() && y==65) {
strips.get(y).setPixel(p, x);
}
//if (y < strips2.size()) {
// strips2.get(y).setPixel(blackP, x);
//}
}
}
}
}