Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 581 lines (508 sloc) 15.013 kb
81294b5 @solexious Add license, version to 0.1
solexious authored
1 /*
2 Copyright 2010 Charles Yarnold charlesyarnold@gmail.com
f7537e2 @solexious Add initText and change interminator
solexious authored
3
4 NotifyBoard is free software: you can redistribute it and/or modify it under the terms of
5 the GNU General Public License as published by the Free Software Foundation, either
6 version 3 of the License, or (at your option) any later version.
7
8 NotifyBoard is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License along with NotifyBoard.
13 If not, see http://www.gnu.org/licenses/.
14
fd7b638 @marksteward Inexplicable merge conflict
authored
15 */
16
17 /* Includes various minor modifications by London Hackspace, incuding:
18 github.com/jonty
19 github.com/marksteward
20 github.com/samthetechie
21 */
81294b5 @solexious Add license, version to 0.1
solexious authored
22
23 /*
f7537e2 @solexious Add initText and change interminator
solexious authored
24 This sketch requires the arduino Library from:
25 http://github.com/solexious/MatrixDisplay
26
00d54ca @solexious Fix scrolling issue and version up
solexious authored
27 Version 0.4
f7537e2 @solexious Add initText and change interminator
solexious authored
28 */
81294b5 @solexious Add license, version to 0.1
solexious authored
29
1e91453 @solexious remove wav sheild
solexious authored
30 //#include <FatReader.h>
31 //#include <SdReader.h>
32 //#include <avr/pgmspace.h>
1b8d3ab @solexious Change from mstimer2 to timedAction
solexious authored
33 #include <TimedAction.h>
1e91453 @solexious remove wav sheild
solexious authored
34 //#include "WaveUtil.h"
35 //#include "WaveHC.h"
801583f @solexious Add waveHC lib and sound on display update
solexious authored
36
37
1e91453 @solexious remove wav sheild
solexious authored
38 /*SdReader card; // This object holds the information for the card
292aa2b @solexious Add support for powerusage board
solexious authored
39 FatVolume vol; // This holds the information for the partition on the card
40 FatReader root; // This holds the information for the filesystem on the card
41 FatReader f; // This holds the information for the file we're play
42
43 WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time*/
801583f @solexious Add waveHC lib and sound on display update
solexious authored
44
3160be9 @solexious Correct file name
solexious authored
45 #include "MatrixDisplay.h"
46 #include "DisplayToolbox.h"
f7537e2 @solexious Add initText and change interminator
solexious authored
47 #include "font.h"
3160be9 @solexious Correct file name
solexious authored
48
75d882e @marksteward Makefile _finally_ working (thanks to sam for patience)
authored
49 void scroll();
50 void initText(void);
51 void drawString(int x, int y, char* c);
52
4a90931 @solexious Switch Scrolling function to using interupts
solexious authored
53
3160be9 @solexious Correct file name
solexious authored
54 // Easy to use function
55 #define setMaster(dispNum, CSPin) initDisplay(dispNum,CSPin,true)
56 #define setSlave(dispNum, CSPin) initDisplay(dispNum,CSPin,false)
57
58 // 4 = Number of displays
59 // Data = 10
60 // WR == 11
61 // False - we dont need a shadow buffer for this example. saves 50% memory!
62
63 // Init Matrix
082183f @solexious Remove serial string function
solexious authored
64 MatrixDisplay disp(4,15,14, false);
292aa2b @solexious Add support for powerusage board
solexious authored
65 MatrixDisplay dispW(1,4,5, false);
3160be9 @solexious Correct file name
solexious authored
66 // Pass a copy of the display into the toolbox
67 DisplayToolbox toolbox(&disp);
292aa2b @solexious Add support for powerusage board
solexious authored
68 DisplayToolbox toolboxW(&dispW);
3160be9 @solexious Correct file name
solexious authored
69
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
70 // Text settings
71 int x;
72 boolean scrolling;
73 int minLeft;
74
3160be9 @solexious Correct file name
solexious authored
75 // Prepare boundaries
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
76 int X_MAX = 0;
77 int Y_MAX = 0;
292aa2b @solexious Add support for powerusage board
solexious authored
78 int X_MAXW = 0;
79 int Y_MAXW = 0;
fd7b638 @marksteward Inexplicable merge conflict
authored
80
80ea93a @marksteward First commit of jonty code and car code
authored
81 int jonty = 0;
82 int car = 0;
3160be9 @solexious Correct file name
solexious authored
83
e37e6a7 @samthetechie Car control from IRC
samthetechie authored
84 // Pins for car control
26f1457 @samthetechie Update pins from testing. Pin 7 appears borked so we are using pins 11,1...
samthetechie authored
85 #define CAR_FWD 9
86 #define CAR_BACK 11
87 #define CAR_LEFT 8
88 #define CAR_RIGHT 10
0567caa @marksteward Smaller car drive times
authored
89 #define FWD_TURN_TIME 600
90 #define BACK_TURN_TIME 600
91 #define DRIVE_TIME 250
e37e6a7 @samthetechie Car control from IRC
samthetechie authored
92
3160be9 @solexious Correct file name
solexious authored
93 //serial in stuff
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
94 #define INLENGTH 162
3160be9 @solexious Correct file name
solexious authored
95 char inString[INLENGTH+1];
00d54ca @solexious Fix scrolling issue and version up
solexious authored
96 char inSerialString[INLENGTH+1];
3160be9 @solexious Correct file name
solexious authored
97 int inCount;
98
a10cd28 @solexious Fix naming
solexious authored
99 TimedAction timedAction = TimedAction(35, scroll);
3160be9 @solexious Correct file name
solexious authored
100
101 void setup() {
1465d56 @solexious Add serial message parsing
solexious authored
102 Serial.begin(9600);
292aa2b @solexious Add support for powerusage board
solexious authored
103
a10cd28 @solexious Fix naming
solexious authored
104 timedAction.disable();
4a90931 @solexious Switch Scrolling function to using interupts
solexious authored
105
3160be9 @solexious Correct file name
solexious authored
106 // Fetch bounds
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
107 X_MAX = disp.getDisplayCount() * disp.getDisplayWidth();
3160be9 @solexious Correct file name
solexious authored
108 Y_MAX = disp.getDisplayHeight();
292aa2b @solexious Add support for powerusage board
solexious authored
109 X_MAXW = dispW.getDisplayCount() * dispW.getDisplayWidth();
110 Y_MAXW = dispW.getDisplayHeight();
f7537e2 @solexious Add initText and change interminator
solexious authored
111
3160be9 @solexious Correct file name
solexious authored
112 // Prepare displays
f7537e2 @solexious Add initText and change interminator
solexious authored
113 // The first number represents how the buffer/display is stored in memory. Could be useful for reorganising the displays or matching
114 // he physical layout
9a2b2bc @solexious Up Version number
solexious authored
115 // The number is a array index and is sequential from 0. You can't use 4-8. You must use the numbers 0-4
292aa2b @solexious Add support for powerusage board
solexious authored
116 disp.setMaster(0,16);
117 disp.setSlave(1,17);
3160be9 @solexious Correct file name
solexious authored
118 disp.setSlave(2,18);
082183f @solexious Remove serial string function
solexious authored
119 disp.setSlave(3,19);
292aa2b @solexious Add support for powerusage board
solexious authored
120 dispW.setMaster(0,6);
f7537e2 @solexious Add initText and change interminator
solexious authored
121
801583f @solexious Add waveHC lib and sound on display update
solexious authored
122 //wave hc stuff
123 byte i;
f7537e2 @solexious Add initText and change interminator
solexious authored
124
1e91453 @solexious remove wav sheild
solexious authored
125 //putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad
126 //Serial.println(freeRam()); // if this is under 150 bytes it may spell trouble!
f7537e2 @solexious Add initText and change interminator
solexious authored
127
801583f @solexious Add waveHC lib and sound on display update
solexious authored
128 // Set the output pins for the DAC control. This pins are defined in the library
129 pinMode(2, OUTPUT);
130 pinMode(3, OUTPUT);
131 pinMode(4, OUTPUT);
132 pinMode(5, OUTPUT);
f7537e2 @solexious Add initText and change interminator
solexious authored
133
801583f @solexious Add waveHC lib and sound on display update
solexious authored
134 // pin13 LED
135 pinMode(6, OUTPUT);
292aa2b @solexious Add support for powerusage board
solexious authored
136 /*
801583f @solexious Add waveHC lib and sound on display update
solexious authored
137 // if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
292aa2b @solexious Add support for powerusage board
solexious authored
138 if (!card.init()) { //play with 8 MHz spi (default faster!)
139 putstring_nl("Card init. failed!"); // Something went wrong, lets print out why
140 sdErrorCheck();
141 while(1); // then 'halt' - do nothing!
142 }
143
144 // enable optimize read - some cards may timeout. Disable if you're having problems
145 card.partialBlockRead(true);
146
147 // Now we will look for a FAT partition!
148 uint8_t part;
149 for (part = 0; part < 5; part++) { // we have up to 5 slots to look in
150 if (vol.init(card, part))
151 break; // we found one, lets bail
152 }
153 if (part == 5) { // if we ended up not finding one :(
154 putstring_nl("No valid FAT partition!");
155 sdErrorCheck(); // Something went wrong, lets print out why
156 while(1); // then 'halt' - do nothing!
157 }
158
159 // Lets tell the user about what we found
160 putstring("Using partition ");
161 Serial.print(part, DEC);
162 putstring(", type is FAT");
163 Serial.println(vol.fatType(),DEC); // FAT16 or FAT32?
164
165 // Try to open the root directory
166 if (!root.openRoot(vol)) {
167 putstring_nl("Can't open root dir!"); // Something went wrong,
168 while(1); // then 'halt' - do nothing!
169 }
170
171 // Whew! We got past the tough parts.
172 putstring_nl("Ready!");*/
9a2b2bc @solexious Up Version number
solexious authored
173
f7537e2 @solexious Add initText and change interminator
solexious authored
174 // INITALISE
292aa2b @solexious Add support for powerusage board
solexious authored
175 dispW.clear();
176 //drawStringW(1,0,"HELLO");
177 //toolboxW.setPixel(0,0, 1);
178 //drawCharW(0, 0, *"H");
179 dispW.syncDisplays();
180 //delay(5000);
b08c676 @solexious Smooth scrolling with interrupts
solexious authored
181 initText();
3160be9 @solexious Correct file name
solexious authored
182 }
183
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
184 //************************ START LOOP **********************
3160be9 @solexious Correct file name
solexious authored
185
186 void loop()
187 {
f7537e2 @solexious Add initText and change interminator
solexious authored
188
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
189 if (Serial.available() > 0)
190 {
191 inCount = 0;
192 do {
00d54ca @solexious Fix scrolling issue and version up
solexious authored
193 inSerialString[inCount] = Serial.read(); // get it
194 if (inSerialString[inCount] == 10) break;
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
195 if (inCount > INLENGTH) break;
196 //Serial.println(inString[inCount]);
00d54ca @solexious Fix scrolling issue and version up
solexious authored
197 if (inSerialString[inCount] > 0 ) inCount++;
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
198 }
199 while (1==1);
00d54ca @solexious Fix scrolling issue and version up
solexious authored
200 inSerialString[inCount] = 0;
292aa2b @solexious Add support for powerusage board
solexious authored
201
202
203
204
00d54ca @solexious Fix scrolling issue and version up
solexious authored
205 if(strstr(inSerialString,"$W$")){
292aa2b @solexious Add support for powerusage board
solexious authored
206 // Send srting to mini board
00d54ca @solexious Fix scrolling issue and version up
solexious authored
207 char* miniString = inSerialString;
292aa2b @solexious Add support for powerusage board
solexious authored
208 miniString +=3;
209 dispW.clear();
210 drawStringW(0,0,miniString);
211 dispW.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
212 }
292aa2b @solexious Add support for powerusage board
solexious authored
213 else{
00d54ca @solexious Fix scrolling issue and version up
solexious authored
214
215 for(int a=0; a<162; a++){
216 inString[a] = inSerialString[a];
217 }
218
219 timedAction.disable();
292aa2b @solexious Add support for powerusage board
solexious authored
220 if (strlen(inString) < 21)
221 {
222 x = floor ((128 - ((strlen(inString)*6) - 1)) / 2);
223 scrolling = false;
224 minLeft = 0;
225 }
226 else
227 {
228 x = X_MAX;
229 scrolling = true;
230 minLeft = 0 - (strlen(inString)*6);
231 }
232
ac47a18 @marksteward First commit of jonty code and car code
authored
233
292aa2b @solexious Add support for powerusage board
solexious authored
234 if (strstr(inString,"jonty"))
235 digitalWrite(13, HIGH); // turn on pullup resistors
236 else
237 digitalWrite(13, LOW); // turn on pullup resistors
eb2fc2c @samthetechie Car control from IRC
samthetechie authored
238
292aa2b @solexious Add support for powerusage board
solexious authored
239 if (strstr(inString,"car")) {
240 if (strlen(inString) > 3) {
241 char car_cmd = inString[3];
242
243 switch (car_cmd){
eb2fc2c @samthetechie Car control from IRC
samthetechie authored
244 case '1':
292aa2b @solexious Add support for powerusage board
solexious authored
245 digitalWrite(CAR_LEFT, HIGH);
246 digitalWrite(CAR_FWD, HIGH);
247 delay(FWD_TURN_TIME);
248 digitalWrite(CAR_LEFT, LOW);
249 digitalWrite(CAR_FWD, LOW);
250 break;
eb2fc2c @samthetechie Car control from IRC
samthetechie authored
251 case '2':
252 digitalWrite(CAR_RIGHT, HIGH);
253 digitalWrite(CAR_FWD, HIGH);
254 delay(FWD_TURN_TIME);
255 digitalWrite(CAR_RIGHT, LOW);
256 digitalWrite(CAR_FWD, LOW);
257 break;
258 case '3':
259 digitalWrite(CAR_LEFT, HIGH);
260 digitalWrite(CAR_BACK, HIGH);
261 delay(BACK_TURN_TIME);
262 digitalWrite(CAR_LEFT, LOW);
263 digitalWrite(CAR_BACK, LOW);
264 break;
265 case '4':
266 digitalWrite(CAR_RIGHT, HIGH);
267 digitalWrite(CAR_BACK, HIGH);
268 delay(BACK_TURN_TIME);
269 digitalWrite(CAR_RIGHT, LOW);
270 digitalWrite(CAR_BACK, LOW);
271 break;
272 case '5':
273 digitalWrite(CAR_FWD, HIGH);
274 delay(DRIVE_TIME);
275 digitalWrite(CAR_FWD, LOW);
276 break;
277 case '6':
278 digitalWrite(CAR_BACK, HIGH);
279 delay(DRIVE_TIME);
280 digitalWrite(CAR_BACK, LOW);
281 break;
b4721a5 @samthetechie Update pins from testing
samthetechie authored
282 case '7':
283 digitalWrite(CAR_LEFT, HIGH);
284 delay(DRIVE_TIME);
285 digitalWrite(CAR_LEFT, LOW);
286 break;
287 case '8':
288 digitalWrite(CAR_RIGHT, HIGH);
289 delay(DRIVE_TIME);
290 digitalWrite(CAR_RIGHT, LOW);
291 break;
292aa2b @solexious Add support for powerusage board
solexious authored
292 }
293 }
eb2fc2c @samthetechie Car control from IRC
samthetechie authored
294 }
ac47a18 @marksteward First commit of jonty code and car code
authored
295
292aa2b @solexious Add support for powerusage board
solexious authored
296 disp.clear();
297 drawString(x,0,inString);
298 disp.syncDisplays();
299 //playfile("PING.WAV");
300 Serial.print("Displaying: ");
301 Serial.println(inString);
302 if (scrolling) timedAction.enable();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
303 }
80ea93a @marksteward First commit of jonty code and car code
authored
304
75d882e @marksteward Makefile _finally_ working (thanks to sam for patience)
authored
305 if (strstr(inString,"jonty"))
80ea93a @marksteward First commit of jonty code and car code
authored
306 digitalWrite(13, HIGH); // turn on pullup resistors
307 else
308 digitalWrite(13, LOW); // turn on pullup resistors
309
75d882e @marksteward Makefile _finally_ working (thanks to sam for patience)
authored
310 if (strstr(inString,"car")) {
e37e6a7 @samthetechie Car control from IRC
samthetechie authored
311 if (strlen(inString) > 3) {
312 char car_cmd = inString[3];
313
314 switch (car_cmd){
315 case '1':
316 digitalWrite(CAR_LEFT, HIGH);
317 digitalWrite(CAR_FWD, HIGH);
318 delay(FWD_TURN_TIME);
319 digitalWrite(CAR_LEFT, LOW);
320 digitalWrite(CAR_FWD, LOW);
321 break;
322 case '2':
323 digitalWrite(CAR_RIGHT, HIGH);
324 digitalWrite(CAR_FWD, HIGH);
325 delay(FWD_TURN_TIME);
326 digitalWrite(CAR_RIGHT, LOW);
327 digitalWrite(CAR_FWD, LOW);
328 break;
329 case '3':
330 digitalWrite(CAR_LEFT, HIGH);
331 digitalWrite(CAR_BACK, HIGH);
332 delay(BACK_TURN_TIME);
333 digitalWrite(CAR_LEFT, LOW);
334 digitalWrite(CAR_BACK, LOW);
335 break;
336 case '4':
337 digitalWrite(CAR_RIGHT, HIGH);
338 digitalWrite(CAR_BACK, HIGH);
339 delay(BACK_TURN_TIME);
340 digitalWrite(CAR_RIGHT, LOW);
341 digitalWrite(CAR_BACK, LOW);
342 break;
343 case '5':
344 digitalWrite(CAR_FWD, HIGH);
345 delay(DRIVE_TIME);
346 digitalWrite(CAR_FWD, LOW);
347 break;
348 case '6':
349 digitalWrite(CAR_BACK, HIGH);
350 delay(DRIVE_TIME);
351 digitalWrite(CAR_BACK, LOW);
352 break;
4f3d9ff @samthetechie Update pins from testing
samthetechie authored
353 case '7':
354 digitalWrite(CAR_LEFT, HIGH);
355 delay(DRIVE_TIME);
356 digitalWrite(CAR_LEFT, LOW);
357 break;
358 case '8':
359 digitalWrite(CAR_RIGHT, HIGH);
360 delay(DRIVE_TIME);
361 digitalWrite(CAR_RIGHT, LOW);
362 break;
e37e6a7 @samthetechie Car control from IRC
samthetechie authored
363 }
364 }
80ea93a @marksteward First commit of jonty code and car code
authored
365 }
366
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
367 disp.clear();
368 drawString(x,0,inString);
369 disp.syncDisplays();
1e91453 @solexious remove wav sheild
solexious authored
370 //playfile("PING.WAV");
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
371 Serial.print("Displaying: ");
372 Serial.println(inString);
a10cd28 @solexious Fix naming
solexious authored
373 if (scrolling) timedAction.enable();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
374 }
a10cd28 @solexious Fix naming
solexious authored
375 timedAction.check();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
376 }
377 // ******************************** END LOOP **********************************
801583f @solexious Add waveHC lib and sound on display update
solexious authored
378 //wave hc stuff
1e91453 @solexious remove wav sheild
solexious authored
379 /*
801583f @solexious Add waveHC lib and sound on display update
solexious authored
380 // this handy function will return the number of bytes currently free in RAM, great for debugging!
292aa2b @solexious Add support for powerusage board
solexious authored
381 int freeRam(void)
382 {
383 extern int __bss_end;
384 extern int *__brkval;
385 int free_memory;
386 if((int)__brkval == 0) {
387 free_memory = ((int)&free_memory) - ((int)&__bss_end);
388 }
389 else {
390 free_memory = ((int)&free_memory) - ((int)__brkval);
391 }
392 return free_memory;
393 }
394
395 void sdErrorCheck(void)
396 {
397 if (!card.errorCode()) return;
398 putstring("\n\rSD I/O error: ");
399 Serial.print(card.errorCode(), HEX);
400 putstring(", ");
401 Serial.println(card.errorData(), HEX);
402 while(1);
403 }
404
405 // Plays a full file from beginning to end with no pause.
406 void playcomplete(char *name) {
407 // call our helper to find and play this name
408 playfile(name);
409 while (wave.isplaying) {
410 // do nothing while its playing
411 }
412 // now its done playing
413 }
414
415 void playfile(char *name) {
416 // see if the wave object is currently doing something
417 if (wave.isplaying) {// already playing something, so stop it!
418 wave.stop(); // stop it
419 }
420 // look in the root directory and open the file
421 if (!f.open(root, name)) {
422 putstring("Couldn't open file ");
423 Serial.print(name);
424 return;
425 }
426 // OK read the file and turn it into a wave object
427 if (!wave.create(f)) {
428 putstring_nl("Not a valid WAV");
429 return;
430 }
431
432 // ok time to play! start playback
433 wave.play();
434 }*/
801583f @solexious Add waveHC lib and sound on display update
solexious authored
435
292aa2b @solexious Add support for powerusage board
solexious authored
436 //sure display
437 void drawCharW(int x, int y, char c)
801583f @solexious Add waveHC lib and sound on display update
solexious authored
438 {
292aa2b @solexious Add support for powerusage board
solexious authored
439 if(c==46){
440 toolboxW.setPixel(x, 0+y, 0);
441 toolboxW.setPixel(x, 1+y, 0);
442 toolboxW.setPixel(x, 2+y, 0);
443 toolboxW.setPixel(x, 3+y, 0);
444 toolboxW.setPixel(x, 4+y, 0);
445 toolboxW.setPixel(x, 5+y, 0);
446 toolboxW.setPixel(x, 6+y, 1);
801583f @solexious Add waveHC lib and sound on display update
solexious authored
447 }
292aa2b @solexious Add support for powerusage board
solexious authored
448 else{
449 uint8_t dots;
450 for (char col=0; col< 5; col++) {
451 dots = pgm_read_byte_near(&myfont[c][col]);
452 for (char row=0; row < 8; row++) {
453 if (x+col<0)
454 {
455
456 }
457 else if (dots & (0x80>>row)) // only 7 rows.
458 toolboxW.setPixel(x+col, y+row, 1);
459 else
460 toolboxW.setPixel(x+col, y+row, 0);
461 }
462 }
801583f @solexious Add waveHC lib and sound on display update
solexious authored
463 }
292aa2b @solexious Add support for powerusage board
solexious authored
464 }
f7537e2 @solexious Add initText and change interminator
solexious authored
465
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
466 void drawChar(int x, int y, char c)
3160be9 @solexious Correct file name
solexious authored
467 {
468 uint8_t dots;
469 for (char col=0; col< 5; col++) {
470 dots = pgm_read_byte_near(&myfont[c][col]);
11310f1 @solexious Remove ascii number change, changed font to 8x5
solexious authored
471 for (char row=0; row < 8; row++) {
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
472 if (x+col<0)
473 {
4a90931 @solexious Switch Scrolling function to using interupts
solexious authored
474
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
475 }
476 else if (dots & (0x80>>row)) // only 7 rows.
3160be9 @solexious Correct file name
solexious authored
477 toolbox.setPixel(x+col, y+row, 1);
478 else
479 toolbox.setPixel(x+col, y+row, 0);
480 }
481 }
482 }
483
484
485 // Write out an entire string (Null terminated)
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
486 void drawString(int x, int y, char* c)
3160be9 @solexious Correct file name
solexious authored
487 {
f7537e2 @solexious Add initText and change interminator
solexious authored
488 for(char i=0; i< strlen(c); i++)
489 {
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
490 if(x>-6)
491 {
492 if(x<X_MAX)
493 {
494 drawChar(x, y, c[i]);
495 }
496 }
f7537e2 @solexious Add initText and change interminator
solexious authored
497 x+=6; // Width of each glyph
498 }
499 }
500
292aa2b @solexious Add support for powerusage board
solexious authored
501 void drawStringW(int x, int y, char* c)
502 {
503 for(char i=0; i< strlen(c); i++)
504 {
505 if(x>-6)
506 {
507 if(x<X_MAXW)
508 {
509 drawCharW(x, y, c[i]);
510 }
511 }
512 if(c[i]==46){
513 x+=2;
514 }
515 else{
516 x+=6; // Width of each glyph
517 }
518 }
519 }
520
f7537e2 @solexious Add initText and change interminator
solexious authored
521 void fadeIn(void)
522 {
523 for(int i=0; i<16; ++i) // The displays have 15 different brightness settings
524 {
525 // This will set the brightness for ALL displays
526 toolbox.setBrightness(i);
527 // Alternatively you could set them individually
528 // disp.setBrightness(displayNumber, i);
529 delay(200); // Let's wait a bit or you'll miss it!
530 }
531 }
532
533 void initText(void)
534 {
535 drawString(0,0,"London Hackspace");
536 disp.syncDisplays();
537 fadeIn();
538 disp.clear();
00d54ca @solexious Fix scrolling issue and version up
solexious authored
539 drawString(0,0,"NotificationBoard 0.4");
9a2b2bc @solexious Up Version number
solexious authored
540 disp.syncDisplays();
541 fadeIn();
542 disp.clear();
f7537e2 @solexious Add initText and change interminator
solexious authored
543 delay(100);
544 drawString(0,0,"Loading, Please wait");
545 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
546 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
547 disp.clear();
548 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
549 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
550 drawString(0,0,"Loading, Please wait");
551 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
552 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
553 disp.clear();
554 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
555 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
556 drawString(0,0,"Loading, Please wait");
557 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
558 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
559 disp.clear();
560 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
561 delay(500);
f7537e2 @solexious Add initText and change interminator
solexious authored
562 disp.clear();
563 drawString(0,0,"Ready for input");
564 disp.syncDisplays();
565 fadeIn();
566 disp.clear();
567 disp.syncDisplays();
3160be9 @solexious Correct file name
solexious authored
568 }
f7537e2 @solexious Add initText and change interminator
solexious authored
569
4a90931 @solexious Switch Scrolling function to using interupts
solexious authored
570 void scroll()
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
571 {
4a90931 @solexious Switch Scrolling function to using interupts
solexious authored
572 x--;
573 if (x<minLeft) x = X_MAX;
574 disp.clear();
575 drawString(x,0,inString);
576 disp.syncDisplays();
89ad427 @solexious Add crude scrolling for > 21 char messages
solexious authored
577 }
80ea93a @marksteward First commit of jonty code and car code
authored
578
292aa2b @solexious Add support for powerusage board
solexious authored
579
580
Something went wrong with that request. Please try again.