Reset and Starting Timers at Zero

I have been given a brilliant piece of code for a Timer Counter by one of the Forum Members of which I managed to modify to make into a Countdown Timer by pure dumb luck. Now I have not been able to figure out how to compensate for any start up delays in the code except to add RunMillis = millis() - 5000. That’s fine if my only delay is a 5 second start delay but what I need to compensate for is a variable delay that will be my Welcome and Instruction Screen i.e. “Connect Battery and Press Start”. I will also need to reset the Countdown Timer once it hits Zero which has stumped me as well.

I’ve been banging my head against the wall for hours trying to figure out why I cannot seem to fix what looks like an incredibly easy problem so now I must ask the experts. I must somehow send a value of zero to the Timers after the Startup Delays but my compensation either does nothing, stops the Timers or they run at the wrong speed. The delay(5000); in void setup(); is just there to test if any compensation I test works and will be removed.

Please and Thank you.

#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

const int VoltInPin = 15;
const int TempHVoltOut = 53;          //Change when Current Sensor is used.
unsigned long LastActionTimeA = 0;
unsigned long RunMillis = 0;
unsigned long RunMillisDown = 0;
unsigned long AllSecondsUp = 0;
unsigned long RunTimeUp = 0;
unsigned long AllSecondsDown = 0;
unsigned long MillisDown = 0;
int RunHoursUp = 0;
int RunHoursDown = 0;
int SecsRemainingUp = 0;
int SecsRemainingDown = 0;
int RunMinutesUp = 0;
int RunMinutesDown = 0;
int RunSecondsUp = 0;
int RunSecondsDown = 0;
float InputVolts = 0.0;
float InputAmps = 0.0;
int AnalogValue = 0;
int Samples = 0;
float TotalAmps = 0.0;
float AverageAmps = 0.0;
float AmpMillis = 0.0;
float AmpHours = 0.0;
float Temp = 0.0;
unsigned long CurrentMillis = 0;
unsigned long CurrentSeconds = 0;
unsigned long CountDownSeconds = 10;
unsigned long CounterTime = 0;
unsigned long UpTimeMillis = 0;

void setup()
{
  lcd.begin(16, 2);
  LastActionTimeA = millis();
  pinMode(VoltInPin, INPUT);
  pinMode(TempHVoltOut, OUTPUT);            //Delete when Current Sensor added
  digitalWrite(TempHVoltOut, HIGH);         //Delete when Current Sensor added
//  lcd.clear();
//  lcd.print("Connect Battery");
//  lcd.setCursor(0, 1);
//  lcd.print("and Press Start");
UpTimeMillis = millis();
delay(5000);
}

int TimerA = 200;
uint8_t i=0;

void loop()
{
  
  RunMillis = millis() - 5000;
  
  if (RunMillis - LastActionTimeA >= TimerA)

  {
    AnalogValue = analogRead(A15);
    InputVolts = 1 + (AnalogValue * 5.0) / 1023.0;
      
  if (InputVolts < 0.1)
    InputVolts = 0.0;
      
    lcd.setCursor(0, 1);
    lcd.print(InputVolts);
    lcd.print("V ");
    lcd.print(InputVolts);
    lcd.print("A ");

    Samples = ++Samples;
    InputAmps = InputVolts;               //Change when Current sensor is used
    TotalAmps = TotalAmps + InputAmps;
    AverageAmps = TotalAmps / Samples;
    AmpMillis = RunMillis * AverageAmps;
    AmpHours = AmpMillis / 3600000;
      
    lcd.print(AmpHours);
    lcd.print("AH");
    LastActionTimeA = RunMillis;
  }

  
    { //Count Up Timer
      
      AllSecondsUp = RunMillis / 1000;
      RunHoursUp = AllSecondsUp / 3600;
      SecsRemainingUp = AllSecondsUp % 3600;
      RunMinutesUp = SecsRemainingUp / 60;
      RunSecondsUp = SecsRemainingUp % 60;

      char buf[8];
      sprintf(buf, "%02d:%02d:%02d", RunHoursUp, RunMinutesUp, RunSecondsUp);
      lcd.setCursor(0, 0);
      lcd.print(buf);
      lcd.print("   ");
    }


    { //Count Down Timer CounterTime = ((HRS * 3600000) + (MINS * 60000) + (SECS * 1000) + 1000(One Second of Padding is Required for Some Reason?))
      CounterTime = ((00 * 3600000) + (00 * 60000) + (10 * 1000) + 1000);
      MillisDown = RunMillis;
      RunMillisDown = -1 * MillisDown + CounterTime;
      AllSecondsDown = RunMillisDown / 1000;
      RunHoursDown = AllSecondsDown /3600;
      SecsRemainingDown = AllSecondsDown % 3600;
      RunMinutesDown = SecsRemainingDown / 60;
      RunSecondsDown = SecsRemainingDown % 60;
      
      char buf[5];
      sprintf(buf, "%02d:%02d", RunMinutesDown, RunSecondsDown);
      lcd.print(buf);
    }


}

buf is too small. Twice.

The original code had buf set to 21 and I adjusted it to 8 because it didn't seem to make any difference. I guess I truly don't understand what I was given and how it works.

I will increase it and see where I can get.

Thanks