2025-11-15 09:07:39 +08:00

31 lines
761 B
C++

#ifndef TIMER_H
#define TIMER_H
#include <Arduino.h>
#include "ui.h"
namespace esp32 {
namespace timer {
struct ClockState {
uint32_t startMs = 0; // 起始时间
uint32_t elapsedMs = 0; // 当前经过时间
static const int MAX_LAPS = 12;
uint16_t lapCount = 0;
float lapAngles[MAX_LAPS]; // 存储圈记录的角度(秒针位置)
uint32_t lapMs[MAX_LAPS]; // 每次记录的时间戳 (ms)
bool running = true;
};
void init(ClockState& s);
void reset(ClockState& s);
void update(ClockState& s, uint32_t nowMs);
void addLap(ClockState& s);
void buildScene(const ClockState& s, esp32::ui::DisplayList& out,
int16_t screenW, int16_t screenH);
} // namespace timer
} // namespace esp32
#endif // TIMER_H