12345678910111213141516171819202122232425262728293031323334353637 |
- #include <gpiod.h>
- #include <list>
- #include <mutex>
- // This is a class GPIO explorer that uses the libgpiod library to read the state of a GPIO pin.
- class GPIOExplorer
- {
- public:
- GPIOExplorer(const char *chipname, int line_offset);
- ~GPIOExplorer();
- int read();
- int monitorRisingEdge();
- bool getFailingStatus(int index) {
- return FailingStatus & (1 << index);
- };
- void resetFailingStatus(int index) {
- std::lock_guard<std::mutex> lock(m_mutex);
- FailingStatus = FailingStatus & ~(1 << index);
- }
- std::mutex* getMutex(){return &m_mutex;}
- bool detectZWave();
- void close();
- private:
- struct gpiod_chip *chip;
- struct gpiod_line *line;
- std::list<int> m_StatusList;
- bool StatusKeep{false};
- unsigned char FailingStatus{0x00};
- std::mutex m_mutex;
- };
- extern GPIOExplorer* g_gpioExplorer;
|