diff --git a/firmware/v01/Makefile b/firmware/v01/Makefile index 670b73a..5faafa4 100644 --- a/firmware/v01/Makefile +++ b/firmware/v01/Makefile @@ -4,7 +4,6 @@ BOARD_TAG = pro BOARD_SUB = 8MHzatmega328 USER_LIB_PATH += /home/ricardo/Arduino/libraries ARDUINO_LIBS += Adafruit_GFX_Library \ - Adafruit_GPS_Library \ SoftwareSerial \ Adafruit_SSD1306 \ SPI \ diff --git a/firmware/v01/v01.ino b/firmware/v01/v01.ino index 8f49e24..113efc1 100644 --- a/firmware/v01/v01.ino +++ b/firmware/v01/v01.ino @@ -13,7 +13,7 @@ Wed 24 Jan 23:11:25 GMT 2018 #include #include #include -#include +//#include #define OLED_RESET 8 Adafruit_SSD1306 display(OLED_RESET); @@ -43,7 +43,7 @@ void two(); // Menu two void three(); // Menu three void read_serial(); // Menu that reads the serial void write_serial(); // Menu that writes to serial -void config(); // Configuration menu +void config_nmm(); // Configuration menu void batt_icon(); // Draws the battery icon acording to value @@ -61,6 +61,7 @@ int chars = 0; char sentence[68]; String s; int i; +int read_s = 0; // Create SoftwareSerial object and designate pins @@ -81,8 +82,7 @@ void setup() { // BEGIN SETUP ------------------------------------ digitalWrite(led2,HIGH); // Turn off led 2 // set the data rate for the SoftwareSerial port - mySerial.begin(4800); - + // set the data rate for the Serial port Serial.begin(4800); @@ -207,24 +207,40 @@ void loop() { if (menuState == 1) { one(); + mySerial.end(); + read_s = 0; } else if (menuState == 2) { two(); + mySerial.end(); + read_s = 0; } else if (menuState == 3) { three(); + mySerial.end(); + read_s = 0; } else if (menuState == 10) { + if (read_s == 0) { + mySerial.begin(4800); + read_s = 1; + } read_serial(); } else if (menuState == 11) { write_serial(); + mySerial.end(); + read_s = 0; } else if (menuState == 12) { - config(); + config_nmm(); + mySerial.end(); + read_s = 0; } else { one(); + mySerial.end(); + read_s = 0; } } @@ -337,58 +353,19 @@ void read_serial (void) { // display.setTextWrap(false); - - - if (mySerial.available()) { -// sentence[i] = mySerial.readString(); - Serial.print((char)mySerial.read()); - } - delay(10); + -/* - // 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){ - lines++; - chars = 0; - } - display.print((char)incomingByte); - display.display(); - delay(10); + + if (mySerial.available()) { + Serial.write(mySerial.read()); + } - // 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; - } - } -*/ + -/* - incomingByte = mySerial.read(); - if (incomingByte == '$') { - sentence[0] = incomingByte; - i++; - } - if (incomingByte != '$' && incomingByte != '\r') { - sentence[i] = incomingByte; - i++; - } - if (i == 68) { - display.println(sentence); - display.display(); - } -*/ } @@ -402,13 +379,13 @@ void write_serial (void) { display.println("Sending GPS....."); batt_icon(); 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(); +// 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); } -void config (void) { +void config_nmm (void) { display.clearDisplay(); display.setTextSize(1);