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
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
// Function declarations
void zero();
void one();
void two();
@@ -43,12 +43,15 @@ void three();
void four();
void read_serial();
void write_serial();
void config();
void batt_icon();
//volatile byte state = LOW;
// 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 OK_state = OFF; // Holds state for OK, either ON or OFF
int DOWN_state = OFF; // Holds state for DOWN, either ON or OFF
@@ -124,42 +127,75 @@ void setup() { // BEGIN SETUP ------------------------------------
ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence
{ // or to show the temperature on the LEDs
digitalWrite(led1, !digitalRead(led1));
if (!rUP && menuState == 1) {
menuState = 1;
}
if (!rUP && menuState == 2) {
menuState = 1;
}
if (!rUP && menuState == 3) {
menuState = 4;
}
if (!rUP && menuState == 4) {
menuState = 1;
}
if (!rUP) {
if (menuState == 1) {
menuState = 1;
}
else if (menuState == 2) {
menuState = 1;
}
else if (menuState == 3) {
menuState = 4;
}
else if (menuState == 4) {
menuState = 1;
}
while (!rUP); // Check if button is still pressed do nothing
}
if (!rDOWN && menuState == 1) {
menuState = 2;
}
if (!rDOWN && menuState == 2) {
menuState = 3;
}
if (!rDOWN && menuState == 3) {
menuState = 3;
}
if (!rDOWN) {
if (menuState == 1) {
menuState = 2;
}
else if (menuState == 2) {
menuState = 3;
}
else if (menuState == 3) {
menuState = 3;
}
else if (menuState == 4) {
menuState = 3;
}
while (!rDOWN); // Check if button is still pressed do nothing
}
if (!rOK && menuState == 1) {
menuState = 10;
}
if (!rOK && menuState == 2) {
menuState = 11;
}
if (!rCANCEL) {
menuState = 1;
if (!rOK) {
if (menuState == 1) {
menuState = 10;
prevMenu = 1;
}
else if (menuState == 2) {
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 (prevMenu == 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) {
write_serial();
}
else {
zero();
else if (menuState == 12) {
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();
}