Digital¶
See the Digital Entity for generic information.
- class brainstem.entity.Digital(module, index)[source]¶
Interface to digital entities on BrainStem modules. Digital entities have the following 5 possibilities: Digital Input, Digital Output, RCServo Input, RCServo Output, and HighZ. Other capabilities may be available and not all pins support all configurations. Please see the product datasheet.
- getConfiguration()[source]¶
Get the digital configuration.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
Current configuration of the digital entity.
- Return type:
- getLinkChannel()[source]¶
Get the link channel (entity index) for linking digital entities.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
The current link channel (entity index) value.
- Return type:
- getState()[source]¶
Get the state.
Note
If in high Z state an error will be returned.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valuebool
The current state of the digital entity. 0 is logic low, 1 is logic high.
- Return type:
- getStateAll()[source]¶
Gets the logical state of all available digitals in a bit mapped representation. Number of digitals varies across BrainStem modules. Refer to the datasheet for the capabilities of your module.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned int
The state of all digitals where bit 0 = digital 0, bit 1 = digital 1 etc. 0 is logic low, 1 is logic high.
- Return type:
- getValue()[source]¶
Get the expected value of the digital pin.
- Returns:
- Object containing error code and returned value on success.
- errorunsigned byte
An error result from the list of defined error codes
- valueunsigned char
The expected value of the digital pin. 0 is logic low, 1 is logic high.
- Return type:
- setConfiguration(configuration)[source]¶
Set the digital configuration to one of the available 5 states.
- Parameters:
configuration (unsigned char) –
- The configuration to be applied
Digital Input: digitalConfigurationInput = 0
Digital Output: digitalConfigurationOutput = 1
RCServo Input: digitalConfigurationRCServoInput = 2
RCServo Output: digitalConfigurationRCServoOutput = 3
High Z State: digitalConfigurationHiZ = 4
Digital Input: digitalConfigurationInputPullUp = 0
Digital Input: digitalConfigurationInputNoPull = 4
Digital Input: digitalConfigurationInputPullDown = 5
Note
Some configurations are only supported on specific pins.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setLinkChannel(link_channel)[source]¶
Set the link channel (entity index) for linking digital entities. Two digital entities will link when one is configured as LinkInput, one as LinkOutput, and both have each others linkChannel indexes.
- Parameters:
link_channel (unsigned char) – The link channel (entity index) value. Entities with matching linkChannel values can be linked.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setState(state)[source]¶
Set the logical state.
- Parameters:
state (bool) – The state to be set. 0 is logic low, 1 is logic high.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte
- setStateAll(state)[source]¶
Sets the logical state of all available digitals based on the bit mapping. Number of digitals varies across BrainStem modules. Refer to the datasheet for the capabilities of your module.
- Parameters:
state (unsigned int) – The state to be set for all digitals in a bit mapped representation. 0 is logic low, 1 is logic high. Where bit 0 = digital 0, bit 1 = digital 1 etc.
- Returns:
An error result from the list of defined error codes in brainstem.result.Result
- Return type:
unsigned byte