@@ -11,11 +11,10 @@ namespace xbot::driver::input {
1111
1212bool GpioInputDriver::OnInputConfigValue (lwjson_stream_parser_t * jsp, const char * key, lwjson_stream_type_t type,
1313 Input& input) {
14- auto & gpio_input = static_cast <GpioInput&>(input);
1514 if (strcmp (key, " line" ) == 0 ) {
1615 JsonExpectType (STRING);
17- gpio_input .line = GetIoLineByName (jsp->data .str .buff );
18- if (gpio_input .line == PAL_NOLINE) {
16+ input. gpio .line = GetIoLineByName (jsp->data .str .buff );
17+ if (input. gpio .line == PAL_NOLINE) {
1918 ULOG_ERROR (" Unknown GPIO line \" %s\" " , jsp->data .str .buff );
2019 return false ;
2120 }
@@ -41,23 +40,23 @@ static void LineCallback(void*) {
4140}
4241
4342bool GpioInputDriver::OnStart () {
44- for (const auto & input : inputs_ ) {
45- palSetLineMode (input.line , PAL_MODE_INPUT);
46- palSetLineCallback (input.line , LineCallback, nullptr );
47- palEnableLineEvent (input.line , PAL_EVENT_MODE_BOTH_EDGES);
43+ for (const auto & input : Inputs () ) {
44+ palSetLineMode (input.gpio . line , PAL_MODE_INPUT);
45+ palSetLineCallback (input.gpio . line , LineCallback, nullptr );
46+ palEnableLineEvent (input.gpio . line , PAL_EVENT_MODE_BOTH_EDGES);
4847 }
4948 return true ;
5049}
5150
5251void GpioInputDriver::OnStop () {
53- for (const auto & input : inputs_ ) {
54- palDisableLineEvent (input.line );
52+ for (const auto & input : Inputs () ) {
53+ palDisableLineEvent (input.gpio . line );
5554 }
5655}
5756
5857void GpioInputDriver::tick () {
59- for (auto & input : inputs_ ) {
60- input.Update (palReadLine (input.line ) == PAL_HIGH);
58+ for (auto & input : Inputs () ) {
59+ input.Update (palReadLine (input.gpio . line ) == PAL_HIGH);
6160 }
6261}
6362
0 commit comments