Commit 26923e5f authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

Added status bar to screen for LTE project.

parent 6fdc4d77
......@@ -76,8 +76,8 @@ char imei[16] = {0}; // MUST use a 16 character buffer for IMEI!
//*********************** Screen ******************
#include <PCD8544.h>
// A custom glyph (a smiley)...
static const byte glyph[] = { B00010000, B00110100, B00110000, B00110100, B00010000 };
// A custom glyph (Network Status)...
static const byte glyphN[] = { 0xe0, 0x00, 0xf8, 0x00, 0xfe };
static PCD8544 lcd;
//*********************** Screen ******************
......@@ -88,8 +88,8 @@ void setup() {
// PCD8544-compatible displays may have a different resolution...
lcd.begin(84, 48);
// Add the smiley to position "0" of the ASCII table...
lcd.createChar(0, glyph);
// Add the smiley to position "netStat" of the ASCII table...
lcd.createChar(0, glyphN);
//*********************** Screen ******************
// while (!Serial);
......@@ -171,12 +171,9 @@ void printMenu(void) {
Serial.println(F("-------------------------------------"));
// General
Serial.println(F("[?] Print this menu"));
Serial.println(F("[a] Read the ADC; 2.8V max for SIM800/808, 0V-VBAT for SIM7000 shield"));
Serial.println(F("[b] Read supply voltage")); // Will also give battery % charged for most modules
Serial.println(F("[C] Read the SIM CCID"));
Serial.println(F("[U] Unlock SIM with PIN code"));
Serial.println(F("[i] Read signal strength (RSSI)"));
Serial.println(F("[n] Get network status"));
Serial.println(F("[1] Get network connection info")); // See what connection type and band you're on!
// SMS
......@@ -212,34 +209,57 @@ void printMenu(void) {
void loop() {
//*********************** Screen ******************
// Just to show the program is alive...
static int counter = 0;
// Write a piece of text on the first line...
// Build the information bar.
// Will look like this: Batt% GPS (indicator) Network (indicator) #SMS (messages)
lcd.setCursor(0, 0);
//lcd.print("Hello, World!");
// Write the counter on the second line...
//lcd.setCursor(0, 1);
//lcd.print(counter, DEC);
//lcd.write(' ');
//lcd.write(0); // write the smiley
// Write the counter on the third line...
//lcd.setCursor(0, 2);
//if (fona.available()) {
//lcd.write(fona.read());
//}
// Use a potentiometer to set the LCD contrast...
// short level = map(analogRead(A0), 0, 1023, 0, 127);
// lcd.setContrast(level);
//delay(200);
//counter++;
//*********************** Screen ******************
// Get the battery percentage:
uint16_t vbat;
if (! fona.getBattPercent(&vbat)) {
Serial.println(F("Failed to read Batt"));
lcd.print("**% ");
} else {
Serial.print(F("VPct = ")); Serial.print(vbat); Serial.println(F("%"));
lcd.print(vbat); lcd.print("% ");
}
// Get the GPS status:
int statGPS = fona.GPSstatus(); Serial.print(F("GPS status = ")); Serial.println(statGPS);
if (statGPS == 1) {lcd.print("GPS ");} else {lcd.print("--- ");}
// Get the network status:
uint8_t n = fona.getNetworkStatus();
Serial.print(F("Network status "));
Serial.print(n);
Serial.print(F(": "));
if (n == 0) {Serial.println(F("Not registered")); lcd.print("X");}
if (n == 1) {Serial.println(F("Registered (home)")); lcd.write(0);}
if (n == 2) {Serial.println(F("Not registered (searching)")); lcd.print("S");}
if (n == 3) {Serial.println(F("Denied")); lcd.print("D");}
if (n == 4) {Serial.println(F("Unknown")); lcd.print("?");}
if (n == 5) {Serial.println(F("Registered roaming")); lcd.write(0);}
lcd.print(" ");
// Get the number of SMS messages:
int8_t smsnum = fona.getNumSMS();
if (smsnum < 0) {
Serial.println(F("Could not read # SMS"));
lcd.print("-0- ");
} else {
Serial.print(smsnum); Serial.println(F(" SMS's on SIM card!"));
lcd.print(smsnum);
}
//*********************** Screen ******************
Serial.print(F("FONA> "));
if (Serial.available() > 0) {
checkSerialConn();
}
delay(10000); // Current arbitrary 10 second delay.
} // End loop
void checkSerialConn() {
Serial.print(F("FONA> "));
while (! Serial.available() ) {
if (fona.available()) {
Serial.write(fona.read());
......@@ -256,41 +276,6 @@ void loop() {
break;
}
case 'a': {
// read the ADC
uint16_t adc;
if (! fona.getADCVoltage(&adc)) {
Serial.println(F("Failed to read ADC"));
} else {
Serial.print(F("ADC = ")); Serial.print(adc); Serial.println(F(" mV"));
}
break;
}
case 'b': {
// read the battery voltage and percentage
uint16_t vbat;
if (! fona.getBattVoltage(&vbat)) {
Serial.println(F("Failed to read Batt"));
} else {
lcd.setCursor(0, 0);
lcd.print("Battery Status");
Serial.print(F("VBat = ")); Serial.print(vbat); Serial.println(F(" mV"));
lcd.setCursor(0, 1); lcd.print("VBat = "); lcd.print(vbat); lcd.print(" mV");
}
if (! fona.getBattPercent(&vbat)) {
Serial.println(F("Failed to read Batt"));
} else {
Serial.print(F("VPct = ")); Serial.print(vbat); Serial.println(F("%"));
lcd.setCursor(0, 2); lcd.print("VPct = "); lcd.print(vbat); lcd.print("%");
}
break;
}
case 'U': {
// Unlock the SIM with a PIN code
char PIN[5];
......@@ -331,20 +316,6 @@ void loop() {
break;
}
case 'n': {
// read the network/cellular status
uint8_t n = fona.getNetworkStatus();
Serial.print(F("Network status "));
Serial.print(n);
Serial.print(F(": "));
if (n == 0) Serial.println(F("Not registered"));
if (n == 1) Serial.println(F("Registered (home)"));
if (n == 2) Serial.println(F("Not registered (searching)"));
if (n == 3) Serial.println(F("Denied"));
if (n == 4) Serial.println(F("Unknown"));
if (n == 5) Serial.println(F("Registered roaming"));
break;
}
case '1': {
// Get connection type, cellular band, carrier name, etc.
fona.getNetworkInfo();
......@@ -352,18 +323,6 @@ void loop() {
}
/*** SMS ***/
case 'N': {
// read the number of SMS's!
int8_t smsnum = fona.getNumSMS();
if (smsnum < 0) {
Serial.println(F("Could not read # SMS"));
} else {
Serial.print(smsnum);
Serial.println(F(" SMS's on SIM card!"));
}
break;
}
case 'r': {
// read an SMS
flushSerial();
......@@ -740,13 +699,13 @@ void loop() {
printMenu();
break;
}
}
// flush input
flushSerial();
while (fona.available()) {
Serial.write(fona.read());
}
}// End serial available.
}
void flushSerial() {
......
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