#pragma once
#include <Arduino.h>

enum class ButtonEvent : uint8_t { NONE, SHORT, LONG, REPEAT };

class Button {
 public:
  explicit Button(uint8_t pin) : pin_(pin) {}
  void begin();
  ButtonEvent update(uint32_t nowMs);
  void suppressUntilRelease();
  bool pressed() const { return stable_; }
 private:
  uint8_t pin_;
  bool raw_ = false, stable_ = false, longSent_ = false;
  bool suppressed_ = false;
  uint32_t changedAt_ = 0, pressedAt_ = 0, nextRepeat_ = 0;
};

