forked from geodaftw/SecKC-Name-Badge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBadgeFinalTemplate.ino
218 lines (189 loc) · 8.79 KB
/
BadgeFinalTemplate.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>
#include "bitmaps.h"
#ifdef ADAFRUIT_HALLOWING
#define TFT_CS D1 // 39 // Hallowing display control pins: chip select
#define TFT_RST D2 // 37 // Display reset
#define TFT_DC D3 // 38 // Display data/command select
#define TFT_BACKLIGHT 7 // Display backlight pin
#else
// For the breakout board, you can use any 2 or 3 pins.
// These pins will also work for the 1.8" TFT shield.
#define TFT_CS D1
#define TFT_RST D2 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC D3
#endif
; // WHAT??!?!
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
//////////////////////////////////////////////////////////
// Print Handle in middle'ish of screen //
//////////////////////////////////////////////////////////
void Handle(){
String handle = "geoda"; // Update this with handle
unsigned int handleLength = handle.length(); // Will be used later to center the handle name
tft.setTextWrap(false);
tft.setCursor(35,72); // Adjust first value (x axis) to align handle in center
tft.setTextSize(2);
tft.setTextColor(ST77XX_BLUE);
tft.println(handle);
}
void setup(void) {
#ifdef ADAFRUIT_HALLOWING
// HalloWing is a special case.
// It uses a ST7735R display just like the
// breakout board, but the orientation and backlight control are different.
tft.initR(INITR_HALLOWING); // Initialize HalloWing-oriented screen
pinMode(TFT_BACKLIGHT, OUTPUT);
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
#else
// OR use this initializer (uncomment) if using a 1.44" TFT:
tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab
#endif
tft.setRotation(2); // Flip screen 180 degrees
tft.fillScreen(ST77XX_BLACK); // Clear Screen Black
}
//////////////////////////////////////////////////////////
// Begin Loop that will be displayed on the screen //
//////////////////////////////////////////////////////////
void loop() {
//////////////////////////////////////////////////////////
// Define Scrolling Text //
//////////////////////////////////////////////////////////
String text1 = " HAKCER ";
String text2 = " Kansas City's Hacker Hive ";
String text3 = " HACK THE PLANET ";
String text4 = " 5ecKC ";
const int width = 15; // width of the marquee display (in characters)
//////////////////////////////////////////////////////////
// Print Handle, then Double font size and set to white //
//////////////////////////////////////////////////////////
Handle();
tft.setTextWrap(false);
tft.setTextSize(2);
tft.setTextColor(ST77XX_WHITE, ST77XX_BLACK); // White on black
//////////////////////////////////////////////////////////
// Draw SecKC Logos on top corners //
//////////////////////////////////////////////////////////
tft.fillRect(0,0,128,64,ST77XX_WHITE); // FIll top half of screen White (to clear)
tft.drawBitmap(0,0,SecKCwhiteBMP, 64,64,ST7735_BLACK); // Print SecKC logo top left
tft.drawBitmap(64,0,SecKCblackBMP,64,64,ST7735_BLACK); // Print SecKC logo top right
//////////////////////////////////////////////////////////
// Scrolling Text1 //
//////////////////////////////////////////////////////////
for (int offset = 0; offset < text1.length(); offset++)
{
//Construct the string to display for this iteration
String t = "";
for (int i = 0; i < width; i++)
t += text1.charAt((offset +i) % text1.length());
// print the string for this iteration
tft.setCursor(0,104);
tft.print(t);
delay(150);
}
//////////////////////////////////////////////////////////
// Flip Flop SecKC Logo on top corners //
//////////////////////////////////////////////////////////
tft.fillRect(0,0,128,64,ST77XX_WHITE); // Fill Top half of screen White (to clear)
tft.drawBitmap(64,0,SecKCwhiteBMP, 64,64,ST7735_BLACK); // x,y,bitmap,xsize,ysize,color
tft.drawBitmap(0,0,SecKCblackBMP,64,64,ST7735_BLACK); // xy,y,bitmap,xsize,ysize,color
//////////////////////////////////////////////////////////
// Scrolling Text2 //
//////////////////////////////////////////////////////////
for (int offset = 0; offset < text2.length(); offset++)
{
//Construct the string to display for this iteration
String t = "";
for (int i = 0; i < width; i++)
t += text2.charAt((offset +i) % text2.length());
// print the string for this iteration
tft.setCursor(0,104);
tft.print(t);
delay(150);
}
//////////////////////////////////////////////////////////
// clear screen and print large black/white seckc logo //
//////////////////////////////////////////////////////////
// Full Screen SecKC - White
tft.fillRect(0,0,128,128,ST77XX_WHITE); // Clear screen White
tft.drawBitmap(0,0,SecKCFullWhite,128,128,ST77XX_BLACK); // Print 128x128 SecKC Image
delay(3000); // Keep image for 3 seconds
// Full Screen SecKC - Black
tft.fillRect(0,0,128,128,ST77XX_WHITE); // Clear screen White
tft.drawBitmap(0,0,SecKCFullBlack,128,128,ST77XX_BLACK); // Print 128x128 SecKC Image
delay(3000); // Keep images for 3 seconds
//////////////////////////////////////////////////////////
// Clear Screen, Add SecKC to top corners, print Handle //
// and prepare for scrolling text //
//////////////////////////////////////////////////////////
tft.fillRect(0,0,128,128,ST77XX_BLACK);
tft.fillRect(0,0,128,64,ST77XX_WHITE); // Fill Top half of screen White (to clear)
tft.drawBitmap(0,0,SecKCwhiteBMP, 64,64,ST7735_BLACK); // x,y,bitmap,xsize,ysize,color
tft.drawBitmap(64,0,SecKCblackBMP,64,64,ST7735_BLACK); // xy,y,bitmap,xsize,ysize,color
Handle(); // Print Handle
tft.setTextWrap(false); //
tft.setTextSize(2); // Double size of Text
tft.setTextColor(ST77XX_WHITE, ST77XX_BLACK); // Change font to White
//////////////////////////////////////////////////////////
// Scrolling Text3 //
//////////////////////////////////////////////////////////
for (int offset = 0; offset < text3.length(); offset++)
{
//Construct the string to display for this iteration
String t = "";
for (int i = 0; i < width; i++)
t += text3.charAt((offset +i) % text3.length());
// print the string for this iteration
tft.setCursor(0,104);
tft.print(t);
delay(150);
}
//////////////////////////////////////////////////////////
// Flip Flop Images and prepare for scrolling text //
//////////////////////////////////////////////////////////
tft.fillRect(0,0,128,64,ST77XX_WHITE); // Fill Top half of screen White (to clear)
tft.drawBitmap(64,0,SecKCwhiteBMP, 64,64,ST7735_BLACK); // x,y,bitmap,xsize,ysize,color
tft.drawBitmap(0,0,SecKCblackBMP,64,64,ST7735_BLACK); // xy,y,bitmap,xsize,ysize,color
//////////////////////////////////////////////////////////
// Scrolling Text 4 //
//////////////////////////////////////////////////////////
for (int offset = 0; offset < text4.length(); offset++)
{
//Construct the string to display for this iteration
String t = "";
for (int i = 0; i < width; i++)
t += text4.charAt((offset +i) % text4.length());
// print the string for this iteration
tft.setCursor(0,104);
tft.print(t);
delay(150);
}
//////////////////////////////////////////////////////////
// end scrolling text. clear screen and display avatar //
//////////////////////////////////////////////////////////
// Clear Screen
tft.fillRect(0,0,128,128,ST77XX_WHITE);
// Display Avatar Image
// Update h and w for size of avatar
int h = 128,w = 91, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
// If needed, add "+X" to col or row to center avatar if less than 128 in size
tft.drawPixel(col+18, row, pgm_read_word(Avatar + buffidx));
buffidx++;
} // end pixel
}
delay(10000); // Keep Avatar up for 10 seconds
//////////////////////////////////////////////////////////
// end avatar. clear screen and prepare to start over //
// Clear Screen //
//////////////////////////////////////////////////////////
tft.fillRect(0,0,128,128,ST77XX_BLACK); // Clear Screen Black
Handle(); // Print hacker handle in Middle blue
}