Advertisement
sprocket2cog

Arduino Gauge 2.1

Nov 12th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.51 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Wire.h>
  3. #include <EEPROM.h>
  4. #include <Adafruit_GFX.h>
  5. #include <Adafruit_SSD1306.h>
  6.  
  7. #define OLED_RESET 4
  8. Adafruit_SSD1306 display(OLED_RESET);
  9. #include <Thermistor.h>
  10.  
  11. Thermistor temp(1);// A1- temperature probe
  12.  
  13.  int VOLTS_PIN = 0;  // the A0 pin the voltage divider from the bike is on. (12 volts=1.2 volts)
  14.  double volts=0;                           //setup volts (read pin in to this variable)
  15.  
  16. const int buttonPinA = 7;                 // the number of the pushbutton pin A (select
  17. const int buttonPinB = 9;                 // the number of the pushbutton pin B (reset)
  18. int readingA = LOW;// button A
  19. int readingB = LOW;// button B
  20. int lastButtonStateA = LOW;                // the previous reading from the input pin
  21. int lastButtonStateB = LOW;                // the previous reading from the input pin
  22. long lastDebounceTime = 0;                // the last time the output pin was toggled
  23. long debounceDelay = 100;                 // the debounce time; increase if the output flickers
  24. int buttonStateB;                          // the current reading from the input pin
  25. int buttonStateA;
  26. int SC1 = 0; // switch case var. update via button A to switch display options
  27.  
  28.  int TEMP_MAX=0;                          // variable to store the max read temp.
  29.  float VOLTS_MAX=0;                       // variable to store the max read volts.
  30.  int WARNING1=30;    //85-100?            // temperature warning thershold in deg C.
  31.  float WARNING2=15.5;                     // temperature warning thershold in volts
  32.  
  33.  unsigned long interval=45000;            // the time we need to wait to read max- to save writes to eeprom.
  34.  unsigned long previousMillis=0;          // millis() returns an unsigned long for timer checker
  35.  
  36. int OIL_ADDRS = 0;                        //address in EEPROM to store temperature max.
  37. int VOLTS_ADDRS = 1;                      //address in EEPROM to store volts max.
  38. int temperature=0;                        //setp temperature
  39.  
  40.  
  41. //center of screen
  42.  int x0=60;
  43.  int y0=32;  
  44.  int a=2;
  45.  // radius  
  46.  int r=30;  
  47.  int TEMP_SENSOR=0;  
  48.  double VOLTS_SENSOR=0;  
  49. // byte array for boot image screen in .xbm array format- search adafruit gfx xbitmap for details
  50. static const uint8_t  PROGMEM CAFE_XBM[] ={
  51.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  52.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  53.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  54.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  55.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  56.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  57.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  58.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  59.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff,
  60.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  61.    0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  62.    0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  63.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff,
  64.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  65.    0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  66.    0xff, 0xff, 0xff, 0x0f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  67.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xfe, 0xff, 0xff,
  68.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
  69.    0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  70.    0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  71.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xff,
  72.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
  73.    0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  74.    0xff, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  75.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xf0, 0xff, 0xff, 0xff,
  76.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
  77.    0xe0, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  78.    0xff, 0xff, 0x01, 0x00, 0x80, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  79.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff,
  80.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xc0,
  81.    0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  82.    0xff, 0x7f, 0x00, 0xf0, 0x01, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
  83.    0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x30, 0x00, 0x00, 0xe0, 0xff,
  84.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
  85.    0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  86.    0x7f, 0x20, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
  87.    0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  88.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
  89.    0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  90.    0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
  91.    0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
  92.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
  93.    0x00, 0x0c, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  94.    0x1f, 0x00, 0x00, 0x00, 0x40, 0x3c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  95.    0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf8,
  96.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x1e, 0x00,
  97.    0x00, 0x3e, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  98.    0x00, 0x00, 0x7c, 0x00, 0x00, 0x3e, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
  99.    0xff, 0xff, 0xff, 0x7f, 0xf0, 0x01, 0x78, 0x00, 0x00, 0x1e, 0xf0, 0xc1,
  100.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0x01, 0x18, 0x00,
  101.    0x00, 0x0c, 0xf0, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
  102.    0xfc, 0x30, 0x00, 0x00, 0x00, 0x04, 0xe1, 0x87, 0xff, 0xff, 0xff, 0xff,
  103.    0xff, 0xff, 0xff, 0x1f, 0x78, 0x30, 0x00, 0x00, 0x00, 0x84, 0xc3, 0x0f,
  104.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
  105.    0x00, 0xc6, 0x03, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
  106.    0x01, 0x00, 0x00, 0x00, 0x00, 0xc2, 0x03, 0x1e, 0xff, 0xff, 0xff, 0xff,
  107.    0xff, 0xff, 0xff, 0x1f, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc2, 0x01, 0x1e,
  108.    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x07, 0x60, 0x00, 0x00,
  109.    0x00, 0xc3, 0x01, 0x1e, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
  110.    0x0f, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x01, 0x1e, 0xfe, 0xff, 0xff, 0xff,
  111.    0xff, 0xff, 0xff, 0x1f, 0x0f, 0x00, 0x00, 0x00, 0x8c, 0xc3, 0x03, 0x1e,
  112.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1e, 0x00, 0x00, 0x00,
  113.    0x80, 0xc7, 0x07, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
  114.    0x7e, 0x3c, 0x00, 0x00, 0xc0, 0x87, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff,
  115.    0xff, 0xff, 0xff, 0x3f, 0xfc, 0x1f, 0x00, 0x00, 0xe0, 0x07, 0xff, 0x87,
  116.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0x0f, 0xfe, 0xff,
  117.    0xff, 0x0f, 0xfe, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
  118.    0xe0, 0x03, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xc0, 0xff, 0xff, 0xff, 0xff,
  119.    0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xe0,
  120.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff,
  121.    0xff, 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  122.    0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
  123.    0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff,
  124.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  125.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  126.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  127.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  128.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  129.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  130.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  131.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  132.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  133.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  134.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  135.    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  136.    0xff, 0xff, 0xff, 0xff };
  137.  
  138.  
  139.  
  140.  void setup()  {  
  141.   Serial.begin(9600);  
  142.   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C -use i2c scanner sketch to find your screen location.
  143.   display.stopscroll();
  144.   display.clearDisplay();
  145.  
  146.   display.drawXBitmap(0, 0,  CAFE_XBM, 128, 64, 1);
  147.    display.invertDisplay(true);
  148.    display.display();
  149.   delay(3000);
  150.  
  151.   display.invertDisplay(false);
  152.   display. fillRect( 0,  0, 128,  96, BLACK);
  153.   display.display();
  154.    
  155.   display.setTextSize(2);  
  156.   display.setTextColor(WHITE);  
  157.   display.setCursor(0,0);  
  158.  
  159.   TEMP_MAX = EEPROM.read(0);// turn on to use EEprom settings temp
  160.   VOLTS_MAX = EEPROM.read(1);// turn on to use EEprom settings volts
  161.  
  162.   delay(100);  //sanity delay on startup to make sure EEPROM is read
  163.   display.clearDisplay();  
  164.  
  165.  }  
  166.  void loop() {
  167.    temperature = temp.getTemp(); // read the thermistor value using the libary.
  168.    
  169.    volts = analogRead(VOLTS_PIN); // read in volts 0-1023 increments for 0-50 volt range.
  170.    volts = map(volts, 0, 1023,0,500); // remap the volts to a better range
  171.    volts = volts/10;     // divide by ten to get 0 to 50 volts again
  172.    volts= volts*.99;  // correction factor for the resistor divider voltage diferance
  173.    //volts=random(11,14);    // psuedo code to simulate volts during testing
  174.    
  175.    TEMP_SENSOR=temperature;//this is the variable for oil temperature from eeprom
  176.    VOLTS_SENSOR=volts;// this is the volts from EEPROM
  177.    readingB = digitalRead(buttonPinB); // READ THE INPUT PIN
  178.    readingA = digitalRead(buttonPinA);
  179.    
  180.    if (readingA!= lastButtonStateA) {
  181.     // reset the debouncing timer
  182.     lastDebounceTime = millis();
  183.     }
  184.    
  185.    if (readingB != lastButtonStateB) {
  186.     // reset the debouncing timer
  187.     lastDebounceTime = millis();
  188.     }
  189.      if ((unsigned long)(millis() - previousMillis) >= interval) {
  190.      previousMillis = millis();
  191.      readMax();// set new temperature data and update eeprom
  192.      readMaxV();// set new max volts if higher and save to eeprom
  193.   }
  194. //------------------
  195.   resetMax();// check if button B pressed and reset max values in eeprom
  196.   SELECT_A(); // button A, change screens
  197.   lastButtonStateA = readingA; // set button reaing A
  198.   lastButtonStateB = readingB; // SET THE STATE OF THE BUTTON B FOR CHECKING IT LATER
  199.  
  200. //----------------------------------------------
  201. //--- case switching here for different display optins.
  202. SELECT_A();
  203. switch (SC1){
  204.   case 0:  // main display screen 1
  205.     display.setTextSize(1);
  206.     voltsA(); // display volts needle
  207.     voltsB(0,0,0,8); // display volts text
  208.     oilA();   // display oil needle
  209.     oilB(0,45,0,55);   // display oil text
  210.     drawMAX(100,55);
  211.     drawMAXv(94,0);
  212.     MAX();//write the word max for main screen
  213.     DRAW_FACE();//draw the dial face circles last main screen
  214.     break;
  215.   case 1 :
  216.   display.setTextSize(2);
  217.     voltsB(0,0,56,0); // display volts text
  218.     oilB(0,48,72,48);   // display oil text
  219.     display.fillRect( 0,  30,  128,  4,  WHITE);
  220.     display.drawCircle( 120,  48, 3,  WHITE);
  221.  
  222.     break;  
  223.   case 2 :
  224.   display.setTextSize(1);
  225.   display.setCursor(0,0);
  226.   display.println("MAX STORED VALUES");
  227.   display.setTextSize(2);
  228.     voltsB(0,26,56,26); // display volts text
  229.     oilB(0,48,72,48);   // display oil text
  230.     display.fillRect( 50,  25,  82,  40,  BLACK);
  231.     drawMAX(72,48);
  232.     drawMAXv(56,26);
  233.     break;
  234. }
  235.  
  236. //---------------------------------------------
  237.   if(temperature > WARNING1){ //flash screen if temp gets above thershold
  238.     DRAW_INVERT();
  239.    
  240.   }
  241.    display.display();  
  242.    display.clearDisplay();  
  243.    delay(250);
  244.  }  
  245. //----end main void loop
  246.  
  247. //---------------start of function loops
  248.  
  249. void DRAW_FACE(){
  250.    //----center of the dial and the ring
  251.    display.drawCircle(x0, y0, r, WHITE);  
  252.    display.fillCircle( x0,  y0,  6,  WHITE);
  253.    display.fillCircle( x0,  y0,  3,  BLACK  );
  254. }
  255.  
  256. void voltsA(){ // voltage gauge needle
  257.    display.drawLine(x0,y0, x0+r*sin(-135+2*(VOLTS_SENSOR+90)*2*3.14/18), y0-r*cos(-135+2*(VOLTS_SENSOR+90)*2*3.14/18), WHITE);
  258.    display.fillCircle( x0,  y0,  20,  BLACK);
  259. }
  260. void voltsB(int x, int y, int x1, int y1){ // voltage text main screen
  261.    
  262.    display.setTextColor(WHITE);  
  263.    display.setCursor(0+x,0+y);
  264.    display.println("VOLT");
  265.    display.setCursor(0+x1,0+y1);    
  266.    display.println(VOLTS_SENSOR); //set voltage var to here later  
  267. }
  268.  void oilA(){ //oil gauge needle
  269.  
  270.    display.drawLine(x0,y0, x0+r*sin(293+2*(TEMP_SENSOR)*2*3.14/360), y0-r*cos(293+2*(TEMP_SENSOR)*2*3.14/360), WHITE);  
  271.    display.drawLine(x0+2,y0, x0+r*sin(293+2*(TEMP_SENSOR)*2*3.14/360), y0-r*cos(293+2*(TEMP_SENSOR)*2*3.14/360), WHITE);  
  272.    display.drawLine(x0-2,y0, x0+r*sin(293+2*(TEMP_SENSOR)*2*3.14/360), y0-r*cos(293+2*(TEMP_SENSOR)*2*3.14/360), WHITE);  
  273.    display.drawLine(x0,y0+2, x0+r*sin(293+2*(TEMP_SENSOR)*2*3.14/360), y0-r*cos(293+2*(TEMP_SENSOR)*2*3.14/360), WHITE);  
  274.    display.drawLine(x0,y0-2, x0+r*sin(293+2*(TEMP_SENSOR)*2*3.14/360), y0-r*cos(293+2*(TEMP_SENSOR)*2*3.14/360), WHITE);  
  275.    
  276.  }
  277.  
  278. void oilB(int x, int y, int x1, int y1){ // oil temp text main screen
  279.    
  280.    display.setTextColor(WHITE);  
  281.    display.setCursor(x,y);
  282.    display.println("OIL");
  283.    display.setCursor(x1,y1);    
  284.    display.println(TEMP_SENSOR); //display temperature
  285. }
  286.  
  287.  
  288.  
  289. void resetMax(){
  290.    if ((millis() - lastDebounceTime) > debounceDelay) {
  291.     if (readingB != buttonStateB) {
  292.       buttonStateB = readingB;
  293.       if (buttonStateB == HIGH) {
  294.         //ledState = !ledState;
  295.         TEMP_MAX=0;
  296.         VOLTS_MAX=0;
  297.       }
  298.     }
  299.   }
  300. }
  301.  
  302. void drawMAX(int x,int y){
  303.    display.setCursor(x,y);
  304.    display.println(TEMP_MAX);  
  305. }
  306.  
  307.  
  308. void MAX(){     //write the word MAX on screen
  309.   display.setTextColor(WHITE);  
  310.    display.setCursor(105,28);
  311.    display.println("MAX");
  312. }
  313.  
  314. void drawMAXv(int x, int y){ //draw max volts on screen
  315.    display.setCursor(x,y);
  316.    display.println(VOLTS_MAX);  
  317. }
  318.  
  319. void readMax(){
  320.   if(temperature > TEMP_MAX){
  321.     TEMP_MAX=temperature;
  322.     EEPROM.update(OIL_ADDRS, TEMP_MAX);//  turn on to start storing EEPROM data
  323.     display.setCursor(50,0);
  324.     display.println("SAVED");
  325.     delay(30);
  326.  }
  327. }
  328.  
  329. void readMaxV(){
  330.   if(volts > VOLTS_MAX){ // need to add function that reads analouge pin A2 and assigns volts
  331.     VOLTS_MAX=volts;
  332.     EEPROM.update(VOLTS_ADDRS, VOLTS_MAX);//  turn on to start storing EEPROM data
  333.     display.setCursor(50,0);
  334.     display.println("SAVED");
  335.     delay(300);
  336.  }
  337. }
  338.  
  339. void DRAW_INVERT(){
  340.    display.invertDisplay(true);
  341.   delay(10);
  342.   display.invertDisplay(false);
  343.   delay(10);
  344. }
  345.  
  346.  
  347. int SELECT_A(){
  348.    if ((millis() - lastDebounceTime) > debounceDelay) {
  349.     if (readingA != buttonStateA) {
  350.       buttonStateA = readingA;
  351.       if (buttonStateA == HIGH) {
  352.         if (SC1 < 2){
  353.           SC1= SC1+1;
  354.         }
  355.       else { SC1 =0;}
  356.        
  357.         //set SC to plus one etc if SC< 3 sc++  else SC=0;
  358.       }
  359.     }
  360.   }
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement