BridgeGain not getting set

Supporting 2.7 and 3.2+
Post Reply
zdwiel
Fresh meat
Posts: 3
Joined: Wed Jul 03, 2019 8:48 am
Contact:

BridgeGain not getting set

Post by zdwiel »

I've modified the VoltageRatioInput python example to set the Bridge Gain, but it doesn't seem to be actually setting. Here is the code and logs:

Code: Select all

# inside the onAttachHandler
print('bridge gain before', ph.getBridgeGain())
ph.setBridgeGain(BridgeGain.BRIDGE_GAIN_128)
print('bridge gain after', ph.getBridgeGain())

Code: Select all

# log:
bridge gain before 8
bridge gain after 8
After this, the code goes on to log some voltage ratios, so I know it is communicating with the hub ok.
zdwiel
Fresh meat
Posts: 3
Joined: Wed Jul 03, 2019 8:48 am
Contact:

Re: BridgeGain not getting set

Post by zdwiel »

Ok, so I figured out the problem. When the Phidgets documentation lists BridgeGain as an Enumeration, I had assumed it was a python Enum. In fact, they are just constants. The problem is that printing out the "enumeration" BridgeGain.BRIDGE_GAIN_128 displays the value 8. It would be nice if the enumeration could be more pythonic. For example from the python3 enum documentation:

Code: Select all

>>> from enum import Enum
>>> class Color(Enum):
...     RED = 1
...     GREEN = 2
...     BLUE = 3
>>> print(Color.RED)
Color.RED
>>> member = Color.RED
>>> member.name
'RED'
>>> member.value
1
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 19 guests