@@ -77,12 +77,14 @@ int ExtGPIO(int gpio, char* mode, int value) {
77
77
return retval;
78
78
}
79
79
80
+ GPIOManager GPIOManager::INSTANCE;
81
+
80
82
class FPPGPIOCommand : public Command {
81
83
public:
82
84
FPPGPIOCommand () :
83
85
Command (" GPIO" ) {
84
86
args.push_back (CommandArg (" pin" , " string" , " Pin" ).setContentListUrl (" api/gpio?list=true" ));
85
- args.push_back (CommandArg (" on" , " bool " , " On" ));
87
+ args.push_back (CommandArg (" on" , " string " , " Action " ). setContentList ({ " On" , " Off " , " Opposite " } ));
86
88
}
87
89
virtual std::unique_ptr<Command::Result> run (const std::vector<std::string>& args) override {
88
90
if (args.size () != 2 ) {
@@ -93,14 +95,27 @@ class FPPGPIOCommand : public Command {
93
95
const PinCapabilities& p = PinCapabilities::getPinByName (n);
94
96
if (p.ptr ()) {
95
97
p.configPin ();
96
- p.setValue (v == " true" || v == " 1" );
98
+ if (v == " On" || v == " on" || v == " true" || v == " True" || v == " 1" ) {
99
+ p.setValue (true );
100
+ GPIOManager::INSTANCE.fppCommandLastValue [n] = true ;
101
+ }
102
+ else if (v == " Off" || v == " off" || v == " false" || v == " False" || v == " 0" ) {
103
+ p.setValue (false );
104
+ GPIOManager::INSTANCE.fppCommandLastValue [n] = false ;
105
+ }
106
+ else if (v == " Opposite" || v == " opposite" ) {
107
+ GPIOManager::INSTANCE.fppCommandLastValue [n] = !GPIOManager::INSTANCE.fppCommandLastValue [n];
108
+ p.setValue (GPIOManager::INSTANCE.fppCommandLastValue [n]);
109
+ }
110
+ else {
111
+ return std::make_unique<Command::ErrorResult>(" Invalid Action" + v);
112
+ }
97
113
return std::make_unique<Command::Result>(" OK" );
98
114
}
99
115
return std::make_unique<Command::ErrorResult>(" No Pin Named " + n);
100
116
}
101
117
};
102
118
103
- GPIOManager GPIOManager::INSTANCE;
104
119
105
120
GPIOManager::GPIOManager () :
106
121
checkDebounces(false ) {
0 commit comments