| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <list> | ||
| 4 | #include <memory> | ||
| 5 | #include <string> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | class FPPStatusOLEDPage; | ||
| 9 | class PinCapabilities; | ||
| 10 | |||
| 11 | #include <atomic> | ||
| 12 | |||
| 13 | class FPPOLEDUtils { | ||
| 14 | public: | ||
| 15 | FPPOLEDUtils(int ledType); | ||
| 16 | ~FPPOLEDUtils(); | ||
| 17 | |||
| 18 | void run(); | ||
| 19 | void cleanup(); | ||
| 20 | |||
| 21 | // Set by fppoled's SIGINT/SIGTERM handlers (a lock-free atomic is all a | ||
| 22 | // handler may touch); run() returns once it is non-zero. | ||
| 23 | static std::atomic<int> exitSignal; | ||
| 24 | |||
| 25 | class InputAction { | ||
| 26 | public: | ||
| 27 | 9 | InputAction() {} | |
| 28 | ~InputAction(); | ||
| 29 | |||
| 30 | class Action { | ||
| 31 | public: | ||
| 32 | 10 | Action(const std::string& a, int min, int max, long long mai, const PinCapabilities* pin = nullptr) : | |
| 33 | 10 | action(a), | |
| 34 | 10 | actionValueMin(min), | |
| 35 | 10 | actionValueMax(max), | |
| 36 | 10 | minActionInterval(mai), | |
| 37 | 10 | nextActionTime(0), | |
| 38 | 10 | gpiodPin(pin) {} | |
| 39 | 40 | virtual ~Action() {} | |
| 40 | |||
| 41 | std::string action; | ||
| 42 | int actionValueMin; | ||
| 43 | int actionValueMax; | ||
| 44 | long long minActionInterval; | ||
| 45 | long long nextActionTime; | ||
| 46 | |||
| 47 | virtual bool checkAction(int i, long long ntimeus); | ||
| 48 | const PinCapabilities* gpiodPin = nullptr; | ||
| 49 | }; | ||
| 50 | |||
| 51 | std::string pin; | ||
| 52 | std::string mode; | ||
| 53 | std::string edge; | ||
| 54 | const PinCapabilities* gpiodPin = nullptr; | ||
| 55 | int file = -1; | ||
| 56 | int pollIndex = -1; | ||
| 57 | std::list<Action*> actions; | ||
| 58 | |||
| 59 | virtual const std::string& checkAction(int i, long long time); | ||
| 60 | }; | ||
| 61 | |||
| 62 | private: | ||
| 63 | int _ledType; | ||
| 64 | FPPStatusOLEDPage* statusPage; | ||
| 65 | |||
| 66 | std::vector<InputAction*> actions; | ||
| 67 | |||
| 68 | bool setupControlPin(const std::string& file); | ||
| 69 | bool parseInputActions(const std::string& file); | ||
| 70 | bool parseInputActionFromGPIO(const std::string& file); | ||
| 71 | |||
| 72 | InputAction* configureGPIOPin(const std::string& pin, | ||
| 73 | const std::string& mode, | ||
| 74 | const std::string& edge, | ||
| 75 | const std::string& name = ""); | ||
| 76 | |||
| 77 | void setInputFlag(const std::string& action); | ||
| 78 | int inputFlags = 0; | ||
| 79 | }; | ||
| 80 |