forked from yazgoo/minitel_twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cpp
367 lines (297 loc) · 6.81 KB
/
demo.cpp
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#include "Arduino.h"
/*
Yazgoo: I add to patch the w5100 lib with:
http://code.google.com/p/arduino/issues/detail?id=605
Chat Server
A simple server that distributes any incoming messages to all
connected clients. To use telnet to your device's IP address and type.
You can see the client's input in the serial monitor as well.
Using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 10 August 2010
by Tom Igoe
*/
#include <SoftwareSerial.h>
#include "Minitel.cpp"
/*extern "C"
{
void *__dso_handle = NULL;
}
extern "C"
{
void *__cxa_atexit = NULL;
}*/
Minitel* m;
void setup() {
m = new Minitel(6,7);
}
void demoGraphics(boolean underline) {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" GRAPHICS DEMO ", 4, 1);
m->bgColor(BLACK);
m->graphicMode();
m->pixelate(underline);
m->noCursor();
// No color
m->useDefaultColors();
int xPos = 5;
int yPos = 5;
m->moveCursorTo(xPos, yPos);
int x = 32;
for (int i=x; i<x+16; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+2);
for (int i=x+16; i<x+32; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+4);
for (int i=x+32; i<x+48; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+6);
for (int i=x+48; i<x+64; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
// Colored
m->bgColor(RED);
m->textColor(WHITE);
m->moveCursorTo(xPos, yPos+10);
x = 32;
for (int i=x; i<x+16; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+12);
for (int i=x+16; i<x+32; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+14);
for (int i=x+32; i<x+48; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->moveCursorTo(xPos, yPos+16);
for (int i=x+48; i<x+64; i++) {
m->serialprint7(i);
m->serialprint7(9);
}
m->useDefaultColors();
m->noPixelate();
}
void demoColor() {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" COLORS DEMO ", 4, 1);
m->mode(GRAPHIC_MODE);
m->bgColor(RED);
m->rect((byte) m->getGraphicChar("011001"), 4, 4, 33, 20);
for(int i=0; i<18; i++) {
m->moveCursorTo(5, 5+i);
m->textColor(WHITE);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(YELLOW);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(CYAN);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(GREEN);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(BLUE);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(RED);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(MAGENTA);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
m->textColor(BLACK);
m->textByte(m->getGraphicChar("111111"));
m->repeat(3);
}
}
void demoCursor() {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" CURSOR DEMO ", 4, 1);
m->bgColor(BLACK);
m->cursor();
int pause = 1000;
m->moveCursorTo(TOP_LEFT);
delay(pause);
m->moveCursor(RIGHT, 39);
delay(pause);
m->moveCursor(DOWN, 23);
delay(pause);
m->moveCursor(LEFT, 39);
delay(pause);
m->moveCursor(UP, 23);
delay(pause);
m->moveCursor(RIGHT, 19);
delay(pause);
m->moveCursor(DOWN, 12);
delay(pause);
m->moveCursorTo(HOME);
delay(pause);
m->moveCursorTo(TOP_RIGHT);
delay(pause);
m->moveCursorTo(BOTTOM_LEFT);
delay(pause);
m->moveCursorTo(BOTTOM_RIGHT);
delay(pause);
m->moveCursorTo(TOP_LEFT);
delay(pause);
m->moveCursorTo(CENTER);
m->noCursor();
}
void demoCharacters() {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" CHARACTERS DEMO ", 4, 1);
m->bgColor(BLACK);
int xPos = 3;
int yPos = 5;
m->cursor();
// a->z
m->moveCursorTo(xPos, yPos);
for (int i=97; i<97+26; i++) {
m->serialprint7(i);
}
// A->Z
m->moveCursorTo(xPos, yPos+1);
for (int i=65; i<65+26; i++) {
m->serialprint7(i);
}
// 0-9 + punctuation marks, ...
m->moveCursorTo(xPos, yPos+2);
for (int i=33; i<33+32; i++) {
m->serialprint7(i);
}
for (int i=91; i<97; i++) {
m->serialprint7(i);
}
// Colored characters
m->moveCursorTo(xPos, yPos+3);
m->textColor(RED);
for (int i=97; i<97+26; i++) {
m->serialprint7(i);
}
m->textColor(WHITE);
// Double width 1/2
m->moveCursorTo(xPos, yPos+4);
m->charSize(SIZE_DOUBLE_WIDTH);
for (int i=97; i<97+13; i++) {
m->serialprint7(i);
}
m->moveCursorTo(xPos, yPos+5);
for (int i=97+13; i<97+26; i++) {
m->serialprint7(i);
}
m->charSize(SIZE_NORMAL);
// Special characters
m->moveCursorTo(xPos, yPos+6);
byte chars[] = {
SPE_CHAR_BOOK, SPE_CHAR_PARAGRAPH, SPE_CHAR_ARROW_LEFT, SPE_CHAR_ARROW_UP, SPE_CHAR_ARROW_RIGHT, SPE_CHAR_ARROW_DOWN, SPE_CHAR_CIRCLE, SPE_CHAR_MINUS_PLUS, SPE_CHAR_1_4, SPE_CHAR_1_2, SPE_CHAR_3_4, SPE_CHAR_UPPER_OE, SPE_CHAR_LOWER_OE, SPE_CHAR_BETA };
for (unsigned int i=0; i<sizeof(chars); i++) {
m->specialChar(chars[i]);
}
// Blink
m->moveCursorTo(xPos, yPos+7);
m->blink();
for (int i=97; i<97+26; i++) {
m->serialprint7(i);
}
m->noBlink();
// Invert video
m->moveCursorTo(xPos, yPos+8);
m->invertVideo();
for (int i=97; i<97+26; i++) {
m->serialprint7(i);
}
m->standardVideo();
// Transparent
// No effet on Minitel 1
m->moveCursorTo(xPos, yPos+9);
m->transparentVideo();
for (int i=97; i<97+26; i++) {
m->serialprint7(i);
}
m->standardVideo();
}
void demoBip() {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" BIP DEMO ", 4, 1);
m->bgColor(BLACK);
for (int i=0; i<2; i++) {
m->bip(50);
delay(700);
m->bip(5);
delay(500);
m->bip(10);
delay(2000);
}
}
void demoText() {
m->clearScreen();
m->mode(TEXT_MODE);
m->textColor(WHITE);
m->bgColor(RED);
m->text(" TEXT DEMO ", 4, 1);
m->bgColor(BLACK);
m->cursor();
m->text("****************************************", 1, 8);
m->blink();
m->text("CAUTION", 17, 13);
m->noBlink();
m->text("This is a test", 13, 15);
m->text("****************************************", 1, 20);
m->noCursor();
}
void loop() {
long pause = 2000;
demoColor();
delay(pause);
demoGraphics(true);
delay(pause);
demoGraphics(false);
delay(pause);
demoBip();
delay(pause);
demoCursor();
delay(pause);
demoText();
delay(pause);
demoCharacters();
delay(pause);
}
/**
*
* DEMOS
*
*/
// Graphic characters