summaryrefslogtreecommitdiffhomepage
path: root/StatusLED.h
blob: 9348f192c47c249b667c601657bac63605573abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <vector>
#include <filesystem>

struct LED
{
  // the root to the whole LED interface, e.g. "/sys/class/leds/ACT"
  std::filesystem::path green;
  std::filesystem::path red;
};

class StatusLED
{
public:
  enum class Mode
  {
    OK,     // green
    OKBeat, // green with heartbeat
    Error,  // red
  };

  StatusLED();

  void add(const LED& led);

  void setMode(Mode mode);
  void setBPM(int bpm);

private:
  bool init(const LED& led);
  void update(const LED& led);

  std::vector<LED> m_leds; // on best effort base, those will all show the same status
  Mode m_mode;
  int m_bpm;
};