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