Skip to content

added keyword argument to UARTDevice to set power on one of the power…#468

Open
ste7anste7an wants to merge 1 commit intopybricks:masterfrom
ste7anste7an:uart_power
Open

added keyword argument to UARTDevice to set power on one of the power…#468
ste7anste7an wants to merge 1 commit intopybricks:masterfrom
ste7anste7an:uart_power

Conversation

@ste7anste7an
Copy link
Copy Markdown

The UARTDevice iodevice is a nice generic way to communicate with external devices using plain uart communciation. When external devices have more power needs than the 3v3 line can deliver (e.g. when driving NeoPixels or Servo motors), it would be nice when such a device can use 8V power coming from one of the power lines P1 or P2.

The PUPDevice iodevice allows for setting power on either P1 or P2 depending how that is negotiatied in the PUP protocol. For I2CDevices, there is a keyword argument powered that allows for powering P1 (not P2). Unfortunately, I2Cdevice is not present for prime hub or technic hub, only for EV3 hub (and there the powered does work, but is not effective, as the P1 pin is connected through a 330Ohm resistor, and the voltage drops sharply when connecting a device that draws some current.)

Proposed solution

I propose to add a keyword argument power_pin to the UARTDevice init method where the argument can be 0 (no power), 1 (P1 powered) or 2 (P2 powered).

In a pybricks program that would look like:

uart = UARTDevice(Port.A, power_pin = 1)

resulting in P1 powered and

uart = UARTDevice(Port.A, power_pin = 0)

resulting in P1 nor P2 powered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant