reformats code

This commit is contained in:
Brendan Haines 2016-12-02 20:00:37 -07:00
parent aa1ed81a6f
commit 7f35b88b81

View File

@ -18,6 +18,9 @@
// Low battery light threshold
#define CHG_VLO 3800
// Time in miliseconds to stop listening for keypad input
#define SLEEP_TIMEOUT 120000
// Keypad pinout
byte rowPins[4] = {5, 10, 9, 7};
byte colPins[3] = {6, 4, 8};
@ -39,6 +42,7 @@ char keys[4][3] = {
unsigned long lastActiveTime;
bool dialtoneActive = false;
bool startDialtone = false;
bool awake = true;
HardwareSerial *fonaSerial = &Serial;
Adafruit_FONA fona = Adafruit_FONA(GSM_RST);
@ -78,6 +82,13 @@ void resumeDialtone() {
dialtoneActive = true;
}
void clearPhoneNumber() {
for ( int j = 0; j < phoneNumberLength; j++) {
phoneNumber[j] = 0;
}
phoneNumberLength = 0;
}
//////////////////////////////////
///// ARDUINO CORE FUNCTIONS /////
//////////////////////////////////
@ -111,6 +122,9 @@ void setup() {
}
void loop() {
if ( awake ) {
// Handle Incoming Call
if ( !digitalRead(GSM_RING) ) {
while ( digitalRead(BUT_ANS) & !digitalRead(GSM_RING) ) delay(10); // Wait for answer button or end ring/call
if ( !digitalRead(BUT_ANS) ) {
@ -120,12 +134,13 @@ void loop() {
}
}
// Begin dialtone if necessary
if ( startDialtone ) {
resumeDialtone();
startDialtone = false;
}
// Read from keypad
// Read keypad input
char key = keypad.getKey();
if ( key != NO_KEY ) {
phoneNumber[ phoneNumberLength ] = key;
@ -145,13 +160,9 @@ void loop() {
}
}
// Clear stored phone number on press of end button
if ( !digitalRead(BUT_END) ) {
for ( int j = 0; j < phoneNumberLength; j++) {
phoneNumber[j] = 0;
}
phoneNumberLength = 0;
clearPhoneNumber();
resumeDialtone();
}
@ -163,9 +174,14 @@ void loop() {
} else {
digitalWrite( LED_BAT_LOW, LOW );
}
} else {
// sleeping
delay(100);
}
}