Commit e16dffae authored by alaskalinuxuser's avatar alaskalinuxuser
Browse files

Now can send text/sms messages!

parent 72bc512c
......@@ -60,8 +60,8 @@
#define FONA_TX 10 // Microcontroller RX
#define FONA_RX 11 // Microcontroller TX
// this is a large buffer for replies
char replybuffer[150];
// this is a buffer for replies
char replybuffer[10];
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
......@@ -75,18 +75,18 @@ 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[141];
char messageText[120];
char sendText[21];
//*********************** Screen ******************
#include <PCD8544.h>
// A custom glyph (Network Status)...
static const byte glyphN[] = { 0xe0, 0x00, 0xf8, 0x00, 0xfe };
int screenNumber = 1; // The menu screen number.
int menuNumber = 285; // The selected menu item.
int updateScreen = 0; // A counter to update the screen.
int numLetter = 0;
int curPos = 0;
static PCD8544 lcd;
//*********************** Screen ******************
......@@ -127,6 +127,11 @@ int read_LCD_buttons(){ // read the buttons
void setup() {
// TESTING ONLY // Not a valid number.
messageText[0] = 'T';messageText[1] = 'E';messageText[2] = 'S';messageText[3] = 'T';
sendText[0] = '1';sendText[1] = '9';sendText[2] = '0';sendText[3] = '7';sendText[4] = '8';sendText[5] = '6';
sendText[6] = '7';sendText[7] = '5';sendText[8] = '3';sendText[9] = '0';sendText[10] = '9';
// TESTING ONLY //
//*********************** Screen ******************
// PCD8544-compatible displays may have a different resolution...
lcd.begin(84, 48);
......@@ -217,6 +222,10 @@ void loop() {
//Get the time.
char buffer[23];
fona.getTime(buffer, 23);
char letterNumbers[91] = {'0','1','2','3','4','5','6','7','8','9',' ','A','B','C','D','E','F','G',
'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e',
'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','`','~','!',
'@','#','$','%','^','&','*','(',')','_','+','|','-','=',';',':',',','/','.','<','>','?'};
//*********************** Status Bar ******************
// Build the information bar.
......@@ -324,11 +333,15 @@ void loop() {
lcd.print("MAIN MENU");
break;
}
case 5:{ // Phone send number screen. // TODO: make this work.
case 5:{ // Phone send number screen.
lcd.setCursor(0, 1);
lcd.print("SEND TO: ");
lcd.setCursor(0, 4);
lcd.print("-SELECT TO SEND-");
lcd.setCursor(0, 2);
lcd.print(sendText);
lcd.setCursor(curPos*6, 2);
lcd.print(letterNumbers[numLetter]);
lcd.setCursor(0, 5);
lcd.print("SELECT SENDS");
break;
}
case 6:{ // SMS screen
......@@ -342,9 +355,13 @@ void loop() {
lcd.print(" ");
break;
}
case 7:{ // Type message screen // TODO: make this work.
case 7:{ // Type message screen
lcd.setCursor(0, 1);
lcd.print("TYPE MESSAGE:");
lcd.setCursor(0, 2);
lcd.print(messageText);
lcd.setCursor(curPos*6, 2);
lcd.print(letterNumbers[numLetter]);
lcd.setCursor(0, 5);
lcd.print("SELECT SENDS");
break;
......@@ -474,7 +491,9 @@ void loop() {
//*********************** Button Reading ******************
//*********************** Menu Options ******************
// TESTING ONLY // Serial.println(menuNumber);
// TESTING ONLY // Serial.println(curPos);
// TESTING ONLY // Serial.println(screenNumber);
switch (menuNumber){
case 2:{ // Screen 1 - Main screen.
......@@ -523,20 +542,42 @@ void loop() {
screenNumber = 1;
break;
}
case 30:{ // Screen 5 - Enter phone number screen. // TODO: make this work.
screenNumber = 1;
case 30:{ // Screen 5 - Enter phone number screen.
// Up one character
if (numLetter >= 91){
numLetter = 0;
} else {
numLetter++;
}
break;
}
case 35:{
screenNumber = 1;
// Down one character
if (numLetter <= 0){
numLetter = 91;
} else {
numLetter--;
}
break;
}
case 40:{
screenNumber = 1;
// Left one position
if (curPos <= 0){
curPos = 0;
} else {
sendText[curPos] = letterNumbers[numLetter];
curPos--;
}
break;
}
case 45:{
screenNumber = 1;
// Right one position
if (curPos >= 21){
curPos = 21;
} else {
sendText[curPos] = letterNumbers[numLetter];
curPos++;
}
break;
}
case 42:{ // Screen 6 - Text/SMS screen.
......@@ -551,20 +592,43 @@ void loop() {
screenNumber = 8;
break;
}
case 56:{ // Screen 7 - Type message screen. // TODO: make this work.
screenNumber = 1;
case 56:{ // Screen 7 - Type message screen.
// Up one character
if (numLetter >= 91){
numLetter = 0;
} else {
numLetter++;
}
break;
}
case 63:{
screenNumber = 1;
// Down one character
if (numLetter <= 0){
numLetter = 91;
} else {
numLetter--;
}
break;
}
}
case 70:{
screenNumber = 1;
// Left one position
if (curPos <= 0){
curPos = 0;
} else {
messageText[curPos] = letterNumbers[numLetter];
curPos--;
}
break;
}
case 77:{
screenNumber = 1;
// Right one position
if (curPos >= 120){
curPos = 120;
} else {
messageText[curPos] = letterNumbers[numLetter];
curPos++;
}
screenNumber = 7;
break;
}
case 88:{ // Screen 8 - Delete ALL message screen.
......@@ -573,7 +637,7 @@ void loop() {
}
case 96:{
for (int deleteALL = 32; deleteALL >= 0; deleteALL--) {
if (fona.deleteSMS(deleteALL)) { // is the first one 0 or 1?
if (fona.deleteSMS(deleteALL)) {
Serial.println(F("K"));
} else {
Serial.println(F("F"));
......@@ -654,8 +718,22 @@ void loop() {
screenNumber = 1;
break;
}
case 255:{ // Screen 15 - Network info.
screenNumber = 1;
case 255:{ // Select Button
if (screenNumber == 5) {
if (!fona.sendSMS(sendText, messageText)) {
Serial.println(F("F"));
} else {
Serial.println(F("Sent"));
}
screenNumber = 6;
curPos = 0;
} else if (screenNumber == 7) {
screenNumber = 5;
curPos = 0;
} else {
screenNumber = screenNumber;
// Essentially, do nothing.
}
break;
}
case 256:{ // Screen 15 - Network info.
......
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