|
@@ -8,7 +8,6 @@
|
8
|
8
|
#include <pifacedigital.h>
|
9
|
9
|
|
10
|
10
|
int MainClass::current_device_ = -1;
|
11
|
|
-uint8_t MainClass::pins_ = 0;
|
12
|
11
|
|
13
|
12
|
MainClass::MainClass(int argc, char* argv[])
|
14
|
13
|
: argc_(argc)
|
|
@@ -88,13 +87,12 @@ bool MainClass::build_actions_()
|
88
|
87
|
actions_.push_back([arg, opt]() -> bool
|
89
|
88
|
{
|
90
|
89
|
if (get_current_device() == -1 &&
|
91
|
|
- !set_current_device(arg))
|
|
90
|
+ !set_current_device(0))
|
92
|
91
|
return false;
|
|
92
|
+ std::cout << "Setting pin " << arg << " " <<
|
|
93
|
+ (opt == 'u' ? "up" : "down") << std::endl;
|
93
|
94
|
pifacedigital_write_bit(opt == 'u', arg, OUTPUT,
|
94
|
95
|
get_current_device());
|
95
|
|
- /*pifacedigital_write_reg(opt == 'u' ? up_pin(arg) : down_pin(arg),
|
96
|
|
- OUTPUT, get_current_device());
|
97
|
|
- std::cout << std::hex << (int)get_pins() << std::endl;*/
|
98
|
96
|
return true;
|
99
|
97
|
});
|
100
|
98
|
}
|
|
@@ -104,6 +102,7 @@ bool MainClass::build_actions_()
|
104
|
102
|
return bad_value_();
|
105
|
103
|
actions_.push_back([arg]() -> bool
|
106
|
104
|
{
|
|
105
|
+ std::cout << "Sleeping " << (arg * 1000) << " ms" << std::endl;
|
107
|
106
|
usleep(arg * 1000);
|
108
|
107
|
return true;
|
109
|
108
|
});
|
|
@@ -143,27 +142,11 @@ int MainClass::get_current_device()
|
143
|
142
|
|
144
|
143
|
bool MainClass::set_current_device(int c)
|
145
|
144
|
{
|
|
145
|
+ std::cout << "Switching to device " << c << std::endl;
|
146
|
146
|
if (pifacedigital_open((current_device_ = c)) == -1)
|
147
|
147
|
{
|
148
|
148
|
std::cerr << std::endl;
|
149
|
149
|
return false;
|
150
|
150
|
}
|
151
|
|
- pifacedigital_enable_interrupts();
|
152
|
|
- pins_ = pifacedigital_read_reg(c, OUTPUT);
|
153
|
151
|
return true;
|
154
|
152
|
}
|
155
|
|
-
|
156
|
|
-uint8_t MainClass::get_pins()
|
157
|
|
-{
|
158
|
|
- return pins_;
|
159
|
|
-}
|
160
|
|
-
|
161
|
|
-uint8_t MainClass::up_pin(uint8_t pin)
|
162
|
|
-{
|
163
|
|
- return (pins_ |= (1 << pin));
|
164
|
|
-}
|
165
|
|
-
|
166
|
|
-uint8_t MainClass::down_pin(uint8_t pin)
|
167
|
|
-{
|
168
|
|
- return (pins_ &= ~(1 << pin));
|
169
|
|
-}
|