-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stacking.ino
76 lines (71 loc) · 1.91 KB
/
Stacking.ino
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
#define FONT_8x13_FIXED_BOLD
#include <StripDisplay.h>
XBMFont * fontP = &fixedBold_8x13;
#define STRIPLED_GPIO 5
#define BITMAP_W 32
#define BITMAP_H 16
#define STRIPLED_W 32
#define STRIPLED_H 8
// stack two 32x8 panels vertically, 2nd panel reversed
StripLEDPanel panels[] = {
{
0,
0,
0,
STRIPLED_W,
STRIPLED_H,
WRAP_COLUMNS,
ORIGIN_TOP_LEFT
},
{
STRIPLED_W*STRIPLED_H, // LED index 256
0, // x0=0
STRIPLED_H, // y0=8
STRIPLED_W,
STRIPLED_H,
WRAP_COLUMNS,
ORIGIN_BOTTOM_RIGHT
}
};
#define N_PANELS (sizeof(panels) / sizeof(StripLEDPanel))
CRGB leds[STRIPLED_W*STRIPLED_H*N_PANELS];
StripDisplay strip(STRIPLED_GPIO, BITMAP_W, BITMAP_H, leds, panels, N_PANELS);
void setup() {
FastLED.addLeds<NEOPIXEL,STRIPLED_GPIO>(leds, STRIPLED_W*STRIPLED_H*N_PANELS);
strip.setup(fontP);
Serial.begin(9600);
Serial.println(String(STRIPLED_W*STRIPLED_H*N_PANELS) + String(" leds on gpio ") + String(strip.getGpio()));
}
void loop() {
// text display API setup
strip.setFgColor(CRGB(1,1,1));
strip.setBgColor(CRGB(0,0,0));
strip.setText("Hey");
// bitmap level APIs
strip.setPixel(0,0,CRGB(16,0,0));
strip.setPixel(BITMAP_W-1,0,CRGB(0,16,0));
strip.setPixel(0,BITMAP_H-1,CRGB(0,0,16));
strip.setPixel(BITMAP_W-1,BITMAP_H-1,CRGB(8,0,8));
// render text on bitmap
strip.renderText(fontP->getWidth()/2, (BITMAP_H-fontP->getHeight())/2, CRGB(4,2,0));
// display bitmap
strip.displayBitmap();
FastLED.delay(2000);
// text alignment example
strip.setFgColor(CRGB(1,1,1));
// text ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT
for (int align=ALIGN_LEFT; align<=ALIGN_RIGHT; align++) {
strip.setAlignment(align);
strip.displayText();
FastLED.delay(1000);
}
// text scrolling example
strip.setAlignment(ALIGN_LEFT);
strip.setFgColor(CRGB(4,2,0));
strip.setBgColor(CRGB(0,0,1));
strip.setText("Hello, world!");
for (int offset=0; offset<strip.getTextWidth(); offset++) {
strip.displayText(offset);
FastLED.delay(100);
}
}