Fixed reading from rs-422 to usb.
This commit is contained in:
@@ -4,7 +4,6 @@ BOARD_TAG = pro
|
|||||||
BOARD_SUB = 8MHzatmega328
|
BOARD_SUB = 8MHzatmega328
|
||||||
USER_LIB_PATH += /home/ricardo/Arduino/libraries
|
USER_LIB_PATH += /home/ricardo/Arduino/libraries
|
||||||
ARDUINO_LIBS += Adafruit_GFX_Library \
|
ARDUINO_LIBS += Adafruit_GFX_Library \
|
||||||
Adafruit_GPS_Library \
|
|
||||||
SoftwareSerial \
|
SoftwareSerial \
|
||||||
Adafruit_SSD1306 \
|
Adafruit_SSD1306 \
|
||||||
SPI \
|
SPI \
|
||||||
|
@@ -13,7 +13,7 @@ Wed 24 Jan 23:11:25 GMT 2018
|
|||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
#include <Adafruit_GPS.h>
|
//#include <Adafruit_GPS.h>
|
||||||
|
|
||||||
#define OLED_RESET 8
|
#define OLED_RESET 8
|
||||||
Adafruit_SSD1306 display(OLED_RESET);
|
Adafruit_SSD1306 display(OLED_RESET);
|
||||||
@@ -43,7 +43,7 @@ void two(); // Menu two
|
|||||||
void three(); // Menu three
|
void three(); // Menu three
|
||||||
void read_serial(); // Menu that reads the serial
|
void read_serial(); // Menu that reads the serial
|
||||||
void write_serial(); // Menu that writes to 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
|
void batt_icon(); // Draws the battery icon acording to value
|
||||||
|
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ int chars = 0;
|
|||||||
char sentence[68];
|
char sentence[68];
|
||||||
String s;
|
String s;
|
||||||
int i;
|
int i;
|
||||||
|
int read_s = 0;
|
||||||
|
|
||||||
|
|
||||||
// Create SoftwareSerial object and designate pins
|
// Create SoftwareSerial object and designate pins
|
||||||
@@ -81,8 +82,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(4800);
|
|
||||||
|
|
||||||
// set the data rate for the Serial port
|
// set the data rate for the Serial port
|
||||||
Serial.begin(4800);
|
Serial.begin(4800);
|
||||||
|
|
||||||
@@ -207,24 +207,40 @@ void loop() {
|
|||||||
|
|
||||||
if (menuState == 1) {
|
if (menuState == 1) {
|
||||||
one();
|
one();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
else if (menuState == 2) {
|
else if (menuState == 2) {
|
||||||
two();
|
two();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
else if (menuState == 3) {
|
else if (menuState == 3) {
|
||||||
three();
|
three();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
else if (menuState == 10) {
|
else if (menuState == 10) {
|
||||||
|
if (read_s == 0) {
|
||||||
|
mySerial.begin(4800);
|
||||||
|
read_s = 1;
|
||||||
|
}
|
||||||
read_serial();
|
read_serial();
|
||||||
}
|
}
|
||||||
else if (menuState == 11) {
|
else if (menuState == 11) {
|
||||||
write_serial();
|
write_serial();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
else if (menuState == 12) {
|
else if (menuState == 12) {
|
||||||
config();
|
config_nmm();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
one();
|
one();
|
||||||
|
mySerial.end();
|
||||||
|
read_s = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,58 +353,19 @@ void read_serial (void) {
|
|||||||
|
|
||||||
// display.setTextWrap(false);
|
// display.setTextWrap(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (mySerial.available()) {
|
|
||||||
// sentence[i] = mySerial.readString();
|
|
||||||
Serial.print((char)mySerial.read());
|
|
||||||
}
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Read text from the serial window
|
if (mySerial.available()) {
|
||||||
incomingByte = mySerial.read();
|
Serial.write(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);
|
|
||||||
|
|
||||||
// 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.....");
|
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.print("$GPGGA,090000.10,6350.37829338,N,02225.18272240,W,1,05,2.87,160.00,M,-21.3213,M,,*64");
|
||||||
mySerial.println();
|
// mySerial.println();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void config (void) {
|
void config_nmm (void) {
|
||||||
|
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
|
Reference in New Issue
Block a user