Lost on read serial.
This commit is contained in:
@@ -40,7 +40,6 @@ Adafruit_SSD1306 display(OLED_RESET);
|
|||||||
void one(); // Menu one
|
void one(); // Menu one
|
||||||
void two(); // Menu two
|
void two(); // Menu two
|
||||||
void three(); // Menu three
|
void three(); // Menu three
|
||||||
void four(); // Menu four
|
|
||||||
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(); // Configuration menu
|
||||||
@@ -74,7 +73,6 @@ void setup() { // BEGIN SETUP ------------------------------------
|
|||||||
pinMode(DOWN, INPUT); // Switch 3 is an input
|
pinMode(DOWN, INPUT); // Switch 3 is an input
|
||||||
pinMode(CANCEL, INPUT); // Switch 4 is an input
|
pinMode(CANCEL, INPUT); // Switch 4 is an input
|
||||||
|
|
||||||
|
|
||||||
// Define the starting state of the led's
|
// Define the starting state of the led's
|
||||||
digitalWrite(led1,HIGH); // Turn off led 1
|
digitalWrite(led1,HIGH); // Turn off led 1
|
||||||
digitalWrite(led2,HIGH); // Turn off led 2
|
digitalWrite(led2,HIGH); // Turn off led 2
|
||||||
@@ -130,10 +128,7 @@ ISR(TIMER1_COMPA_vect) //
|
|||||||
menuState = 1;
|
menuState = 1;
|
||||||
}
|
}
|
||||||
else if (menuState == 3) {
|
else if (menuState == 3) {
|
||||||
menuState = 4;
|
menuState = 2;
|
||||||
}
|
|
||||||
else if (menuState == 4) {
|
|
||||||
menuState = 1;
|
|
||||||
}
|
}
|
||||||
while (!rUP); // Check if button is still pressed do nothing
|
while (!rUP); // Check if button is still pressed do nothing
|
||||||
}
|
}
|
||||||
@@ -149,9 +144,6 @@ ISR(TIMER1_COMPA_vect) //
|
|||||||
else if (menuState == 3) {
|
else if (menuState == 3) {
|
||||||
menuState = 3;
|
menuState = 3;
|
||||||
}
|
}
|
||||||
else if (menuState == 4) {
|
|
||||||
menuState = 3;
|
|
||||||
}
|
|
||||||
while (!rDOWN); // Check if button is still pressed do nothing
|
while (!rDOWN); // Check if button is still pressed do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,10 +161,6 @@ ISR(TIMER1_COMPA_vect) //
|
|||||||
menuState = 12;
|
menuState = 12;
|
||||||
prevMenu = 3;
|
prevMenu = 3;
|
||||||
}
|
}
|
||||||
else if (menuState == 4) {
|
|
||||||
menuState = 11;
|
|
||||||
prevMenu = 4;
|
|
||||||
}
|
|
||||||
while (!rOK); // Check if button is still pressed do nothing
|
while (!rOK); // Check if button is still pressed do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,9 +175,6 @@ ISR(TIMER1_COMPA_vect) //
|
|||||||
else if (prevMenu == 3) {
|
else if (prevMenu == 3) {
|
||||||
menuState = 3;
|
menuState = 3;
|
||||||
}
|
}
|
||||||
else if (prevMenu == 4) {
|
|
||||||
menuState = 4;
|
|
||||||
}
|
|
||||||
while (!rCANCEL); // Check if button is still pressed do nothing
|
while (!rCANCEL); // Check if button is still pressed do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,9 +208,6 @@ void loop() {
|
|||||||
else if (menuState == 3) {
|
else if (menuState == 3) {
|
||||||
three();
|
three();
|
||||||
}
|
}
|
||||||
else if (menuState == 4) {
|
|
||||||
four();
|
|
||||||
}
|
|
||||||
else if (menuState == 10) {
|
else if (menuState == 10) {
|
||||||
read_serial();
|
read_serial();
|
||||||
}
|
}
|
||||||
@@ -299,131 +281,89 @@ void batt_icon (void) {
|
|||||||
|
|
||||||
void one (void) {
|
void one (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
display.clearDisplay();
|
||||||
display.display();
|
display.setTextSize(1);
|
||||||
display.clearDisplay();
|
display.setTextColor(WHITE);
|
||||||
display.setTextSize(1);
|
display.setCursor(1,12);
|
||||||
display.setTextColor(WHITE);
|
display.println("Receive NMEA0183 <--");
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,22);
|
||||||
display.println("Receive NMEA0183 <--");
|
display.println("Send NMEA0183");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,32);
|
||||||
display.println("Send NMEA0183");
|
display.println("Config NMEA0183");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void two (void) {
|
void two (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
display.clearDisplay();
|
||||||
display.display();
|
display.setTextSize(1);
|
||||||
display.clearDisplay();
|
display.setTextColor(WHITE);
|
||||||
display.setTextSize(1);
|
display.setCursor(1,12);
|
||||||
display.setTextColor(WHITE);
|
display.println("Receive NMEA0183");
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,22);
|
||||||
display.println("Receive NMEA0183");
|
display.println("Send NMEA0183 <--");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,32);
|
||||||
display.println("Send NMEA0183 <--");
|
display.println("Config NMEA0183");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void three (void) {
|
void three (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
display.clearDisplay();
|
||||||
display.display();
|
display.setTextSize(1);
|
||||||
display.clearDisplay();
|
display.setTextColor(WHITE);
|
||||||
display.setTextSize(1);
|
display.setCursor(1,12);
|
||||||
display.setTextColor(WHITE);
|
display.println("Receive NMEA0183");
|
||||||
display.setCursor(1,12);
|
display.setCursor(1,22);
|
||||||
display.println("Send NMEA0183");
|
display.println("Send NMEA0183");
|
||||||
display.setCursor(1,22);
|
display.setCursor(1,32);
|
||||||
display.println("Config NMEA0183 <--");
|
display.println("Config NMEA0183 <--");
|
||||||
batt_icon();
|
batt_icon();
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void four (void) {
|
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
|
||||||
display.display();
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setCursor(1,12);
|
|
||||||
display.println("Send NMEA0183 <--");
|
|
||||||
display.setCursor(1,22);
|
|
||||||
display.println("Config NMEA0183");
|
|
||||||
batt_icon();
|
|
||||||
display.display();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_serial (void) {
|
void read_serial (void) {
|
||||||
|
|
||||||
|
// display.setTextWrap(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Read text from the serial window
|
// Read text from the serial window
|
||||||
incomingByte = mySerial.read();
|
incomingByte = mySerial.read();
|
||||||
|
|
||||||
// Print incoming characters, if any, and keep track of the line and chars number
|
// Print incoming characters, if any, and keep track of the line and chars number
|
||||||
if(incomingByte != -1){
|
if(incomingByte != -1){
|
||||||
chars++;
|
chars++;
|
||||||
if(incomingByte == '\r' || chars == 21){
|
if(incomingByte == '\r' || chars == 21){
|
||||||
display.println();
|
lines++;
|
||||||
chars = 0;
|
chars = 0;
|
||||||
}
|
}
|
||||||
display.print((char)incomingByte);
|
display.print(incomingByte);
|
||||||
display.display();
|
display.display();
|
||||||
delay(10);
|
delay(10);
|
||||||
|
|
||||||
// Clear screen to print new message if we reach the end
|
// Clear screen to print new message if we reach the end
|
||||||
if(lines == 8){
|
if(lines == 8){
|
||||||
delay(500);
|
delay(500);
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(0,0);
|
display.setCursor(0,0);
|
||||||
lines = 0;
|
lines = 0;
|
||||||
chars = 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.display();
|
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
@@ -439,8 +379,6 @@ void write_serial (void) {
|
|||||||
|
|
||||||
void config (void) {
|
void config (void) {
|
||||||
|
|
||||||
display.drawRect(0, 8, 168, 24, BLACK);
|
|
||||||
display.display();
|
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
|
Reference in New Issue
Block a user