-
Notifications
You must be signed in to change notification settings - Fork 0
/
hackpack-testing.ino
144 lines (118 loc) · 3.7 KB
/
hackpack-testing.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
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
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#define PIN 1
#include "RGB.h"
#define arr_len( x ) ( sizeof( x ) / sizeof( *x ) )
//initialize the matrix
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
void setup() {
matrix.begin();
matrix.setBrightness(30);
matrix.setTextColor( matrix.Color(255, 255, 255) );
matrix.setTextWrap(false);
}
void loop() {/*
crossFade(testgrey, swuorange, 50, 5);
delay(1000);
scrollText("sendwithus", 90);
crossFade(swuorange, testgrey, 50, 5);
delay(1000);
int envelope[8][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 0, 1, 0, 0, 1, 0, 1},
{1, 0, 0, 1, 1, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0, 0}
};
extractFrameMono(swuorange, testgrey, envelope, 4);
delay(1000);
colorWipe(testgrey, 0);
delay(1000);
*/}
void scrollDownMono(RGB color, RGB bgColor, int drawing[][8]){
}
void extractFrameMono(RGB color, RGB bgColor, int drawing[][8], int offset){
int frame[8][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
int anchorRow = arr_len(drawing) -1 - offset;
for(int row = 0; row < 8; row++) {
for(int column = 0; column < 8; column++) {
frame[row][column] = drawing[anchorRow - row][column];
}
}
drawFrameMono( color, bgColor, frame);
}
void drawFrameMono(RGB color, RGB bgColor, int frame[][8]){
for(int row = 0; row < 8; row++) {
for(int column = 0; column < 8; column++) {
if(frame[row][column] == 1) {
matrix.drawPixel(column, row, matrix.Color(color.r, color.g, color.b));
}
else{
matrix.drawPixel(column, row, matrix.Color(bgColor.r, bgColor.g, bgColor.b));
}
}
}
matrix.show();
}
void colorWipe(RGB color, uint8_t wait) {
for(uint16_t row=0; row < 8; row++) {
for(uint16_t column=0; column < 8; column++) {
matrix.drawPixel(column, row, matrix.Color(color.r, color.g, color.b));
matrix.show();
delay(wait);
}
}
}
void fadePixel(int x, int y, RGB startColor, RGB endColor, int steps, int wait) {
for(int i = 0; i <= steps; i++)
{
int newR = startColor.r + (endColor.r - startColor.r) * i / steps;
int newG = startColor.g + (endColor.g - startColor.g) * i / steps;
int newB = startColor.b + (endColor.b - startColor.b) * i / steps;
matrix.drawPixel(x, y, matrix.Color(newR, newG, newB));
matrix.show();
delay(wait);
}
}
void crossFade(RGB startColor, RGB endColor, int steps, int wait) {
for(int i = 0; i <= steps; i++)
{
int newR = startColor.r + (endColor.r - startColor.r) * i / steps;
int newG = startColor.g + (endColor.g - startColor.g) * i / steps;
int newB = startColor.b + (endColor.b - startColor.b) * i / steps;
matrix.fillScreen(matrix.Color(newR, newG, newB));
matrix.show();
delay(wait);
}
}
void scrollText(String textToDisplay, int scrollDelay) {
int x = matrix.width();
// Account for 6 pixel wide characters plus a space
int pixelsInText = textToDisplay.length() * 7;
matrix.setCursor(x, 0);
matrix.print(textToDisplay);
matrix.show();
while(x > (matrix.width() - pixelsInText)) {
matrix.fillScreen(matrix.Color(swuorange.r, swuorange.g, swuorange.b));
matrix.setCursor(--x, 0);
matrix.print(textToDisplay);
matrix.show();
delay(scrollDelay);
}
}