 
 void loop()
 {
+    getTime();
+
     if ( mode != MODE_SERIAL_MON)
     {
         mode %= NUM_MODE_ENUMS;

    if ( mode == MODE_DISCHARGE)
    {
        if ( g_Buttons.up_button != 0 &&
            g_LastButtons.up_button == 0)
        {
            digitalWrite(3, HIGH);
            discharging = false;
        }
        if ( g_Buttons.bottom_button != 0 &&
            g_LastButtons.bottom_button == 0)
        {
            if( voltage >= 3.0 )
            {
                digitalWrite(3, LOW);
                discharging = true;
                dischargeStart = millis();
            }
        }
        if( voltage < 3.0 )
        {
            if( discharging )
            {
                discharged = true;
            }
            digitalWrite(3, HIGH);
            discharging = false;
        }
    }
    else if ( mode == MODE_CHARGE)
    {
        if ( g_Buttons.up_button != 0 &&
            g_LastButtons.up_button == 0)
        {
            digitalWrite(9, HIGH);
            discharging = false;
        }
        if ( g_Buttons.bottom_button != 0 &&
            g_LastButtons.bottom_button == 0)
        {
            digitalWrite(9, LOW);
            charging = true;
        }
    }
    else if ( mode == MODE_LCD_TIMER)
    {
        // Serial.write("mode timer");
        if ( g_Buttons.up_button != 0 &&
            g_LastButtons.up_button == 0)
        {
            lcd_timer = 0;
            if ( lcd_timeout == 0 )
                lcd_timeout++;
            lcd_timeout *= 2;
            if ( lcd_timeout > 255 )
                lcd_timeout = 0;
            light = 1;
            EEPROM.write(eeprom_address, lcd_timeout);
        }
    }

    if ( lcd_timer > lcd_timeout &&
        lcd_timeout > 0 &&
        charging == false &&
        discharging == false)
    {
        light = 0;
    }

#include <EEPROM.h>
#include <Adafruit_INA219.h>

#define VERBOSE 1

Adafruit_INA219 ina219;
bool light = true;
int lastLight = 0;
double current_mA = 0;
bool g_charging = false;
bool g_charged = false;
bool g_discharging = false;
bool g_discharged = false;

enum MODE_ENUM
{
