-
Notifications
You must be signed in to change notification settings - Fork 7
/
emote.py
186 lines (175 loc) · 5.63 KB
/
emote.py
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
## Some canned emotes that you might find interesting.
import dcfurs
import badge
from random import choice
## Tall font for emotes
font7bit = {
'!':bytearray([0x2f]),
'"':bytearray([0x06,0x00,0x06]),
'#':bytearray([0x14,0x3e,0x14,0x3e,0x14]),
'$':bytearray([0x04,0x2a,0x6b,0x2a,0x10]),
'%':bytearray([0x26,0x16,0x08,0x34,0x32]),
'&':bytearray([0x16,0x29,0x29,0x10,0x28]),
'\'':bytearray([0x06]),
'(':bytearray([0x1e,0x21]),
')':bytearray([0x21,0x1e]),
'*':bytearray([0x08,0x1c,0x08]),
'+':bytearray([0x08,0x08,0x3e,0x08,0x08]),
',':bytearray([0x10,0x30]),
'-':bytearray([0x08,0x08,0x08]),
'.':bytearray([0x10]),
'/':bytearray([0x20,0x10,0x08,0x04,0x02]),
'0':bytearray([0x1e,0x21,0x21,0x1e]),
'1':bytearray([0x22,0x3f,0x20]),
'2':bytearray([0x32,0x29,0x29,0x26]),
'3':bytearray([0x12,0x21,0x25,0x1a]),
'4':bytearray([0x0e,0x08,0x08,0x3f]),
'5':bytearray([0x13,0x25,0x25,0x19]),
'6':bytearray([0x1e,0x25,0x25,0x18]),
'7':bytearray([0x01,0x31,0x0d,0x03]),
'8':bytearray([0x1a,0x25,0x25,0x1a]),
'9':bytearray([0x06,0x29,0x29,0x1e]),
':':bytearray([0x14]),
';':bytearray([0x34]),
'<':bytearray([0x08,0x14,0x22,0x00]),
'=':bytearray([0x14,0x14,0x14,0x14]),
'>':bytearray([0x00,0x22,0x14,0x08]),
'?':bytearray([0x02,0x01,0x29,0x09,0x06]),
'@':bytearray([0x1c,0x42,0x59,0x15,0x3d,0x22,0x1c]),
'A':bytearray([0x3e,0x09,0x09,0x3e]),
'B':bytearray([0x3f,0x25,0x25,0x1a]),
'C':bytearray([0x1e,0x21,0x21,0x12]),
'D':bytearray([0x3f,0x21,0x21,0x1e]),
'E':bytearray([0x3f,0x25,0x25,0x21]),
'F':bytearray([0x3f,0x05,0x05,0x01]),
'G':bytearray([0x1e,0x21,0x29,0x32]),
'H':bytearray([0x3f,0x08,0x08,0x3f]),
'I':bytearray([0x21,0x3f,0x21]),
'J':bytearray([0x11,0x21,0x1f,0x01]),
'K':bytearray([0x3f,0x04,0x0a,0x31]),
'L':bytearray([0x3f,0x20,0x20,0x20]),
'M':bytearray([0x3f,0x02,0x04,0x02,0x3f]),
'N':bytearray([0x3f,0x02,0x04,0x3f]),
'O':bytearray([0x1e,0x21,0x21,0x1e]),
'P':bytearray([0x3f,0x09,0x09,0x06]),
'Q':bytearray([0x1e,0x21,0x31,0x5e]),
'R':bytearray([0x3f,0x09,0x09,0x36]),
'S':bytearray([0x24,0x2a,0x2a,0x12]),
'T':bytearray([0x01,0x01,0x3f,0x01,0x01]),
'U':bytearray([0x1e,0x20,0x20,0x1e]),
'V':bytearray([0x0e,0x10,0x20,0x10,0x0e]),
'W':bytearray([0x1e,0x20,0x18,0x20,0x1e]),
'X':bytearray([0x22,0x14,0x08,0x14,0x22]),
'Y':bytearray([0x03,0x04,0x38,0x04,0x03]),
'Z':bytearray([0x31,0x29,0x25,0x23]),
'[':bytearray([0x3f,0x21]),
'\\':bytearray([0x02,0x04,0x08,0x10,0x20]),
']':bytearray([0x21,0x3f]),
'^':bytearray([0x08,0x04,0x02,0x04,0x08]),
'_':bytearray([0x20,0x20,0x20,0x20,0x20]),
## TODO: `
## TODO: lowercase alphabet
'o':bytearray([0x18,0x24,0x18]),
'{':bytearray([0x08,0x36,0x41]),
'|':bytearray([0x3f]),
'}':bytearray([0x41,0x36,0x08]),
'~':bytearray([0x08,0x04,0x08,0x04]),
}
def owo(color=0xffffff):
dcfurs.set_row(0, 0x1c00e, color)
dcfurs.set_row(1, 0x22011, color)
dcfurs.set_row(2, 0x22851, color)
dcfurs.set_row(3, 0x22b51, color)
dcfurs.set_row(4, 0x22491, color)
dcfurs.set_row(5, 0x22011, color)
dcfurs.set_row(6, 0x1c00e, color)
def boop(color=0xffffff):
dcfurs.set_row(0, 0x0e48e, color)
dcfurs.set_row(1, 0x12b52, color)
dcfurs.set_row(2, 0x12b52, color)
dcfurs.set_row(3, 0x0eb4e, color)
dcfurs.set_row(4, 0x02492, color)
dcfurs.set_row(5, 0x02012, color)
dcfurs.set_row(6, 0x0200e, color)
def beep(color=0xffffff):
dcfurs.set_row(0, 0x0e00e, color)
dcfurs.set_row(1, 0x12492, color)
dcfurs.set_row(2, 0x12b52, color)
dcfurs.set_row(3, 0x0e6ce, color)
dcfurs.set_row(4, 0x02d92, color)
dcfurs.set_row(5, 0x02012, color)
dcfurs.set_row(6, 0x0200e, color)
def awoo(color=0xffffff):
dcfurs.set_row(0, 0x00006, color)
dcfurs.set_row(1, 0x11229, color)
dcfurs.set_row(2, 0x2aa29, color)
dcfurs.set_row(3, 0x2aaaf, color)
dcfurs.set_row(4, 0x11149, color)
dcfurs.set_row(5, 0x00009, color)
dcfurs.set_row(6, 0x00000, color)
## Render an emote from an ascii string
def render(str, color=0xffffff):
## Check for special cases
if str == 'boop':
boop(color)
return
if str == 'owo':
owo(color)
return
if str == 'awoo':
awoo(color)
return
## Otherwise, generate from our character set.
lbits = font7bit[str[0]]
rbits = font7bit[str[-1]]
dcfurs.clear()
## Draw the left character.
column = int((8 - len(lbits))/2)
for colbits in lbits:
for y in range(0, dcfurs.nrows):
if (colbits & (1 << y)) != 0:
dcfurs.set_pix_rgb(column, y, color)
column = column + 1
## Draw the right character.
column = int((28 - len(rbits) + 1)/2)
for colbits in rbits:
for y in range(0, dcfurs.nrows):
if (colbits & (1 << y)) != 0:
dcfurs.set_pix_rgb(column, y, color)
column = column + 1
prebuilt = [
owo,
"\./"
"X.X",
"-.-",
'"."',
"C.C",
"?.?",
"#.#",
"@.@",
"!.!",
"~.^",
"o.o",
"O.o",
"O.O",
">.<",
"=.=",
"9.9",
## c.c
[0x00000, 0x00000, 0x0f03c, 0x01020, 0x01020, 0, 0],
## \\.\\
[0x00000, 0x00000, 0x0a00a, 0x0a00a, 0x14014, 0x14014, 0],
## ` . `
[0x00000, 0x10002, 0x08004, 0, 0, 0, 0],
## u.u
[0x00000, 0x00000, 0x00000, 0x11022, 0x1f03e, 0, 0],
]
## Draw a random emote from prebuilt[]
def random(color=0xffffff):
x = choice(prebuilt)
if type(x) is str:
render(x, color)
elif callable(x):
x(color)
else:
dcfurs.set_frame(x, color)