#include "U8glib.h"  
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI

enum class State {
    A,
    B,
    C
};

void setup() {
  Serial.begin(9600);
    Serial.println("egg salad5");
  pinMode(D2, INPUT);
  pinMode(D3, INPUT);
  u8g.setFont(u8g_font_tpssb);
  u8g.setColorIndex(1);
    Serial.println("egg salad6");

}

void loop() {

    State currentState = State::A;

        switch (currentState) {
            case State::A:
                if (digitalRead(D3)) {
                    currentState = State::B;
                    Serial.println("state 2");
                } else if (digitalRead(D2)) {
                    currentState = State::C;
                    Serial.println("starte 3");
                }
                break;
            case State::B:
            case State::C:
                // Add transitions for states B and C if needed
                break;
    }



  int a = analogRead(A0);
  int b = analogRead(A1);

  u8g.firstPage();
  do {

    // Prints the RPM potentiometer value
    u8g.drawStr(1, 10, "Velocity");
    enum {BufSize=9}; 
    char bufa[BufSize];
    snprintf (bufa, BufSize, "%d", a);
    u8g.drawStr(80, 10, bufa);
    //prints the Rof potentoiometer value
    u8g.drawStr(1, 25, "Rate of Fire");
    char bufb[BufSize];
    snprintf (bufb, BufSize, "%d", b);
    u8g.drawStr(80, 25, bufb);
    //prints the mode
    // The dipswitch is in lieu of a rotary switch
    u8g.drawStr(1, 40, "Mode Select");
    if (digitalRead(2)) {
      u8g.drawStr(80, 40, "Semi");
    }
    else if (digitalRead(3)) {
      u8g.drawStr(80, 40, "Burst 2");
    }
    else if (digitalRead(4)) {
      u8g.drawStr(80, 40, "Burst 3");
    }
    else if (digitalRead(5)) {
      u8g.drawStr(80, 40, "Full");
    }
    else {
      u8g.drawStr(80, 40, "Safe");
    }

}
  while ( u8g.nextPage() );
}