#include <fDigitsSegtPin.h>
#include "button.h"
fDigitsSegtPin Display(6, 5, 9, 4, 8, 13, 3, 12, 11, 7, 2, 10);
button_ startStop(A0, INPUT_PULLUP);
button_ reset(A1, INPUT_PULLUP);
timer_ timer(1000);
void setup()
{
timer.restart();
Display.begin();
Display.doPrint_lastDot = 0;
Display.doPrint_firstZero = 1;
}
void loop()
{
static float deciSeconds = 0; //время, отображаемое на индикаторе
static boolean stop = false;
if (startStop.onPressed()) {
stop = !stop;
}
if (reset.onPressed())
{
if (stop == true) {
deciSeconds = 0;
}
}
if (timer.isExpired()) //прошла 1 сек
{
if (stop == false) {
deciSeconds += 0.01;
}
if (deciSeconds >= 99.99) // выход из диапазона
{
deciSeconds = 0;
}
timer.restart();
}
Display.print(deciSeconds); //периодический вызов функции в основном цикле
}