36 #include <avr/pgmspace.h>
39 #define SSD1306_ADDR 0x3C
46 #define SLEEP_OFF false
48 #define SSD1306_COMMAND 0x00
49 #define SSD1306_DATA 0xC0
50 #define SSD1306_DATA_CONTINUE 0x40
53 #define SSD1306_128X64 0x40
54 #define H64_MULTIPLEX_RATIO 0x3F
55 #define H64_COM_PINS 0x12
56 #define H64_BUFFER_SIZE 0x0400
57 #define H64_DISPLAY_HEIGHT 0x40
62 #define SSD1306_SET_CONTRAST_CONTROL 0x81
63 #define SSD1306_DISPLAY_ALL_ON_RESUME 0xA4
64 #define SSD1306_DISPLAY_ALL_ON 0xA5
65 #define SSD1306_NORMAL_DISPLAY 0xA6
66 #define SSD1306_INVERT_DISPLAY 0xA7
67 #define SSD1306_DISPLAY_OFF 0xAE
68 #define SSD1306_DISPLAY_ON 0xAF
69 #define SSD1306_NOP 0xE3
71 #define SSD1306_HORIZONTAL_SCROLL_RIGHT 0x26
72 #define SSD1306_HORIZONTAL_SCROLL_LEFT 0x27
73 #define SSD1306_HORIZONTAL_SCROLL_VERTICAL_AND_RIGHT 0x29
74 #define SSD1306_HORIZONTAL_SCROLL_VERTICAL_AND_LEFT 0x2A
75 #define SSD1306_DEACTIVATE_SCROLL 0x2E
76 #define SSD1306_ACTIVATE_SCROLL 0x2F
77 #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
79 #define SSD1306_SET_LOWER_COLUMN 0x00
80 #define SSD1306_SET_HIGHER_COLUMN 0x10
81 #define SSD1306_MEMORY_ADDR_MODE 0x20
82 #define SSD1306_SET_COLUMN_ADDR 0x21
83 #define SSD1306_SET_PAGE_ADDR 0x22
85 #define SSD1306_SET_START_LINE 0x40
86 #define SSD1306_SET_SEGMENT_REMAP 0xA0
87 #define SSD1306_SET_MULTIPLEX_RATIO 0xA8
88 #define SSD1306_COM_SCAN_DIR_INC 0xC0
89 #define SSD1306_COM_SCAN_DIR_DEC 0xC8
90 #define SSD1306_SET_DISPLAY_OFFSET 0xD3
91 #define SSD1306_SET_COM_PINS 0xDA
92 #define SSD1306_CHARGE_PUMP 0x8D
94 #define SSD1306_SET_DISPLAY_CLOCK_DIV_RATIO 0xD5
95 #define SSD1306_SET_PRECHARGE_PERIOD 0xD9
96 #define SSD1306_SET_VCOM_DESELECT 0xDB
98 #define SSD1306_SEND_CMD(x) this->cmd(x);\
105 const uint8_t font[] PROGMEM =
107 0x06, 0x08, 0x20, 0x5f,
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,
110 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,
111 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,
112 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,
113 0x00, 0x23, 0x13, 0x08, 0x64, 0x62,
114 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,
115 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,
116 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,
117 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,
118 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,
119 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,
120 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,
121 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,
122 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
123 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,
125 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,
126 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,
127 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,
128 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,
129 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,
130 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,
131 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,
132 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,
133 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,
134 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,
135 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,
136 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,
137 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
138 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,
139 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,
140 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,
142 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,
143 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,
144 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,
145 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,
146 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,
147 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,
148 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,
149 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,
150 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,
151 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,
152 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,
153 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,
154 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,
155 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,
156 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,
157 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,
159 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,
160 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,
161 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,
162 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,
163 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,
164 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,
165 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,
166 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,
167 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,
168 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,
169 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,
170 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,
171 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,
172 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,
173 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,
174 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,
176 0x00, 0x00, 0x03, 0x05, 0x00, 0x00,
177 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,
178 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,
179 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,
180 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,
181 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,
182 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,
183 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,
184 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,
185 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,
186 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,
187 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,
188 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,
189 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,
190 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,
191 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,
193 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,
194 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,
195 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,
196 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,
197 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,
198 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,
199 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,
200 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,
201 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,
202 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,
203 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,
204 0x00, 0x00, 0x10, 0x7C, 0x82, 0x00,
205 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
206 0x00, 0x00, 0x82, 0x7C, 0x10, 0x00,
207 0x00, 0x00, 0x06, 0x09, 0x09, 0x06
211 const uint8_t repeatBmp[] PROGMEM ={
212 0x00,0x08,0x18,0x3e,0x1a,0x4a,0x42,0x42,0x42,0x42,0x52,0x58,0x7c,0x18,0x10,0x00};
215 const uint8_t playPauseBmp[] PROGMEM ={
216 0x00,0x00,0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,
217 0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0x00,0x00,0xfc,0xfc,0x00,0x00,0x00};
220 const uint8_t fastForwardBmp[] PROGMEM={
221 0x00,0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x00,0x00,
222 0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0x00,0x00};
225 const uint8_t fastRewindBmp[] PROGMEM ={
226 0x00,0x00,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,0x00,
227 0x00,0x00,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00};
230 const uint8_t playBmp[] PROGMEM ={
231 0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x00,0x00,0x00,0x00,0x00,
232 0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0x00,0x00,0x00,0x00,0x00};
235 const uint8_t pauseBmp[] PROGMEM = {
236 0x00,0x00,0x00,0x1f,0x1f,0x1f,0x1f,0x00,0x00,0x1f,0x1f,0x1f,0x1f,0x00,0x00,0x00,
237 0x00,0x00,0x00,0xf8,0xf8,0xf8,0xf8,0x00,0x00,0xf8,0xf8,0xf8,0xf8,0x00,0x00,0x00};
240 const uint8_t stopBmp[] PROGMEM = {
241 0x00,0x00,0x00,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x00,0x00,0x00,
242 0x00,0x00,0x00,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0x00,0x00,0x00};
245 const uint8_t recordBmp[] PROGMEM ={
246 0x00,0x00,0x00,0x03,0x0f,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x0f,0x03,0x00,0x00,0x00,
247 0x00,0x00,0x00,0xc0,0xf0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xf0,0xc0,0x00,0x00,0x00};
250 const uint8_t logoBmp[] PROGMEM ={
251 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
252 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
253 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
254 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
255 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,
256 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
257 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
258 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
259 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3e,0x62,0x42,0x42,
260 0x7c,0x00,0x01,0x3e,0x40,0x00,0x0c,0x4a,0x4a,0x4a,0x6c,0x00,0x00,0x3e,0x40,0x00,
261 0x3e,0x42,0x02,0x07,0x3e,0x40,0x00,0x38,0x68,0x44,0x45,0x47,0x40,0x00,0x00,0x00,
262 0x00,0x1c,0x22,0x42,0x42,0x7c,0x00,0x00,0x1e,0xe2,0x42,0x42,0x7c,0x00,0x00,0x04,
263 0x44,0x44,0x45,0x7e,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
264 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
265 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
266 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
267 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
268 0x03,0x03,0x03,0x83,0x03,0x01,0x00,0x80,0x80,0x80,0x80,0x00,0x03,0x03,0x03,0x03,
269 0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,
270 0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
271 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
272 0x00,0x00,0x00,0x00,0x06,0x1f,0x3f,0x3f,0x7f,0x7f,0x67,0x63,0x73,0x71,0x3c,0x3c,
273 0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x03,0x63,0x7f,0x7f,0x7f,0x7f,0x60,0x03,
274 0x17,0x37,0x77,0x76,0x77,0x7f,0x7f,0x3f,0x1e,0x0f,0x1f,0x3f,0x7f,0x79,0x71,0x77,
275 0xff,0xff,0xff,0xfd,0x80,0x0f,0x1f,0x3f,0x7f,0x79,0x71,0x77,0xff,0xff,0xff,0xfd,
276 0x80,0x03,0x17,0x37,0x77,0x76,0x77,0x7f,0x7f,0x3f,0x1c,0x00,0x30,0x30,0x7f,0x7f,
277 0x7f,0x7f,0x3c,0x00,0x06,0x1f,0x3f,0x3f,0x7f,0x7f,0x67,0x63,0x73,0x71,0x3c,0x3c,
278 0x00,0x23,0x3f,0x7f,0x7f,0x7c,0x30,0x21,0x7f,0x7f,0x7f,0x3e,0x00,0x00,0x00,0x00,
279 0x00,0x00,0x00,0x00,0x38,0x38,0x98,0x8c,0xcc,0xfc,0xfc,0xf8,0xf8,0xf0,0xc0,0x00,
280 0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0x80,0xc0,0xc0,0xc0,0x80,0x80,0x00,0x00,
281 0x80,0xc0,0xc0,0xc0,0xc0,0x80,0x80,0x00,0x00,0x80,0xc0,0xc0,0xc0,0xc0,0x80,0xc0,
282 0xc0,0xc0,0x80,0x80,0x00,0x80,0xc0,0xc0,0xc0,0xc0,0x80,0xc0,0xc0,0xc0,0x80,0x80,
283 0x00,0x00,0x80,0xc0,0xc0,0xc0,0xc0,0x80,0x80,0x00,0x00,0xc0,0xc0,0xf0,0xf0,0xf0,
284 0xe0,0xe0,0xc0,0x00,0x38,0x38,0x98,0x8c,0xcc,0xfc,0xfc,0xf8,0xf8,0xf0,0xc0,0x00,
285 0x00,0xc0,0xc0,0xc0,0xc0,0x80,0x00,0xc0,0xc0,0xc0,0xc0,0x80,0x00,0x00,0x00,0x00,
286 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
287 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
288 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
289 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
290 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
291 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
292 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
300 void drawRect(
int x1,
int y1,
int x2,
int y2,
bool color);
301 void drawImage(
const uint8_t *
string, uint8_t x, uint8_t y, uint8_t width, uint8_t height,
bool invert = 0);
302 void printString(
const uint8_t *
string, uint8_t x, uint8_t y,
bool invert = 0);
303 void*
operator new(
size_t size);
307 void cmd(uint8_t cmd);
308 volatile uint8_t twsr;
309 volatile uint8_t twbr;
310 volatile uint8_t twdr;
311 volatile uint8_t twcr;