Arduino Counter with button to reset

Hi, I searched in the forum but I didn't find a project simple as mine (and because it is that simple I have problems)

Basically, I want to create a 60 bpm counter that writes seconds in a Adfrauit 4 digit 7 segment display, make a buzzer sound at every second (like a metronome) and with an esternal button I want to reset anytime that counter. The aim is to put that counter in a car that runs in a circuit (or a shot piece of road) in a pre decided time (like 300 mt in 30 seconds, for exampre.

I'll put the code that I wrote.

The problem is that i think that the code that reset the counter it dosen't reset correctly and lost time in that process.

#include <Wire.h>
#include <SPI.h>
#include "Adafruit_LEDBackpack.h"

#define DISPLAY_ADDRESS   0x70
Adafruit_7segment clockDisplay = Adafruit_7segment();

int buzzer = 12;     //buzzer connesso al pin 12
int i=0;                  //counter
const byte interruptPin = 2;
volatile byte state = LOW;

int CurrentBuzzerMillis;
int StartBuzzerMillis;
int CurrentTempoMillis;
int StartTempoMillis;

void setup() 
{
  Serial.begin(9600);
  clockDisplay.begin(DISPLAY_ADDRESS);
  pinMode(buzzer,OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), reset, LOW);
  StartTempoMillis=millis();
}

void loop() 
{
  CurrentTempoMillis=millis();
  if(CurrentTempoMillis-StartTempoMillis>=1000)
  {
    StartBuzzerMillis=CurrentTempoMillis;
    i++;
     tone(buzzer,3000,200);         //suona nota sul pin 12 alla frequenza di 1000Hz
     CurrentBuzzerMillis=millis();
     if(CurrentBuzzerMillis-StartBuzzerMillis>=8)
     {
        noTone(buzzer);           
        StartBuzzerMillis=CurrentBuzzerMillis;
     }
    clockDisplay.print(i);
    clockDisplay.writeDisplay(); 
    StartTempoMillis=millis();
  }
}

void reset() 
{
  i=0;
}

You may lose up up to a second because your variable i is not synchronised with CurrentTempoMillis.

To solve that, you could also add this to reset():
StartTempoMillis=millis();

Incidentally, variable i should be declared as volatile.

Does it otherwise appear to work ?

Thank you for your reply.

I declared i as volatile and now is a little bit faster.

Instead, if I put StartTempoMillis=millis(); in the interrupt function, "i" will be shown every millisecond, so i will loose the fact that the display shows "i" only every 1 second.

Sorry for my english.

EDIT: I understood better what you said and I had put StartTempoMillis=millis(); ALSO in the reset function. Now it's working properly. I'll update you when I'll try with the chronometer.

Thank you a lot

finnishstyle:
. .
Instead, if I put StartTempoMillis=millis(); in the interrupt function, "i" will be shown every millisecond, so i will loose the fact that the display shows "i" only every 1 second.
. . .

What I meant was that the statement: StartTempoMillis=millis() ; should be in two places. 1) where you had it originally and 2) additionally in reset().