-
Notifications
You must be signed in to change notification settings - Fork 1
/
gpio_button.h
46 lines (34 loc) · 972 Bytes
/
gpio_button.h
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
39
40
41
42
43
44
45
46
// Copyright (c) Christoph M. Wintersteiger
// Licensed under the MIT License.
#ifndef _GPIO_BUTTON_H_
#define _GPIO_BUTTON_H_
#include <mutex>
#include "device.h"
class GPIOButton : public DeviceBase {
public:
GPIOButton(const char *chip_path, int offset, bool inverted=false);
virtual ~GPIOButton();
virtual const char* Name() const { return name; }
virtual void UpdateTimed();
virtual void UpdateFrequent();
virtual void UpdateInfrequent();
using DeviceBase::Read;
using DeviceBase::Write;
virtual void Write(std::ostream &os) const;
virtual void Read(std::istream &is);
virtual void Reset();
bool Read();
bool ReadBuffered() const;
void Write(bool value);
protected:
std::mutex mtx;
char name[256];
static constexpr const char *gpio_consumer = "WLMCD-GPIOButton";
struct gpiod_chip *chip;
struct gpiod_line *line;
const char *chip_path;
unsigned offset;
bool inverted;
int buffer;
};
#endif // _GPIO_BUTTON_H_