             {
                 digitalWrite(3, LOW);
                 discharging = true;
+                dischargeStart = millis();
             }
         }
         if( voltage < 3.0 )
         {
+            if( discharging )
+            {
+                discharged = true;
+            }
             digitalWrite(3, HIGH);
             discharging = false;
         }

        sprintf(line2, "%16s", str_volt);
        break;
    case MODE_DISCHARGE:
        sprintf(line1, "%16s", discharging ? "DISCHARGING..." : "DISCHARGE");
        sprintf(line2, "%6s %6s mA", str_volt, str_mA);
        break;
    case MODE_SERIAL_MON:
        sprintf(line1, "%16s", serial_buf2);

char str_vcc[6];
char str_volt[6];
char str_mA[6];
char str_mAh[8];
char serial_buf1[20];
char serial_buf2[20];
int serial_buf_line_no = 1;
