-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDieselPunk_Cellphone_r1.ino
734 lines (579 loc) · 17.6 KB
/
DieselPunk_Cellphone_r1.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
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
//*******************************************************************
// NOTES: V5
// 12/04/2016 thisoldgeek
// - Makes and answers calls
// - Flashlight
// - Favorites added and working
// - FM Favorites working(??) - check
// Uses 27,666 bytes program memory
// 1419 bytes dynamic memory
//*******************************************************************
#include <Keypad.h>
#include <SoftwareSerial.h>
#include "Adafruit_FONA.h"
#include <Adafruit_NeoPixel.h>
#include "U8glib.h"
// DPC Feather Fona SPI Settings
U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(5, 3, 11, 6, 10); // (SCLK/Clk, MOSI/Data, CS (SA0?), A0/DC, Rst)
// In order from High-to-Low pins: 11, 10, 6, 5, 3 CS, RST, DC, CLK, DATA
// Neopixel Jewel
#define PIN 2
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 7
#define BRIGHTNESS 50
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);
//------------------------------------------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------
// W=80 H=64
#define DPC_Welcome_Dubba_Dubba_Font_r1_width 80
#define DPC_Welcome_Dubba_Dubba_Font_r1_height 64
const unsigned char Welcome_Splash_Screen[] PROGMEM = {
0x00, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x91, 0x47, 0xc0, 0xe0,
0x83, 0xb0, 0x07, 0x00, 0x00, 0x10, 0x91, 0x47, 0xe0, 0xf8, 0x87, 0xb9,
0x07, 0x00, 0x00, 0x10, 0x91, 0x40, 0x30, 0x1c, 0x8e, 0xbf, 0x01, 0x00,
0x00, 0x10, 0x91, 0x40, 0x18, 0x0c, 0x9c, 0xbf, 0x01, 0x00, 0x00, 0x10,
0x91, 0x40, 0x18, 0x0e, 0x98, 0xb6, 0x01, 0x00, 0x00, 0x10, 0x93, 0x40,
0x18, 0x06, 0x98, 0xb6, 0x01, 0x00, 0x00, 0x30, 0x93, 0x40, 0x18, 0x06,
0x90, 0xb6, 0x01, 0x00, 0x00, 0x30, 0x93, 0x40, 0x18, 0x06, 0x90, 0xb6,
0x01, 0x00, 0x00, 0x70, 0x97, 0x4f, 0x18, 0x06, 0x98, 0xb6, 0x1f, 0x00,
0x00, 0xe0, 0x9f, 0x4f, 0x38, 0x0c, 0x98, 0xb6, 0x1f, 0x00, 0x00, 0xe0,
0x9f, 0x40, 0x30, 0x1c, 0x8c, 0xb6, 0x01, 0x00, 0x00, 0xc0, 0x9d, 0x40,
0xe0, 0x38, 0x8f, 0xb6, 0x01, 0x00, 0x00, 0x80, 0x99, 0xc7, 0xc3, 0xf0,
0x87, 0xb6, 0x07, 0x00, 0x00, 0x00, 0x80, 0xc3, 0x81, 0xc0, 0x81, 0xb4,
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x3f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc1, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc3, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x63, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x63, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc3, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x83, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00,
0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x73, 0x20, 0x07, 0x81,
0x07, 0x63, 0x32, 0x78, 0x20, 0x3d, 0x63, 0x38, 0x1f, 0xe3, 0x0f, 0x63,
0x33, 0xfc, 0xe1, 0x3d, 0x63, 0x3c, 0x19, 0xf3, 0x1c, 0x63, 0x32, 0xce,
0xe3, 0x0d, 0x63, 0x3e, 0x31, 0x33, 0x30, 0x63, 0x32, 0x03, 0xe3, 0x0d,
0x63, 0x26, 0x31, 0x1b, 0x60, 0x63, 0xb3, 0x03, 0xa6, 0x0d, 0x33, 0x22,
0x61, 0x1b, 0x60, 0x73, 0xb3, 0x01, 0xa6, 0x0d, 0x3b, 0x22, 0x61, 0x1b,
0x60, 0x33, 0xb3, 0x01, 0xa4, 0x0d, 0x1f, 0x23, 0x31, 0x1b, 0x60, 0x1f,
0xb3, 0x01, 0xa4, 0x0d, 0x1f, 0x3f, 0x31, 0x1b, 0x60, 0x1f, 0xbf, 0x01,
0xa6, 0xfd, 0x3f, 0x3f, 0x31, 0x1b, 0x60, 0x07, 0xbf, 0x03, 0xa6, 0xfd,
0x33, 0x33, 0x19, 0x33, 0x30, 0x03, 0x37, 0x03, 0xa3, 0x1d, 0x33, 0x23,
0x0f, 0xf3, 0x3c, 0x03, 0x33, 0x8e, 0xa3, 0x0d, 0x33, 0x23, 0x07, 0xe3,
0x1f, 0x03, 0x33, 0xfc, 0xa1, 0x3d, 0x33, 0x23, 0x01, 0x81, 0x07, 0x03,
0x32, 0x78, 0xa0, 0x3d };
#include "Adafruit_FONA.h"
#define FONA_RX 9
#define FONA_TX 8
#define FONA_RST 4
#define FONA_RI 7
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {A3, A2, A1, A0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {0, A5, A4}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
// this is a large buffer for replies
char replybuffer[255];
// Use this one for FONA 3G
//Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
uint8_t type;
unsigned long lastDisplay = millis();
boolean flashlight_on = false;
int hue = 0; // 0 = warm white, 255 = red
String dispTime;
String dispDate;
String callStatus; //Shows Number entered and called
// variables for display
int8_t i_8;
int8_t dbi; // RSSI level
int16_t i_16;
int16_t vbat; // battery level
// Store your favorite phone numbers here
char favorites[][20]={"9255551212","9255551212","7075551212","9255551212","18003222702"};
// don't forget to change the names in the display routine for favs!
// Store your favorite FM station frequencies here
// no decomals, eg.: 103.7 is stored as 1037
int fm_station[5] = { 965, 921, 899, 1037 };
void setup() {
// clear the screen
// left from last "on"
u8g.firstPage();
do {
} while( u8g.nextPage() );
delay(1000);
Serial.begin(115200);
u8g.firstPage();
do {
splash();
} while( u8g.nextPage() );
delay(4000);
u8g.firstPage();
do {
msgConnect();
} while( u8g.nextPage() );
delay(2000);
// Check FONA is there
fonaSS.begin(9600); // if you're using software serial
// See if the FONA is responding
if (! fona.begin(fonaSS)) {
Serial.println(F("Couldn't find FONA :("));
while (1);
}
// Check we can connect to the network
while (fona.getNetworkStatus() != 1) {
u8g.firstPage();
do {
msgNetService();
} while( u8g.nextPage() );
}
u8g.firstPage();
do {
msgNetConnect();
} while( u8g.nextPage() );
delay(2000);
// set to external mic & headphone
fona.setAudio(FONA_EXTAUDIO);
// Print module IMEI number.
char imei[15] = {0}; // MUST use a 16 character buffer for IMEI!
uint8_t imeiLen = fona.getIMEI(imei);
if (imeiLen > 0) {
Serial.print(F("Module IMEI: "));
Serial.println(imei);
}
pixels.begin(); // This initializes the NeoPixel library.
pixelsStartup(); // Sets NeoPixels to their default
}
void pixelsStartup()
{
pixelShow(4,BRIGHTNESS );
pixelShow(0, BRIGHTNESS);
pixelShow(1, BRIGHTNESS);
}
void pixelShow(int i, int j)
{
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(hue, 0, 0, j)); // WARM white COLOR
pixels.show(); // This sends the updated pixel color to the hardware.
//delay(50); // Delay for a period of time (in milliseconds).
}
void flashlight()
{
if (flashlight_on)
{ for(int i=0;i<NUMPIXELS;i++)
{pixelShow(i, 255);}
}
else {
for(int i=0;i<NUMPIXELS;i++)
{pixelShow(i, 0);}
pixelsStartup();}
}
void answerPhone()
{
if (! fona.pickUp()) {
Serial.println(F("Failed"));
}
}
void msgConnect()
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.drawStr(30, 32,"Connecting...");
}
void msgNetService()
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.drawStr(20, 32,"Looking for Service");
}
void msgNetConnect()
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.drawStr(10, 32,"Connected to Network!");
}
void splash() {
u8g.drawXBMP( 24, 0, 80, 64, Welcome_Splash_Screen);
}
int8_t getRSSI (int8_t i)
{
uint8_t n = fona.getRSSI();
int8_t r;
if (n == 0) r = -115;
if (n == 1) r = -111;
if (n == 31) r = -52;
if ((n >= 2) && (n <= 30)) {
r = map(n, 2, 30, -110, -54);
}
return(r);
}
uint16_t getBattery(uint16_t i) {
uint16_t vbat;
if (! fona.getBattPercent(&vbat))
{
} else
{
return(vbat);
}
}
void cellDate()
{
char buffer[23];
fona.getTime(buffer, 23); // make sure replybuffer is at least 23 bytes!
String Str1 = buffer;
dispDate = Str1.substring(4,9);
dispDate.concat("/");
dispDate.concat(Str1.substring(1,3));
}
void cellTime()
{ // Changes 24-hour time to 12-hour format
char buffer[23];
fona.getTime(buffer, 23); // make sure replybuffer is at least 23 bytes!
String Str1 = buffer;
String Str2; // stores reformated hours:minutes for display
// the following is for 12-hour time
// and to add leading zero when minutes < 10
int rptHour = (Str1.substring(10,12).toInt());
int rptMinutes = (Str1.substring(13,15).toInt());
int i = rptHour;
if ( rptHour > 12 ) // convert to 12-hour format
{ rptHour = rptHour-12; }
Str2.concat(rptHour);
Str2.concat(":");
if (rptMinutes < 10)
{ Str2.concat(0);}
Str2.concat(rptMinutes);
if ( i >= 12 )
{ Str2.concat(" PM");}
else
{ Str2.concat(" AM");}
dispTime = Str2;
}
void callEntry()
{char phoneNumber[20]= " ";
char key = keypad.getKey();
int i = 0;
callStatus = " Number, Please!";
//Display the page!
u8g.firstPage();
do {
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
while ((key != '*') and (key != '#'))
{
key = keypad.getKey();
if (key)
{
phoneNumber[i] = key;
i++;
u8g.firstPage();
do {
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
}
}
// remove "*" from string
int length = strlen(phoneNumber);
phoneNumber[length-1] = '\0';
if (key == '#')
{ return;}
if (key == '*')
{
callStatus = " Call in Progress";
u8g.firstPage();
do {
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
makeCall(phoneNumber);}
}
void makeCall(char phoneNumber[20])
{
char key = keypad.getKey();
if (!fona.callPhone(phoneNumber))
{
callStatus = " Call Failed!";
}
while (key != '#')
{
key = keypad.getKey();
if (key)
{
u8g.firstPage();
do
{
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
}
int callstatus = fona.getCallStatus();
if (callstatus == 2) // phone is currently ringing
{
// use ringing tone AT+STONE 8
}
}
if (! fona.hangUp())
{
Serial.println(F("Failed"));
}
}
void callEntryDisplay(char inNumber[20])
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.setPrintPos(20,16);
u8g.print(callStatus);
u8g.setPrintPos(30,32);
u8g.print(inNumber);
u8g.setPrintPos(1,56);
u8g.print(F("*=DIAL"));
u8g.setPrintPos(88,56);
u8g.print(F("#=HUP"));
}
void favsEntryDisplay()
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.setPrintPos(20,8);
u8g.print(F("Favorite Numbers:"));
u8g.setPrintPos(30, 20);
u8g.print(F(" 1 - Bob"));
u8g.setPrintPos(30, 30);
u8g.print(F(" 2 - Janet"));
u8g.setPrintPos(30, 40);
u8g.print(F(" 3 - John"));
u8g.setPrintPos(30, 50);
u8g.print(F(" 4 - Claudette"));
u8g.setPrintPos(30, 60);
u8g.print(F(" 5 - Work"));
u8g.setPrintPos(88,64);
u8g.print(F("#=HUP"));
}
void favsFMEntryDisplay()
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.setPrintPos(20,8);
u8g.print("Favorite Stations:");
u8g.setPrintPos(30, 20);
u8g.print(F("1 - 96.5/KOIT "));
u8g.setPrintPos(30, 30);
u8g.print(F("2 - 92.1/KKVD"));
u8g.setPrintPos(30, 40);
u8g.print(("3 - 89.9/KDFC"));
u8g.setPrintPos(30, 50);
u8g.print(F("4 - 103.7/KOSF"));
u8g.setPrintPos(88,64);
u8g.print(F("#=BACK"));
}
void dispFM(int station)
{
u8g.setFont(u8g_font_lucasfont_alternater);
u8g.setPrintPos(30,8);
u8g.print(F("Now Playing:"));
u8g.setPrintPos(48, 24);
u8g.print(station);
u8g.setPrintPos(88,64);
u8g.print("#=OFF");
}
void onFM(int freq)
{ char key = keypad.getKey();
uint16_t station = freq;
// FM radio ON using external audio
if (fona.FMradio(true, FONA_EXTAUDIO)) {
}
if (! fona.tuneFMradio(station))
{ } else
{ }
// Set FM volume.
uint8_t vol = 4;
if (!fona.setFMVolume(vol)) {
} else { }
while (key != '#')
{
key = keypad.getKey();
}
if (! fona.FMradio(false))
{ }
else
{ }
}
void callFMfavs()
{
char key = keypad.getKey();
int i = 0;
int ikey;
//Display the page!
u8g.firstPage();
do {
favsFMEntryDisplay();
} while( u8g.nextPage() );
while (key != '#')
{
key = keypad.getKey();
if (key)
if ((key != '*') and (key != '#'))
{ // convert a single character to int
ikey = key - '0';
switch (ikey) {
case 1 ... 4: // choice of 4 FM stations only
// turn on FM and tune the stations
u8g.firstPage();
do {
dispFM(fm_station[ikey-1]);
} while( u8g.nextPage() );
onFM(fm_station[ikey-1]); // will stay in this routine until '#'
return; // then, returns to main menu display
default:
// if nothing else matches, do the default
// default is optional
break;
}
}
}
if (key == '#')
{ return;}
}
void callFavorites()
{
char phoneNumber[20] = " ";
char key = keypad.getKey();
int i = 0;
//Display the page!
u8g.firstPage();
do {
favsEntryDisplay();
} while( u8g.nextPage() );
while ((key != '*') and (key != '#'))
{
key = keypad.getKey();
if (key)
if ((key != '*') and (key != '#'))
{ // convert a single character to int
int ikey = key - '0';
strcpy(phoneNumber, favorites[ikey-1]);
u8g.firstPage();
do {
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
}
}
// remove "*" from string
int length = sizeof(phoneNumber);
phoneNumber[length-1] = '\0';
if (key == '#')
{ return;}
if (key == '*')
{ callStatus = " Calling ";
u8g.firstPage();
do {
callEntryDisplay(phoneNumber);
} while( u8g.nextPage() );
makeCall(phoneNumber);}
}
void keyPress()
{
char key = keypad.getKey();
// NeoPixel Flashlight
if (key == '*')
{ flashlight_on = !flashlight_on;
flashlight();
return;
}
// Answer an incoming call
if (key == '#')
{ answerPhone();
return;
}
// convert a single character to int
int ikey = key - '0';
switch (ikey) {
case 1:
callEntry();
break;
case 2:
callFavorites();
break;
case 3:
callFMfavs();
break;
default:
// if nothing else matches, do the default
// default is optional
break;
}
}
void dispMenu(int8_t dbi, uint16_t vbat)
{ // set font
u8g.setFont(u8g_font_lucasfont_alternater);
// draw turnstile antenna (4 lines)
u8g.drawLine(0, 0, 7, 7);
u8g.drawLine(7, 7, 14, 0);
u8g.drawLine(7, 0, 7, 13 );
u8g.drawLine(1, 0, 13, 0);
// draw battery outline (2 lines)
u8g.drawFrame(105,2,20,11); // outside of battery
u8g.drawBox(126,5,2,4); // positive battery end
// draw RSSI level
u8g.setPrintPos(0,24);
u8g.print(dbi);
u8g.print("dBi");
// draw variable battery level and per cent battery remaining
u8g.drawBox(107,4,(16 * (vbat *.01)),7);
u8g.setPrintPos(105,24);
u8g.print(vbat);
u8g.print("%");
// draw text menu
u8g.drawStr(48, 32,"1-DIAL");
u8g.drawStr(48, 48,"2-FAVS");
u8g.drawStr(48, 64,"3-FM");
//u8g.drawStr(72, 58,"*-LED");
// Utility functions
u8g.drawStr(0, 64,"*-LED"); // flashlight
u8g.drawStr(96, 64,"#-ANS"); // answer call
// display the date
u8g.setPrintPos(40, 7);
u8g.print(dispDate);
// display the time
u8g.setPrintPos(48, 18);
u8g.print(dispTime);
}
void loop()
{
// don't hog the processor!
if (millis() - lastDisplay > 10000)
{
dbi = getRSSI(i_8);
vbat = getBattery(i_16);
cellDate();
cellTime();
lastDisplay = millis();
}
u8g.firstPage();
do {
dispMenu(dbi, vbat);
keyPress();
} while( u8g.nextPage() );
}