Commit 70c217ed authored by alaskalinuxuser's avatar alaskalinuxuser
Browse files

Fixed compass and a few GPS related issues.

parent dfae4067
......@@ -72,12 +72,10 @@ SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_LTE fona = Adafruit_FONA_LTE();
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
uint8_t type;
char imei[16] = {0}; // MUST use a 16 character buffer for IMEI!
bool GPSon = 0;
char messageText[120];
char sendText[21];
int smsNum = 1;
bool GPSon = 0;
//*********************** Screen ******************
#include <PCD8544.h>
......@@ -160,14 +158,6 @@ void setup() {
while (1); // Don't proceed if it couldn't find the device
}
type = fona.type();
// Print module IMEI number.
uint8_t imeiLen = fona.getIMEI(imei);
if (imeiLen > 0) {
Serial.print("IMEI: "); Serial.println(imei);
}
// Set modem to full functionality
fona.setFunctionality(1); // AT+CFUN=1
......@@ -244,8 +234,7 @@ void loop() {
}
// Get the GPS status:
int statGPS = fona.GPSstatus(); Serial.print(F("GPS stat = ")); Serial.println(statGPS);
if (statGPS == 1) {lcd.print("GPS ");} else {lcd.print("--- ");}
if (GPSon == 1) {lcd.print("GPS ");} else {lcd.print("--- ");}
// Get the network status:
uint8_t n = fona.getNetworkStatus();
......@@ -300,38 +289,43 @@ void loop() {
switch (screenNumber){
case 1:{ // Main screen
lcd.setCursor(0, 1);
lcd.print("TEXT");
lcd.print("1:TEXT");
lcd.setCursor(0, 2);
lcd.print("GPS");
lcd.print("2:GPS");
lcd.setCursor(0, 3);
lcd.print("PROGRAMS");
lcd.print("3:PROGRAMS");
lcd.setCursor(0, 4);
lcd.print(" ");lcd.print(buffer);
break;
}
case 2:{ // Location screen
lcd.setCursor(0, 1);
lcd.print("SEND LOCATION");
lcd.setCursor(0, 2);
if (GPSon == 1) {char gpsdata[120];
fona.getGPS(0, gpsdata, 120);
lcd.print(gpsdata);} else { lcd.print("Turn on GPS.");}
if (fona.GPSstatus() == 1) {
fona.getGPS(0, messageText, 120);
lcd.print(messageText);} else { lcd.print("Turn on GPS.");}
lcd.setCursor(0, 5);
lcd.print("1:SEND LOCATION");
break;
}
case 3:{ // GPS screen
lcd.setCursor(0, 1);
lcd.print("VIEW LOCATION");
lcd.print("1:VIEW LOCATION");
lcd.setCursor(0, 2);
lcd.print("COMPASS");
lcd.print("2:COMPASS");
lcd.setCursor(0, 3);
lcd.print("GPS ON");
lcd.print("3:GPS ON");
lcd.setCursor(0, 4);
lcd.print("GPS OFF");
lcd.print("4:GPS OFF");
break;
}
case 4:{ // Compass screen // TODO: Make Compass work
case 4:{ // Compass screen
float heading;
if (fona.getGPS(&heading, &heading, &heading, &heading)) {
lcd.setCursor(0, 1);
lcd.print("Heading: "); lcd.print(heading);
}
lcd.setCursor(0, 4);
lcd.print("MAIN MENU");
lcd.print("4:MAIN MENU");
break;
}
case 5:{ // Phone send number screen.
......@@ -347,11 +341,11 @@ void loop() {
}
case 6:{ // SMS screen
lcd.setCursor(0, 1);
lcd.print("READ SMS");
lcd.print("1:READ SMS");
lcd.setCursor(0, 2);
lcd.print("SEND SMS");
lcd.print("2:SEND SMS");
lcd.setCursor(0, 3);
lcd.print("DELETE ALL SMS");
lcd.print("3:DELETE ALL SMS");
lcd.setCursor(0, 4);
lcd.print(" ");
break;
......@@ -373,9 +367,9 @@ void loop() {
lcd.setCursor(0, 2);
lcd.print("MESSAGES?");
lcd.setCursor(0, 3);
lcd.print(" NO");
lcd.print(" 3:NO");
lcd.setCursor(0, 4);
lcd.print(" YES");
lcd.print(" 4:YES");
break;
}
case 9:{ // View all messages screen
......@@ -393,9 +387,9 @@ void loop() {
lcd.setCursor(0, 2);
lcd.print(messageText);
lcd.setCursor(0, 4);
lcd.print("L-REPLY");
lcd.print("3:REPLY");
lcd.setCursor(0, 5);
lcd.print("R-DELETE");
lcd.print("4:DELETE");
break;
}
case 11:{ // Delete message screen
......@@ -404,34 +398,34 @@ void loop() {
lcd.setCursor(0, 2);
lcd.print("MESSAGE?");
lcd.setCursor(0, 3);
lcd.print(" NO");
lcd.print(" 3:NO");
lcd.setCursor(0, 4);
lcd.print(" YES");
lcd.print(" 4:YES");
break;
}
case 12:{ // Programs screen
lcd.setCursor(0, 1);
lcd.print("LINEMODE BROWSER");
lcd.print("1:LINEMODE BROWSER");
lcd.setCursor(0, 2);
lcd.print("GAMES");
lcd.print("2:GAMES");
lcd.setCursor(0, 3);
lcd.print("SETTINGS");
lcd.print("3:SETTINGS");
break;
}
case 13:{ // Settings screen
lcd.setCursor(0, 1);
lcd.print("NETWORK");
lcd.print("1:NETWORK");
lcd.setCursor(0, 2);
lcd.print("SCREEN");
lcd.print("2:SCREEN");
break;
}
case 14:{ // Network Settings screen
lcd.setCursor(0, 1);
lcd.print("DATA ON");
lcd.print("1:DATA ON");
lcd.setCursor(0, 2);
lcd.print("DATA OFF");
lcd.print("2:DATA OFF");
lcd.setCursor(0, 3);
lcd.print("NET INFO");
lcd.print("3:NET INFO");
break;
}
case 15:{ // Network info screen
......@@ -452,7 +446,7 @@ void loop() {
lcd.setCursor(0, 3);
lcd.print(r);
lcd.setCursor(0, 4);
lcd.print("MAIN MENU");
lcd.print("4:MAIN MENU");
break;
}
}
......@@ -535,16 +529,16 @@ void loop() {
}
case 18:{
// turn GPS on
GPSon=1;
if (!fona.enableGPS(true))
Serial.println(F("F"));
GPSon=1;
break;
}
case 21:{
// turn GPS off
GPSon=0;
if (!fona.enableGPS(false))
Serial.println(F("F"));
GPSon=0;
break;
}
case 32:{ // Screen 4 - Compass screen.
......@@ -916,14 +910,14 @@ void checkSerialConn() {
case 'o': {
// turn GPS off
GPSon =0;
GPSon=0;
if (!fona.enableGPS(false))
Serial.println(F("F"));
break;
}
case 'O': {
// turn GPS on
GPSon =1;
GPSon=1;
if (!fona.enableGPS(true))
Serial.println(F("F"));
break;
......
......@@ -163,7 +163,7 @@ class Adafruit_FONA : public FONAStreamType {
int8_t GPSstatus(void);
uint8_t getGPS(uint8_t arg, char *buffer, uint8_t maxbuff);
// boolean getGPS(float *lat, float *lon, float *speed_kph=0, float *heading=0, float *altitude=0);
boolean getGPS(float *lat, float *lon, float *speed_kph, float *heading, float *altitude,
boolean getGPS(float *lat, float *lon, float *speed_kph, float *heading, float *altitude = NULL,
uint16_t *year = NULL, uint8_t *month = NULL, uint8_t *day = NULL, uint8_t *hour = NULL, uint8_t *min = NULL, float *sec = NULL);
boolean enableGPSNMEA(uint8_t nmea);
......@@ -329,4 +329,4 @@ class Adafruit_FONA_LTE : public Adafruit_FONA {
boolean hangUp(void);
};
#endif
\ No newline at end of file
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment