inav icon indicating copy to clipboard operation
inav copied to clipboard

PINIO: Fix inverted pin handling

Open mluessi opened this issue 1 year ago • 2 comments

PINIO pins that are inverted are initially set to High and the internal state is false, which is correct. But in pinioSet the newState was XOR-ed with the inverted flag before comparing with the stored state. So when calling pinioSet with on = True, the pin was not set to Low as it should. To put the pin in the correct state, one therefore had to call pinioSet with on = False first.

Due to this bug, it was e.g. necessary to toggle the RC transmitter switch assigned to the VTX pit switch after boot to turn off the VTX, as the VTX was on even though the RC transmitter switch was in the "VTX off position" (pit switch active).

This PR fixes this bug by XOR-ing the new state with the inverted flag when calling IOWrite, such that the output of the pin is inverted.

mluessi avatar Dec 11 '23 22:12 mluessi

@stronnag I think this should be included in 7.1.0 as well.

mluessi avatar Dec 17 '23 14:12 mluessi

@stronnag I think this should be included in 7.1.0 as well.

Can you rebase the pr to release_7.1.0 branch?

mmosca avatar Jan 27 '24 14:01 mmosca