Transmitting GPS successfull. Working on reading nmea.
This commit is contained in:
@@ -55,6 +55,10 @@ int OK_state = OFF; // Holds state for OK, either ON or OFF
|
|||||||
int DOWN_state = OFF; // Holds state for DOWN, either ON or OFF
|
int DOWN_state = OFF; // Holds state for DOWN, either ON or OFF
|
||||||
int CANCEL_state = OFF; // Holds state for CANCEL, either ON or OFF
|
int CANCEL_state = OFF; // Holds state for CANCEL, either ON or OFF
|
||||||
int batt_val = 0; // Holds the value of battery voltage
|
int batt_val = 0; // Holds the value of battery voltage
|
||||||
|
int incomingByte; // Serial incoming byte buffer
|
||||||
|
int lines = 0;
|
||||||
|
int chars = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create SoftwareSerial object and designate pins
|
// Create SoftwareSerial object and designate pins
|
||||||
@@ -76,7 +80,7 @@ void setup() { // BEGIN SETUP ------------------------------------
|
|||||||
digitalWrite(led2,HIGH); // Turn off led 2
|
digitalWrite(led2,HIGH); // Turn off led 2
|
||||||
|
|
||||||
// set the data rate for the SoftwareSerial port
|
// set the data rate for the SoftwareSerial port
|
||||||
mySerial.begin(9600);
|
mySerial.begin(4800);
|
||||||
|
|
||||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||||
@@ -104,7 +108,7 @@ void setup() { // BEGIN SETUP ------------------------------------
|
|||||||
|
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(36,12);
|
display.setCursor(36,22);
|
||||||
display.println("NMM-1");
|
display.println("NMM-1");
|
||||||
display.display();
|
display.display();
|
||||||
delay(3000);
|
delay(3000);
|
||||||
@@ -301,9 +305,9 @@ void one (void) {
|
|||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,12);
|
||||||
display.println("Read NMEA0183 <--");
|
display.println("Receive NMEA0183 <--");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,22);
|
||||||
display.println("Write NMEA0183");
|
display.println("Send NMEA0183");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
@@ -317,9 +321,9 @@ void two (void) {
|
|||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,12);
|
||||||
display.println("Read NMEA0183");
|
display.println("Receive NMEA0183");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,22);
|
||||||
display.println("Write NMEA0183 <--");
|
display.println("Send NMEA0183 <--");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
@@ -333,7 +337,7 @@ void three (void) {
|
|||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,12);
|
||||||
display.println("Write NMEA0183");
|
display.println("Send NMEA0183");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,22);
|
||||||
display.println("Config NMEA0183 <--");
|
display.println("Config NMEA0183 <--");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
@@ -349,7 +353,7 @@ void four (void) {
|
|||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,12);
|
||||||
display.println("Write NMEA0183 <--");
|
display.println("Send NMEA0183 <--");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,22);
|
||||||
display.println("Config NMEA0183");
|
display.println("Config NMEA0183");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
@@ -359,29 +363,77 @@ void four (void) {
|
|||||||
|
|
||||||
void read_serial (void) {
|
void read_serial (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
|
||||||
display.display();
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setCursor(1,17);
|
|
||||||
display.println("Lets Read :)");
|
|
||||||
batt_icon();
|
|
||||||
display.display();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Read text from the serial window
|
||||||
|
incomingByte = mySerial.read();
|
||||||
|
|
||||||
|
// Print incoming characters, if any, and keep track of the line and chars number
|
||||||
|
if(incomingByte != -1){
|
||||||
|
chars++;
|
||||||
|
if(incomingByte == '\r' || chars == 21){
|
||||||
|
display.println();
|
||||||
|
chars = 0;
|
||||||
|
}
|
||||||
|
display.print((char)incomingByte);
|
||||||
|
display.display();
|
||||||
|
delay(10);
|
||||||
|
|
||||||
|
// Clear screen to print new message if we reach the end
|
||||||
|
if(lines == 8){
|
||||||
|
delay(500);
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setCursor(0,0);
|
||||||
|
lines = 0;
|
||||||
|
chars = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
display.drawRect(0, 8, 168, 24, BLACK);
|
||||||
|
display.display();
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setCursor(1,17);
|
||||||
|
// display.println("Lets Read :)");
|
||||||
|
// batt_icon();
|
||||||
|
// reading = mySerial.read();
|
||||||
|
// display.println(reading);
|
||||||
|
|
||||||
|
|
||||||
|
display.display();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_serial (void) {
|
void write_serial (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
display.drawRect(0, 8, 168, 24, BLACK);
|
||||||
display.display();
|
display.display();
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(1,17);
|
display.setCursor(1,17);
|
||||||
display.println("Lets Write :)");
|
display.println("Sending GPS.....");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
mySerial.print("$GPGGA,090000.10,6350.37829338,N,02225.18272240,W,1,05,2.87,160.00,M,-21.3213,M,,*64");
|
||||||
|
mySerial.println();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user