Fixed menus.

This commit is contained in:
Ricardo
2018-01-25 01:23:25 +00:00
parent 1a1cdfc8ab
commit 59563564c7

View File

@@ -1,7 +1,7 @@
/********************************************************************* /*********************************************************************
NMM-1
NMEA0183 serial monitor.
By Jony Silva By Jony Silva
Wed 24 Jan 23:11:25 GMT 2018 Wed 24 Jan 23:11:25 GMT 2018
@@ -35,7 +35,7 @@ Adafruit_SSD1306 display(OLED_RESET);
#define rCANCEL digitalRead(CANCEL) // Read button CANCEL state #define rCANCEL digitalRead(CANCEL) // Read button CANCEL state
// Function declarations
void zero(); void zero();
void one(); void one();
void two(); void two();
@@ -43,12 +43,15 @@ void three();
void four(); void four();
void read_serial(); void read_serial();
void write_serial(); void write_serial();
void config();
void batt_icon();
//volatile byte state = LOW; //volatile byte state = LOW;
// Variables creation // Variables creation
int menuState = 0; // Integer with the number of the menu you are in int menuState = 1; // Integer with the number of the menu you are in
int prevMenu = 1; // Previous menu
int UP_state = OFF; // Holds state for UP, either ON or OFF int UP_state = OFF; // Holds state for UP, either ON or OFF
int OK_state = OFF; // Holds state for OK, either ON or OFF 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
@@ -124,43 +127,76 @@ void setup() { // BEGIN SETUP ------------------------------------
ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence
{ // or to show the temperature on the LEDs { // or to show the temperature on the LEDs
if (!rUP) {
digitalWrite(led1, !digitalRead(led1)); if (menuState == 1) {
if (!rUP && menuState == 1) {
menuState = 1; menuState = 1;
} }
if (!rUP && menuState == 2) { else if (menuState == 2) {
menuState = 1; menuState = 1;
} }
if (!rUP && menuState == 3) { else if (menuState == 3) {
menuState = 4; menuState = 4;
} }
if (!rUP && menuState == 4) { else if (menuState == 4) {
menuState = 1; menuState = 1;
} }
while (!rUP); // Check if button is still pressed do nothing
}
if (!rDOWN && menuState == 1) { if (!rDOWN) {
if (menuState == 1) {
menuState = 2; menuState = 2;
} }
if (!rDOWN && menuState == 2) { else if (menuState == 2) {
menuState = 3; menuState = 3;
} }
if (!rDOWN && 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
}
if (!rOK && menuState == 1) { if (!rOK) {
if (menuState == 1) {
menuState = 10; menuState = 10;
prevMenu = 1;
} }
if (!rOK && menuState == 2) { else if (menuState == 2) {
menuState = 11; menuState = 11;
prevMenu = 2;
} }
else if (menuState == 3) {
menuState = 12;
prevMenu = 3;
}
else if (menuState == 4) {
menuState = 11;
prevMenu = 4;
}
while (!rOK); // Check if button is still pressed do nothing
}
if (!rCANCEL) { if (!rCANCEL) {
if (prevMenu == 1) {
menuState = 1; menuState = 1;
} }
else if (prevMenu == 2) {
menuState = 2;
}
else if (prevMenu == 3) {
menuState = 3;
}
else if (prevMenu == 4) {
menuState = 4;
}
while (!rCANCEL); // Check if button is still pressed do nothing
}
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -188,10 +224,12 @@ void loop() {
else if (menuState == 11) { else if (menuState == 11) {
write_serial(); write_serial();
} }
else { else if (menuState == 12) {
zero(); config();
}
else {
one();
} }
} }
@@ -315,3 +353,16 @@ void write_serial (void) {
} }
void config (void) {
display.drawRect(0, 8, 168, 24, BLACK);
display.display();
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(46,17);
display.println("BLOCKED");
batt_icon();
display.display();
}