philander package¶
Submodules¶
philander.accelerometer module¶
Abstract interface for accelerometer sensors accessible via serial communication.
Provide an API to abstract from acceleration measurement devices.
- class Activity(*values)[source]¶
Bases:
EnumIdentifies general types of human walking activities, that an accelerometer is possibly able to detect or distinguish.
- running = 4¶
- still = 2¶
- unknown = 1¶
- walking = 3¶
- class AxesSign(*values)[source]¶
Bases:
FlagData class to name coordinate axes along with their positive or negative sign.
- all = 7¶
- none = 0¶
- sign = 8¶
- signNeg = 8¶
- signPos = 0¶
- x = 1¶
- y = 2¶
- z = 4¶
- class Configuration(item: ConfigItem = ConfigItem.implicit, value: int = 1, fifo: CfgFifo = None, rateMode: CfgRateMode = None, eventCondition: CfgInterrupt = None)[source]¶
Bases:
ConfigurationData class to describe common configuration settings.
Use the parental class
sensor.Configuration.itemattribute to de-multiplex the inner data types.- class CfgInterrupt(delay: int = 10, thrshld: int = 1500, hysteresis: int = 200, axes: philander.accelerometer.AxesSign = <AxesSign.z: 4>, event: philander.accelerometer.EventSource = <EventSource.dataReady: 1>)[source]¶
Bases:
object- delay: int = 10¶
- event: EventSource = 1¶
- hysteresis: int = 200¶
- thrshld: int = 1500¶
- class CfgRateMode(mValue: int = 2, control: philander.accelerometer.SamplingMode = <SamplingMode.normal: 2>)[source]¶
Bases:
object- control: SamplingMode = 2¶
- mValue: int = 2¶
- eventCondition: CfgInterrupt = None¶
- rateMode: CfgRateMode = None¶
- class Data(x: int = 0, y: int = 0, z: int = 0)[source]¶
Bases:
objectContainer type to wrap an accelerometer’s primary measurement result.
Measurement data should always be expressed as a signed value in per-mille of the standard gravity milli-g [mg] along the three axes. Of course:
1000 mg = 1 g = 9,80665 m/s^2
- x: int = 0¶
- y: int = 0¶
- z: int = 0¶
- class EventContext(source: EventSource = <EventSource.none: 0>, data: Data = None, status: int = 0)[source]¶
Bases:
EventContextData class holding the context information of an event (interrupt).
Use the
sourceattribute to de-multiplex the inner data items.- source: EventSource = 0¶
- status: int = 0¶
- class EventSource(*values)[source]¶
Bases:
FlagData class to hold known event (interrupt) sources.
- activity = 32768¶
- all = 4294967295¶
- dataReady = 1¶
- error = 262144¶
- fifoFull = 4¶
- fifoWatermark = 2¶
- gesture = 16384¶
- highG = 32¶
- highGTime = 64¶
- highSlope = 512¶
- highSlopeTime = 1024¶
- lowG = 8¶
- lowGTime = 16¶
- lowSlope = 128¶
- lowSlopeTime = 256¶
- lyingFlat = 65536¶
- none = 0¶
- orientation = 131072¶
- significantMotion = 2048¶
- step = 8192¶
- tap = 4096¶
- class Orientation(*values)[source]¶
Bases:
FlagData class to enumerate orientations that the device carrying the accelerometer may be in.
- faceDown = 4¶
- faceMask = 4¶
- faceUp = 0¶
- invalidFace = 32¶
- invalidMask = 240¶
- invalidStand = 16¶
- invalidTilt = 64¶
- landscapeLeft = 2¶
- landscapeRight = 3¶
- portraitDown = 1¶
- portraitUp = 0¶
- standMask = 3¶
- tiltFlat = 8¶
- tiltMask = 8¶
- tiltStand = 0¶
- unknown = 255¶
- class SamplingMode(*values)[source]¶
Bases:
EnumMnemonic type to identify different types of sampling techniques, such as averaging, normal or over-sampling.
- OSR2 = 3¶
- OSR4 = 4¶
- average = 1¶
- normal = 2¶
philander.actuator module¶
Abstract actuator interface.
Provide an API to abstract from any type of actuators. Only a very basic set of common types and functions is provided.
- class Actuator[source]¶
Bases:
objectUnified interface to parts and subsystems with mechanical capabilities.
This may involve some sort of motor to execute mechanical work, such as in gears, drives or stimulators. However, also other physical media like electricity (taser) or light (laser) might be the functional basis of an actuator.
An actuator is meant to reflect the most atomic component of a mechanical device. Several actuators may compose a more complex subsystem, such as a steering axis of a rover.
- action(pattern=None)[source]¶
Executes a predefined action or movement pattern with this actuator.
Runs an action on this actuator instance. The type of action can be specified further using the optional
patternparameter. In most cases, this will be an integer number designating one or the other pre-defined / default movement. If applicable, the value zero (0) shall encode a “move to home/rest/parking position” action. Also “switch off” could be a valid interpretation. A value of one (1) shall be used for “the standard/default movement”. The interpretation of other values is at the discretion of the implementation.- Parameters:
pattern (int) – The action pattern to execute.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- startOperation(direction=Direction.positive, strengthIntensity=0, onSpeedDuty=0, ctrlInterval=0, durationLengthCycles=0)[source]¶
Start a continuous or lengthy operation of this actuator instance.
Begin an operation, such as running a motor. The operation may or may not end automatically. In any case, the operation can be stopped intentionally by calling
stopOperation().The optional
directionparameter may be used to indicate the direction of the operation. Interpretation of left/right or positive/negative etc. is up to the implementation.The
strengthIntensityparameter may be used to set the drive strength or intensity of a movement. The strength should be given in a meaningful physical unit. If meant as an intensity, it should be an integer percentage in the range [0…100]. In the context of PWM control, this parameter may be interpreted as the voltage amplitude applied, expressed in milli Volt. This parameter is optional.The optional parameter
onSpeedDutymay indicate the speed of the movement or the length of the ON phase in a rectangular control signal. If interpreted as a speed, it should be given either as a value in meters per second (m/s) or as an integer percentage related to some maximum possible or reference speed. When controlling a PWM device, this is the duty cycle expressed as a percentage.The
ctrlIntervalparameter gives the total length of a periodic control interval, e.g. for PWM control. It is expressed in milliseconds. This parameter is optional.The parameter
durationLengthCyclesis optional. It and may be interpreted as a run time duration, preferably expressed as a number in milliseconds (ms). Alternatively, this parameter may also be interpreted as a way length for the actuator to go, preferably expressed as a number in millimeters (mm). Finally, this can also be the number of cycles to last, e.g. when controlling a PWM device. Then, this is a unitless integer number.See also:
stopOperation().- Parameters:
direction (Direction) – The direction to move the actuator in.
strengthIntensity (int) – The speed or intensity of the movement.
durationLengthCycles (int) – The duration, length or number of cycles to move.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- stopOperation()[source]¶
Immediately stops the current operation.
See also:
startOperation().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.adc module¶
Abstraction module for analogue-to-digital conversion.
Provide a convergence layer API to abstract from several different ADC implementing driver modules possibly installed on the target system.
- class ADC[source]¶
Bases:
ModuleAnalogue-to-digital converter abstraction class.
Provide access to and control over the underlying ADC hardware. For that, an implementing driver module is used. As a convergence layer, this class is to hide specifics and to level syntactic requirements of the implementing package.
- CHANNEL_DIE_TEMP = -1¶
- DEFAULT_SAMPLING_TIME = 100¶
- DEFAULT_VREF_LOWER = 0¶
- DEFAULT_VREF_UPPER = 3000¶
- DIGITAL_MAX = 65535¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
The given dictionary should not be None, on entry. Options not present in the dictionary will be added and set to their defaults on return. The following options are supported.
Key
Range
Default
adc.channel
pin name or channel number (e.g. 2 or “2”)
None
adc.samplingTime
Sampling time in microseconds; integer>=0
None
adc.vref.lower
lower reference voltage in mV; integer
adc.vref.upper
upper reference voltage in mV; integer
- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
none
- Return type:
None
- close()[source]¶
Closes this instance and releases associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- static getADC(provider=SysProvider.AUTO)[source]¶
Generates an ADC implementation according to the requested provider.
- Parameters:
provider (SysProvider) – The low-level lib to rely on, or AUTO for automatic detection.
- Returns:
An ADC implementation object, or None in case of an error.
- Return type:
- getDigital()[source]¶
Retrieve a sample and return its digital value.
Gives the most recent sample as a digital value between zero and the maximum digital value [0…DIGITAL_MAX].
- Returns:
A value in the range [0, DIGITAL_MAX] and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
- getVoltage()[source]¶
Retrieve a sample and return it as a voltage in mV.
Gives the most recent sample as a voltage value between the lower and upper reference voltage, expressed as milli Volts. Calibration and temperature correction is at the discretion of the implementation and hence, cannot be assured.
- Returns:
A mV-value in the range [vref_lower, vref_upper] and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
- open(paramDict)[source]¶
Opens the instance and sets it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setRunLevel(level)[source]¶
Select the power-saving operation mode.
Switches the instance to one of the power-saving modes or recovers from these modes. Situation-aware deployment of these modes can greatly reduce the system’s total power consumption.
- toVoltage(digital)[source]¶
Convert a digital value to its corresponding voltage in mV.
Map the digital sample value to the range of [vref_lower, vref_upper] and return the corresponding voltage expressed in millivolts [mV].
- Parameters:
digital (int) – The digital value to convert. Must be in [0, 0xFFFF].
- Returns:
A mV-value in the range [vref_lower, vref_upper] and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
philander.adc_micropython module¶
philander.adc_sim module¶
ADC implementation with a built-in simulation.
philander.battery module¶
A module to reflect capabilities and properties of re-chargeable batteries.
- class Level(*values)[source]¶
Bases:
EnumLevel of a battery in [0…100]%
- deepDischarge = 0¶
- empty = 5¶
- static fromPercentage(percentage)[source]¶
Convert a given percentage into the corresponding level predicate.
Returns the largest level, that is less than or equal to the given percentage. So, the returned level is an underestimation. Or, to put it differently, the real capacity remaining is at least the level returned.
If the given percentage is
Percentage.invalidor does not compare to a number,Level.invalidis returned.Values below zero are mapped toLevel.min, while values beyond 100 are mapped toLevel.max.- Parameters:
percentage (Percentage) – The percentage value to be converted.
- Returns:
The largest level just under-estimating the given percentage.
- Return type:
- full = 90¶
- good = 70¶
- invalid = 255¶
- low = 20¶
- max = 100¶
- medium = 40¶
- min = 0¶
- class Status(*values)[source]¶
Bases:
FlagContainer class to reflect the battery status
- broken = 2¶
Charging takes (too) long; old/damaged battery
- cold = 256¶
Battery is too cold
- coldOrHot = 768¶
Battery temperature is outside its operating conditions
- empty = 16¶
Battery empty, deep discharge
- hot = 512¶
Battery is too hot
- low = 32¶
Battery voltage low
- normal = 0¶
Battery ok
- overcurrent = 128¶
Battery current to high
- overvoltage = 64¶
Battery voltage greater than threshold
- problemElectrical = 240¶
Any electrical problem
- problemPhysical = 15¶
Any physical problem
- problemThermal = 3840¶
Any thermal problem
- removed = 1¶
Battery removed
- unknown = 65535¶
Battery status information is unavailable
philander.bma456 module¶
Driver implementation for the BMA456 3-axis digital acceleromter.
More information on the functionality of the chip can be found at the Bosch-Sensortec site: https://www.bosch-sensortec.com/products/motion-sensors/accelerometers/bma456/#documents
- class BMA456[source]¶
Bases:
BMA456_Reg,SerialBusDevice,Accelerometer,InterruptableBMA456 driver implementation.
- ADDRESSES_ALLOWED = [24, 25]¶
Default address is 0x18 assuming that SDO is set/tied to GND.
Alternatively, the address can be 0x19 by pulling SDO high (VDDIO).
- BMA456_CHUNK_SIZE = 8¶
No. of bytes that can be written at once.
- BMA456_FEATUREBUF_CONTENT_IDX = 1¶
- BMA456_FEATUREBUF_HEADER_IDX = 0¶
- BMA456_FEATUREBUF_HEADER_SIZE = 1¶
- BMA456_FEATUREBUF_TOTAL_SIZE = 97¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address, one ofADDRESSES_ALLOWED; default isADDRESSES_ALLOWED[0].Sensor.dataRange
intMeasurement range in milli-g; default corresponds toBMA456_CNT_ACC_RANGE_DEFAULT.Sensor.dataRate
intData rate in Hz; default corresponds toBMA456_CNT_ACC_CONF_ODR_DEFAULT.BMA456.INT1_IO_CTRL
intContent of the INT1_IO_CTRL register; default isBMA456_CNT_INT1_IO_CTRL_DEFAULT.BMA456.INT2_IO_CTRL
intContent of the INT2_IO_CTRL register; default isBMA456_CNT_INT2_IO_CTRL_DEFAULT.BMA456.INT1_MAP
intContent of the INT1_MAP register; default isBMA456_CNT_INTX_MAP_DEFAULT.BMA456.INT2_MAP
intContent of the INT2_MAP register; default isBMA456_CNT_INTX_MAP_DEFAULT.BMA456.INT_MAP_DATA
intContent of the INT_MAP_DATA register; default isBMA456_CNT_INT_MAP_DATA_DEFAULT.BMA456.int1.gpio.direction
see
GPIO.Params_init(); default isGPIO.DIRECTION_IN.BMA456.int2.gpio.direction
see
GPIO.Params_init(); default isGPIO.DIRECTION_IN.BMA456.int1.gpio.trigger
see
GPIO.Params_init(); default isGPIO.TRIGGER_EDGE_FALLING.BMA456.int2.gpio.trigger
see
GPIO.Params_init(); default isGPIO.TRIGGER_EDGE_FALLING.BMA456.int1.gpio.bounce
see
GPIO.Params_init(); default isGPIO.BOUNCE_NONE.BMA456.int2.gpio.bounce
see
GPIO.Params_init(); default isGPIO.BOUNCE_NONE.All other BMA456.int1.gpio.* and BMA456.int1.gpio.* settings as documented at
GPIO.Params_init().For the
SerialBusDevice.addressvalue, also 0 or 1 can be specified alternatively to the absolute addresses to reflect the level of theSDOpin. In this case, 0 will be mapped to 0x18, while 1 maps to 0x19.Also see:
Sensor.Params_init(),SerialBusDevice.Params_init(),GPIO.Params_init().
- calibrate(calib)[source]¶
Execute a calibration.
The details for the calibration are given by the
calibparameter.Also see:
Sensor.calibrate(),Calibration.- Parameters:
calib (Calibration) – The calibration data.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- close()[source]¶
Shut down the device after usage.
This method should be called when the device is not used, anymore, e.g. as part of the application exit procedure. The following steps are executed:
shut down the device by switching to
RunLevel.shutdownclose serial communication, detach from bus.
close GPIO pins for int1 and int2
After return, the device can still be re-used, by calling
open()again.Also see:
SerialBusDevice.close(),GPIO.close(),Module.close().
- configure(config)[source]¶
Configure the device as specified in the
configparameter.Remember, the
configparameter should be an instance ofaccelerometer.Configuration. Its attributes are de-multiplexed bysensor.Configuration.item. The following configuration types are supported:ConfigItem.rate: The data rate given as an integer value in Hz is expected inConfiguration.value. If it doesn’t match a supported rate value exactly, it is rounded up appropriately. So, the rate actually configured may be slightly higher than the value given here. Furthermore, the sampling mode must be specified in theConfiguration.rateModeattribute. The chip supports under-sampling (SamplingMode.average), normal sampling and over-sampling (2x and 4x). For averaging mode, the number of samples to average must be given inConfiguration.rateMode.mValue.ConfigItem.range: TheConfiguration.valueattribute is expected to carry the measurement range given as an integer in milli-g. If the given value doesn’t match one of the hardware-supported range levels, exactly, it is rounded-up accordingly.ConfigItem.fifo: Not yet implemented.ConfigItem.eventArm: Selectively enables or disables certain event sources (interrupts). Remember that the following conditions must be fulfilled in order to get a specific interrupt fired:Interrupts must be enabled. See
enableInterrupt().That interrupt (event source) must be armed - using this method.
The corresponding interrupt condition must be true.
Note that the armed events are always configured to fire on both interrupt lines
interruptable.Event.evtInt1andinterruptable.Event.evtInt2. The bit mask of events to be armed is expected inaccelerometer.Configuration.valueas an equivalent ofaccelerometer.EventSource. The translation between the given event source and the underlying hardware interrupt is as follows:Event source
Hardware interrupt mapping bit mask
dataReady
INT_MAP_DATA: (INT1_DRDY | INT2_DRDY)
fifoWatermark
INT_MAP_DATA: (INT1_FIFO_WM | INT2_FIFO_WM)
fifoFull
INT_MAP_DATA: (INT1_FIFO_FULL | INT2_FIFO_FULL)
error
INTX_MAP: ERROR
lowSlopeTime
INTX_MAP: NO_MOTION
highSlopeTime
INTX_MAP: ANY_MOTION
gesture
INTX_MAP: WRIST_WKUP
activity
INTX_MAP: ACTIVITY
step
INTX_MAP: STEP_CNT
tap
INTX_MAP: STAP (wearable), TAP (hearable, MM)
significantMotion
INTX_MAP: SIG_MOTION
highGTime
INTX_MAP: HIGH_G
lowGTime
INTX_MAP: LOW_G
orientation
INTX_MAP: ORIENT
ConfigItem.eventCondition: Configures the trigger condition for parameterized events, such astaporlowGTime. The details, such as thresholds and delays, are expected in the givenconfig‘saccelerometer.Configuration.eventConditionattribute, which is de-multiplexed by itsaccelerometer.Configuration.CfgInterrupt.eventattribute.Note that the event sources
dataReady,fifoWatermark,fifoFullanderrorare not parameterized. They cannot be conditioned any further.The configuration of other event conditions is not implemented, yet.
Also see:
Sensor.configure().- Parameters:
config (.accelerometer.Configuration) – Specific configuration information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- dictAverage = <philander.dictionary.Dictionary object>¶
Dictionary to map config mode settings into averaging window size, i.e. the number of samples to average.
- dictConfigData = <philander.dictionary.Dictionary object>¶
- dictFeatureSetLength = <philander.dictionary.Dictionary object>¶
- dictRange = <philander.dictionary.Dictionary object>¶
The dictionary to map range setting bits into the corresponding range value, meant in milli-g.
- dictRate = <philander.dictionary.Dictionary object>¶
Dictionary to map data rate setting bits into the corresponding data rates, meant in Hz.
- disableInterrupt()[source]¶
Disable interrupts.
Switch off the interrupt functionality both, on the GPIO and the chip level.
Note that this method is just for switching the interrupt capability off. For switching it on, see
enableInterrupt().Also see
Interruptable.disableInterrupt().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableInterrupt()[source]¶
Enable the interrupt mechanism/engine.
Clear the interrupts that possibly occurred so far. Then, enable interrupt signaling at the corresponding GPIO pin. Finally, set the OUTPUT_ENABLE bit at the involved interrupt IO_CTRL registers.
Note that this method is just for switching the interrupt capability on. For switching it off, see
disableInterrupt(). For configuring interrupts, seeconfigure()andregisterInterruptHandler().Also see
Interruptable.enableInterrupt().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getEventContext(event, context)[source]¶
Retrieve more detailed information on an event.
Typically, an original event notification just carries the information, that an event/interrupt occurred. This method is to reveal more details on the cause of the interrupt.
The
eventparameter is an input to tell, which of the two interrupt lined actually fired. On return, thecontextparameter carries the resulting information. It must be an instance ofaccelerometer.EventContext, which is semantically multiplexed by itsaccelerometer.EventContext.sourceattribute. Depending on that event source indicator, the rest of the structure is filled as follows:Event source (flag)
Context attribute and data
dataReady
datalatest measurement as retrieved bygetLatestData()fifoWatermark, fifoFull
statusfifo status retrieved fromgetStatus()andStatusID.fifoactivity
statusactivity status retrieved fromgetStatus()andStatusID.activitystep
statusstep count retrieved fromgetStatus()andStatusID.stepCounthighGTime
statushigh-G status retrieved fromgetStatus()andStatusID.highGorientation
statusorientation retrieved fromgetStatus()andStatusID.orientationtap
statusTapinstance depending on feature set and interruptA single interrupt may have several reasons, simultaneously. That’s why, it may be meaningful/necessary to call this method repeatedly, until all reasons were reported. Upon its first call after an event, the context’s
interruptable.EventContext.controlattribute must be set tointerruptable.EventContextControl.evtCtxtCtrl_getFirst. Upon subsequent calls, this attribute should not be changed by the caller, anymore. In generally, event context information is retrieved in the order according to the priority of the corresponding event sources.The return value indicates, whether or not more information is available as follows:
Return value
Meaning
Success. Last context info. No more data to retrieve.
Success. Context is valid. More data to be retrieved.
No data to retrieve. Context is invalid.
any other ErrorCode.*
Error. Context data is invalid.
Also see:
Interruptable.getEventContext().- Parameters:
event (int) – The original event occurred, as received by the handling routine. This must be one of the event mnemonics defined by :class:
.interruptable.Event.context (.accelerometer.EventContext) – Context information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getInfo()[source]¶
Retrieve static information from the sensor chip.
Supported information is
Info.validModelIDandInfo.validChipID.Also see:
Sensor.getInfo().
- getLatestData()[source]¶
Retrieve the most-recent available measurement data.
This method is guaranteed to be non-blocking. Therefore, the data retrieved might be /old/ or /outdated/ to some extend.
The result is given as a data object containing 3 signed integers, representing the acceleration in milli-G in the x, y and z direction, respectively.
Also see:
Sensor.getLatestData().- Returns:
The measurement data and an error code indicating either success or the reason of failure.
- Return type:
- getNextData()[source]¶
Get the next-available measurement data.
This method is guaranteed to produce up-to-date measurement data. This may come at the price of a blocking delay.
As with
getLatestData(), the result is given as a data object containing three integers that represent the acceleration in x, y and z direction, respectively, expressed in milli-G.Also see:
Sensor.getNextData().- Returns:
The measurement data and an error code indicating either success or the reason of failure.
- Return type:
- getStatus(statID)[source]¶
Retrieve dynamic meta information from the sensor chip.
The information requested is indicated by the parameter
statID. The resulting status information is passed back as a part of the return value. The following information is available:accelerometer.StatusID.dieTemp: The chip temperature as read from the registerBMA456_REG_TEMPERATUREis returned as an Q8.8 integer given in degree Celsius.accelerometer.StatusID.dataReady: Returns a boolean to flag whether or not new data is available. For that, evaluates theDRDY_ACCbit inBMA456_REG_STATUSaccelerometer.StatusID.interrupt: Give the pending interrupts by readingBMA456_REG_INT_STATUS. This information is cleared until interrupt conditions are fulfilled anew. The result is given as anacceleroometer.EventSourcebit mask. The mapping of hardware interrupt bits to event source flags is as follows:Interrupt (Bit)
EventSource
ACC_DRDY
dataReady
ACTIVITY
activity
ANY_MOTION
highSlopeTime
AUX_DRDY
none
DBL_TAP
tap
ERROR
error
FIFO_FULL
fifoFull
FIFO_WM
fifoWatermark
HIGH_G
highGTime
LOW_G
lowGTime
NO_MOTION
lowSlopeTime
ORIENT
orientation
SIG_MOTION
significantMotion
STEP_COUNT
step
TAP_DETECT
tap
WRIST_WKUP
gesture
accelerometer.StatusID.fifo: Retrieve the FIFO length by readingBMA456_REG_FIFO_LENGTH. The result is returned as an integer value.accelerometer.StatusID.error: Gives the sensor health code as a 32-bit integer value, obtained by just concatenating the content of the registersBMA456_REG_INTERNAL_ERR:BMA456_REG_INTERNAL_STATUS:BMA456_REG_EVENT:BMA456_REG_ERRORin that order.accelerometer.StatusID.activity: For the wearable and hearable feature set, read the current activity from theBMA456_FSWBL_REG_ACTIVITY_TYPEregister and return the result as an instance ofActivity. Indicate a failure if another feature set is active.accelerometer.StatusID.stepCount: For the wearable and hearable feature set, return the current step count as read from the registerBMA456_FSWBL_REG_STEP_COUNTER. The result is given as a 32 bit integer number.accelerometer.StatusID.highG: For the MM feature set, retrieve the axis information for a high-G event from theBMA456_FSMM_REG_HIGH_G_OUTPUTregister. The result is passed back as anAxesSignbit mask.accelerometer.StatusID.orientation: For the MM feature set, retrieve the current orientation of the device as read from theBMA456_FSMM_REG_ORIENT_OUTPUTregister. The result is given as anOrientationbit mask.accelerometer.StatusID.tap: For the hearable and MM feature set, give the type of the recently detected tap (single, double etc.) as aTapbit mask after reading that information from theBMA456_FSHBL_REG_FEAT_OUTandBMA456_FSMM_REG_MULTITAP_OUTPUTregisters, respectively. For the wearable feature set, there are dedicated interrupts for this information, which get cleared upon reading. That’s why,getEventContext()should be intentionally used by the caller to retrieve this information.accelerometer.StatusID.sensorTime: Retrieve the current sensor time in milli-seconds [ms]. The result is given as a Q24.8 integer value.Also see:
Sensor.getStatus().- Parameters:
statID (accelerometer.StatusID) – Identifies the status information to be retrieved.
- Returns:
The status object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Set up serial communication and initialize the chip.
Must be called once, before the device can be used. Carry out the following steps:
establish serial communication, attach device to bus, if necessary.
execute the device initialization procedure, see chapter 4.2 of the data sheet for more information.
adjust data rate and measurement range
set up interrupt GPIO pins - direction, trigger etc.
set up interrupt behavior - registers IOCTRL, INT1_MAP etc.
enable interrupts
Additionally to the defaults generated by
Params_init(), the following configuration parameters are supported - as documented atGPIO.open():BMA456.int1.gpio.pinDesignator
BMA456.int2.gpio.pinDesignator
Also see
Sensor.open(),close().
- registerInterruptHandler(onEvent=None, callerFeedBack=None, handler=None)[source]¶
Registers a handling routine for interrupt notification.
The caller feedback will be directly passed to the handling routine. In case that multiple different interrupts are handled by the same routine, this parameter may be used to distinguish them and remember the source of interrupt.
The handler should be a method or function that expects at least one argument. That first argument will be the
callerFeedBackobject given as the above-mentioned parameter. Further parameters may follow, as they were handed in to the_fire()method. The handler’s signature should look like this:def handlingRoutine( feedback, *args) -> None:Note that the
onEventparameter is not passed to the handler. It is eaten up by_fire()and just controls the selection of the handling routine called.Depending on the parameter, this method behaves as follows:
onEvent
handler
semantics and action
Event.evtNone
None
All interrupts are disabled and all registrations cleared.
Event.evtNone
valid
De-register the given handler from all events {Event.evtInt1|2|Any}.
Event.evtInt1|2|*
None
De-register all handlers from the given event.
Event.evtInt1|2|*
valid
Enable interrupt and register this handler for the given event.
Event.evtAny
None
Clear the
Event.evtAnyregistrations, only!Event.evtAny
valid
Register the handler for any event {Event.evtInt1|2}.
For this method,
Event.evtNoneis a semantic equivalent toNone.- Parameters:
onEvent (int) – Exactly one of the event mnemonics defined by the
interruptable.Eventenumeration.callerFeedBack (object) – Arbitrary object not evaluated here, but passed on to the handler when an event is fired.
handler – The handling routine to be called as an immediate response to an event.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Reset the sensor to its default state.
After executing the reset command with the chip, it is re-configured using the start-up settings. Also, interrupt configuration is restored and interrupts are enabled.
Also see:
Sensor.reset().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- selfTest(tests)[source]¶
Execute one or more sensor self tests.
The test(s) to execute is given as a bit mask. This sensor supports the following tests:
SelfTest.CONNECTION: An attempt is made to read the sensor’s chip ID. If reading is successful, the result is compared toBMA456_CNT_CHIP_ID. On a match, the method returns successfully. Otherwise, a failure is indicated.SelfTest.FUNCTIONAL: A functional sensor self test is executed as described in the data sheet, chapter 4.9.Also see:
Sensor.selfTest().- Parameters:
tests (int) – A bit mask to select the tests to be executed.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setRunLevel(level)[source]¶
Switches the device to the desired power-save mode.
The given run level affects the hardware registers
BMA456_REG_PWR_CTRL,BMA456_REG_PWR_CONFandBMA456_REG_ACC_CONFand, thus, chip behavior as follows:RunLevel
ACC_EN
AUX_EN
FIFO_SELF_WAKEUP
ADV_POWER_SAVE
ACC_PERF_MODE
active
ENABLE
DISABLE
DISABLE
DISABLE
CONT
idle
ENABLE
DISABLE
DISABLE
DISABLE
AVG
relax
ENABLE
DISABLE
ENABLE
ENABLE
AVG
snooze
ENABLE
DISABLE
DISABLE
ENABLE
AVG
nap and below
DISABLE
DISABLE
DISABLE
ENABLE
AVG
For detailed information on the power modes of the underlying hardware, see the data shhet, chapter 4.3.
Also see
Module.setRunLevel().
philander.bma456_reg module¶
Register definition for the BMA456 accelerometer.
Definition of registers, content masks and default values for the above mentioined chip. Externalized, just for clarity of the source code.
- class BMA456_Reg[source]¶
Bases:
object- BMA456_CNT_ACC_CONF_BWP = 112¶
- BMA456_CNT_ACC_CONF_DEFAULT = 168¶
- BMA456_CNT_ACC_CONF_MODE = 240¶
- BMA456_CNT_ACC_CONF_MODE_AVG1 = 0¶
- BMA456_CNT_ACC_CONF_MODE_AVG128 = 112¶
- BMA456_CNT_ACC_CONF_MODE_AVG16 = 64¶
- BMA456_CNT_ACC_CONF_MODE_AVG2 = 16¶
- BMA456_CNT_ACC_CONF_MODE_AVG32 = 80¶
- BMA456_CNT_ACC_CONF_MODE_AVG4 = 32¶
- BMA456_CNT_ACC_CONF_MODE_AVG64 = 96¶
- BMA456_CNT_ACC_CONF_MODE_AVG8 = 48¶
- BMA456_CNT_ACC_CONF_MODE_CIC = 176¶
- BMA456_CNT_ACC_CONF_MODE_DEFAULT = 160¶
- BMA456_CNT_ACC_CONF_MODE_NORM = 160¶
- BMA456_CNT_ACC_CONF_MODE_OSR2 = 144¶
- BMA456_CNT_ACC_CONF_MODE_OSR4 = 128¶
- BMA456_CNT_ACC_CONF_ODR = 15¶
- BMA456_CNT_ACC_CONF_ODR_0P78 = 1¶
- BMA456_CNT_ACC_CONF_ODR_100 = 8¶
- BMA456_CNT_ACC_CONF_ODR_12K8 = 15¶
- BMA456_CNT_ACC_CONF_ODR_12P5 = 5¶
- BMA456_CNT_ACC_CONF_ODR_1K6 = 12¶
- BMA456_CNT_ACC_CONF_ODR_1P5 = 2¶
- BMA456_CNT_ACC_CONF_ODR_200 = 9¶
- BMA456_CNT_ACC_CONF_ODR_25 = 6¶
- BMA456_CNT_ACC_CONF_ODR_3K2 = 13¶
- BMA456_CNT_ACC_CONF_ODR_3P1 = 3¶
- BMA456_CNT_ACC_CONF_ODR_400 = 10¶
- BMA456_CNT_ACC_CONF_ODR_50 = 7¶
- BMA456_CNT_ACC_CONF_ODR_6K4 = 14¶
- BMA456_CNT_ACC_CONF_ODR_6P25 = 4¶
- BMA456_CNT_ACC_CONF_ODR_800 = 11¶
- BMA456_CNT_ACC_CONF_ODR_DEFAULT = 8¶
- BMA456_CNT_ACC_CONF_PERF_MODE = 128¶
- BMA456_CNT_ACC_CONF_PERF_MODE_AVG = 0¶
- BMA456_CNT_ACC_CONF_PERF_MODE_CONT = 128¶
- BMA456_CNT_ACC_RANGE_16G = 3¶
- BMA456_CNT_ACC_RANGE_2G = 0¶
- BMA456_CNT_ACC_RANGE_4G = 1¶
- BMA456_CNT_ACC_RANGE_8G = 2¶
- BMA456_CNT_ACC_RANGE_DEFAULT = 1¶
- BMA456_CNT_CHIP_ID = 22¶
- BMA456_CNT_CMD_FIFO_FLUSH = 176¶
- BMA456_CNT_CMD_NVM_PROG = 160¶
- BMA456_CNT_CMD_SOFTRESET = 182¶
- BMA456_CNT_ERROR_AUX = 128¶
- BMA456_CNT_ERROR_CMD = 2¶
- BMA456_CNT_ERROR_CODE = 28¶
- BMA456_CNT_ERROR_CODE_ACC = 4¶
- BMA456_CNT_ERROR_CODE_NONE = 0¶
- BMA456_CNT_ERROR_FATAL = 1¶
- BMA456_CNT_ERROR_FIFO = 64¶
- BMA456_CNT_EVENT_POR = 1¶
- BMA456_CNT_FEATURES_ANY_MOT1 = 0¶
- BMA456_CNT_FEATURES_ANY_MOT2 = 2¶
- BMA456_CNT_FEATURES_GEN_AXES_REMAP = 62¶
- BMA456_CNT_FEATURES_GEN_CFG_ID = 60¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT1 = 4¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT10 = 22¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT11 = 24¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT12 = 26¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT13 = 28¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT14 = 30¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT15 = 32¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT16 = 34¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT17 = 36¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT18 = 38¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT19 = 40¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT2 = 6¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT20 = 42¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT21 = 44¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT22 = 46¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT23 = 48¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT24 = 50¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT25 = 52¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT26 = 54¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT3 = 8¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT4 = 10¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT5 = 12¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT6 = 14¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT7 = 16¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT8 = 18¶
- BMA456_CNT_FEATURES_STEPBMA456_CNT9 = 20¶
- BMA456_CNT_FEATURES_TAP_DTAP = 56¶
- BMA456_CNT_FEATURES_WRIST_TILT = 58¶
- BMA456_CNT_FIFO_CFG_ACC = 16384¶
- BMA456_CNT_FIFO_CFG_ACC_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_ACC_ENABLE = 16384¶
- BMA456_CNT_FIFO_CFG_AUX = 8192¶
- BMA456_CNT_FIFO_CFG_AUX_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_AUX_ENABLE = 8192¶
- BMA456_CNT_FIFO_CFG_HEAD = 4096¶
- BMA456_CNT_FIFO_CFG_HEAD_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_HEAD_ENABLE = 4096¶
- BMA456_CNT_FIFO_CFG_INT1_TAG = 2048¶
- BMA456_CNT_FIFO_CFG_INT1_TAG_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_INT1_TAG_ENABLE = 2048¶
- BMA456_CNT_FIFO_CFG_INT2_TAG = 1024¶
- BMA456_CNT_FIFO_CFG_INT2_TAG_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_INT2_TAG_ENABLE = 1024¶
- BMA456_CNT_FIFO_CFG_STOP = 1¶
- BMA456_CNT_FIFO_CFG_STOP_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_STOP_ENABLE = 1¶
- BMA456_CNT_FIFO_CFG_TIME = 2¶
- BMA456_CNT_FIFO_CFG_TIME_DISABLE = 0¶
- BMA456_CNT_FIFO_CFG_TIME_ENABLE = 2¶
- BMA456_CNT_FIFO_DOWNS_DS0 = 0¶
- BMA456_CNT_FIFO_DOWNS_DS1 = 16¶
- BMA456_CNT_FIFO_DOWNS_DS2 = 32¶
- BMA456_CNT_FIFO_DOWNS_DS3 = 48¶
- BMA456_CNT_FIFO_DOWNS_DS4 = 64¶
- BMA456_CNT_FIFO_DOWNS_DS5 = 80¶
- BMA456_CNT_FIFO_DOWNS_DS6 = 96¶
- BMA456_CNT_FIFO_DOWNS_DS7 = 112¶
- BMA456_CNT_FIFO_DOWNS_DSAMPLING = 112¶
- BMA456_CNT_FIFO_DOWNS_FILTER = 128¶
- BMA456_CNT_FIFO_DOWNS_NOFILT = 0¶
- BMA456_CNT_IF_CFG_AUX = 16¶
- BMA456_CNT_IF_CFG_AUX_MAG = 16¶
- BMA456_CNT_IF_CFG_AUX_OFF = 0¶
- BMA456_CNT_IF_CFG_SPI = 1¶
- BMA456_CNT_IF_CFG_SPI_3 = 1¶
- BMA456_CNT_IF_CFG_SPI_4 = 0¶
- BMA456_CNT_INIT_CTRL_LOAD_CONFIG_FILE = 0¶
- BMA456_CNT_INIT_CTRL_START_INIT = 1¶
- BMA456_CNT_INT1_IO_CTRL_COND = 1¶
- BMA456_CNT_INT1_IO_CTRL_COND_EDGE = 1¶
- BMA456_CNT_INT1_IO_CTRL_COND_LEVEL = 0¶
- BMA456_CNT_INT1_IO_CTRL_DEFAULT = 0¶
- BMA456_CNT_INT1_IO_CTRL_INPUT = 16¶
- BMA456_CNT_INT1_IO_CTRL_INPUT_DISABLE = 0¶
- BMA456_CNT_INT1_IO_CTRL_INPUT_ENABLE = 16¶
- BMA456_CNT_INT1_IO_CTRL_LEVEL = 2¶
- BMA456_CNT_INT1_IO_CTRL_LEVEL_ACT_HI = 2¶
- BMA456_CNT_INT1_IO_CTRL_LEVEL_ACT_LOW = 0¶
- BMA456_CNT_INT1_IO_CTRL_MODE = 4¶
- BMA456_CNT_INT1_IO_CTRL_MODE_OPEN_DRAIN = 4¶
- BMA456_CNT_INT1_IO_CTRL_MODE_PUSH_PULL = 0¶
- BMA456_CNT_INT1_IO_CTRL_OUTPUT = 8¶
- BMA456_CNT_INT1_IO_CTRL_OUTPUT_DISABLE = 0¶
- BMA456_CNT_INT1_IO_CTRL_OUTPUT_ENABLE = 8¶
- BMA456_CNT_INT2_IO_CTRL_COND = 1¶
- BMA456_CNT_INT2_IO_CTRL_COND_EDGE = 1¶
- BMA456_CNT_INT2_IO_CTRL_COND_LEVEL = 0¶
- BMA456_CNT_INT2_IO_CTRL_DEFAULT = 0¶
- BMA456_CNT_INT2_IO_CTRL_INPUT = 16¶
- BMA456_CNT_INT2_IO_CTRL_INPUT_DISABLE = 0¶
- BMA456_CNT_INT2_IO_CTRL_INPUT_ENABLE = 16¶
- BMA456_CNT_INT2_IO_CTRL_LEVEL = 2¶
- BMA456_CNT_INT2_IO_CTRL_LEVEL_ACT_HI = 2¶
- BMA456_CNT_INT2_IO_CTRL_LEVEL_ACT_LOW = 0¶
- BMA456_CNT_INT2_IO_CTRL_MODE = 4¶
- BMA456_CNT_INT2_IO_CTRL_MODE_OPEN_DRAIN = 4¶
- BMA456_CNT_INT2_IO_CTRL_MODE_PUSH_PULL = 0¶
- BMA456_CNT_INT2_IO_CTRL_OUTPUT = 8¶
- BMA456_CNT_INT2_IO_CTRL_OUTPUT_DISABLE = 0¶
- BMA456_CNT_INT2_IO_CTRL_OUTPUT_ENABLE = 8¶
- BMA456_CNT_INTERNAL_ERR_FATAL = 4¶
- BMA456_CNT_INTERNAL_ERR_LONG = 2¶
- BMA456_CNT_INTERNAL_STATUS_ALP_SLEEP = 16¶
- BMA456_CNT_INTERNAL_STATUS_AXES_REMAP_ERROR = 32¶
- BMA456_CNT_INTERNAL_STATUS_MSG = 15¶
- BMA456_CNT_INTERNAL_STATUS_MSG_DRV_ERR = 3¶
- BMA456_CNT_INTERNAL_STATUS_MSG_INIT_ERR = 2¶
- BMA456_CNT_INTERNAL_STATUS_MSG_INIT_OK = 1¶
- BMA456_CNT_INTERNAL_STATUS_MSG_NOT_INIT = 0¶
- BMA456_CNT_INTERNAL_STATUS_MSG_SNS_STOP = 4¶
- BMA456_CNT_INTERNAL_STATUS_ODR_50HZ_ERROR = 64¶
- BMA456_CNT_INTERNAL_STATUS_ODR_HIGH_ERROR = 128¶
- BMA456_CNT_INTX_MAP_ALL = 255¶
- BMA456_CNT_INTX_MAP_DEFAULT = 0¶
- BMA456_CNT_INTX_MAP_ERROR = 128¶
- BMA456_CNT_INTX_MAP_NONE = 0¶
- BMA456_CNT_INTX_MAP_TAP = 1¶
- BMA456_CNT_INT_LATCH_NONE = 0¶
- BMA456_CNT_INT_LATCH_PERM = 1¶
- BMA456_CNT_INT_MAP_DATA_DEFAULT = 0¶
- BMA456_CNT_INT_MAP_DATA_INT1_DRDY = 4¶
- BMA456_CNT_INT_MAP_DATA_INT1_FIFO_FULL = 1¶
- BMA456_CNT_INT_MAP_DATA_INT1_FIFO_WM = 2¶
- BMA456_CNT_INT_MAP_DATA_INT2_DRDY = 64¶
- BMA456_CNT_INT_MAP_DATA_INT2_FIFO_FULL = 16¶
- BMA456_CNT_INT_MAP_DATA_INT2_FIFO_WM = 32¶
- BMA456_CNT_INT_STATUS_ACC_DRDY = 32768¶
- BMA456_CNT_INT_STATUS_AUX_DRDY = 8192¶
- BMA456_CNT_INT_STATUS_ERROR = 128¶
- BMA456_CNT_INT_STATUS_FIFO_FULL = 256¶
- BMA456_CNT_INT_STATUS_FIFO_WM = 512¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDT = 4¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDTPER = 2¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDTPER_LONG = 2¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDTPER_SHORT = 0¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDT_DISABLE = 0¶
- BMA456_CNT_NVM_BE_CFG_I2C_WDT_ENABLE = 4¶
- BMA456_CNT_NVM_BE_CFG_OFFSET = 8¶
- BMA456_CNT_NVM_BE_CFG_OFFSET_DISABLE = 0¶
- BMA456_CNT_NVM_BE_CFG_OFFSET_ENABLE = 8¶
- BMA456_CNT_NVM_BE_CFG_SPI = 1¶
- BMA456_CNT_NVM_BE_CFG_SPI_DISABLE = 0¶
- BMA456_CNT_NVM_BE_CFG_SPI_ENABLE = 1¶
- BMA456_CNT_NVM_CFG_PPROG = 2¶
- BMA456_CNT_NVM_CFG_PPROG_DISABLE = 0¶
- BMA456_CNT_NVM_CFG_PPROG_ENABLE = 2¶
- BMA456_CNT_PWR_CONF_ADV_PWR_SAVE = 1¶
- BMA456_CNT_PWR_CONF_ADV_PWR_SAVE_DISABLE = 0¶
- BMA456_CNT_PWR_CONF_ADV_PWR_SAVE_ENABLE = 1¶
- BMA456_CNT_PWR_CONF_FIFO_WKUP = 2¶
- BMA456_CNT_PWR_CONF_FIFO_WKUP_DISABLE = 0¶
- BMA456_CNT_PWR_CONF_FIFO_WKUP_ENABLE = 2¶
- BMA456_CNT_PWR_CTRL_ACC = 4¶
- BMA456_CNT_PWR_CTRL_ACC_DISABLE = 0¶
- BMA456_CNT_PWR_CTRL_ACC_ENABLE = 4¶
- BMA456_CNT_PWR_CTRL_AUX = 1¶
- BMA456_CNT_PWR_CTRL_AUX_DISABLE = 0¶
- BMA456_CNT_PWR_CTRL_AUX_ENABLE = 1¶
- BMA456_CNT_SELF_TST_AMP = 8¶
- BMA456_CNT_SELF_TST_AMP_HI = 8¶
- BMA456_CNT_SELF_TST_AMP_LOW = 0¶
- BMA456_CNT_SELF_TST_DISABLE = 0¶
- BMA456_CNT_SELF_TST_ENABLE = 1¶
- BMA456_CNT_SELF_TST_SIGN = 4¶
- BMA456_CNT_SELF_TST_SIGN_NEG = 0¶
- BMA456_CNT_SELF_TST_SIGN_POS = 4¶
- BMA456_CNT_STATUS_AUX_MAN_OP = 4¶
- BMA456_CNT_STATUS_CMD_RDY = 16¶
- BMA456_CNT_STATUS_DRDY_ACC = 128¶
- BMA456_CNT_STATUS_DRDY_AUX = 32¶
- BMA456_DEFAULT_FEATURE_SET = 0¶
- BMA456_FEATURE_MAX_SIZE = 96¶
- BMA456_FEATURE_SET_AN = 3¶
- BMA456_FEATURE_SET_HEARABLE = 1¶
- BMA456_FEATURE_SET_MM = 2¶
- BMA456_FEATURE_SET_WEARABLE = 0¶
- BMA456_FEAT_ANYNO_MOTION_DURATION = 8191¶
- BMA456_FEAT_ANYNO_MOTION_DURATION_MAX_MS = 163000¶
- BMA456_FEAT_ANYNO_MOTION_DURATION_MIN_MS = 0¶
- BMA456_FEAT_ANYNO_MOTION_INT_BHVR = 2048¶
- BMA456_FEAT_ANYNO_MOTION_INT_BHVR_MULTI = 0¶
- BMA456_FEAT_ANYNO_MOTION_INT_BHVR_SINGLE = 2048¶
- BMA456_FEAT_ANYNO_MOTION_SLOPE = 4096¶
- BMA456_FEAT_ANYNO_MOTION_SLOPE_CONSEC = 4096¶
- BMA456_FEAT_ANYNO_MOTION_SLOPE_LAST_TO_CURRENT = 0¶
- BMA456_FEAT_ANYNO_MOTION_THRESHOLD = 2047¶
- BMA456_FEAT_ANYNO_MOTION_THRESHOLD_MAX_MG = 1000¶
- BMA456_FEAT_ANYNO_MOTION_THRESHOLD_MIN_MG = 0¶
- BMA456_FEAT_ANYNO_MOTION_X_EN = 8192¶
- BMA456_FEAT_ANYNO_MOTION_Y_EN = 16384¶
- BMA456_FEAT_ANYNO_MOTION_Z_EN = 32768¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR = 24576¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_12p5 = 24576¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_1p5625 = 0¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_3p125 = 8192¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_6p25 = 16384¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_MAX_HZ = 13¶
- BMA456_FEAT_AUTO_LOW_POWER_LP_ODR_MIN_HZ = 1¶
- BMA456_FEAT_AUTO_LOW_POWER_MGT_AUTO = 32768¶
- BMA456_FEAT_AUTO_LOW_POWER_MGT_AUTO_DISABLE = 0¶
- BMA456_FEAT_AUTO_LOW_POWER_MGT_AUTO_ENABLE = 32768¶
- BMA456_FEAT_AUTO_LOW_POWER_NO_MOTION = 1¶
- BMA456_FEAT_AUTO_LOW_POWER_TIME_OUT = 2¶
- BMA456_FEAT_AUTO_LOW_POWER_TIME_OUT_DURATION = 4092¶
- BMA456_FEAT_AUTO_LOW_POWER_TIME_OUT_DURATION_MAX_MS = 20460¶
- BMA456_FEAT_AUTO_LOW_POWER_TIME_OUT_DURATION_MIN_MS = 0¶
- BMA456_FEAT_AXES_REMAP_ALL_ON_X = 0¶
- BMA456_FEAT_AXES_REMAP_ALL_ON_Y = 73¶
- BMA456_FEAT_AXES_REMAP_ALL_ON_Z = 146¶
- BMA456_FEAT_AXES_REMAP_STRAIGHT = 136¶
- BMA456_FEAT_AXES_REMAP_X = 3¶
- BMA456_FEAT_AXES_REMAP_X_SIGN = 4¶
- BMA456_FEAT_AXES_REMAP_X_SIGN_INVERT = 4¶
- BMA456_FEAT_AXES_REMAP_X_SIGN_KEEP = 0¶
- BMA456_FEAT_AXES_REMAP_X_STRAIGHT = 0¶
- BMA456_FEAT_AXES_REMAP_X_TO_X = 0¶
- BMA456_FEAT_AXES_REMAP_X_TO_Y = 1¶
- BMA456_FEAT_AXES_REMAP_X_TO_Z = 2¶
- BMA456_FEAT_AXES_REMAP_Y = 24¶
- BMA456_FEAT_AXES_REMAP_Y_SIGN = 32¶
- BMA456_FEAT_AXES_REMAP_Y_SIGN_INVERT = 32¶
- BMA456_FEAT_AXES_REMAP_Y_SIGN_KEEP = 0¶
- BMA456_FEAT_AXES_REMAP_Y_STRAIGHT = 8¶
- BMA456_FEAT_AXES_REMAP_Y_TO_X = 0¶
- BMA456_FEAT_AXES_REMAP_Y_TO_Y = 8¶
- BMA456_FEAT_AXES_REMAP_Y_TO_Z = 16¶
- BMA456_FEAT_AXES_REMAP_Z = 192¶
- BMA456_FEAT_AXES_REMAP_Z_SIGN = 256¶
- BMA456_FEAT_AXES_REMAP_Z_SIGN_INVERT = 256¶
- BMA456_FEAT_AXES_REMAP_Z_SIGN_KEEP = 0¶
- BMA456_FEAT_AXES_REMAP_Z_STRAIGHT = 128¶
- BMA456_FEAT_AXES_REMAP_Z_TO_X = 0¶
- BMA456_FEAT_AXES_REMAP_Z_TO_Y = 64¶
- BMA456_FEAT_AXES_REMAP_Z_TO_Z = 128¶
- BMA456_FEAT_HIGH_G_ENABLE = 32768¶
- BMA456_FEAT_HIGH_G_ENABLE_X = 4096¶
- BMA456_FEAT_HIGH_G_ENABLE_Y = 8192¶
- BMA456_FEAT_HIGH_G_ENABLE_Z = 16384¶
- BMA456_FEAT_HIGH_G_HYSTERESIS_RCMD_MAX_MG = 2000¶
- BMA456_FEAT_HIGH_G_HYSTERESIS_RCMD_MIN_MG = 0¶
- BMA456_FEAT_HIGH_G_THRESHOLD_RCMD_MAX_MG = 16000¶
- BMA456_FEAT_HIGH_G_THRESHOLD_RCMD_MIN_MG = 0¶
- BMA456_FEAT_HILOW_G_DURATION = 4095¶
- BMA456_FEAT_HILOW_G_DURATION_MAX_MS = 81900¶
- BMA456_FEAT_HILOW_G_DURATION_MIN_MS = 0¶
- BMA456_FEAT_HILOW_G_HYSTERESIS = 4095¶
- BMA456_FEAT_HILOW_G_HYSTERESIS_MAX_MG = 2000¶
- BMA456_FEAT_HILOW_G_HYSTERESIS_MIN_MG = 0¶
- BMA456_FEAT_HILOW_G_SIG_THRESHOLD = 32767¶
- BMA456_FEAT_HILOW_G_SIG_THRESHOLD_MAX_MG = 16000¶
- BMA456_FEAT_HILOW_G_SIG_THRESHOLD_MIN_MG = 0¶
- BMA456_FEAT_LOW_G_ENABLE = 4096¶
- BMA456_FEAT_LOW_G_HYSTERESIS_RCMD_MAX_MG = 500¶
- BMA456_FEAT_LOW_G_HYSTERESIS_RCMD_MIN_MG = 0¶
- BMA456_FEAT_LOW_G_THRESHOLD_RCMD_MAX_MG = 1000¶
- BMA456_FEAT_LOW_G_THRESHOLD_RCMD_MIN_MG = 0¶
- BMA456_FEAT_MULTITAP_AXIS_SELECT = 3¶
- BMA456_FEAT_MULTITAP_AXIS_SELECT_X = 0¶
- BMA456_FEAT_MULTITAP_AXIS_SELECT_Y = 1¶
- BMA456_FEAT_MULTITAP_AXIS_SELECT_Z = 2¶
- BMA456_FEAT_MULTITAP_DURATION = 65535¶
- BMA456_FEAT_MULTITAP_DURATION_GEST_RCMD_MAX_MS = 1000¶
- BMA456_FEAT_MULTITAP_DURATION_GEST_RCMD_MIN_MS = 250¶
- BMA456_FEAT_MULTITAP_DURATION_QUIET_RCMD_MAX_MS = 500¶
- BMA456_FEAT_MULTITAP_DURATION_QUIET_RCMD_MIN_MS = 250¶
- BMA456_FEAT_MULTITAP_DURATION_SHOCK_RCMD_MAX_MS = 100¶
- BMA456_FEAT_MULTITAP_DURATION_SHOCK_RCMD_MIN_MS = 20¶
- BMA456_FEAT_MULTITAP_ENABLE_AVERAGING2 = 8¶
- BMA456_FEAT_MULTITAP_ENABLE_DOUBLE_TAP = 2¶
- BMA456_FEAT_MULTITAP_ENABLE_SINGLE_TAP = 1¶
- BMA456_FEAT_MULTITAP_ENABLE_TRIPLE_TAP = 4¶
- BMA456_FEAT_MULTITAP_SENSITIVITY = 65535¶
- BMA456_FEAT_MULTITAP_SENSITIVITY_RCMD_MAX_MG = 1200¶
- BMA456_FEAT_MULTITAP_SENSITIVITY_RCND_MIN_MG = 0¶
- BMA456_FEAT_MULTITAP_TIMEOUT = 65535¶
- BMA456_FEAT_MULTITAP_TIMEOUT_DISABLE = 0¶
- BMA456_FEAT_MULTITAP_TIMEOUT_ENABLE = 1¶
- BMA456_FEAT_ORIENTATION_BLOCKING = 48¶
- BMA456_FEAT_ORIENTATION_BLOCKING_MOST = 48¶
- BMA456_FEAT_ORIENTATION_BLOCKING_NONE = 0¶
- BMA456_FEAT_ORIENTATION_BLOCKING_SHAKE = 32¶
- BMA456_FEAT_ORIENTATION_BLOCKING_SHOCK = 16¶
- BMA456_FEAT_ORIENTATION_ENABLE = 1¶
- BMA456_FEAT_ORIENTATION_FACE_UPDOWN_ENABLE = 2¶
- BMA456_FEAT_ORIENTATION_HYSTERESIS = 2047¶
- BMA456_FEAT_ORIENTATION_HYSTERESIS_MAX_MG = 1000¶
- BMA456_FEAT_ORIENTATION_HYSTERESIS_MIN_MG = 0¶
- BMA456_FEAT_ORIENTATION_MODE = 12¶
- BMA456_FEAT_ORIENTATION_MODE_ASYMMETRIC_HI = 4¶
- BMA456_FEAT_ORIENTATION_MODE_ASYMMETRIC_LO = 8¶
- BMA456_FEAT_ORIENTATION_MODE_SYMMETRIC = 0¶
- BMA456_FEAT_ORIENTATION_THETA = 4032¶
- BMA456_FEAT_ORIENTATION_THETA_BITSHIFT = 6¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_0 = 0¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_0p0 = 0¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_10 = 128¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_10p0 = 128¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_12p2 = 192¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_14p0 = 256¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_15 = 320¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_15p6 = 320¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_17p0 = 384¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_18p3 = 448¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_19p5 = 512¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_20 = 512¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_20p6 = 576¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_21p6 = 640¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_22p5 = 704¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_23p4 = 768¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_24p3 = 832¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_25 = 896¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_25p1 = 896¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_25p8 = 960¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_26p6 = 1024¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_27p3 = 1088¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_27p9 = 1152¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_28p6 = 1216¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_29p2 = 1280¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_29p8 = 1344¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_30 = 1344¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_30p4 = 1408¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_30p9 = 1472¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_31p5 = 1536¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_32p0 = 1600¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_32p5 = 1664¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_33p0 = 1728¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_33p5 = 1792¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_33p9 = 1856¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_34p4 = 1920¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_34p8 = 1984¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_35 = 1984¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_35p3 = 2048¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_35p7 = 2112¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_36p1 = 2176¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_36p5 = 2240¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_36p9 = 2304¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_37p2 = 2368¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_37p6 = 2432¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_38p0 = 2496¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_38p3 = 2560¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_38p7 = 2624¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_39p0 = 2688¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_39p3 = 2752¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_39p7 = 2816¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_40 = 2880¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_40p0 = 2880¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_40p3 = 2944¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_40p6 = 3008¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_40p9 = 3072¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_41p2 = 3136¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_41p5 = 3200¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_41p8 = 3264¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_42p0 = 3328¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_42p3 = 3392¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_42p6 = 3456¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_42p8 = 3520¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_43p1 = 3584¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_43p3 = 3648¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_43p6 = 3712¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_43p8 = 3776¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_44p1 = 3840¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_44p3 = 3904¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_44p5 = 3968¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_44p8 = 4032¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_45 = 4032¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_5 = 64¶
- BMA456_FEAT_ORIENTATION_THETA_DEG_7p1 = 64¶
- BMA456_FEAT_ORIENTATION_THETA_MAX = 4032¶
- BMA456_FEAT_ORIENTATION_THETA_MAX_DEG = 45¶
- BMA456_FEAT_ORIENTATION_THETA_MIN = 0¶
- BMA456_FEAT_ORIENTATION_THETA_MIN_DEG = 0¶
- BMA456_FEAT_ORIENTATION_THETA_UNIT = 64¶
- BMA456_FEAT_PROOF_TIME = 127¶
- BMA456_FEAT_PROOF_TIME_MAX_MS = 2540¶
- BMA456_FEAT_PROOF_TIME_MIN_MS = 0¶
- BMA456_FEAT_SKIP_TIME = 511¶
- BMA456_FEAT_SKIP_TIME_MAX_MS = 10220¶
- BMA456_FEAT_SKIP_TIME_MIN_MS = 0¶
- BMA456_FEAT_STEP_COUNTER_ENABLE_ACTIVITY = 8192¶
- BMA456_FEAT_STEP_COUNTER_ENABLE_COUNT = 4096¶
- BMA456_FEAT_STEP_COUNTER_ENABLE_DETECT = 2048¶
- BMA456_FEAT_STEP_COUNTER_RESET_COUNTER = 1024¶
- BMA456_FEAT_STEP_COUNTER_WATERMARK_LEVEL = 1023¶
- BMA456_FEAT_STEP_COUNTER_WATERMARK_MAX_STEPS = 20460¶
- BMA456_FEAT_STEP_COUNTER_WATERMARK_MIN_STEPS = 20¶
- BMA456_FEAT_TAP_ENABLE = 1¶
- BMA456_FEAT_TAP_SENSITIVITY = 14¶
- BMA456_FEAT_TAP_SENSITIVITY_0 = 0¶
- BMA456_FEAT_TAP_SENSITIVITY_1 = 2¶
- BMA456_FEAT_TAP_SENSITIVITY_2 = 4¶
- BMA456_FEAT_TAP_SENSITIVITY_3 = 6¶
- BMA456_FEAT_TAP_SENSITIVITY_4 = 8¶
- BMA456_FEAT_TAP_SENSITIVITY_5 = 10¶
- BMA456_FEAT_TAP_SENSITIVITY_6 = 12¶
- BMA456_FEAT_TAP_SENSITIVITY_7 = 14¶
- BMA456_FEAT_TAP_SENSITIVITY_HIGHEST = 0¶
- BMA456_FEAT_TAP_SENSITIVITY_LOWEST = 14¶
- BMA456_FEAT_TAP_SENSITIVITY_MAX_VAL = 7¶
- BMA456_FEAT_TAP_SENSITIVITY_MIN_VAL = 0¶
- BMA456_FEAT_WRIST_WAKEUP_ANGLE_LANDSCAPE_LEFT = 65280¶
- BMA456_FEAT_WRIST_WAKEUP_ANGLE_LANDSCAPE_RIGHT = 255¶
- BMA456_FEAT_WRIST_WAKEUP_ANGLE_PORTRAIT_DOWN = 255¶
- BMA456_FEAT_WRIST_WAKEUP_ANGLE_PORTRAIT_UP = 65280¶
- BMA456_FEAT_WRIST_WAKEUP_DURATION_MOVED = 255¶
- BMA456_FEAT_WRIST_WAKEUP_DURATION_QUIET = 65280¶
- BMA456_FEAT_WRIST_WAKEUP_ENABLE = 16¶
- BMA456_FSAN_CNT_INTX_MAP_ANY_MOTION = 32¶
- BMA456_FSAN_CNT_INTX_MAP_ERROR = 128¶
- BMA456_FSAN_CNT_INTX_MAP_NO_MOTION = 64¶
- BMA456_FSAN_CNT_INT_STATUS_ANY_MOTION = 32¶
- BMA456_FSAN_CNT_INT_STATUS_ERROR = 128¶
- BMA456_FSAN_CNT_INT_STATUS_NO_MOTION = 64¶
- BMA456_FSAN_IDX_ANY_MOTION_1 = 0¶
- BMA456_FSAN_IDX_ANY_MOTION_2 = 2¶
- BMA456_FSAN_IDX_GENERAL_AXES_REMAP = 10¶
- BMA456_FSAN_IDX_GENERAL_CONFIG_ID = 8¶
- BMA456_FSAN_IDX_NO_MOTION_1 = 4¶
- BMA456_FSAN_IDX_NO_MOTION_2 = 6¶
- BMA456_FSAN_TOTAL_SIZE = 12¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO = 56¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO_ALL = 56¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO_NONE = 0¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO_X = 8¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO_Y = 16¶
- BMA456_FSHBL_CNT_FEAT_EN1_ANYMO_Z = 32¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO = 7¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO_ALL = 7¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO_NONE = 0¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO_X = 1¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO_Y = 2¶
- BMA456_FSHBL_CNT_FEAT_EN1_NOMO_Z = 4¶
- BMA456_FSHBL_CNT_FEAT_EN1_SW_LOCK = 192¶
- BMA456_FSHBL_CNT_FEAT_EN1_SW_LOCK_CALC = 192¶
- BMA456_FSHBL_CNT_FEAT_EN1_SW_LOCK_CLEAR = 0¶
- BMA456_FSHBL_CNT_FEAT_EN2_ACTIVITY_DETECT = 4¶
- BMA456_FSHBL_CNT_FEAT_EN2_AUTO_LOW_POW = 8¶
- BMA456_FSHBL_CNT_FEAT_EN2_AVERAGING2 = 128¶
- BMA456_FSHBL_CNT_FEAT_EN2_DTAP = 32¶
- BMA456_FSHBL_CNT_FEAT_EN2_STAP = 16¶
- BMA456_FSHBL_CNT_FEAT_EN2_STEP_COUNT = 2¶
- BMA456_FSHBL_CNT_FEAT_EN2_STEP_DETECT = 1¶
- BMA456_FSHBL_CNT_FEAT_EN2_TTAP = 64¶
- BMA456_FSHBL_CNT_FEAT_OUT_ACTTYPE = 3¶
- BMA456_FSHBL_CNT_FEAT_OUT_ACTTYPE_RUN = 2¶
- BMA456_FSHBL_CNT_FEAT_OUT_ACTTYPE_STILL = 0¶
- BMA456_FSHBL_CNT_FEAT_OUT_ACTTYPE_UNKNOWN = 3¶
- BMA456_FSHBL_CNT_FEAT_OUT_ACTTYPE_WALK = 1¶
- BMA456_FSHBL_CNT_FEAT_OUT_DTAP = 8¶
- BMA456_FSHBL_CNT_FEAT_OUT_STAP = 4¶
- BMA456_FSHBL_CNT_FEAT_OUT_TTAP = 16¶
- BMA456_FSHBL_CNT_INTX_MAP_ACTIVITY = 4¶
- BMA456_FSHBL_CNT_INTX_MAP_ANY_MOTION = 16¶
- BMA456_FSHBL_CNT_INTX_MAP_ERROR = 128¶
- BMA456_FSHBL_CNT_INTX_MAP_NO_MOTION = 32¶
- BMA456_FSHBL_CNT_INTX_MAP_STEP_CNT = 2¶
- BMA456_FSHBL_CNT_INTX_MAP_TAP = 1¶
- BMA456_FSHBL_CNT_INT_STATUS_ACTIVITY = 4¶
- BMA456_FSHBL_CNT_INT_STATUS_ANY_MOTION = 16¶
- BMA456_FSHBL_CNT_INT_STATUS_ERROR = 128¶
- BMA456_FSHBL_CNT_INT_STATUS_NO_MOTION = 32¶
- BMA456_FSHBL_CNT_INT_STATUS_STEP_COUNT = 2¶
- BMA456_FSHBL_CNT_INT_STATUS_TAP_DETECT = 1¶
- BMA456_FSHBL_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION = 8188¶
- BMA456_FSHBL_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION_MAX_MS = 40940¶
- BMA456_FSHBL_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION_MIN_MS = 0¶
- BMA456_FSHBL_IDX_ANY_MOTION_1 = 0¶
- BMA456_FSHBL_IDX_ANY_MOTION_2 = 2¶
- BMA456_FSHBL_IDX_AUTO_LOW_POWER = 88¶
- BMA456_FSHBL_IDX_GENERAL_AXES_REMAP = 92¶
- BMA456_FSHBL_IDX_GENERAL_CONFIG_ID = 90¶
- BMA456_FSHBL_IDX_MULTI_TAP_1 = 60¶
- BMA456_FSHBL_IDX_MULTI_TAP_10 = 78¶
- BMA456_FSHBL_IDX_MULTI_TAP_11 = 80¶
- BMA456_FSHBL_IDX_MULTI_TAP_12 = 82¶
- BMA456_FSHBL_IDX_MULTI_TAP_2 = 62¶
- BMA456_FSHBL_IDX_MULTI_TAP_3 = 64¶
- BMA456_FSHBL_IDX_MULTI_TAP_4 = 66¶
- BMA456_FSHBL_IDX_MULTI_TAP_5 = 68¶
- BMA456_FSHBL_IDX_MULTI_TAP_6 = 70¶
- BMA456_FSHBL_IDX_MULTI_TAP_7 = 72¶
- BMA456_FSHBL_IDX_MULTI_TAP_8 = 74¶
- BMA456_FSHBL_IDX_MULTI_TAP_9 = 76¶
- BMA456_FSHBL_IDX_NO_MOTION_1 = 4¶
- BMA456_FSHBL_IDX_NO_MOTION_2 = 6¶
- BMA456_FSHBL_IDX_SOFTWARE_LOCK_IN = 84¶
- BMA456_FSHBL_IDX_SOFTWARE_LOCK_OUT = 86¶
- BMA456_FSHBL_IDX_STEP_COUNTER_1 = 8¶
- BMA456_FSHBL_IDX_STEP_COUNTER_10 = 26¶
- BMA456_FSHBL_IDX_STEP_COUNTER_11 = 28¶
- BMA456_FSHBL_IDX_STEP_COUNTER_12 = 30¶
- BMA456_FSHBL_IDX_STEP_COUNTER_13 = 32¶
- BMA456_FSHBL_IDX_STEP_COUNTER_14 = 34¶
- BMA456_FSHBL_IDX_STEP_COUNTER_15 = 36¶
- BMA456_FSHBL_IDX_STEP_COUNTER_16 = 38¶
- BMA456_FSHBL_IDX_STEP_COUNTER_17 = 40¶
- BMA456_FSHBL_IDX_STEP_COUNTER_18 = 42¶
- BMA456_FSHBL_IDX_STEP_COUNTER_19 = 44¶
- BMA456_FSHBL_IDX_STEP_COUNTER_2 = 10¶
- BMA456_FSHBL_IDX_STEP_COUNTER_20 = 46¶
- BMA456_FSHBL_IDX_STEP_COUNTER_21 = 48¶
- BMA456_FSHBL_IDX_STEP_COUNTER_22 = 50¶
- BMA456_FSHBL_IDX_STEP_COUNTER_23 = 52¶
- BMA456_FSHBL_IDX_STEP_COUNTER_24 = 54¶
- BMA456_FSHBL_IDX_STEP_COUNTER_25 = 56¶
- BMA456_FSHBL_IDX_STEP_COUNTER_26 = 58¶
- BMA456_FSHBL_IDX_STEP_COUNTER_3 = 12¶
- BMA456_FSHBL_IDX_STEP_COUNTER_4 = 14¶
- BMA456_FSHBL_IDX_STEP_COUNTER_5 = 16¶
- BMA456_FSHBL_IDX_STEP_COUNTER_6 = 18¶
- BMA456_FSHBL_IDX_STEP_COUNTER_7 = 20¶
- BMA456_FSHBL_IDX_STEP_COUNTER_8 = 22¶
- BMA456_FSHBL_IDX_STEP_COUNTER_9 = 24¶
- BMA456_FSHBL_REG_FEAT_EN1 = 40¶
- BMA456_FSHBL_REG_FEAT_EN2 = 41¶
- BMA456_FSHBL_REG_FEAT_OUT = 39¶
- BMA456_FSHBL_REG_STEP_COUNTER = 30¶
- BMA456_FSHBL_REG_STEP_COUNTER0 = 30¶
- BMA456_FSHBL_REG_STEP_COUNTER1 = 31¶
- BMA456_FSHBL_REG_STEP_COUNTER2 = 32¶
- BMA456_FSHBL_REG_STEP_COUNTER3 = 33¶
- BMA456_FSHBL_TOTAL_SIZE = 94¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_AXES = 7¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_AXES_X = 1¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_AXES_Y = 2¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_AXES_Z = 4¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_SIGN = 8¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_SIGN_NEG = 8¶
- BMA456_FSMM_CNT_HIGH_G_OUTPUT_SIGN_POS = 0¶
- BMA456_FSMM_CNT_INTX_MAP_ANY_MOTION = 32¶
- BMA456_FSMM_CNT_INTX_MAP_ERROR = 128¶
- BMA456_FSMM_CNT_INTX_MAP_HIGH_G = 8¶
- BMA456_FSMM_CNT_INTX_MAP_LOW_G = 4¶
- BMA456_FSMM_CNT_INTX_MAP_NO_MOTION = 64¶
- BMA456_FSMM_CNT_INTX_MAP_ORIENT = 2¶
- BMA456_FSMM_CNT_INTX_MAP_SIG_MOTION = 16¶
- BMA456_FSMM_CNT_INTX_MAP_TAP = 1¶
- BMA456_FSMM_CNT_INT_STATUS_ANY_MOTION = 32¶
- BMA456_FSMM_CNT_INT_STATUS_ERROR = 128¶
- BMA456_FSMM_CNT_INT_STATUS_HIGH_G = 8¶
- BMA456_FSMM_CNT_INT_STATUS_LOW_G = 4¶
- BMA456_FSMM_CNT_INT_STATUS_NO_MOTION = 64¶
- BMA456_FSMM_CNT_INT_STATUS_ORIENT = 2¶
- BMA456_FSMM_CNT_INT_STATUS_SIG_MOTION = 16¶
- BMA456_FSMM_CNT_INT_STATUS_TAP_DETECT = 1¶
- BMA456_FSMM_CNT_MULTITAP_OUTPUT_DTAP = 2¶
- BMA456_FSMM_CNT_MULTITAP_OUTPUT_STAP = 1¶
- BMA456_FSMM_CNT_MULTITAP_OUTPUT_TTAP = 4¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_FACE = 4¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_FACE_DOWN = 4¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_FACE_UP = 0¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_STAND = 3¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_STAND_LAND_LEFT = 1¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_STAND_LAND_RIGHT = 3¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_STAND_PORT_DOWN = 2¶
- BMA456_FSMM_CNT_ORIENT_OUTPUT_STAND_PORT_UP = 0¶
- BMA456_FSMM_DEF_AUTO_LOW_POWER_ENABLE = 4096¶
- BMA456_FSMM_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION = 4092¶
- BMA456_FSMM_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION_MAX_MS = 20460¶
- BMA456_FSMM_DEF_AUTO_LOW_POWER_TIME_OUT_DURATION_MIN_MS = 0¶
- BMA456_FSMM_DEF_SIG_MOTION_ENABLE = 512¶
- BMA456_FSMM_IDX_ANY_MOTION_1 = 0¶
- BMA456_FSMM_IDX_ANY_MOTION_2 = 2¶
- BMA456_FSMM_IDX_AUTO_LOW_POWER = 44¶
- BMA456_FSMM_IDX_GENERAL_AXES_REMAP = 60¶
- BMA456_FSMM_IDX_GENERAL_CONFIG_ID = 58¶
- BMA456_FSMM_IDX_HIGH_G_1 = 46¶
- BMA456_FSMM_IDX_HIGH_G_2 = 48¶
- BMA456_FSMM_IDX_HIGH_G_3 = 50¶
- BMA456_FSMM_IDX_LOW_G_1 = 12¶
- BMA456_FSMM_IDX_LOW_G_2 = 14¶
- BMA456_FSMM_IDX_LOW_G_3 = 16¶
- BMA456_FSMM_IDX_MULTI_TAP_1 = 18¶
- BMA456_FSMM_IDX_MULTI_TAP_2 = 22¶
- BMA456_FSMM_IDX_MULTI_TAP_3 = 24¶
- BMA456_FSMM_IDX_MULTI_TAP_4 = 28¶
- BMA456_FSMM_IDX_MULTI_TAP_5 = 32¶
- BMA456_FSMM_IDX_MULTI_TAP_6 = 34¶
- BMA456_FSMM_IDX_MULTI_TAP_7 = 38¶
- BMA456_FSMM_IDX_NO_MOTION_1 = 4¶
- BMA456_FSMM_IDX_NO_MOTION_2 = 6¶
- BMA456_FSMM_IDX_ORIENT_1 = 8¶
- BMA456_FSMM_IDX_ORIENT_2 = 10¶
- BMA456_FSMM_IDX_SIG_MOTION_1 = 52¶
- BMA456_FSMM_IDX_SIG_MOTION_2 = 54¶
- BMA456_FSMM_IDX_SIG_MOTION_3 = 56¶
- BMA456_FSMM_REG_HIGH_G_OUTPUT = 31¶
- BMA456_FSMM_REG_MULTITAP_OUTPUT = 32¶
- BMA456_FSMM_REG_ORIENT_OUTPUT = 30¶
- BMA456_FSMM_TOTAL_SIZE = 62¶
- BMA456_FSWBL_CNT_ACTIVITY_TYPE = 3¶
- BMA456_FSWBL_CNT_ACTIVITY_TYPE_RUN = 2¶
- BMA456_FSWBL_CNT_ACTIVITY_TYPE_STILL = 0¶
- BMA456_FSWBL_CNT_ACTIVITY_TYPE_UNKNOWN = 3¶
- BMA456_FSWBL_CNT_ACTIVITY_TYPE_WALK = 1¶
- BMA456_FSWBL_CNT_INTX_MAP_ACTIVITY = 4¶
- BMA456_FSWBL_CNT_INTX_MAP_ANY_MOTION = 32¶
- BMA456_FSWBL_CNT_INTX_MAP_DTAP = 16¶
- BMA456_FSWBL_CNT_INTX_MAP_ERROR = 128¶
- BMA456_FSWBL_CNT_INTX_MAP_NO_MOTION = 64¶
- BMA456_FSWBL_CNT_INTX_MAP_STAP = 1¶
- BMA456_FSWBL_CNT_INTX_MAP_STEP_CNT = 2¶
- BMA456_FSWBL_CNT_INTX_MAP_WRIST_WKUP = 8¶
- BMA456_FSWBL_CNT_INT_STATUS_ACTIVITY = 4¶
- BMA456_FSWBL_CNT_INT_STATUS_ANY_MOTION = 32¶
- BMA456_FSWBL_CNT_INT_STATUS_DBL_TAP = 16¶
- BMA456_FSWBL_CNT_INT_STATUS_ERROR = 128¶
- BMA456_FSWBL_CNT_INT_STATUS_NO_MOTION = 64¶
- BMA456_FSWBL_CNT_INT_STATUS_STEP_COUNT = 2¶
- BMA456_FSWBL_CNT_INT_STATUS_TAP_DETECT = 1¶
- BMA456_FSWBL_CNT_INT_STATUS_WRIST_WKUP = 8¶
- BMA456_FSWBL_IDX_ANY_MOTION_1 = 0¶
- BMA456_FSWBL_IDX_ANY_MOTION_2 = 2¶
- BMA456_FSWBL_IDX_GENERAL_AXES_REMAP = 74¶
- BMA456_FSWBL_IDX_GENERAL_CONFIG_ID = 72¶
- BMA456_FSWBL_IDX_NO_MOTION_1 = 4¶
- BMA456_FSWBL_IDX_NO_MOTION_2 = 6¶
- BMA456_FSWBL_IDX_STEP_COUNTER_1 = 8¶
- BMA456_FSWBL_IDX_STEP_COUNTER_10 = 26¶
- BMA456_FSWBL_IDX_STEP_COUNTER_11 = 28¶
- BMA456_FSWBL_IDX_STEP_COUNTER_12 = 30¶
- BMA456_FSWBL_IDX_STEP_COUNTER_13 = 32¶
- BMA456_FSWBL_IDX_STEP_COUNTER_14 = 34¶
- BMA456_FSWBL_IDX_STEP_COUNTER_15 = 36¶
- BMA456_FSWBL_IDX_STEP_COUNTER_16 = 38¶
- BMA456_FSWBL_IDX_STEP_COUNTER_17 = 40¶
- BMA456_FSWBL_IDX_STEP_COUNTER_18 = 42¶
- BMA456_FSWBL_IDX_STEP_COUNTER_19 = 44¶
- BMA456_FSWBL_IDX_STEP_COUNTER_2 = 10¶
- BMA456_FSWBL_IDX_STEP_COUNTER_20 = 46¶
- BMA456_FSWBL_IDX_STEP_COUNTER_21 = 48¶
- BMA456_FSWBL_IDX_STEP_COUNTER_22 = 50¶
- BMA456_FSWBL_IDX_STEP_COUNTER_23 = 52¶
- BMA456_FSWBL_IDX_STEP_COUNTER_24 = 54¶
- BMA456_FSWBL_IDX_STEP_COUNTER_25 = 56¶
- BMA456_FSWBL_IDX_STEP_COUNTER_26 = 58¶
- BMA456_FSWBL_IDX_STEP_COUNTER_3 = 12¶
- BMA456_FSWBL_IDX_STEP_COUNTER_4 = 14¶
- BMA456_FSWBL_IDX_STEP_COUNTER_5 = 16¶
- BMA456_FSWBL_IDX_STEP_COUNTER_6 = 18¶
- BMA456_FSWBL_IDX_STEP_COUNTER_7 = 20¶
- BMA456_FSWBL_IDX_STEP_COUNTER_8 = 22¶
- BMA456_FSWBL_IDX_STEP_COUNTER_9 = 24¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP = 60¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP_ANGLE_LANDSCAPE = 66¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP_ANGLE_PORTRAIT = 68¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP_DURATION = 70¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP_MINANGLE_FOCUS = 62¶
- BMA456_FSWBL_IDX_WRIST_WAKEUP_MINANGLE_NONFOCUS = 64¶
- BMA456_FSWBL_REG_ACTIVITY_TYPE = 39¶
- BMA456_FSWBL_REG_STEP_COUNTER = 30¶
- BMA456_FSWBL_REG_STEP_COUNTER0 = 30¶
- BMA456_FSWBL_REG_STEP_COUNTER1 = 31¶
- BMA456_FSWBL_REG_STEP_COUNTER2 = 32¶
- BMA456_FSWBL_REG_STEP_COUNTER3 = 33¶
- BMA456_FSWBL_TOTAL_SIZE = 76¶
- BMA456_NUM_FEATURE_SETS = 4¶
- BMA456_REG_ACC_CONF = 64¶
- BMA456_REG_ACC_RANGE = 65¶
- BMA456_REG_ACC_X = 18¶
- BMA456_REG_ACC_X_HI = 19¶
- BMA456_REG_ACC_X_LOW = 18¶
- BMA456_REG_ACC_Y = 20¶
- BMA456_REG_ACC_Y_HI = 21¶
- BMA456_REG_ACC_Y_LOW = 20¶
- BMA456_REG_ACC_Z = 22¶
- BMA456_REG_ACC_Z_HI = 23¶
- BMA456_REG_ACC_Z_LOW = 22¶
- BMA456_REG_AUX_CONF = 68¶
- BMA456_REG_AUX_DEV_ID = 75¶
- BMA456_REG_AUX_IF_CONF = 76¶
- BMA456_REG_AUX_R = 16¶
- BMA456_REG_AUX_RD_ADDR = 77¶
- BMA456_REG_AUX_R_HI = 17¶
- BMA456_REG_AUX_R_LOW = 16¶
- BMA456_REG_AUX_WR_ADDR = 78¶
- BMA456_REG_AUX_WR_DATA = 79¶
- BMA456_REG_AUX_X = 10¶
- BMA456_REG_AUX_X_HI = 11¶
- BMA456_REG_AUX_X_LOW = 10¶
- BMA456_REG_AUX_Y = 12¶
- BMA456_REG_AUX_Y_HI = 13¶
- BMA456_REG_AUX_Y_LOW = 12¶
- BMA456_REG_AUX_Z = 14¶
- BMA456_REG_AUX_Z_HI = 15¶
- BMA456_REG_AUX_Z_LOW = 14¶
- BMA456_REG_CHIP_ID = 0¶
- BMA456_REG_CMD = 126¶
- BMA456_REG_DATA0 = 10¶
- BMA456_REG_DATA1 = 11¶
- BMA456_REG_DATA10 = 20¶
- BMA456_REG_DATA11 = 21¶
- BMA456_REG_DATA12 = 22¶
- BMA456_REG_DATA13 = 23¶
- BMA456_REG_DATA2 = 12¶
- BMA456_REG_DATA3 = 13¶
- BMA456_REG_DATA4 = 14¶
- BMA456_REG_DATA5 = 15¶
- BMA456_REG_DATA6 = 16¶
- BMA456_REG_DATA7 = 17¶
- BMA456_REG_DATA8 = 18¶
- BMA456_REG_DATA9 = 19¶
- BMA456_REG_DMA_HI = 92¶
- BMA456_REG_DMA_LOW = 91¶
- BMA456_REG_ERROR = 2¶
- BMA456_REG_EVENT = 27¶
- BMA456_REG_FEATURES = 94¶
- BMA456_REG_FIFO_CFG = 72¶
- BMA456_REG_FIFO_CFG0 = 72¶
- BMA456_REG_FIFO_CFG1 = 73¶
- BMA456_REG_FIFO_DATA = 38¶
- BMA456_REG_FIFO_DOWNS = 69¶
- BMA456_REG_FIFO_LENGTH = 36¶
- BMA456_REG_FIFO_LENGTH_HI = 37¶
- BMA456_REG_FIFO_LENGTH_LOW = 36¶
- BMA456_REG_FIFO_WM = 70¶
- BMA456_REG_FIFO_WM_HI = 71¶
- BMA456_REG_FIFO_WM_LOW = 70¶
- BMA456_REG_IF_CFG = 107¶
- BMA456_REG_INIT_CTRL = 89¶
- BMA456_REG_INT1_IO_CTRL = 83¶
- BMA456_REG_INT1_MAP = 86¶
- BMA456_REG_INT2_IO_CTRL = 84¶
- BMA456_REG_INT2_MAP = 87¶
- BMA456_REG_INTERNAL_ERR = 95¶
- BMA456_REG_INTERNAL_STATUS = 42¶
- BMA456_REG_INT_LATCH = 85¶
- BMA456_REG_INT_MAP_DATA = 88¶
- BMA456_REG_INT_STATUS = 28¶
- BMA456_REG_INT_STATUS0 = 28¶
- BMA456_REG_INT_STATUS1 = 29¶
- BMA456_REG_NVM_BE_CFG = 112¶
- BMA456_REG_NVM_CFG = 106¶
- BMA456_REG_OFFSET_X = 113¶
- BMA456_REG_OFFSET_Y = 114¶
- BMA456_REG_OFFSET_Z = 115¶
- BMA456_REG_PWR_CONF = 124¶
- BMA456_REG_PWR_CTRL = 125¶
- BMA456_REG_SELF_TST = 109¶
- BMA456_REG_SENSOR_TIME = 24¶
- BMA456_REG_SENSOR_TIME0 = 24¶
- BMA456_REG_SENSOR_TIME1 = 25¶
- BMA456_REG_SENSOR_TIME2 = 26¶
- BMA456_REG_STATUS = 3¶
- BMA456_REG_TEMPERATURE = 34¶
- BMA456_SELFTEST_DELAY_CONFIG = 2000¶
- BMA456_SELFTEST_DELAY_MEASURE = 50000¶
- BMA456_SELFTEST_RANGE = 8000¶
- BMA456_SELFTEST_THRESHOLD = 1800¶
- BMA456_TEMPERATURE_SHIFT = 23¶
philander.charger module¶
Abstract base types for implementations of battery chargers.
- class Charger[source]¶
Bases:
objectAbstract base class to describe a battery charger.
- getBatStatus()[source]¶
Get the battery status to tell about the health and state of the battery.
Returns one of the
battery.Statusvalues to indicate battery voltage level or presence or health state.- Returns:
The battery state.
- Return type:
- getBatteryTempStatus()[source]¶
Retrieves the battery’s temperature status.
- Returns:
A rating code to indicate the temperature rating of the battery element.
- Return type:
- getChargerTempStatus()[source]¶
Retrieves the charger’s temperature state.
- Returns:
A rating code to indicate the temperature rating of the charger chip.
- Return type:
- getChgStatus()[source]¶
Retrieves the charging phase or status.
- Returns:
A charger status code to indicate the current charger status.
- Return type:
- getDCStatus()[source]¶
Retrieves the DC supply status.
- Returns:
A status code to indicate the DC supply status.
- Return type:
- getError()[source]¶
Determines the error state for the charger chip, if one.
- Returns:
A charger error code to further describe reason for the error.
- Return type:
- getInfo()[source]¶
Retrieves an information block from the charging device.
Typically, this kind of information is rather static in that, it does not change over time. Usually, this information is somewhat unique for the charger origin, manufacturing date, hardware/firmware revision, product/model ID, chip series and alike. For that reason, this function can be used to see, if communication works reliably.
- getNumCells()[source]¶
Retrieves the number of battery cells configured.
Returns the number of battery cells or a negative number if this information could not be retrieved.
- Returns:
The number of cells.
- Return type:
int
- getPowerSrc()[source]¶
Retrieves the power source, that presumably drives the system at the moment that this function is executed.
- Returns:
A code to indicate the power source.
- Return type:
- isBatteryPresent()[source]¶
Checks, if the battery is present.
This does not tell anything about whether the battery is charged or not.
Returns
ErrorCode.errOkif a battery is present,ErrorCode.errUnavailableif the battery is not present and any other value to indicate the reason, why this information could not be retrieved.See also:
getChgStatus().- Returns:
An error code.
- Return type:
- class ChargerError(*values)[source]¶
Bases:
EnumA type to describe the charger’s error condition more precisely.
This is to detail the reason, why charging was stopped or is not going to start.
- bat = 40¶
- batBroken = 42¶
- batLow = 41¶
- batRemoved = 43¶
- config = 10¶
- dc = 30¶
- dcHigh = 32¶
- dcLow = 31¶
- ok = 0¶
- temp = 20¶
- tempBat = 22¶
- tempChg = 21¶
- timer = 50¶
- unknown = 100¶
- class DCStatus(*values)[source]¶
Bases:
EnumWrapper to hold status information of a DC supply.
- off = 1¶
- overvoltage = 4¶
- undervoltage = 2¶
- unknown = 5¶
- valid = 3¶
- class EventContext(source: EventSource = <EventSource.none: 0>)[source]¶
Bases:
EventContextData class holding the context information of an event (interrupt).
Use the
sourceattribute to de-multiplex the inner data items.- source: EventSource = 0¶
- class EventSource(*values)[source]¶
Bases:
FlagEvent source type to detail the reason for an interrupt occurrence.
It’s ok for an implementation to not support every type of interrupt.
- all = 2047¶
- batteryOvercurrent = 128¶
- batteryTemperature = 64¶
- chargingPhase = 4¶
- inputCurrentLimitOwn = 16¶
- inputCurrentLimitSrc = 32¶
- inputVoltage = 8¶
- internal = 1¶
- none = 0¶
- onOff = 2¶
- systemOvervoltage = 512¶
- systemUndervoltage = 256¶
- thermalShutdown = 1024¶
- unknown = 32768¶
- class PowerSrc(*values)[source]¶
Bases:
FlagA power source describes a supplier of electrical energy that can be used, e.g. to drive the system.
- bat = 2¶
- dc = 1¶
- dcBat = 3¶
- unknown = 0¶
- class Status(*values)[source]¶
Bases:
EnumData class to describe the status or mode of a charging circuitry. This is mainly specified by the phase of a charging cycle.
- done = 8¶
- fastCharge = 4¶
- fastChargeConstCurrent = 5¶
- fastChargeConstVoltage = 6¶
- off = 1¶
- preCharge = 2¶
- topOff = 7¶
- trickle = 3¶
- unknown = 9¶
philander.configurable module¶
Module to provide helper classes related to configuration.
- class ConfigItem(*values)[source]¶
Bases:
EnumMnemonic type to identify a specific kind of configuration. This helps interpreting configuration data, correctly. The meaning is as follows:
Item
Meaning
rate
Data rate as a frequency in Hz.
range
Data measurement range, depending on the physical dimension.
resolution
Resolution of a measurement result in bits.
fifo
Fifo low/hogh water marks, empty signals etc.
eventArm
Arming the event machine, enabling interrupt(s).
eventCondition
Thresholds and counts to define event conditions.
implicit
Configured property is implicitly given by the enclosing type.
- eventArm = 5¶
- eventCondition = 6¶
- fifo = 4¶
- implicit = 7¶
- range = 2¶
- rate = 1¶
- resolution = 3¶
- class Configurable[source]¶
Bases:
objectGeneric interface for configurable objects.
Unless described otherwise by sub-classes, the exact interpretation of configuration parameters as well as the behavior of the
configure()method is at the discretion of the implementation.- configure(configData)[source]¶
Configures the device as described by the given configuration data.
Note that the type of the provided data and its interpretation will depend on the actual implementation.
Also see:
Configuration.- Parameters:
configData (.Configuration) – Specific configuration information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- class Configuration(item: ConfigItem = ConfigItem.implicit, value: int = 1, fifo: CfgFifo = None)[source]¶
Bases:
objectContainer structure to hold common configuration data.
Instances of this class will be passed to the
Configurable.configure()method. Use theitemattribute to de-multiplex the inner data attributes.- class CfgFifo(watermark: int = 4, control: int = 0)[source]¶
Bases:
object- control: int = 0¶
- watermark: int = 4¶
- item: ConfigItem = 7¶
Multiplex configured item and data attribute interpretation as follows:
Value
Attribute valid
ConfigItem.rate
value
ConfigItem.range
value
ConfigItem.resolution
value
ConfigItem.fifo
fifo
ConfigItem.eventArm
value
ConfigItem.eventCondition
to be defined in subclass
ConfigItem.implicit
to be defined in subclass
- value: int = 1¶
philander.dictionary module¶
Types and functions making up the dictionary module.
- class Dictionary(myMap={}, mode=12)[source]¶
Bases:
objectA dictionary is meant to translate keys to values, both of them being integers.
For example, a certain configuration register content could be translated into its physical data domain by means of a dictionary. The BMA456 acceleration sensor can adjust its measurement range to +/- 2g, 4g, 8g or even 16g by setting its ACC_RANGE register to either 0, 1, 2 or 3, respectively. Considering the register content to be the key domain, whereas the corresponding range limits are the values, a dictionary would translate as follows:
Key
Value
0
2000
1
4000
2
8000
3
16000
It is also possible to translate vice-versa, i.e. from the value-domain into keys by finding the nearest matching key. The behavior of this search algorithm can be controlled by the dictionary’s
modeattribute.Note that at the advantage of runtime speed, this implementation assumes the dictionary be sorted by values in ascending order.
- DICT_MODE_MAP = 12¶
Bitmask for the mode particle to define the mapping for values that are in the range defined by the minimum and maximum values in the dictionary.
- DICT_MODE_MAP_NEAREST = 12¶
Map by ordinary rounding: A value is mapped to the key that corresponds to the nearest value in dictionary.
- DICT_MODE_MAP_NEAREST_HIGHER = 8¶
Map by rounding up: A value is mapped to the key that corresponds to the smallest value, that is larger than (or equal to) it.
- DICT_MODE_MAP_NEAREST_LOWER = 4¶
Map by rounding down: A value is mapped to the key that corresponds to the largest value, that is smaller than (or equal to) it.
- DICT_MODE_MAP_STRICTLY = 0¶
Strict mapping: Only those values, that are contained in the dictionary will be mapped to their corresponding keys. Other values will produce errors.
- DICT_MODE_OVERRUN = 2¶
Bitmask for the mode particle to define the mapping for values above the highest value in the dictionary, a so-called overrun.
- DICT_MODE_OVERRUN_ERROR = 2¶
Values larger than the highest value in dictionary will not be mapped, but cause an error when trying to find a matching key.
- DICT_MODE_OVERRUN_MAP = 0¶
Values above the highest value will be mapped to the key corresponding to that highest value.
- DICT_MODE_UNDERRUN = 1¶
Bitmask for the mode particle to define the mapping for values below the lowest value (!) in the dictionary, a so-called underrun.
- DICT_MODE_UNDERRUN_ERROR = 1¶
Values below the lowest value in the dictionary are not mapped, but cause an error when trying to find a matching key.
- DICT_MODE_UNDERRUN_MAP = 0¶
Make values below the lowest value be mapped to the key corresponding to that lowest value.
- DICT_STDMODE_CLIP = 15¶
Shortcut, just for convenience. Clip mode maps to the nearest possible key, but generates errors for underruns and overruns.
- DICT_STDMODE_DOWN = 4¶
Shortcut, just for convenience. Downward mode rounds down to the nearest key and maps underruns and overruns without errors.
- DICT_STDMODE_NORMAL = 12¶
Shortcut, just for convenience. Normal mode maps to the nearest possible key, as well as underruns and overruns without errors.
- DICT_STDMODE_STRICT = 3¶
Shortcut, just for convenience. Strict mode just maps to the matching key and generates errors for all values that are not in the dictionary.
- DICT_STDMODE_UP = 8¶
Shortcut, just for convenience. Upward mode rounds up to the nearest key and maps underruns and overruns without errors.
- findKey(value)[source]¶
Given a value, finds the (nearest) key according to the dictionary’s mode.
The value-to-key mapping behavior can be controlled by the dictionary mode as defined during object construction.
- Parameters:
value (int) – The value for which to find the corresponding key.
- Returns:
The key and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
- getValue(inKey)[source]¶
Given a key, retrieves the corresponding value.
The first key in the dictionary exactly matching the given argument, delivers the value returned by this function. If no matching key is found, an error is returned.
- Parameters:
inKey (int) – Key value for which to find the corresponding value.
- Returns:
The key’s value and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
philander.display module¶
Display module to support different kinds of visible user interface.
This is a convergence layer to provide unified access to displays, screens and other visible user interfaces beyond LEDs.
- class Color[source]¶
Bases:
intColors that can be used when drawing to the LCD.
The underlying hardware might support different color spaces, like 8 bit gray scale or 24 bit true color levels.
- class ColorSpace(*values)[source]¶
Bases:
EnumMnemonics to define color / gray scale resolution.
- GRAY_1 = 1¶
- GRAY_2 = 2¶
- GRAY_4 = 3¶
- GRAY_8 = 4¶
- PALETTE_4 = 10¶
- PALETTE_8 = 11¶
- RGB_16 = 20¶
- RGB_24 = 21¶
- RGB_32 = 22¶
- class Display[source]¶
Bases:
ABC,ModuleGeneric interface for a visual user interface (display).
This is an abstract base class (ABC), that cannot be instantiated directly, but must be derived before making use of it.
The design of this class aims at being agnostic to the display technology. Derivatives of this class may be more specific to e.g. just symbols displays, text-only displays or graphic displays.
However, a display may tell about its nature, shape and capabilities. Moreover, it supports the concept of orientation and may adjust back light, contrast and inverse presentation.
- CAPABILITIES_GRAPHIC = 2¶
- CAPABILITIES_TEXT_ONLY = 1¶
- CAPABILITIES_UNKNOWN = 0¶
- INTENSITY_FULL = 100¶
- INTENSITY_HIGH = 75¶
- INTENSITY_LOW = 25¶
- INTENSITY_MEDIUM = 50¶
- INTENSITY_OFF = 0¶
- MODULE_PARAM_PREFIX = 'display'¶
- ORIENTATION_FLIP_H = 2¶
- ORIENTATION_FLIP_HV = 3¶
- ORIENTATION_FLIP_V = 1¶
- ORIENTATION_NATURAL = 0¶
- ORIENTATION_ROTATE_180 = 3¶
- ORIENTATION_ROTATE_CCW = 7¶
- ORIENTATION_ROTATE_CW = 4¶
- ORIENTATION_ROTATE_CW_FLIP_H = 6¶
- ORIENTATION_ROTATE_CW_FLIP_HV = 7¶
- ORIENTATION_ROTATE_CW_FLIP_V = 5¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with default values.
Supported key names and their meanings are:
Key
Meaning, Range, Default
display.brightness
Brightness of screen or backlight as a percentage; 0…100;
Display.INTENSITY_HIGHdisplay.contrast
Screen contrast setting as a percentage; 0…100;
Display.INTENSITY_HIGHdisplay.orientation
Orientation of the screen;
Display.ORIENTATION_NATURAL- Parameters:
paramDict (dict(str, object)) – Dictionary of configuration settings.
- Returns:
none
- Return type:
None
- SHAPE_CIRCLE = 1¶
- SHAPE_RECTANGLE = 0¶
- property capabilities¶
Retrieve the capabilities of the underlying display hardware.
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property orientation¶
Retrieve the current display orientation.
- setBrightness(value)[source]¶
Configure the brightness or back light intensity.
A bright light significantly improves the readability of the display content, but, at the same time, drastically increases electrical power consumption of the system. The situation-aware adjustment of the back light level could provide a chance to balance between these two contradicting requirements.
The new brightness value is given as an integer percentage in the range of zero (0) to hundred (100), inclusively. Setting it to 0[%] will effectively switch off the light. Giving a value of 100[%] will put the light always on resulting in the brightest-possible illumination. Dimming the light corresponding to values in between might be implemented e.g. through pulse-width modulation (PWM).
- Parameters:
value (int) – The new value to set the brightness to.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setContrast(value)[source]¶
Adjusts the contrast intensity.
Contrast is the difference between the brightness levels of bright white and full black pixels. For LCD due to technical reasons, the brightness of white pixels is not affected by this function. Instead, the saturation of black pixels can be faded from full black into faint grey. Note that low contrast will nominally reduce drawn current and thus, marginally save some power. At the same time, it will severely degrade reading comfort. The caller should deploy this function in conjunction with back light adjustment and power saving modes to balance readability with power consumption.
The new contrast level is given as an integer percentage in the range of zero (0) to hundred (100), inclusively. A value of zero will obliterate any contrast and make black and white pixels appear the same resulting in nothing can be seen on an LCD. The value of 100 will impose the maximum contrast making black pixels clearly differ from white pixels.
- Parameters:
value (int) – The new value to set the contrast to.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setInverse(inverseOn=True)[source]¶
Invert the display.
Make white and light pixels appear black and gray, respectivley and vice-versa.
- Parameters:
inverseOn (bool) – True for inverse mode, False for normal mode.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setOrientation(orientation)[source]¶
Set the new display orientation.
This is to maximize mechanical flexibility and to easily allow for flipping/rotating the content.
- Parameters:
orientation (int) – The new orientation to set. One of the
Display.ORIENTATION_*values.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setRunLevel(level)[source]¶
Select the power-saving operation mode.
Switches the instance to one of the power-saving modes or recovers from these modes. Situation-aware deployment of these modes can greatly reduce the system’s total power consumption.
- property shape¶
Retrieve the shape of the display.
- class Font(charWidth: int = 8, charHeight: int = 8, encoding: str = 'ascii', colorspace: ColorSpace = ColorSpace.GRAY_1, firstAscii: int = 32, numCharacters: int = 96, name: str = '', idxAdr: int = 0, letter: bytes = None)[source]¶
Bases:
objectThe font data structure.
Font data mainly contain some meta information plus the pixel data for each ASCII character. A font can omit non-printable characters to save memory. A font could extend to non-ASCII characters, however.
- charHeight: int = 8¶
- charWidth: int = 8¶
- colorspace: ColorSpace = 1¶
- encoding: str = 'ascii'¶
- firstAscii: int = 32¶
- idxAdr: int = 0¶
- letter: bytes = None¶
- name: str = ''¶
- numCharacters: int = 96¶
- class GraphicDisplay[source]¶
Bases:
TextDisplayAbstract API class for displays capable of showing graphics.
Implementations of this interface are expected to drive a specific hardware, which is usually an LCD or OLED.
Beyond everything that is inherited from TextDisplay, graphic displays know of different colors and inks.
The concept of ink is a short cut for logic operations executed when drawing a possibly colored pixel on the background. Pixel data may originate from drawing (and anti-aliasing) a line or from the font when printing a character. Logic is computed bit-wise of the pixel and background color values as follows:
Ink
Effect
REPLACE
Old content is simply replaced. No logic applies.
OVERLAY
New content is logically ORed with the old one. Usually that leads to the screen area becoming darker as more pixels are set or gray scales sum up.
MASK
New content is logically ANDed with the old one resulting in lighter screen area. Only those pixels keep set, that were set before and would be set by the new content.
INVERT
New content is logically XORed with the old one. Original content is preserved were the new content has white pixels, while the original content is negated were the new content has black pixels.
- INK_STYLE_INVERT = 3¶
- INK_STYLE_MASK = 2¶
- INK_STYLE_OVERLAY = 1¶
- INK_STYLE_REPLACE = 0¶
- property backgroundColor¶
Retrieve the current background color.
- clearScreen()[source]¶
Clear the screen, so there is no content visible, anymore.
Reset all character fields and by this, erase the current display content. Afterwards, place the internal
current positionto the upper left corner position at(0,0). So, subsequent printing of characters will start there. Finally, reset the current background color to white, which is only important for the case that the screen-full policy is set toINVERT.Note that the position of the (visible) hardware cursor is not affected. If the screen should be blanked without erasing its content, consider throttling the contrast or try one of the run levels.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property colorspace¶
Retrieve the display color space.
- drawBox(width, height, color)[source]¶
Draw a filled rectangle.
The upper left corner of the rectangle is defined by the virtual drawing cursor. The size is given by the parameters, as well as the color and ink type to draw with. A width of 1 will produce a vertical line, a height of 1 will result in a horizontal line. If both, width and height are 1, the box will be a single pixel.
Note that the rectangle’s border color is the same as the fill color. Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
On return, the virtual drawing cursor is not changed.
- Parameters:
width (int) – The horizontal width of the box, given in pixels.
height (int) – The vertical size of the box to draw, given in pixels.
color (int) – The color or shade of grey, that the box shall be of.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawCircle(radius, color)[source]¶
Draw a circle.
The center of the circle is defined by the current position of the virtual drawing cursor. This position is not changed on return. The radius of the circle is provided as a parameter.
Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
The implementation uses a variant of the Bresenham algorithm.
- Parameters:
radius (int) – The radius of the circle, given in pixels. Should be positive.
color (int) – The color of the circle.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawHLine(width, color)[source]¶
Draw a horizontal line.
Drawing starts from the virtual drawing cursor’s current position and extends over the specified width. Upon return, the position of the virtual drawing cursor is left unchanged. In terms of speed, this function is preferable over the more general function
drawLine().Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
Also see:
drawVLine(),drawLine()- Parameters:
width (int) – The length of the line, given in pixels.
color (int) – The color of the line.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawImage(image)[source]¶
Draw an image at the current position of the virtual drawing cursor.
The size and data of the image are encapsulated in the ``image```parameter. Depending on the current ink set, logic operation between the image data/color and the background may be applied.
On return, the position of the virtual drawing cursor is left unchanged.
- Parameters:
image (int) – The image including meta data like width and height.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawLine(xEnd, yEnd, color)[source]¶
Draw a line in an arbitrary direction.
Drawing starts from the current position of the virtual drawing cursor. The end point is given by the parameters. Upon return, the virtual drawing cursor is at the end point position.
If the caller knows, that the line is simply vertical or horizontal,
drawVLine()ordrawHLine()should be called, instead. Otherwise, this function will find out and optimize performance that way.For all other, non-trivial lines, implementation uses the Bresenham algorithm to construct the line pixel by pixel.
Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
- Parameters:
xEnd (int) – The x coordinate of the end point, given in pixels.
yEnd (int) – The vertical component of the end point, given in pixels.
color (int) – The color of the line.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawPixel(x, y, color)[source]¶
Set a pixel at the given position with the given color and ink.
Moves the virtual drawing cursor to the given position and draws a 1x1 box with the given color. Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
Also see:
drawBox()- Parameters:
x (int) – The x coordinate of the pixel to draw.
y (int) – The y coordinate of the pixel to draw.
color (int) – The color to draw with.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawRectangle(width, height, color)[source]¶
Draw an empty rectangle.
The upper left corner of the rectangle is defined by the virtual drawing cursor. The size is given by the parameters as well as the color and ink type to draw with.
A width of 1 will produce a vertical line, a height of 1 will result in a horizontal line. If both, width and height are 1, the result will be a single pixel.
Note that the rectangle’s border width is always one pixel. Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
On return, the virtual drawing cursor is not changed.
Also see:
drawBox()- Parameters:
width (int) – The horizontal width of the rectangle, given in pixels.
height (int) – The vertical size of the rectangle to draw, given in pixels.
color (int) – The color or shade of grey, that the box line shall be of.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- drawVLine(height, color)[source]¶
Draw a vertical line.
Drawing starts at the current position of the virtual drawing cursor. The length of the line is specified as a parameter. On return, the virtual drawing cursor is still at the same position. In terms of speed, this function is preferable over the more general function
drawLine().Depending on the current ink set, logic operation between the given (foreground-)color and the background may be applied.
Also see:
drawHLine(),drawLine()- Parameters:
height (int) – The vertical length of the line, given in pixels.
color (int) – The color of the line.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- goByChar(x, y)[source]¶
Move the internal
current positionby the given number of characters.Remember that this internal
current positionis not visible. It is conceptually different from the hardware cursor, which is controlled by the :meth:´moveCursorToChar` and similar functions.Note that positive arguments will make the current position move right/down while negatives will move left/up.
If the movement would exceed the display limits, nothing is changed and the function returns an error code.
- Parameters:
x (int) – The number of characters to move horizontally.
y (int) – The number of characters (lines) to move vertically.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- goByPixel(x, y)[source]¶
Move the virtual drawing cursor by a relative distance, expressed in pixels.
Actually, the new position calculates as the arithmetic sum of the internal
current positionand the arguments. If the movement would exceed the screen limits, nothing is moved and the function returns an error code.Positive values will move the virtual cursor to the right or downwards, while negative values will move it to the left or upwards, respectively.
Also see:
goToPixel(),TextDisplay.goByChar()- Parameters:
x (int) – The horizontal displacement in pixels.
y (int) – The vertical distance to move, given in pixels.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- goToChar(x, y)[source]¶
Move the internal
current positionto the specified absolute position.The
current positionis, where the next character will be printed, independent of where the hardware cursor is. If the given position is out of range, nothing changes and an error is returned.Also see:
moveCursorByChar().- Parameters:
x (int) – The new horizontal position, given in characters.
y (int) – The new vertical position, given in characters.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- goToPixel(x, y)[source]¶
Move the internal drawing cursor or
current positionto the given absolute position.The internal cursor is the starting point when drawing lines, characters etc. and is not visible to the user. Instead, it is a virtual cursor. It should not be mixed up with the hardware cursor that can be controlled by
TextDisplay.moveCursorToChar(). The same cursor is also manipulated by theTextDisplay.goToChar()method.Also see:
goByPixel()- Parameters:
x (int) – The new horizontal position given in pixels.
y (int) – The new vertical position given in pixels.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property heightPixel¶
Retrieve the display height in characters.
- property ink¶
Retrieve the ink logic.
- moveCursorByChar(x, y)[source]¶
Move the hardware cursor by the given number of characters.
Actual movement may depend on the current font selected, as this determines the character width and height. The cursor’s new absolute position will be its current position incremented by the arguments given.
Also see:
moveCursorToChar()- Parameters:
x (int) – The number of characters to move horizontally.
y (int) – The number of character lines to move vertically.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- moveCursorToChar(x, y)[source]¶
Sets the new absolute position of the hardware cursor.
Moves the visible hardware cursor to the position given in characters. The cursor position is independent of the internal
current position. The latter one defines, where the next characters is drawn and is controlled bygoTo(). The cursor position just defines, where the hardware cursor appears. Also, this function does not make the cursor appear or disappear. Instead, this can be controlled by calling thesetCursorMode()function. If the given position is out of range, nothing changes and an error is returned.Also see:
moveCursorByChar().- Parameters:
x (int) – The horizontal cursor position, given in characters.
y (int) – The vertical cursor position, given in characters.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- printChar(code)[source]¶
Print a character at the current position of the virtual drawing cursor.
This current position defines the upper left corner of the character bitmap to draw. The size of that bitmap is defined by the current font. The content of the bitmap is defined by the given character code and the corresponding font entry. The color is also defined by that font entry.
Depending on the current ink set, logic operation between the character color and the background may be applied.
Upon successful return, the virtual drawing cursor is moved by one character position. Usually, this means moving right by the character’s width. At the end of a line, the virtual drawing cursor is automatically placed at the beginning of the next line. At the end of the screen, the screen-full policy applies.
Also see:
TextDisplay.printChar()- Parameters:
code (int) – The character to print, given as an ASCII code.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- scrollHstart(direction, start_row, end_row, start_col, end_col, scroll_step)[source]¶
Execute a horizontal scroll of the content displayed.
- Parameters:
direction (int) – The direction of scrolling. One of
TextDisplay.SCROLL_DIR_LEFTorTextDisplay.SCROLL_DIR_RIGHT.start_row (int) – Starting row number.
end_row (int) – End row number.
start_col (int) – Start column number.
end_col (int) – End column number.
scroll_step (int) – The time interval in frames per scroll step
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- scrollHstop()[source]¶
Deactivate (stop) the horizontal scrolling.
After calling this function the display data may need to be rewritten
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setFont(font)[source]¶
Select a new font as current.
The new font is in effect instantly after returning from this function. The current drawing position may change to align with the new character size.
- Parameters:
font – The new character font to set as current.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property widthPixel¶
Retrieve the display width, measured in characters.
- class GrayScale1(*values)[source]¶
Bases:
EnumMnemonics for the black/white color space.
The underlying color-space is 1-bit b/w scale allowing for just 2 nuances - black and white.
- BLACK = 0¶
- WHITE = 255¶
- class GrayScale2(*values)[source]¶
Bases:
EnumMnemonics for a simple 2-bit mono-chromatic color space.
The underlying color-space is 2-bit gray scale allowing for just 4 nuances.
- BLACK = 0¶
- DARK_GRAY = 85¶
- LIGHT_GRAY = 170¶
- WHITE = 255¶
- class GrayScale4(*values)[source]¶
Bases:
EnumMnemonics for a 4-bit mono-chromatic color space.
The underlying color-space is 4-bit gray scale allowing for 16 nuances.
- BLACK = 0¶
- COAL_GRAY = 51¶
- DARK_GRAY = 85¶
- DARK_WHITE = 204¶
- DIRTY_BLACK = 17¶
- DIRTY_WHITE = 238¶
- LEAD_GRAY = 119¶
- LIGHT_BLACK = 68¶
- LIGHT_GRAY = 170¶
- MEDIUM_BLACK = 34¶
- MEDIUM_GRAY = 136¶
- MEDIUM_WHITE = 221¶
- SILVER_GRAY = 187¶
- SPANISH_GRAY = 153¶
- WHITE = 255¶
- ZINC_GRAY = 102¶
- class GrayScale8(*values)[source]¶
Bases:
EnumMnemonics to short-cut official names for shades of black, white and gray.
The underlying color-space is 8-bit gray scale allowing for a total of 256 nuances. Only some of them are named.
Also see: https://en.wikipedia.org/wiki/Shades_of_black https://en.wikipedia.org/wiki/Shades_of_gray https://en.wikipedia.org/wiki/Shades_of_white
- BLACK = 0¶
- CHINESE_BLACK = 20¶
- DARK_CHARCOAL = 51¶
- DARK_GRAY = 169¶
- DAVYS_GRAY = 85¶
- DIM_GRAY = 105¶
- EERIE_BLACK = 27¶
- GAINSBORO = 220¶
- GRAY = 128¶
- JET_BLACK = 52¶
- LIGHT_GRAY = 211¶
- MEDIUM_GRAY = 190¶
- ONYX = 15¶
- SILVER = 192¶
- SILVER_CHALICE = 172¶
- SONIC_SILVER = 117¶
- SPANISH_GRAY = 152¶
- TUNDORA = 64¶
- VAMPIRE_BLACK = 8¶
- WHITE = 255¶
- WHITE_SMOKE = 245¶
- class Image[source]¶
Bases:
objectHelper class to represent an image.
- property colorspace¶
- property height¶
- property width¶
- class TextDisplay[source]¶
Bases:
DisplayAbstract API class for displays capable of showing text.
Implementations of this interface are expected to drive a specific hardware, which is assumed to be a text-only display. However, this interface may also be implemented for graphical displays being able to draw text.
Text displays may support one or more fonts. They may have a hardware cursor and adjust its mode and size. Moreover, they offer to define a certain screen-full policy which may involve scrolling.
Text displays are not aware of colors. Further on, logic operations of character font data with the background are not supported. So, there is nothing comparable to the ink concept introduced for
GraphicDisplay.- CURSOR_MODE_BLACK = 2¶
- CURSOR_MODE_BLINK_BLACK = 5¶
- CURSOR_MODE_BLINK_INVERSE = 6¶
- CURSOR_MODE_BLINK_WHITE = 4¶
- CURSOR_MODE_INVERSE = 3¶
- CURSOR_MODE_OFF = 0¶
- CURSOR_MODE_WHITE = 1¶
- CURSOR_SIZE_FULL = 4¶
- CURSOR_SIZE_HALF = 3¶
- CURSOR_SIZE_QUARTER = 2¶
- CURSOR_SIZE_SLIM = 1¶
- DEFAULT_TAB_SIZE = 4¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with default values.
Supported key names and their meanings are:
Key
Meaning, Range, Default
display.screenpolicy
Screen-full policy to apply;
TextDisplay.SCREEN_POLICY_STOPdisplay.tabsize
Number of spaces for a tab; positive integer; 4
- Parameters:
paramDict (dict(str, object)) – Dictionary of configuration settings.
- Returns:
none
- Return type:
None
- SCREEN_POLICY_CLEAR = 1¶
- SCREEN_POLICY_INVERT = 2¶
- SCREEN_POLICY_SCROLL = 3¶
- SCREEN_POLICY_STOP = 0¶
- SCROLL_DIR_DOWN = 4¶
- SCROLL_DIR_LEFT = 1¶
- SCROLL_DIR_RIGHT = 2¶
- SCROLL_DIR_UP = 3¶
- clearScreen()[source]¶
Clear the screen, so there is no content visible, anymore.
Reset all character fields and by this, erase the current display content. Afterwards, place the internal
current positionto the upper left corner position at(0,0). So, subsequent printing of characters will start there. Finally, reset the current background color to white, which is only important for the case that the screen-full policy is set toINVERT.Note that the position of the (visible) hardware cursor is not affected. If the screen should be blanked without erasing its content, consider throttling the contrast or try one of the run levels.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getFont(name='')[source]¶
Retrieve a font, given its name.
If the name parameter is an empty string, the default font is retrieved.
- goByChar(x, y)[source]¶
Move the internal
current positionby the given number of characters.Remember that this internal
current positionis not visible. It is conceptually different from the hardware cursor, which is controlled by the :meth:´moveCursorToChar` and similar functions.Note that positive arguments will make the current position move right/down while negatives will move left/up.
If the movement would exceed the display limits, nothing is changed and the function returns an error code.
- Parameters:
x (int) – The number of characters to move horizontally.
y (int) – The number of characters (lines) to move vertically.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- goToChar(x, y)[source]¶
Move the internal
current positionto the specified absolute position.The
current positionis, where the next character will be printed, independent of where the hardware cursor is. If the given position is out of range, nothing changes and an error is returned.Also see:
moveCursorByChar().- Parameters:
x (int) – The new horizontal position, given in characters.
y (int) – The new vertical position, given in characters.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property heightChar¶
Retrieve the display height in characters.
- moveCursorByChar(x, y)[source]¶
Move the hardware cursor by the given number of characters.
Actual movement may depend on the current font selected, as this determines the character width and height. The cursor’s new absolute position will be its current position incremented by the arguments given.
Also see:
moveCursorToChar()- Parameters:
x (int) – The number of characters to move horizontally.
y (int) – The number of character lines to move vertically.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- moveCursorToChar(x, y)[source]¶
Sets the new absolute position of the hardware cursor.
Moves the visible hardware cursor to the position given in characters. The cursor position is independent of the internal
current position. The latter one defines, where the next characters is drawn and is controlled bygoTo(). The cursor position just defines, where the hardware cursor appears. Also, this function does not make the cursor appear or disappear. Instead, this can be controlled by calling thesetCursorMode()function. If the given position is out of range, nothing changes and an error is returned.Also see:
moveCursorByChar().- Parameters:
x (int) – The horizontal cursor position, given in characters.
y (int) – The vertical cursor position, given in characters.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- printChar(code)[source]¶
Print a character at the internal
current position.The size of the character is defined by the current font. Upon successful return, the current position is moved on by one character position. Usually, this means moving right by one character. At the end of a line, the new current position is automatically placed at the beginning of the next line. At the end of the screen, the screen-full policy applies.
The character handed in should be a genuine ASCII code. Codes less than 32 (hex. 0x20) are control codes and thus, are not printed. Still, passing those codes to this function may have visible effects. As far as these codes concern cursor control, the associated movement is emulated with the internal
current positionas good as possible. Other codes in this category may be simply are ignored.Codes from 32…127, inclusively, are printed according to the current font. It’s up to the implementation, how to handle non-ASCII codes beyond 127.
Also see:
goToChar(),setScreenFullPolicy()- Parameters:
code (int) – The character to print.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- printString(string)[source]¶
Print a string.
The first character of the given string is printed at the internal
current position. Then, the rest of it is printed consecutively character by character advancing the internalcurrent positionuntil the screen-full policy must be applied.Also see:
printChar()- Parameters:
string (str) – The string to be printed.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setCursorMode(mode)[source]¶
Switches the hardware cursor to a specific appearance.
The cursor shape is mostly rectangular and usually it cannot be modified. The size and position of the cursor can be manipulated by the
setCursorSize(),CursorGoto()and similar functions. Like with all the content displayed, the cursor is subject to the inverse feature controlled by :meth:’setInverse`.The given
modeparameter defines, how the cursor should behave and look like. The specific appearance is detailed in the following table.Mode
Appearance
OFF
Switches the cursor off. The cursor does not show up.
WHITE
The cursor is static white. This cursor cannot be seen when between spaces.
BLACK
A constantly black cursor.
INVERSE
Cursor reverts, but does not blink. This mode gives a steady cursor field inverting the content beneath, that is, black pixels become white and vice-versa. This cursor is always visible.
BLINK_WHITE
The area under the cursor will blink white. It shows the original content and an all-white area alternating. Note that this cursor is not visible over a white field, such as a space character.
BLINK_BLACK
The cursor blinks black. The corresponding area shows the original content and an all-black field alternating. This cursor is visible for the majority of meaningful characters.
BLINK_INVERSE
The cursor blinks reverted. It shows the original content and the reverted content alternating. This cursor is always visible.
Also see:
setCursorSizePosition()- Parameters:
mode – The cursor mode to switch to. One of the CURSOR_MODE_* values.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setCursorSize(width, height)[source]¶
Sets the size of the cursor.
The cursor shape is always rectangular. Depending on the underlying hardware, vertical or horizontal bars can be used as cursor by setting the width or the height parameter accordingly.
Remember to set an appropriate cursor mode by calling
setCursorMode()to control thecursor’s visibility.If the given position or size are invalid, nothing happens and the function returns an appropriate error code.
- Parameters:
width – The width of the cursor. One of the CURSOR_SIZE_* values.
height – The height of the cursor. One of the CURSOR_SIZE_* values.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setFont(font)[source]¶
Select a new font as current.
The new font is in effect instantly after returning from this function. The current drawing position may change to align with the new character size.
- Parameters:
font – The new character font to set as current.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setScreenFullPolicy(policy)[source]¶
Configure the screen-full policy.
This policy describes, what should happen if, while writing text, the internal
current positionreaches the end of screen (EOS), i.e. the bottom-right corner of the screen, and no more character can be placed.Depending on
policyargument, printing characters behaves as follows.Policy
Behavior
STOP
Simply does nothing. Does not update the internal drawing cursor. So, further attempts of drawing characters will address invalid screen area and thus, return with an error code. The handling of reaching the end of screen is solely put into the responsibility of the application. To support the application in this mode, printing the last character at the bottom right corner returns an :attr:
ErrorCode.ErrSpecRangeindication, upon which the caller should take appropriate action.CLEAR
After reaching the end, the screen is immediately cleared, positioning the internal
current positionat the upper left corner. So, further text starts from the top-left of the screen. The advantage of this policy is, that it is a light-weight implementation that allows for continuous text output without caller interaction. The disadvantage is, that after text rolls over a screen boundary - even if only by one letter - old text cannot be seen, anymore.INVERT
Each time, text placement reaches a new line (!), that line is cleared and by this, colored with a certain background color starting with white. When reaching the bottom right corner, text continues at the top left screen position without clearing the screen. Instead, the background color is flipped from white to black or vice versa, clearly marking the new lines. The current screen and the previous one appear clearly separated by inverse colors. And even if the screen is full, as much as possible of the old text can be seen.
SCROLL
This is the most popular policy known from common console applications. When the text reaches the end of the screen, the whole content scrolls up by one line of text. That is, the first line at the top is abandoned, the second line is placed on the first one, the third goes to the second and so on. The last line is placed in the last but one freeing space for a new last line. After blanking the last line, further text goes there until the end of line, and thus, the end of the screen is reached again and the procedure starts anew. This is the policy with the most convenient user experience. If this behavior is not supported by hardware, it requires the most complex software implementation.
Due to the varying support for different policies or code size requirements, the caller should be prepared to get an
ErrorCode.errNotImplementedreturn value for one or the other policy.- Parameters:
policy (int) – The new policy to apply. One of the
SCREEN_POLICY_*values.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- property widthChar¶
Retrieve the display width, measured in characters.
philander.gasgauge module¶
A module to provide base classes and data types for gas gauge driver implementations.
- class EventContext(source: EventSource = EventSource.none, soc: Percentage = 255, voltage: Voltage = 65535, batStatus: Status = <Status.unknown: 65535>)[source]¶
Bases:
objectEvent context type to detail the context information for an interrupt occurrence.
- soc: Percentage = 255¶
- source: EventSource = (1,)¶
- class EventSource(*values)[source]¶
Bases:
EnumEvent source type to detail the reason for an interrupt occurrence.
Not all implementations will support all types of interrupt.
- batFail = (5,)¶
General battery failure, e.g. battery swapped
- hardReset = (7,)¶
Power-on reset detected
- highSOC = (3,)¶
SOC reached a high/full info level
- lowSOC = (2,)¶
SOC dropped below a threshold
- lowVolt = (4,)¶
Battery voltage dropped below a threshold
- none = (1,)¶
No event reason
- undervoltage = (6,)¶
Brown-out/Lockout due to low voltage
- unknown = (8,)¶
Unknown event reason
- class GasGauge[source]¶
Bases:
objectThis is a driver base class for a gas gauge IC.
A gas gauge allows to keep track of the state of charge (SOC), remaining capacity, current voltage etc. of a battery.
- getBatteryCurrent()[source]¶
Retrieves the battery current in micro Ampere at the time this function is executed.
See also:
getBatteryCurrentAvg()- Returns:
A on-negative integer value [µA] or
Current.invalidto indicate that this information could not be retrieved.- Return type:
- getBatteryCurrentAvg()[source]¶
Retrieves the average battery current.
The average is taken over some time interval, e.g. 2 seconds. The length of the time window is at the discretion of the implementation and cannot be adjusted by the caller.
See also:
getBatteryCurrent()- Returns:
A on-negative integer value [�A] or
Current.invalidto indicate that this information could not be retrieved.- Return type:
- getBatteryVoltage()[source]¶
Retrieves the battery voltage in milli Volt.
- Returns:
A on-negative integer value [mV] or
Voltage.invalidto indicate that this information could not be retrieved.- Return type:
- getChangeRate()[source]¶
Retrieves the SOC change rate in milli C.
Remember that 1C = 100% in 1 hour. This information may be used to estimate the remaining stamina or how long the charging process will still take. :return: A SOC change rate (non-negative) or :attr:’SOCChangeRate.invalid` to indicate that this information could not be retrieved. :rtype: SOCChangeRate
- getInfo()[source]¶
Retrieves an information block from the gas gauge device.
Typically, this kind of information is rather static in that, it does not change over time. Usually, this information is somewhat unique for the charger origin, manufacturing date, hardware/firmware revision, product/model ID, chip series and alike. For that reason, this function can be used to see, if communication works reliably.
For more dynamic meta-information see
getStatus().The method returns both, an instance of
Info, carrying the information block as well as an error code, indicating success or failure. The info block shall be evaluated only, if the method returned successfully. Even then, the caller should still evaluate thevalidityattribute of the returned info block to find out, which of the information is actually valid.
- getRatedSOC()[source]¶
Retrieve the current state of charge as a discrete battery level predicate.
- Returns:
The next-lower battery level corresponding to the current SOC.
- Return type:
- getRatedSOCStr()[source]¶
Retrieve the remaining capacity as a battery level string.
- Returns:
The next-lower battery level corresponding to the current SOC.
- Return type:
String
- getStateOfCharge()[source]¶
Retrieves the state of charge.
That is the fraction of electric energy from the total capacity, that is still or already stored in the battery. This information is valid for both, the charging as well as the discharging process.
- Returns:
A percentage [0…100] value or
Percentage.invalidto indicate that this information could not be retrieved.- Return type:
- getStatus(statusID)[source]¶
Retrieves status data from the device.
Typically, this kind of information is more dynamic in that, it changes (much) over time. Usually, it further describes the IC’s current shape and condition, such as the availability of new data, the cause of an interrupt or the status of certain hardware functions. Also, secondary measurements such as the die temperature could be subject to status data.
For more static meta-information see
getInfo().The given
statusIDparameter specifies, exactly which status information should be retrieved. Its type and interpretation depends on the implementation.The method returns both, resulting status data and an error code indicating success or failure. The status data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the status data depends on the specific implementation.
- Parameters:
statusID (int) – Identifies the status information to be retrieved.
- Returns:
The status object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
philander.gpio module¶
General-purpose I/O abstraction module.
Provide a convergence layer API to abstract from several different GPIO implementing driver modules possibly installed on the target system.
- class GPIO[source]¶
Bases:
Module,InterruptableGeneral-purpose I/O abstraction class.
Provide access to and control over the underlying GPIO hardware. For that, an implementing driver module is used. As a convergence layer, this class is to hide specifics and level syntactic requirements of the implementing package.
- BOUNCE_DEFAULT = 200¶
- BOUNCE_NONE = 0¶
- DIRECTION_IN = 1¶
- DIRECTION_OUT = 2¶
- EVENT_DEFAULT = 'gpioFired'¶
- LEVEL_HIGH = 1¶
- LEVEL_LOW = 0¶
- PINNUMBERING_BCM = 'BCM'¶
- PINNUMBERING_BOARD = 'BOARD'¶
- PULL_DEFAULT = 0¶
- PULL_DOWN = 3¶
- PULL_NONE = 1¶
- PULL_UP = 2¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
The given dictionary should not be None, on entry. Options not present in the dictionary will be added and set to their defaults on return. The following options are supported.
Key
Range
Default
gpio.provider
SysProviderto select implementationSysProvider.AUTO.gpio.pinNumbering
GPIO.PINNUMBERING_[BCM | BOARD]
GPIO.PINNUMBERING_BCM
gpio.pinDesignator
pin name or number (e.g. 17 or “GPIO17”)
None
gpio.direction
GPIO.DIRECTION_[IN | OUT]
GPIO.DIRECTION_OUT
gpio.inverted
[True | False]
False
gpio.level
GPIO.LEVEL_[LOW | HIGH]
GPIO.LEVEL_LOW
gpio.pull
GPIO.PULL_[DEFAULT | NONE | UP | DOWN]
GPIO.PULL_DEFAULT (NONE)
gpio.trigger
GPIO.TRIGGER_EDGE_[RISING | FALLING | ANY]
GPIO.TRIGGER_EDGE_RISING
gpio.bounce
integer number, delay in milliseconds [ms]
GPIO.BOUNCE_DEFAULT
gpio.feedback
Arbitrary. Passed on to the interrupt handler.
None
gpio.handler
Handling routine reference.
None
- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
none
- Return type:
None
- TRIGGER_EDGE_ANY = 3¶
- TRIGGER_EDGE_FALLING = 2¶
- TRIGGER_EDGE_RISING = 1¶
- TRIGGER_LEVEL_HIGH = 4¶
- TRIGGER_LEVEL_LOW = 5¶
- close()[source]¶
Closes this instance and releases associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disableInterrupt()[source]¶
Disables the gpio interrupt for that pin.
Immediately disables the interrupt for that pin. It will not _fire an event anymore, unless
enableInterrupt()is called anew.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableInterrupt()[source]¶
Enables the gpio interrupt for that pin.
If the pin is configured for input, enables the interrupt for that pin. Depending on the trigger configured during
open(), an event will be fired the next time when the condition is satisfied.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- get()[source]¶
Retrieve the pin level.
Gives the pin level, independent of whether the pin direction is set to input or output.
- Returns:
GPIO.LEVEL_HIGH, if the pin is at high level. Otherwise, GPIO.LEVEL_LOW.
- Return type:
int
- static getGPIO(provider=SysProvider.AUTO)[source]¶
Generates a GPIO implementation according to the requested provider.
- Parameters:
provider (SysProvider) – The low-level lib to rely on, or AUTO for automatic detection.
- Returns:
A GPIO implementation object, or None in case of an error.
- Return type:
- open(paramDict)[source]¶
Opens the instance and sets it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- set(newLevel)[source]¶
Sets the pin to the given level.
Outputs the given level at this pin. Does not work, if this pin is set to input direction.
- Parameters:
newLevel (int) – The new level to set this pin to. Must be one of GPIO.LEVEL_[HIGH | LOW].
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.gpio_micropython module¶
philander.gpio_periphery module¶
GPIO implementation using the periphery lib.
philander.gpio_rpi module¶
philander.gpio_sim module¶
GPIO implementation using the built-in simulation model.
philander.gpio_zero module¶
GPIO implementation using the gpiozero lib.
philander.htu21d module¶
Driver implementation for the HTU21D relative humidity and temperature sensor.
More information on the functionality of the chip can be found at the TE site: https://www.te.com/deu-de/product-CAT-HSC0004.html
- class Data(humidity: Percentage = 0, temperature: PreciseTemperature = 0)[source]¶
-
Container type to wrap this sensor’s measurement result.
This data type carries both, temperature and humidity measurement results. Also see:
thermometer.Data,hygrometer.Data
- class HTU21D[source]¶
Bases:
Sensor,SerialBusDeviceHTU21D driver implementation.
- ADDRESS = 64¶
- CFG_RESOLUTION_DEFAULT = 14¶
- CFG_RESOLUTION_HUM10_TEMP13 = 13¶
- CFG_RESOLUTION_HUM11_TEMP11 = 11¶
- CFG_RESOLUTION_HUM12_TEMP14 = 14¶
- CFG_RESOLUTION_HUM8_TEMP12 = 12¶
- CMD_GET_HUM = 245¶
- CMD_GET_HUM_HOLD = 229¶
- CMD_GET_TEMP = 243¶
- CMD_GET_TEMP_HOLD = 227¶
- CMD_READ_USR_REG = 231¶
- CMD_SOFT_RESET = 254¶
- CMD_WRITE_USR_REG = 230¶
- CNT_USR_CHIP_HEATER = 4¶
- CNT_USR_CHIP_HEATER_OFF = 0¶
- CNT_USR_CHIP_HEATER_ON = 4¶
- CNT_USR_DEFAULT = 2¶
- CNT_USR_OTP_RELOAD = 2¶
- CNT_USR_OTP_RELOAD_DISABLE = 2¶
- CNT_USR_OTP_RELOAD_ENABLE = 0¶
- CNT_USR_POWER = 64¶
- CNT_USR_POWER_GOOD = 0¶
- CNT_USR_POWER_LOW = 64¶
- CNT_USR_RESERVED = 56¶
- CNT_USR_RESOLUTION = 129¶
- CNT_USR_RESOLUTION_DEFAULT = 0¶
- CNT_USR_RESOLUTION_RH10_T13 = 128¶
- CNT_USR_RESOLUTION_RH11_T11 = 129¶
- CNT_USR_RESOLUTION_RH12_T14 = 0¶
- CNT_USR_RESOLUTION_RH8_T12 = 1¶
- DIAG_CIRC_OPEN = 0¶
- DIAG_CIRC_SHORT = 3¶
- DIAG_HUM_OK = 2¶
- DIAG_TEMP_OK = 1¶
- MEAS_TIME_MAX_MS_RH10 = 5¶
- MEAS_TIME_MAX_MS_RH11 = 8¶
- MEAS_TIME_MAX_MS_RH12 = 16¶
- MEAS_TIME_MAX_MS_RH8 = 3¶
- MEAS_TIME_MAX_MS_T11 = 7¶
- MEAS_TIME_MAX_MS_T12 = 13¶
- MEAS_TIME_MAX_MS_T13 = 25¶
- MEAS_TIME_MAX_MS_T14 = 50¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address, must beADDRESS; default isADDRESS.Sensor.dataRate
intData rate in Hz; default is set bySensor.Params_init().HTU21D.resolution
intResolution in bits; default isCFG_RESOLUTION_HUM12_TEMP14.Also see:
Sensor.Params_init(),SerialBusDevice.Params_init().
- RESET_TIME_MAX_MS = 15¶
- SELFTEST_TIME_WAIT_S = 5¶
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- configure(configData)[source]¶
Configures the sensor device as described by the given configuration data.
Note that the type of the provided data and its interpretation will depend on the sensor implementation. Also see:
Configuration.- Parameters:
configData (.sensor.Configuration) – Specific configuration information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getLatestData()[source]¶
Retrieves the most recent data.
If the data is older than the measurement interval indicated by the configured data rate, a new measurement sample is retrieved from the sensor.
Also see:
Sensor.getLatestData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getNextData()[source]¶
Wait for the next sample and retrieve that measurement.
If a full measurement interval, as defined by the configured data rate, has not yet elapsed, wait until that point. Then, retrieve a fresh measurement sample.
Also see:
Sensor.getNextData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getStatus(statusID)[source]¶
Retrieve dynamic status info from the sensor.
The resulting status data object depends on the requested info as follows:
htu21d.StatusID.powerOk: Reads the power indicator bit (#6, End-of-Battery) and returns a boolean True, if the VDD power is above the minimum required, or False otherwise.Also see:
Sensor.getStatus().- Parameters:
statusID (int) – Identifies the status information to be retrieved.
- Returns:
The status object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Opens an instance and puts it into a usable state.
Configures the sensor by reading the supported parameters or applying default values and calling
configure(). Also see:module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Reboots the sensor.
Power-cycles the chip and restarts it with the default configuration. So, any user configuration applied before, will be lost.
Also see:
Sensor.reset().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- selfTest(tests)[source]¶
Execute one or more sensor self tests.
SelfTest.FUNCTIONAL: The on-chip heater is used to check if the sensor shows the expected temperature raise and humidity drop. The heater consumes ~5.5mW and the test takes about 5 seconds.Also see:
Sensor.selfTest().- Parameters:
tests (int) – A bit mask to select the tests to be executed.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.hygrometer module¶
Abstract interface for humidity sensors accessible via serial communication.
Provide an API to abstract from relative humidity measurement devices.
- class Data(humidity: Percentage = 0)[source]¶
Bases:
objectContainer type to wrap a hygrometer’s primary measurement result.
Measurement data should always be expressed as percentage.
- humidity: Percentage = 0¶
philander.imath module¶
Integer mathematics helper functions.
Provide mathematical functions implementing bit-twiddling hacks, such as ispowtwo, iprevpowtwo and vlbs or ffs.
- ctz(x: int)[source]¶
Count trailing zeroes.
Count the number of zero-bits following the least-significant set bit. Note that ffs(x) = ctz(x) + 1. To maintain this relation when the argument is zero, this function returns -1 in this case.
Example: For x=24 the result is 3. For x=25 the result is 0.
- Parameters:
x (int) – The input argument, interpreted as an unsigned integer.
- Returns:
The number of trailing zeroes after the least-significant set bit.
- Return type:
int
- ffs(x: int)[source]¶
Find first set.
Finds the first, i.e. least-significant bit set and returns its index number, where counting starts from 1. For an input of zero, the result is zero, by definition. Note that ffs(x) = ctz(x) + 1.
Example: For x=24 the result is 4. For x=25 the result is 1.
- Parameters:
x (int) – The input argument, interpreted as an unsigned integer.
- Returns:
The one-based position index of the least-significant set bit.
- Return type:
int
- iprevpowtwo(n: int)[source]¶
Gives the previous power of two for the given argument.
Returns the greatest power of two, that is less than or equal to the provided argument. For zero, the function returns zero.
Example: For n=32 the result is 32. For n=47 the result is 32, too.
- Parameters:
n (int) – The argument, interpreted as an unsigned integer.
- Returns:
The previous power of two for that argument, or zero if n=0.
- Return type:
int
- ispowtwo(x: int)[source]¶
Checks if the argument is a power of two, i.e. has exactly one bit set.
Note that one (1) is considered a power of two, while zero (0) is not.
Example: For x=32 the result is True. For x=47 the result is False.
- Parameters:
x (int) – The argument to check, interpreted as an unsigned integer.
- Returns:
True, if the argument is a power of two, False otherwise.
- Return type:
Boolean
- vlbs(x: int)[source]¶
For a given integer, find the value of the least bit set.
If no bit of the argument is set, i.e. for zero (0), the result is zero (0). Otherwise, the result is a bit value and not a bit number! That’s why, the return value is always a power of two - or zero.
Example: For x=32 the result is 32. For x=47 the result is 1.
- Parameters:
x (int) – The input argument, interpreted as an unsigned integer.
- Returns:
The value of the least bit set, or zero.
- Return type:
int
philander.interruptable module¶
Module to provide interrupt-related interfaces and helper classes.
This is to support event-based programming techniques, also referred to
as publish-subscribe, asynchronous, event-driven behavior and so on.
The central interface is Interruptable, which is meant to be
sub-classed by implementing devices. It can be registered with interrupt
handling routines and used to enable or disable interrupts on that device.
Upon an interrupt occurrence, the registered handler is called with an
interruptable.Event argument. It is intended to carry all
information available at no extra price in the moment of interrupt
occurrence. For that reason, it is likely to represent no more
information than just the fact, that an interrupt occurred. If a device
supports multiple INT lines, it can identify which one exactly caused
the interrupt.
All further information beyond that immediate response, especially if
requiring extra communication with the device, is considered to be event
context information and is represented by an EventContext object.
This kind of data must be explicitly polled by the subscriber.
Whenever possible, that context polling should be done outside of the
handling routine as part of the response action.
EventContextControl objects are used to control the order/priority
of context items while retrieving them from the device.
- class Event[source]¶
Bases:
objectGeneric class to indicate the nature of an interrupt (source).
Instances of this class are meant to be passed to the handling routine as an immediate response to interrupts.
- evtAny = 'EventAny'¶
- evtInt1 = 'EventInt1'¶
- evtInt2 = 'EventInt2'¶
- evtNone = 'EventNone'¶
- class EventContext(control: EventContextControl = 1, remainInt: int = 0)[source]¶
Bases:
objectDetails or quantifies the reason for an interrupt occurrence.
Will probably be sub-classed to represent specifics of the implementing
Interruptabledevice.
- class EventContextControl[source]¶
Bases:
objectControl data to navigate through the list of event context items.
- clearAll = 0¶
- getFirst = 1¶
- getLast = 3¶
- getNext = 2¶
- getPrevious = 4¶
- class Interruptable[source]¶
Bases:
objectGeneric interface to describe the capabilities of an event or interrupt source.
This is an abstract base class to define common methods for enabling and disabling events as well as for managing event information of a specific device (implementation).
- disableInterrupt()[source]¶
Disables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableInterrupt()[source]¶
Enables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getEventContext(event, context)[source]¶
After an event occurred, retrieves more detailed information on the reason(s) for that interrupt.
If a device supports more interrupt conditions than physical interrupt signalling lines, this is the way to find out, which of the condition(s) were met causing the last interrupt to _fire. For example, a temperature sensor could _fire its (one and only) interrupt line, if: * a high-temperature threshold is exceeded * a low-temperature threshold is undercut * the temperature didn’t change (much) for some time interval * a new temperature measurement is available And some of these conditions could hold true simultaneously. Then, this function is to reveal more information on each single condition. E.g. the /new measurement available/ condition will deliver that new measurement data.
That’s why, it may be meaningful/necessary to call this method repeatedly, until all reasons were reported. Upon its first call after an event, the context’s
interruptable.EventContext.controlattribute must be set tointerruptable.EventContextControl.getFirst. Upon subsequent calls, this attribute should not be changed by the caller, anymore. In generally, event context information is retrieved in the order according to the priority of the corresponding event sources.The return value indicates, whether or not more information is available as follows:
Return value
Meaning
Success. Last context info. No more data to retrieve.
Success. Context is valid. More data to be retrieved.
No data to retrieve. Context is invalid.
any other ErrorCode.*
Error. Context data is invalid.
- Parameters:
event (int) – The original event occurred, as recieved by the handling routine. This must be one of the event mnemonics defined by :class:
.interruptable.Event.context (EventContext) – A representation of the context information. The appropriate sub-class must be provided by the device implementation. Upon the first call for each interrupt, the
controlattribute must be set to either one ofevtCtxtCtrl_[clearAll | getFirst | getLast]. In subsequent calls, this attribute is updated automatically. Upon return, this parameter contains the desired context information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- registerInterruptHandler(onEvent=None, callerFeedBack=None, handler=None)[source]¶
Registers a handling routine for interrupt notification.
The caller feedback will be directly passed to the handling routine. In case that multiple different interrupts are handled by the same routine, this parameter may be used to distinguish them and remember the source of interrupt.
The handler should be a method or function that expects at least one argument. That first argument will be the
callerFeedBackobject given as the above-mentioned parameter. Further parameters may follow, as they were handed in to the_fire()method. The handler’s signature should look like this:def handlingRoutine( feedback, *args) -> None:Note that the
onEventparameter is not passed to the handler. It is eaten up by_fire()and just controls the selection of the handling routine called.Depending on the parameter, this method behaves as follows:
onEvent
handler
semantics and action
Event.evtNone
None
All interrupts are disabled and all registrations cleared.
Event.evtNone
valid
De-register the given handler from all events {Event.evtInt1|2|Any}.
Event.evtInt1|2|*
None
De-register all handlers from the given event.
Event.evtInt1|2|*
valid
Enable interrupt and register this handler for the given event.
Event.evtAny
None
Clear the
Event.evtAnyregistrations, only!Event.evtAny
valid
Register the handler for any event {Event.evtInt1|2}.
For this method,
Event.evtNoneis a semantic equivalent toNone.- Parameters:
onEvent (int) – Exactly one of the event mnemonics defined by the
interruptable.Eventenumeration.callerFeedBack (object) – Arbitrary object not evaluated here, but passed on to the handler when an event is fired.
handler – The handling routine to be called as an immediate response to an event.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.l6924 module¶
Driver implementation for the L6924D/U battery chargers.
More information on the functionality of the chip can be found at the ST website under e.g. https://www.st.com/en/power-management/l6942d.html
- class L6924[source]¶
Bases:
ChargerL6924 driver implementation.
This implementation was tested using STEVAL-ISA076V1 board (based on L6924D) but also should work for other devices. This implementation does only read information on two gpio pins, and thus cannot communicate with the charger in any way.
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
All L6924.[St1 | St2].gpio.* settings as documented at
GPIO.Params_init().Also see:
Charger.Params_init(),SerialBusDevice.Params_init(),GPIO.Params_init().
- close()[source]¶
Shut down the device after usage.
This method should be called when the device is not used, anymore, e.g. as part of the application exit procedure. The following steps are executed:
close GPIO pins for st1 and st1
After return, the device can still be re-used, by calling
open()again.Also see:
GPIO.close(),Module.close().
- getBatStatus()[source]¶
Get the battery status to tell about the health and state of the battery.
Returns one of the
battery.Statusvalues to indicate battery voltage level or presence or health state. Because of the very limited output, this will only return the states Status.normal (charging, etc.) and Status.problemPhysical (Battery absent, too hot, etc.)- Returns:
The battery state.
- Return type:
- getBatteryTempStatus()[source]¶
Retrieves the battery’s temperature status.
This device does not report on the battery’s temperature. The given status is guessed based on the ChgStatus. If the charger status is ok, the battery temperature is assumed to be ok too. If the charger status is indicating any problem, the temperature rating is assumed to be unknown.
- Returns:
A rating code to indicate the temperature rating of the battery element.
- Return type:
- getChargerTempStatus()[source]¶
Retrieves the charger’s temperature state.
This device does not report it’s temperature.
- Returns:
A rating code to indicate the temperature rating of the charger chip.
- Return type:
- getChgStatus()[source]¶
Retrieves the charging phase or status.
- Returns:
A charger status code to indicate the current charger status.
- Return type:
- getDCStatus()[source]¶
Retrieves the DC supply status.
This device does not indicate it’s status. The given status is guessed based on the ChgStatus.
- Returns:
A status code to indicate the DC supply status.
- Return type:
- getError()[source]¶
Determines the error state for the charger chip, if one.
Because this device only has one error status, ChargerError.bat indicates any kind of error e.g. thermal problems, battery absent or charge timer expired.
- Returns:
A charger error code to further describe reason for the error.
- Return type:
- getInfo()[source]¶
Retrieves an information block from the charging device.
This device does not report any static information.
- getNumCells()[source]¶
Retrieves the number of battery cells configured.
This board only supports one cell.
- Returns:
The number of cells.
- Return type:
int
- getPowerSrc()[source]¶
Retrieves the power source, that presumably drives the system at the moment that this function is executed.
This device does not report it’s power source. The given status is guessed based on the ChgStatus.
- Returns:
A code to indicate the power source.
- Return type:
- isBatteryPresent()[source]¶
Checks, if the battery is present.
Because there is only one error code without any differentiation, if Error.errUnavailable is returned, it could be the case, that there is no battery present. Specifically the following is true: If there is no battery present, this function will return Error.errUnavailable. If the function returns Error.errUnavailable, the reason could also be a high/low temperature, a faulty battery or that the time limit has elapsed. If the chip is not powered, it will always return ErrorCode.errOk, guessing that there is a battery present.
Returns
ErrorCode.errOkif a battery is present,ErrorCode.errUnavailableif the battery could possibly not be present. This can not be exactly determined, because there is only one error state, which could indicate that the battery is not present, but which also could indicate another problem.See also:
getChgStatus().- Returns:
An error code.
- Return type:
- open(paramDict)[source]¶
Opens the instance and sets it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. In this case the two GPIO-Pins for reading the charger status are initialized. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (paramDict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Soft resets the device.
As there is nothing to reset, this routine does not execute an actual reset. It is just here to fulfill the interface.
The device is in some default state, afterwards and must be re-configured according to the application’s needs. :return: An error code indicating either success or the reason of failure. :rtype: ErrorCode
philander.led module¶
Module to provide access to and control over LEDs.
- class LED[source]¶
Bases:
ModuleGeneric LED driver class.
- CURVE_BLINK_CLASSIC = [1, 0]¶
- CURVE_HARTBEAT = [1, 0, 1, 0.7, 0.4, 0.2, 0, 0, 0, 0]¶
- CYCLEN_FAST = 0.4¶
- CYCLEN_NORMAL = 1¶
- CYCLEN_SLOW = 2¶
- LABEL_DEFAULT = 'LED'¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
LED.label
str; A descriptive string label;LABEL_DEFAULT.All LED.gpio.* settings as documented at
GPIO.Params_init().Also see:
Module.Params_init(),GPIO.Params_init().
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.max77960 module¶
Support module for the MAX77960 USB battery charger.
- class MAX77960[source]¶
Bases:
MAX77960_Reg,SerialBusDevice,Charger,Configurable,Interruptable,WatchdogDriver implementation for the MAX77960 USB battery charger.
More information on the functionality of the chip can be found at the Analog site: https://www.analog.com/en/products/max77960.html
- ADDRESSES_ALLOWED = [105]¶
- CFG_B2SOVRC = 'Charger.Current.Batt2Sys'¶
- CFG_CHGCC = 'Charger.Current.FastCharge'¶
- CFG_CHGIN_ILIM = 'Charger.Current.Input'¶
- CFG_CHG_CV_PRM = 'Charger.Voltage.ChargeTermination'¶
- CFG_CHG_RSTRT = 'Charger.Restart'¶
- CFG_COMM_MODE = 'Charger.Comm.Mode'¶
- CFG_DISIBS = 'Charger.DisIBS'¶
- CFG_FCHGTIME = 'Charger.Timer.FastCharge'¶
- CFG_ICHGCC_COOL = 'Charger.Current.Jeita.FastCharge'¶
- CFG_ITRICKLE = 'Charger.Current.Trickle'¶
- CFG_JEITA_EN = 'Charger.Jeita'¶
- CFG_MINVSYS = 'Charger.Voltage.MinVSys'¶
- CFG_MODE = 'Charger.Mode'¶
- CFG_OTG_ILIM = 'Charger.Current.OTG'¶
- CFG_PQEN = 'Charger.Prequal'¶
- CFG_REGTEMP = 'Charger.Temp.Reg'¶
- CFG_STAT_EN = 'Charger.Stat'¶
- CFG_TO_ITH = 'Charger.Current.Topoff'¶
- CFG_TO_TIME = 'Charger.Timer.Topoff'¶
- CFG_VCHGCV_COOL = 'Charger.Voltage.Jeita.Term'¶
- CFG_VCHGIN_REG = 'Charger.Voltage.ChargeIn'¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address; default isADDRESSES_ALLOWED[0].Charger.Comm.Mode
intCommunication mode; default isMAX77960_Reg.COMM_MODE_DEFAULT.Charger.DisIBS
int; default isMAX77960_Reg.DISIBS_DEFAULT.Charger.Mode
int; default isMAX77960_Reg.MODE_DEFAULT.Charger.Prequal
int; default isMAX77960_Reg.PQEN_DEFAULT.Charger.Restart
int; default isMAX77960_Reg.CHG_RSTRT_DEFAULT.Charger.Stat
int; default isMAX77960_Reg.STAT_EN_DEFAULT.Charger.Timer.FastCharge
int; default isMAX77960_Reg.FCHGTIME_DEFAULT.Charger.Current.FastCharge
int; default isMAX77960_Reg.CHGCC_DEFAULT.Charger.Timer.Topoff
int; default isMAX77960_Reg.TO_TIME_DEFAULT.Charger.Current.Topoff
int; default isMAX77960_Reg.TO_ITH_DEFAULT.Charger.Voltage.ChargeTermination
int; default isMAX77960_Reg.CHG_CV_PRM_DEFAULT.Charger.Current.Trickle
int; default isMAX77960_Reg.ITRICKLE_DEFAULT.Charger.Current.Batt2Sys
int; default isMAX77960_Reg.B2SOVRC_DEFAULT.Charger.Jeita
int; default isMAX77960_Reg.JEITA_EN_DEFAULT.Charger.Temp.Reg
int; default isMAX77960_Reg.REGTEMP_DEFAULT.Charger.Voltage.Jeita.Term
int; default isMAX77960_Reg.VCHGCV_COOL_DEFAULT.Charger.Current.Jeita.FastCharge
int; default isMAX77960_Reg.ICHGCC_COOL_DEFAULT.Charger.Current.Input
int; default isMAX77960_Reg.CHGIN_ILIM_DEFAULT.Charger.Current.OTG
int; default isMAX77960_Reg.OTG_ILIM_DEFAULT.Charger.Voltage.MinVSys
int; default isMAX77960_Reg.MINVSYS_DEFAULT.Charger.Voltage.ChargeIn
int; default isMAX77960_Reg.VCHGIN_REG_DEFAULT.All Charger.int.gpio.* settings as documented at
GPIO.Params_init().Also see:
Charger.Params_init(),SerialBusDevice.Params_init(),GPIO.Params_init().
- REVISION_MAJOR_5 = 5¶
- REVISION_MAJOR_6 = 6¶
- REVISION_MAJOR_MAX = 6¶
- REVISION_MAJOR_MAX7796x = 5¶
- REVISION_MAJOR_MAX7796xB = 6¶
- REVISION_MAJOR_MIN = 5¶
- REVISION_MINOR_MAX = 31¶
- REVISION_MINOR_MIN = 0¶
- WATCHDOG_INTERVAL_MS = 80000¶
- clearWatchdog()[source]¶
Clear the watch dog.
This is the implementation of the acknowledge mechanism. Calling this function is necessary for an application to prevent the watch dog from elapsing. Note that this method does not start the watch dog, when it is disabled.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- clearWatchdogElapsed()[source]¶
Clear the elapsed flag.
The application should call this function after it observed that the watch dog interval time expired.
Also see:
isWatchdogElapsed().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- close()[source]¶
Shut down this instance and release associated hardware resources.
If this instance is attached to some bus, it gets detached, before the method returns.
Also see:
module.Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- configure(configData)[source]¶
Configures the device as described by the given configuration data.
Note that the type of the provided data and its interpretation will depend on the actual implementation.
Also see:
Configuration.- Parameters:
configData (.Configuration) – Specific configuration information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disableInterrupt()[source]¶
Disables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disableWatchdog()[source]¶
Disable the watch dog and stop it from running, immediately.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableInterrupt()[source]¶
Enables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableWatchdog()[source]¶
Enable and restart the watch dog.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getBatStatus()[source]¶
Get the battery status to tell about the health and state of the battery.
Returns one of the
battery.Statusvalues to indicate battery voltage level or presence or health state.- Returns:
The battery state.
- Return type:
- getBatteryTempStatus()[source]¶
Retrieves the battery’s temperature status.
- Returns:
A rating code to indicate the temperature rating of the battery element.
- Return type:
- getChargerTempStatus()[source]¶
Retrieves the charger’s temperature state.
- Returns:
A rating code to indicate the temperature rating of the charger chip.
- Return type:
- getChgStatus()[source]¶
Retrieves the charging phase or status.
- Returns:
A charger status code to indicate the current charger status.
- Return type:
- getDCStatus()[source]¶
Retrieves the DC supply status.
- Returns:
A status code to indicate the DC supply status.
- Return type:
- getError()[source]¶
Determines the error state for the charger chip, if one.
- Returns:
A charger error code to further describe reason for the error.
- Return type:
- getEventContext(event, context)[source]¶
Retrieve more detailed information on an event.
The
eventparameter should beinterruptable.Event.evtInt1, as there is only this one interrupt line. On return, thecontextparameter carries the resulting information. It must be an instance ofcharger.EventContext, which is semantically multiplexed by itscharger.EventContext.sourceattribute.Also see:
Interruptable.getEventContext().- Parameters:
event (int) – The original event occurred.
context (.charger.EventContext) – Context information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getInfo()[source]¶
Retrieves an information block from the charging device.
Typically, this kind of information is rather static in that, it does not change over time. Usually, this information is somewhat unique for the charger origin, manufacturing date, hardware/firmware revision, product/model ID, chip series and alike. For that reason, this function can be used to see, if communication works reliably.
- getNumCells()[source]¶
Retrieves the number of battery cells configured.
Returns the number of battery cells or a negative number if this information could not be retrieved.
- Returns:
The number of cells.
- Return type:
int
- getPowerSrc()[source]¶
Retrieves the power source, that presumably drives the system at the moment that this function is executed.
- Returns:
A code to indicate the power source.
- Return type:
- isBatteryPresent()[source]¶
Checks, if the battery is present.
This does not tell anything about whether the battery is charged or not.
Returns
ErrorCode.errOkif a battery is present,ErrorCode.errUnavailableif the battery is not present and any other value to indicate the reason, why this information could not be retrieved.See also:
getChgStatus().- Returns:
An error code.
- Return type:
- isWatchdogElapsed()[source]¶
Check, whether the configured time interval has expired, or not.
By calling this function, an application may observe the expiration without using the interrupt mechanism. Note, that this flag is not cleared automatically. The caller would have to use
clearWatchdogElapsed()for this purpose.Returns
ErrorCode.errOk, if the watch dog has elapsed,ErrorCode.errUnavailable, if it is not elapsed, yet, and any other value to indicate the reason, why this information could not be retrieved.- Returns:
An error code indicating the result.
- Return type:
- isWatchdogRunning()[source]¶
Check, whether the watchdog is currently running or not.
Returns
ErrorCode.errOk, if the watch dog is running,ErrorCode.errUnavailable, if it is not running and any other value to indicate the reason, why this information could not be retrieved.- Returns:
An error code indicating the result.
- Return type:
- open(paramDict)[source]¶
Opens this serial device and puts it into a usable state.
If this device has been attached to some bus, already, this method returns an error code. Otherwise, it tries to do this attachment as follows:
If the
paramDictconfiguration parameters contain theSerialBusDevice.buskey, the associated value object is checked to be an instance ofSerialBus. If successful, this device is attached to that bus. Otherwise, an error code is returned.If no bus instance is passed in, one is created and opened using the same
paramDictdictionary of options. If successful, this device gets attached to that new bus. Upon return, the caller might retrieve a reference to the new bus from the parameter dictionary entry with keySerialBusDevice.bus, or by reading theSerialBusDevice.serialBusattribute.
Also see:
module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- registerInterruptHandler(onEvent=None, callerFeedBack=None, handler=None)[source]¶
Registers a handling routine for interrupt notification.
The caller feedback will be directly passed to the handling routine. In case that multiple different interrupts are handled by the same routine, this parameter may be used to distinguish them and remember the source of interrupt.
The handler should be a method or function that expects at least one argument. That first argument will be the
callerFeedBackobject given as the above-mentioned parameter. Further parameters may follow, as they were handed in to the_fire()method. The handler’s signature should look like this:def handlingRoutine( feedback, *args) -> None:Note that the
onEventparameter is not passed to the handler. It is eaten up by_fire()and just controls the selection of the handling routine called.Depending on the parameter, this method behaves as follows:
onEvent
handler
semantics and action
Event.evtNone
None
All interrupts are disabled and all registrations cleared.
Event.evtNone
valid
De-register the given handler from all events {Event.evtInt1|2|Any}.
Event.evtInt1|2|*
None
De-register all handlers from the given event.
Event.evtInt1|2|*
valid
Enable interrupt and register this handler for the given event.
Event.evtAny
None
Clear the
Event.evtAnyregistrations, only!Event.evtAny
valid
Register the handler for any event {Event.evtInt1|2}.
For this method,
Event.evtNoneis a semantic equivalent toNone.- Parameters:
onEvent (int) – Exactly one of the event mnemonics defined by the
interruptable.Eventenumeration.callerFeedBack (object) – Arbitrary object not evaluated here, but passed on to the handler when an event is fired.
handler – The handling routine to be called as an immediate response to an event.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Soft resets the device.
The device is in some default state, afterwards and must be re-configured according to the application’s needs. :return: An error code indicating either success or the reason of failure. :rtype: ErrorCode
- restartCharging()[source]¶
Tries to restart the charging phase.
This could be necessary, e.g. after recovering from a thermal shutdown.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.max77960_reg module¶
Register definition for the MAX77960 USB battery charger.
Definition of registers, content masks and default values for the above mentioined chip. Externalized, just for clarity of the source code.
- class MAX77960_Reg[source]¶
Bases:
object- AICL_I = 128¶
- AICL_M = 128¶
- AICL_OK = 128¶
- APP_MODE_DTLS = 8¶
- APP_MODE_DTLS_CHRG = 8¶
- APP_MODE_DTLS_CONV = 0¶
- B2SOVRC = 15¶
- B2SOVRC_10000 = 15¶
- B2SOVRC_3000 = 1¶
- B2SOVRC_3500 = 2¶
- B2SOVRC_4000 = 3¶
- B2SOVRC_4500 = 4¶
- B2SOVRC_5000 = 5¶
- B2SOVRC_5500 = 6¶
- B2SOVRC_6000 = 7¶
- B2SOVRC_6500 = 8¶
- B2SOVRC_7000 = 9¶
- B2SOVRC_7500 = 10¶
- B2SOVRC_8000 = 11¶
- B2SOVRC_8500 = 12¶
- B2SOVRC_9000 = 13¶
- B2SOVRC_9500 = 14¶
- B2SOVRC_DEFAULT = 4¶
- B2SOVRC_DISABLED = 0¶
- B2SOVRC_DTC = 64¶
- B2SOVRC_DTC_100_MS = 64¶
- B2SOVRC_DTC_6_MS = 0¶
- B2SOVRC_DTC_DEFAULT = 0¶
- B2SOVRC_DTC_MAX = 64¶
- B2SOVRC_DTC_MIN = 0¶
- B2SOVRC_I = 32¶
- B2SOVRC_M = 32¶
- B2SOVRC_MAX = 15¶
- B2SOVRC_MIN = 1¶
- B2SOVRC_OK = 32¶
- BAT_DTLS = 112¶
- BAT_DTLS_BELOW_PREQ = 16¶
- BAT_DTLS_LOW_VOLT = 64¶
- BAT_DTLS_NO_LEVEL = 112¶
- BAT_DTLS_OK = 48¶
- BAT_DTLS_OVR_CURR = 96¶
- BAT_DTLS_OVR_VOLT = 80¶
- BAT_DTLS_REMOVAL = 0¶
- BAT_DTLS_TIME_OUT = 32¶
- BAT_I = 8¶
- BAT_M = 8¶
- BAT_OK = 8¶
- CHGCC = 63¶
- CHGCC_100 = 0¶
- CHGCC_1000 = 13¶
- CHGCC_1100 = 14¶
- CHGCC_1200 = 15¶
- CHGCC_1300 = 16¶
- CHGCC_1400 = 17¶
- CHGCC_150 = 1¶
- CHGCC_1500 = 18¶
- CHGCC_1600 = 19¶
- CHGCC_1700 = 20¶
- CHGCC_1800 = 21¶
- CHGCC_1900 = 22¶
- CHGCC_200 = 2¶
- CHGCC_2000 = 23¶
- CHGCC_2100 = 24¶
- CHGCC_2200 = 25¶
- CHGCC_2300 = 26¶
- CHGCC_2400 = 27¶
- CHGCC_250 = 3¶
- CHGCC_2500 = 28¶
- CHGCC_2600 = 29¶
- CHGCC_2700 = 30¶
- CHGCC_2800 = 31¶
- CHGCC_2900 = 32¶
- CHGCC_300 = 4¶
- CHGCC_3000 = 33¶
- CHGCC_3100 = 34¶
- CHGCC_3200 = 35¶
- CHGCC_3300 = 36¶
- CHGCC_3400 = 37¶
- CHGCC_350 = 5¶
- CHGCC_3500 = 38¶
- CHGCC_3600 = 39¶
- CHGCC_3700 = 40¶
- CHGCC_3800 = 41¶
- CHGCC_3900 = 42¶
- CHGCC_400 = 6¶
- CHGCC_4000 = 43¶
- CHGCC_4100 = 44¶
- CHGCC_4200 = 45¶
- CHGCC_4300 = 46¶
- CHGCC_4400 = 47¶
- CHGCC_450 = 7¶
- CHGCC_4500 = 48¶
- CHGCC_4600 = 49¶
- CHGCC_4700 = 50¶
- CHGCC_4800 = 51¶
- CHGCC_4900 = 52¶
- CHGCC_500 = 8¶
- CHGCC_5000 = 53¶
- CHGCC_5100 = 54¶
- CHGCC_5200 = 55¶
- CHGCC_5300 = 56¶
- CHGCC_5400 = 57¶
- CHGCC_5500 = 58¶
- CHGCC_5600 = 59¶
- CHGCC_5700 = 60¶
- CHGCC_5800 = 61¶
- CHGCC_5900 = 62¶
- CHGCC_600 = 9¶
- CHGCC_6000 = 63¶
- CHGCC_700 = 10¶
- CHGCC_800 = 11¶
- CHGCC_900 = 12¶
- CHGCC_DEFAULT = 7¶
- CHGCC_MAX = 63¶
- CHGCC_MIN = 0¶
- CHGINLIM_I = 4¶
- CHGINLIM_M = 4¶
- CHGINLIM_OK = 4¶
- CHGIN_DTLS = 96¶
- CHGIN_DTLS_GOOD = 96¶
- CHGIN_DTLS_RSVD = 32¶
- CHGIN_DTLS_TOO_HIGH = 64¶
- CHGIN_DTLS_TOO_LOW = 0¶
- CHGIN_I = 64¶
- CHGIN_ILIM = 127¶
- CHGIN_ILIM_100 = 0¶
- CHGIN_ILIM_1000 = 21¶
- CHGIN_ILIM_100_1 = 1¶
- CHGIN_ILIM_100_2 = 2¶
- CHGIN_ILIM_100_3 = 3¶
- CHGIN_ILIM_1050 = 22¶
- CHGIN_ILIM_1100 = 23¶
- CHGIN_ILIM_1150 = 24¶
- CHGIN_ILIM_1200 = 25¶
- CHGIN_ILIM_1250 = 26¶
- CHGIN_ILIM_1300 = 27¶
- CHGIN_ILIM_1350 = 28¶
- CHGIN_ILIM_1400 = 29¶
- CHGIN_ILIM_1450 = 30¶
- CHGIN_ILIM_150 = 4¶
- CHGIN_ILIM_1500 = 31¶
- CHGIN_ILIM_1550 = 32¶
- CHGIN_ILIM_1600 = 33¶
- CHGIN_ILIM_1650 = 34¶
- CHGIN_ILIM_1700 = 35¶
- CHGIN_ILIM_1750 = 36¶
- CHGIN_ILIM_1800 = 37¶
- CHGIN_ILIM_1850 = 38¶
- CHGIN_ILIM_1900 = 39¶
- CHGIN_ILIM_1950 = 40¶
- CHGIN_ILIM_200 = 5¶
- CHGIN_ILIM_2000 = 41¶
- CHGIN_ILIM_2050 = 42¶
- CHGIN_ILIM_2100 = 43¶
- CHGIN_ILIM_2150 = 44¶
- CHGIN_ILIM_2200 = 45¶
- CHGIN_ILIM_2250 = 46¶
- CHGIN_ILIM_2300 = 47¶
- CHGIN_ILIM_2350 = 48¶
- CHGIN_ILIM_2400 = 49¶
- CHGIN_ILIM_2450 = 50¶
- CHGIN_ILIM_250 = 6¶
- CHGIN_ILIM_2500 = 51¶
- CHGIN_ILIM_2550 = 52¶
- CHGIN_ILIM_2600 = 53¶
- CHGIN_ILIM_2650 = 54¶
- CHGIN_ILIM_2700 = 55¶
- CHGIN_ILIM_2750 = 56¶
- CHGIN_ILIM_2800 = 57¶
- CHGIN_ILIM_2850 = 58¶
- CHGIN_ILIM_2900 = 59¶
- CHGIN_ILIM_2950 = 60¶
- CHGIN_ILIM_300 = 7¶
- CHGIN_ILIM_3000 = 61¶
- CHGIN_ILIM_3050 = 62¶
- CHGIN_ILIM_3100 = 63¶
- CHGIN_ILIM_3150 = 64¶
- CHGIN_ILIM_3200 = 65¶
- CHGIN_ILIM_3250 = 66¶
- CHGIN_ILIM_3300 = 67¶
- CHGIN_ILIM_3350 = 68¶
- CHGIN_ILIM_3400 = 69¶
- CHGIN_ILIM_3450 = 70¶
- CHGIN_ILIM_350 = 8¶
- CHGIN_ILIM_3500 = 71¶
- CHGIN_ILIM_3550 = 72¶
- CHGIN_ILIM_3600 = 73¶
- CHGIN_ILIM_3650 = 74¶
- CHGIN_ILIM_3700 = 75¶
- CHGIN_ILIM_3750 = 76¶
- CHGIN_ILIM_3800 = 77¶
- CHGIN_ILIM_3850 = 78¶
- CHGIN_ILIM_3900 = 79¶
- CHGIN_ILIM_3950 = 80¶
- CHGIN_ILIM_400 = 9¶
- CHGIN_ILIM_4000 = 81¶
- CHGIN_ILIM_4050 = 82¶
- CHGIN_ILIM_4100 = 83¶
- CHGIN_ILIM_4150 = 84¶
- CHGIN_ILIM_4200 = 85¶
- CHGIN_ILIM_4250 = 86¶
- CHGIN_ILIM_4300 = 87¶
- CHGIN_ILIM_4350 = 88¶
- CHGIN_ILIM_4400 = 89¶
- CHGIN_ILIM_4450 = 90¶
- CHGIN_ILIM_450 = 10¶
- CHGIN_ILIM_4500 = 91¶
- CHGIN_ILIM_4550 = 92¶
- CHGIN_ILIM_4600 = 93¶
- CHGIN_ILIM_4650 = 94¶
- CHGIN_ILIM_4700 = 95¶
- CHGIN_ILIM_4750 = 96¶
- CHGIN_ILIM_4800 = 97¶
- CHGIN_ILIM_4850 = 98¶
- CHGIN_ILIM_4900 = 99¶
- CHGIN_ILIM_4950 = 100¶
- CHGIN_ILIM_500 = 11¶
- CHGIN_ILIM_5000 = 101¶
- CHGIN_ILIM_5050 = 102¶
- CHGIN_ILIM_5100 = 103¶
- CHGIN_ILIM_5150 = 104¶
- CHGIN_ILIM_5200 = 105¶
- CHGIN_ILIM_5250 = 106¶
- CHGIN_ILIM_5300 = 107¶
- CHGIN_ILIM_5350 = 108¶
- CHGIN_ILIM_5400 = 109¶
- CHGIN_ILIM_5450 = 110¶
- CHGIN_ILIM_550 = 12¶
- CHGIN_ILIM_5500 = 111¶
- CHGIN_ILIM_5550 = 112¶
- CHGIN_ILIM_5600 = 113¶
- CHGIN_ILIM_5650 = 114¶
- CHGIN_ILIM_5700 = 115¶
- CHGIN_ILIM_5750 = 116¶
- CHGIN_ILIM_5800 = 117¶
- CHGIN_ILIM_5850 = 118¶
- CHGIN_ILIM_5900 = 119¶
- CHGIN_ILIM_5950 = 120¶
- CHGIN_ILIM_600 = 13¶
- CHGIN_ILIM_6000 = 121¶
- CHGIN_ILIM_6050 = 122¶
- CHGIN_ILIM_6100 = 123¶
- CHGIN_ILIM_6150 = 124¶
- CHGIN_ILIM_6200 = 125¶
- CHGIN_ILIM_6250 = 126¶
- CHGIN_ILIM_6300 = 127¶
- CHGIN_ILIM_650 = 14¶
- CHGIN_ILIM_700 = 15¶
- CHGIN_ILIM_750 = 16¶
- CHGIN_ILIM_800 = 17¶
- CHGIN_ILIM_850 = 18¶
- CHGIN_ILIM_900 = 19¶
- CHGIN_ILIM_950 = 20¶
- CHGIN_ILIM_DEFAULT = 11¶
- CHGIN_ILIM_DEFAULT_VALUE = 500¶
- CHGIN_ILIM_MAX = 127¶
- CHGIN_ILIM_MIN = 0¶
- CHGIN_M = 64¶
- CHGIN_OK = 64¶
- CHGPROT = 12¶
- CHGPROT_DEFAULT = 0¶
- CHGPROT_LOCK = 0¶
- CHGPROT_LOCK_4 = 4¶
- CHGPROT_LOCK_8 = 8¶
- CHGPROT_UNLOCK = 12¶
- CHG_CV_PRM = 63¶
- CHG_CV_PRM_2C_8000 = 0¶
- CHG_CV_PRM_2C_8020 = 1¶
- CHG_CV_PRM_2C_8040 = 2¶
- CHG_CV_PRM_2C_8060 = 3¶
- CHG_CV_PRM_2C_8080 = 4¶
- CHG_CV_PRM_2C_8100 = 5¶
- CHG_CV_PRM_2C_8120 = 6¶
- CHG_CV_PRM_2C_8140 = 7¶
- CHG_CV_PRM_2C_8160 = 8¶
- CHG_CV_PRM_2C_8180 = 9¶
- CHG_CV_PRM_2C_8200 = 10¶
- CHG_CV_PRM_2C_8220 = 11¶
- CHG_CV_PRM_2C_8240 = 12¶
- CHG_CV_PRM_2C_8260 = 13¶
- CHG_CV_PRM_2C_8280 = 14¶
- CHG_CV_PRM_2C_8300 = 15¶
- CHG_CV_PRM_2C_8320 = 16¶
- CHG_CV_PRM_2C_8340 = 17¶
- CHG_CV_PRM_2C_8360 = 18¶
- CHG_CV_PRM_2C_8380 = 19¶
- CHG_CV_PRM_2C_8400 = 20¶
- CHG_CV_PRM_2C_8420 = 21¶
- CHG_CV_PRM_2C_8440 = 22¶
- CHG_CV_PRM_2C_8460 = 23¶
- CHG_CV_PRM_2C_8480 = 24¶
- CHG_CV_PRM_2C_8500 = 25¶
- CHG_CV_PRM_2C_8520 = 26¶
- CHG_CV_PRM_2C_8540 = 27¶
- CHG_CV_PRM_2C_8560 = 28¶
- CHG_CV_PRM_2C_8580 = 29¶
- CHG_CV_PRM_2C_8600 = 30¶
- CHG_CV_PRM_2C_8620 = 31¶
- CHG_CV_PRM_2C_8640 = 32¶
- CHG_CV_PRM_2C_8660 = 33¶
- CHG_CV_PRM_2C_8680 = 34¶
- CHG_CV_PRM_2C_8700 = 35¶
- CHG_CV_PRM_2C_8720 = 36¶
- CHG_CV_PRM_2C_8740 = 37¶
- CHG_CV_PRM_2C_8760 = 38¶
- CHG_CV_PRM_2C_8780 = 39¶
- CHG_CV_PRM_2C_8800 = 40¶
- CHG_CV_PRM_2C_8820 = 41¶
- CHG_CV_PRM_2C_8840 = 42¶
- CHG_CV_PRM_2C_8860 = 43¶
- CHG_CV_PRM_2C_8880 = 44¶
- CHG_CV_PRM_2C_8900 = 45¶
- CHG_CV_PRM_2C_8920 = 46¶
- CHG_CV_PRM_2C_8940 = 47¶
- CHG_CV_PRM_2C_8960 = 48¶
- CHG_CV_PRM_2C_8980 = 49¶
- CHG_CV_PRM_2C_9000 = 50¶
- CHG_CV_PRM_2C_9020 = 51¶
- CHG_CV_PRM_2C_9040 = 52¶
- CHG_CV_PRM_2C_9060 = 53¶
- CHG_CV_PRM_2C_9080 = 54¶
- CHG_CV_PRM_2C_9100 = 55¶
- CHG_CV_PRM_2C_9120 = 56¶
- CHG_CV_PRM_2C_9140 = 57¶
- CHG_CV_PRM_2C_9160 = 58¶
- CHG_CV_PRM_2C_9180 = 59¶
- CHG_CV_PRM_2C_9200 = 60¶
- CHG_CV_PRM_2C_9220 = 61¶
- CHG_CV_PRM_2C_9240 = 62¶
- CHG_CV_PRM_2C_9260 = 63¶
- CHG_CV_PRM_2C_DEFAULT = 0¶
- CHG_CV_PRM_2C_MAX = 63¶
- CHG_CV_PRM_2C_MIN = 0¶
- CHG_CV_PRM_3C_12000 = 0¶
- CHG_CV_PRM_3C_12030 = 1¶
- CHG_CV_PRM_3C_12060 = 2¶
- CHG_CV_PRM_3C_12090 = 3¶
- CHG_CV_PRM_3C_12120 = 4¶
- CHG_CV_PRM_3C_12150 = 5¶
- CHG_CV_PRM_3C_12180 = 6¶
- CHG_CV_PRM_3C_12210 = 7¶
- CHG_CV_PRM_3C_12240 = 8¶
- CHG_CV_PRM_3C_12270 = 9¶
- CHG_CV_PRM_3C_12300 = 10¶
- CHG_CV_PRM_3C_12330 = 11¶
- CHG_CV_PRM_3C_12360 = 12¶
- CHG_CV_PRM_3C_12390 = 13¶
- CHG_CV_PRM_3C_12420 = 14¶
- CHG_CV_PRM_3C_12450 = 15¶
- CHG_CV_PRM_3C_12480 = 16¶
- CHG_CV_PRM_3C_12510 = 17¶
- CHG_CV_PRM_3C_12540 = 18¶
- CHG_CV_PRM_3C_12570 = 19¶
- CHG_CV_PRM_3C_12600 = 20¶
- CHG_CV_PRM_3C_12630 = 21¶
- CHG_CV_PRM_3C_12660 = 22¶
- CHG_CV_PRM_3C_12690 = 23¶
- CHG_CV_PRM_3C_12720 = 24¶
- CHG_CV_PRM_3C_12750 = 25¶
- CHG_CV_PRM_3C_12780 = 26¶
- CHG_CV_PRM_3C_12810 = 27¶
- CHG_CV_PRM_3C_12840 = 28¶
- CHG_CV_PRM_3C_12870 = 29¶
- CHG_CV_PRM_3C_12900 = 30¶
- CHG_CV_PRM_3C_12930 = 31¶
- CHG_CV_PRM_3C_12960 = 32¶
- CHG_CV_PRM_3C_12990 = 33¶
- CHG_CV_PRM_3C_13020 = 34¶
- CHG_CV_PRM_3C_13050 = 35¶
- CHG_CV_PRM_3C_DEFAULT = 0¶
- CHG_CV_PRM_3C_MAX = 35¶
- CHG_CV_PRM_3C_MIN = 0¶
- CHG_CV_PRM_DEFAULT = 0¶
- CHG_DTLS = 15¶
- CHG_DTLS_DONE = 4¶
- CHG_DTLS_E_TIMER = 6¶
- CHG_DTLS_FAST_CURR = 1¶
- CHG_DTLS_FAST_VOLT = 2¶
- CHG_DTLS_OFF_CHGIN = 8¶
- CHG_DTLS_OFF_RESIST = 5¶
- CHG_DTLS_OFF_TEMP = 10¶
- CHG_DTLS_OFF_WDOG = 11¶
- CHG_DTLS_PRECHRG = 0¶
- CHG_DTLS_SUSP_JEITA = 12¶
- CHG_DTLS_SUSP_NOBAT = 13¶
- CHG_DTLS_SUSP_QBAT = 7¶
- CHG_DTLS_TOP_OFF = 3¶
- CHG_I = 16¶
- CHG_INT_MASK_ALL = 255¶
- CHG_INT_MASK_DEFAULT = 255¶
- CHG_INT_MASK_NONE = 0¶
- CHG_M = 16¶
- CHG_OK = 16¶
- CHG_RSTRT = 48¶
- CHG_RSTRT_100 = 0¶
- CHG_RSTRT_150 = 16¶
- CHG_RSTRT_200 = 32¶
- CHG_RSTRT_DEFAULT = 16¶
- CHG_RSTRT_DISABLED = 48¶
- CHG_RSTRT_MAX = 32¶
- CHG_RSTRT_MIN = 0¶
- CID_MAX7796x = 160¶
- CID_MAX7796xB = 192¶
- CID_REVISION = 224¶
- CID_REV_5 = 160¶
- CID_REV_6 = 192¶
- CID_REV_MAX = 192¶
- CID_REV_MIN = 160¶
- CID_VERSION = 31¶
- COMM_MODE = 128¶
- COMM_MODE_AUTO = 0¶
- COMM_MODE_DEFAULT = 0¶
- COMM_MODE_I2C = 128¶
- DISIBS = 64¶
- DISIBS_DEFAULT = 0¶
- DISIBS_FET_OFF = 64¶
- DISIBS_FET_PPSM = 0¶
- DISKIP = 1¶
- DISKIP_AUTO = 0¶
- DISKIP_DEFAULT = 0¶
- DISKIP_DISABLED = 1¶
- DISQBAT_I = 2¶
- DISQBAT_M = 2¶
- DISQBAT_OK = 2¶
- FCHGTIME = 7¶
- FCHGTIME_10H = 7¶
- FCHGTIME_3H = 1¶
- FCHGTIME_4H = 2¶
- FCHGTIME_5H = 3¶
- FCHGTIME_6H = 4¶
- FCHGTIME_7H = 5¶
- FCHGTIME_8H = 6¶
- FCHGTIME_DEFAULT = 1¶
- FCHGTIME_DISABLED = 0¶
- FCHGTIME_MAX = 7¶
- FCHGTIME_MIN = 1¶
- FSHIP_MODE = 1¶
- FSHIP_MODE_DEFAULT = 0¶
- FSHIP_MODE_OFF = 0¶
- FSHIP_MODE_ON = 1¶
- FSW_DTLS = 6¶
- FSW_DTLS_1200K = 2¶
- FSW_DTLS_600K = 0¶
- ICHGCC_COOL = 2¶
- ICHGCC_COOL_DEFAULT = 2¶
- ICHGCC_COOL_NORMAL = 0¶
- ICHGCC_COOL_REDUCED = 2¶
- INLIM_CLK = 192¶
- INLIM_CLK_1024 = 128¶
- INLIM_CLK_256 = 64¶
- INLIM_CLK_4096 = 192¶
- INLIM_CLK_8 = 0¶
- INLIM_CLK_DEFAULT = 128¶
- INLIM_CLK_MAX = 192¶
- INLIM_CLK_MIN = 0¶
- ITRICKLE = 48¶
- ITRICKLE_100 = 0¶
- ITRICKLE_200 = 16¶
- ITRICKLE_300 = 32¶
- ITRICKLE_400 = 48¶
- ITRICKLE_DEFAULT = 0¶
- ITRICKLE_MAX = 48¶
- ITRICKLE_MIN = 0¶
- JEITA_EN = 128¶
- JEITA_EN_DEFAULT = 0¶
- JEITA_EN_OFF = 0¶
- JEITA_EN_ON = 128¶
- LPM = 64¶
- LPM_DEFAULT = 0¶
- LPM_NORMAL = 0¶
- LPM_ON = 64¶
- MINVSYS = 7¶
- MINVSYS_2C_5535 = 0¶
- MINVSYS_2C_5740 = 1¶
- MINVSYS_2C_5945 = 2¶
- MINVSYS_2C_6150 = 3¶
- MINVSYS_2C_6355 = 4¶
- MINVSYS_2C_6560 = 5¶
- MINVSYS_2C_6765 = 6¶
- MINVSYS_2C_6970 = 7¶
- MINVSYS_2C_DEFAULT = 3¶
- MINVSYS_2C_MAX = 7¶
- MINVSYS_2C_MIN = 0¶
- MINVSYS_3C_10148 = 6¶
- MINVSYS_3C_10455 = 7¶
- MINVSYS_3C_8303 = 0¶
- MINVSYS_3C_8610 = 1¶
- MINVSYS_3C_8918 = 2¶
- MINVSYS_3C_9225 = 3¶
- MINVSYS_3C_9533 = 4¶
- MINVSYS_3C_9840 = 5¶
- MINVSYS_3C_DEFAULT = 3¶
- MINVSYS_3C_MAX = 7¶
- MINVSYS_3C_MIN = 0¶
- MINVSYS_DEFAULT = 3¶
- MODE = 15¶
- MODE_ALL_OFF = 0¶
- MODE_ALL_OFF_1 = 1¶
- MODE_ALL_OFF_2 = 2¶
- MODE_ALL_OFF_3 = 3¶
- MODE_CHRG_DCDC = 5¶
- MODE_CHRG_DCDC_6 = 6¶
- MODE_CHRG_DCDC_7 = 7¶
- MODE_DCDC_ONLY = 4¶
- MODE_DEFAULT = 5¶
- MODE_OTG_ONLY = 10¶
- NUM_CELL_DTLS = 1¶
- NUM_CELL_DTLS_2 = 0¶
- NUM_CELL_DTLS_3 = 1¶
- OTG_DTLS = 24¶
- OTG_DTLS_ILIM = 24¶
- OTG_DTLS_OTG_GOOD = 8¶
- OTG_DTLS_OVERVOLT = 16¶
- OTG_DTLS_UNDERVOLT = 0¶
- OTG_ILIM = 56¶
- OTG_ILIM_1200 = 16¶
- OTG_ILIM_1500 = 24¶
- OTG_ILIM_2000 = 32¶
- OTG_ILIM_2250 = 40¶
- OTG_ILIM_2500 = 48¶
- OTG_ILIM_3000 = 56¶
- OTG_ILIM_500 = 0¶
- OTG_ILIM_900 = 8¶
- OTG_ILIM_DEFAULT = 24¶
- OTG_ILIM_MAX = 56¶
- OTG_ILIM_MIN = 0¶
- OTG_PLIM_I = 1¶
- OTG_PLIM_M = 1¶
- OTG_PLIM_OK = 1¶
- PQEN = 128¶
- PQEN_DEFAULT = 128¶
- PQEN_OFF = 0¶
- PQEN_ON = 128¶
- QB_DTLS = 1¶
- QB_DTLS_OFF = 0¶
- QB_DTLS_ON = 1¶
- REGTEMP = 120¶
- REGTEMP_100 = 24¶
- REGTEMP_105 = 32¶
- REGTEMP_110 = 40¶
- REGTEMP_115 = 48¶
- REGTEMP_120 = 56¶
- REGTEMP_125 = 64¶
- REGTEMP_130 = 72¶
- REGTEMP_85 = 0¶
- REGTEMP_90 = 8¶
- REGTEMP_95 = 16¶
- REGTEMP_DEFAULT = 48¶
- REGTEMP_MAX = 72¶
- REGTEMP_MIN = 0¶
- REG_CHG_CNFG_00 = 22¶
- REG_CHG_CNFG_01 = 23¶
- REG_CHG_CNFG_02 = 24¶
- REG_CHG_CNFG_03 = 25¶
- REG_CHG_CNFG_04 = 26¶
- REG_CHG_CNFG_05 = 27¶
- REG_CHG_CNFG_06 = 28¶
- REG_CHG_CNFG_07 = 29¶
- REG_CHG_CNFG_08 = 30¶
- REG_CHG_CNFG_09 = 31¶
- REG_CHG_CNFG_10 = 32¶
- REG_CHG_DETAILS_00 = 19¶
- REG_CHG_DETAILS_01 = 20¶
- REG_CHG_DETAILS_02 = 21¶
- REG_CHG_INT = 16¶
- REG_CHG_INT_MASK = 17¶
- REG_CHG_INT_OK = 18¶
- REG_CID = 0¶
- REG_SWRST = 1¶
- REG_TOP_INT = 2¶
- REG_TOP_INT_MASK = 3¶
- REG_TOP_INT_OK = 4¶
- STAT_EN = 8¶
- STAT_EN_DEFAULT = 8¶
- STAT_EN_OFF = 0¶
- STAT_EN_ON = 8¶
- STBY_EN = 32¶
- STBY_EN_DCDC_DEFAULT = 0¶
- STBY_EN_DCDC_OFF = 32¶
- STBY_EN_DCDC_PPSM = 0¶
- SWRST_DEFAULT = 0¶
- SWRST_NONE = 0¶
- SWRST_TYPE_O = 165¶
- SYSOVLO_I = 2¶
- SYSOVLO_M = 2¶
- SYSOVLO_OK = 2¶
- SYSUVLO_I = 1¶
- SYSUVLO_M = 1¶
- SYSUVLO_OK = 1¶
- SYS_TRACK_DEFAULT = 128¶
- SYS_TRACK_DIS = 128¶
- SYS_TRACK_DISABLED = 128¶
- SYS_TRACK_ENABLED = 0¶
- THM_DTLS = 112¶
- THM_DTLS_BAT_RMVD = 80¶
- THM_DTLS_COLD = 0¶
- THM_DTLS_COOL = 16¶
- THM_DTLS_DISABLED = 96¶
- THM_DTLS_HOT = 64¶
- THM_DTLS_NORMAL = 32¶
- THM_DTLS_WARM = 48¶
- TOP_INT_MASK_ALL = 7¶
- TOP_INT_MASK_DEFAULT = 255¶
- TOP_INT_MASK_NONE = 0¶
- TO_ITH = 7¶
- TO_ITH_100 = 0¶
- TO_ITH_200 = 1¶
- TO_ITH_300 = 2¶
- TO_ITH_400 = 3¶
- TO_ITH_500 = 4¶
- TO_ITH_600 = 5¶
- TO_ITH_600_6 = 6¶
- TO_ITH_600_7 = 7¶
- TO_ITH_DEFAULT = 0¶
- TO_ITH_MAX = 5¶
- TO_ITH_MIN = 0¶
- TO_TIME = 56¶
- TO_TIME_10_MIN = 8¶
- TO_TIME_20_MIN = 16¶
- TO_TIME_30_MIN = 24¶
- TO_TIME_30_SEC = 0¶
- TO_TIME_40_MIN = 32¶
- TO_TIME_50_MIN = 40¶
- TO_TIME_60_MIN = 48¶
- TO_TIME_70_MIN = 56¶
- TO_TIME_DEFAULT = 24¶
- TO_TIME_MAX = 56¶
- TO_TIME_MIN = 0¶
- TREG = 128¶
- TREG_GOOD = 0¶
- TREG_HIGH = 128¶
- TSHDN_I = 4¶
- TSHDN_M = 4¶
- TSHDN_OK = 4¶
- VCHGCV_COOL = 4¶
- VCHGCV_COOL_DEFAULT = 0¶
- VCHGCV_COOL_NORMAL = 0¶
- VCHGCV_COOL_REDUCED = 4¶
- VCHGIN_REG = 62¶
- VCHGIN_REG_10150 = 30¶
- VCHGIN_REG_10675 = 32¶
- VCHGIN_REG_10950 = 34¶
- VCHGIN_REG_11550 = 36¶
- VCHGIN_REG_12150 = 38¶
- VCHGIN_REG_12750 = 40¶
- VCHGIN_REG_13350 = 42¶
- VCHGIN_REG_13950 = 44¶
- VCHGIN_REG_14550 = 46¶
- VCHGIN_REG_15150 = 48¶
- VCHGIN_REG_15750 = 50¶
- VCHGIN_REG_16350 = 52¶
- VCHGIN_REG_16950 = 54¶
- VCHGIN_REG_17550 = 56¶
- VCHGIN_REG_18150 = 58¶
- VCHGIN_REG_18750 = 60¶
- VCHGIN_REG_19050 = 62¶
- VCHGIN_REG_4025 = 0¶
- VCHGIN_REG_4200 = 2¶
- VCHGIN_REG_4375 = 4¶
- VCHGIN_REG_4550 = 6¶
- VCHGIN_REG_4725 = 8¶
- VCHGIN_REG_4900 = 10¶
- VCHGIN_REG_5425 = 12¶
- VCHGIN_REG_5950 = 14¶
- VCHGIN_REG_6475 = 16¶
- VCHGIN_REG_7000 = 18¶
- VCHGIN_REG_7525 = 20¶
- VCHGIN_REG_8050 = 22¶
- VCHGIN_REG_8575 = 24¶
- VCHGIN_REG_9100 = 26¶
- VCHGIN_REG_9625 = 28¶
- VCHGIN_REG_DEFAULT = 8¶
- VCHGIN_REG_MAX = 62¶
- VCHGIN_REG_MIN = 0¶
- WDTCLR = 3¶
- WDTCLR_DEFAULT = 0¶
- WDTCLR_DO_CLEAR = 1¶
- WDTCLR_DO_NOT_TOUCH = 0¶
- WDTCLR_DO_NOT_TOUCH_2 = 2¶
- WDTCLR_DO_NOT_TOUCH_3 = 3¶
- WDTEN = 16¶
- WDTEN_DEFAULT = 0¶
- WDTEN_OFF = 0¶
- WDTEN_ON = 16¶
- registerMap = [[0, 'CID', ([224, 'REV'], [31, 'VER'], [255, 'ID'])], [1, 'SWRST', ()], [2, 'TOP_INT', ([4, 'TSHDN_I'], [2, 'SYSOVLO_I'], [1, 'SYSUVLO_I'])], [3, 'TOP_INT_MASK', ([4, 'TSHDN_M'], [2, 'SYSOVLO_M'], [1, 'SYSUVLO_M'])], [4, 'TOP_INT_OK', ([4, 'TSHDN_OK'], [2, 'SYSOVLO_OK'], [1, 'SYSUVLO_OK'])], [16, 'CHG_INT', ([128, 'AICL_I'], [64, 'CHGIN_I'], [32, 'B2SOVRC_I'], [16, '_CHG_I'], [8, 'BAT_I'], [4, 'CHGINLIM_I'], [2, 'DISQBAT_I'], [1, 'OTG_PLIM_I'])], [17, 'CHG_INT_MASK', ([128, 'AICL_M'], [64, 'CHGIN_M'], [32, 'B2SOVRC_M'], [16, 'CHG_M'], [8, 'BAT_M'], [4, 'CHGINLIM_M'], [2, 'DISQBAT_M'], [1, 'OTG_PLIM_M'])], [18, 'CHG_INT_OK', ([128, 'AICL_OK'], [64, 'CHGIN_OK'], [32, 'B2SOVRC_OK'], [16, 'CHG_OK'], [8, 'BAT_OK'], [4, 'CHGINLIM_OK'], [2, 'DISQBAT_OK'], [1, 'OTG_PLIM_OK'])], [19, 'CHG_DETAILS_00', ([96, 'CHGIN_DTLS'], [24, 'OTG_DTLS'], [1, 'QB_DTLS'])], [20, 'CHG_DETAILS_01', ([128, 'TREG'], [112, 'BAT_DTLS'], [15, 'CHG_DTLS'])], [21, 'CHG_DETAILS_02', ([112, 'THM_DTLS'], [8, 'APP_MODE_DTLS'], [6, 'FSW_DTLS'], [1, 'NUM_CELL_DTLS'])], [22, 'CHG_CNFG_00', ([128, 'COMM_MODE'], [64, 'DISIBS'], [32, 'STBY_EN'], [16, 'WDTEN'], [15, 'MODE'])], [23, 'CHG_CNFG_01', ([128, 'PQEN'], [64, 'LPM'], [48, 'CHG_RSTRT'], [8, 'STAT_EN'], [7, 'FCHGTIME'])], [24, 'CHG_CNFG_02', ([63, 'CHGCC'],)], [25, 'CHG_CNFG_03', ([128, 'SYS_TRACK_DIS'], [64, 'B2SOVRC_DTC'], [56, 'TO_TIME'], [7, 'TO_ITH'])], [26, 'CHG_CNFG_04', ([63, 'CHG_CV_PRM'],)], [27, 'CHG_CNFG_05', ([48, 'ITRICKLE'], [15, 'B2SOVRC'])], [28, 'CHG_CNFG_06', ([12, 'CHGPROT'], [3, 'WDTCLR'])], [29, 'CHG_CNFG_07', ([128, 'JEITA_EN'], [120, 'REGTEMP'], [4, 'VCHGCV_COOL'], [2, 'ICHGCC_COOL'], [1, 'FSHIP_MODE'])], [30, 'CHG_CNFG_08', ([127, 'CHGIN_ILIM'],)], [31, 'CHG_CNFG_09', ([192, 'INLIM_CLK'], [56, 'OTG_ILIM'], [7, 'MINVSYS'])], [32, 'CHG_CNFG_10', ([62, 'VCHGIN_REG'], [1, 'DISKIP'])]]¶
philander.mcp40 module¶
Driver implementation for the MCP40 17/18/19 digital potentiometers.
More information on the functionality of the chip can be found at the microchip’s site for the 18 series chip with download for data sheet of all three chips: https://www.microchip.com/en-us/product/MCP4018
- class MCP40[source]¶
Bases:
SerialBusDevice,PotentiometerMCP40 family and MCP40D family driver implementation. This implementation was tested using a MCP40D18T-104E/LT. It should also work for any other specified chip.
The MCP40 and MCP40D family’s chips are digital potentiometers that are controlled via an I2C interface. Their difference lies in their terminal configurations. The all come in different resistances of 5kOhm, 10kOhm, 50kOhm and 100kOhm. Read more under https://www.microship.com/en-us/product/MCP4017
- ADDRESSES_ALLOWED = [46, 62, 47]¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address; default isADDRESSES_ALLOWED[0].Potentiometer.resistance.max
intMaximum resistance in Ohm;DEFAULT_RESISTANCE_MAX.Also see:
SerialBusDevice.Params_init(),Potentiometer.Params_init().
- close()[source]¶
Close this instance and release hardware resources.
Also see:
Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getDigital()[source]¶
Get resistance of potentiometer as a digital value in [0…digital.max]
Also see:
Potentiometer.get().
- open(paramDict)[source]¶
Initialize an instance and prepare it for use.
Also see:
Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as possibly obtained from
Params_init().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setDigital(digital)[source]¶
Set resistance of potentiometer to a digital value.
Also see:
Potentiometer.setDigital().- Parameters:
digital (int) – Digital resistance value to be sent directly to the potentiometer without conversion.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.module module¶
Module to provide the Module base class.
- class Module[source]¶
Bases:
objectGeneric interface to describe the capabilities of a module.
This is an abstract base class to define methods for ramp-up, shut-down or switch into certain run level, that are common to each class on module-level.
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
The given dictionary should not be None, on entry. Options not present in the dictionary will be added and set to their defaults on return.
- Parameters:
paramDict (dict(str, object)) – Dictionary mapping option names to their respective values.
- Returns:
none
- Return type:
None
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.mux module¶
Module to control multiplexer chips.
Usually, multiplexer / de-multiplexer connect one common line X to one of four or one of eight other lines Y0, Y1, …. As this connection can be used both ways, those Y-lines are often called input / output or I/O channels.
The selection is made by two (1:4) or three (1:8) control lines A, B, …, which can be interpreted as a bit pattern. Moreover, there may be an enable or disable line to have no connection at all. A general pin/logic scheme of a 3:8 de-/multiplexer could look like this:
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
| | | | | | | |
+-----------------------+
A --| |
B --| * |-- ENA
C --| |
+-----------------------+
|
X
Typical implementations of such devices are the TI SN74HCS237, ST M74HC4851, and ST HCF4051.
Variants of this chip family work as de-multiplexer or decoder, only: Lacking a common line, the I/O lines are operated in output only. This can be used to drive exactly one out of four or eight lines high or low. An example of this sort of device is the TI SN74LVC138,
Note that the core intention of this module is to control the A, B, C selector bits and the ENA enabling/disabling/inhibiting line, if present. However, manipulating the common X and I/O Y lines is beyond the scope of this driver.
- class Mux[source]¶
Bases:
ModuleGeneric driver class for a de-/multiplexer device.
- MAXNUM_BITS = 4¶
- MODULE_PARAM_PREFIX = 'mux.'¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
Note that general or global GPIO adjustments or defaults can be set using the mux.gpio.* keys. They apply to both, the bit control lines as well as the enable line. They can be pin-wise overridden by specific e.g. mux.bit0.gpio.* settings.
The following settings are supported:
Key name
Value type, meaning and default
mux.gpio.pinNumbering
Global setting: numbering scheme
mux.gpio.inverted
Global setting: True if low-active
mux.gpio.level
Global setting: initial logic level
mux.bit[0…3].gpio.pinNumbering
Bit pin: Numbering scheme
mux.bit[0…3].gpio.pinDesignator
Bit pin: Name or number of the pin
mux.bit[0…3].gpio.inverted
Bit pin: True, if pin is low-active
mux.bit[0…3].gpio.level
Bit pin: Initial logic level
mux.enable.gpio.pinNumbering
ENA pin: Numbering scheme
mux.enable.gpio.pinDesignator
ENA pin: Name or number of the pin
mux.enable.gpio.inverted
ENA pin: True, if pin is low-active
mux.enable.gpio.level ENA pin: Initial logic level
The number of mux.bit0.pinDesignator, mux.bit1.pinDesignator etc. settings implicitly defines the size of the multiplexer, i.e. the number of control bits. For safety reasons, a 4 bit multiplexer (1:16) is supported, at maximum.
If the mux.enable.pinDesignator is not given, the driver assumes, there is no enable/disable line.
Also see:
Module.Params_init(),GPIO.Params_init().
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disable()[source]¶
Disable the multiplexer, if supported by the underlying chip.
Also see:
enable().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enable(activate=True)[source]¶
Set the ENA line to activate the device as given.
If supported by the driven chip, enables or disables the devices, as given by the activate parameter. Note that the actual effect on the physical line may be inverted by using the GPIO’s inverted option. This may be necessary to semantically match the chip’s ENA line meaning and behavior.
- Parameters:
activate (bool) – Whether to activate (default) or deactivate the multiplexer.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- select(number, automute=False)[source]¶
Switch to the channel with the given, zero-based number.
Depending on the size of the multiplexer, the least-significant bits of the given number are used to set the control lines A, B, C etc. That directly determines, which of the I/O channels Y0, Y1, etc. is connected to the common line X.
If the automute flag is set, the device is first disabled. Then, the channel is selected and finally, the device is enabled, again. Note that this will always leave the device in an enabled state!
- Parameters:
number (int) – Zero-based index number of the channel to select.
automute (bool) – Flag, if the device should be disabled for switching.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.penum module¶
A light-weight replication of the Python 3.4 built-in Enum and Flag classes.
For portability, this is to support the MicroPython environments. While functionality is drastically reduced, this implementation strives for providing the most basic features of enums, flags and dataclasses.
- class Enum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
objectCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- class Flag(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumSupport for flags
- class auto(value=_auto_null)[source]¶
Bases:
objectInstances are replaced with an appropriate value in Enum class suites.
- dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)[source]¶
Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.
philander.potentiometer module¶
A module to provide a base class for potentiometer driver implementations.
philander.primitives module¶
A module to reflect fundamental physical units and scales.
- class Percentage[source]¶
Bases:
int- static checkRange(value)[source]¶
Check if the given value is a plausible percentage.
If the given value is within the range of [0…100], this method returns
ErrorCode.errOk. Otherwise, it givesErrorCode.errInvalidParameter.- Parameters:
value (int) – Something that compares to integer numbers, interpreted as a percentage.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- invalid = 255¶
philander.pwm module¶
Abstraction module for the pulse-width-modulation feature.
Provide a convergence layer API to abstract from several different PWM implementing driver modules provided on the target system.
- class PWM[source]¶
Bases:
ModulePulse-width-modulation abstraction class.
Provide access to and control over the underlying PWM hardware. For that, an implementing driver module is used. As a convergence layer, this class is to hide specifics and to level syntactic requirements of the implementing package.
- DEFAULT_DUTY = 50¶
- DEFAULT_FREQUENCY = 100000¶
- OFF = 0¶
- ON = 1¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
The given dictionary should not be None, on entry. Options not present in the dictionary will be added and set to their defaults on return. The following options are supported.
Key
Range
Default
pwm.pinNumbering
GPIO.PINNUMBERING_[BCM | BOARD]
GPIO.PINNUMBERING_BCM
pwm.pinDesignator
pin name or number (e.g. 2 or “2”)
None
pwm.chip
alt. to pin designator: PWM chip id as int.
Impl. specific; maybe None
pwm.channel
alt. to pin designator: PWM channel number
Impl. specific; maybe None
pwm.frequency
pulse frequency in Hz; integer
pwm.duty
duty cycle in percent [%]; integer
- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
none
- Return type:
None
- close()[source]¶
Closes this instance and releases associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- static getPWM(provider=SysProvider.AUTO)[source]¶
Generates a PWM implementation according to the requested provider.
- Parameters:
provider (SysProvider) – The low-level lib to rely on, or AUTO for automatic detection.
- Returns:
A PWM implementation object, or None in case of an error.
- Return type:
- getState()[source]¶
Retrieve the state of this PWM instance.
Gives
PWM.ONif this instance is up and running (started) orPWM.OFFotherwise.- Returns:
A status value [PWM.ON | PWM.OFF] and an error code indicating either success or the reason of failure.
- Return type:
int, ErrorCode
- open(paramDict)[source]¶
Opens the instance and sets it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setDuty(duty)[source]¶
Set the new duty cycle percentage without altering the on/off state.
Just update the duty value. If the PWM is off, it stays off and just stores the new duty cycle. When starting the PWM again, the signal will show this new duty cycle. If the PWM is running while calling this method, the new duty value will immediately affect the output signal.
A duty cycle of 0 or 100 will effectively switch the PWM off. Still, the caller should prefer using
start()orstop()for this purpose, instead.- Parameters:
duty (int) – A value [0…100] giving the new duty cycle as a percentage [%].
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setFrequency(frequency)[source]¶
Set the new base frequency. Does not alter the on/off state.
Just update the frequency value. If the PWM is off, it stays off and just stores the new frequency. When starting the PWM at a later point, the signal will have this new base frequency. If the PWM is running (on) while calling this method, the new frequency will immediately affect the output signal.
It’s at the discretion of the implementation whether or not special values (e.g. 0) will cause side effects, like switching the PWM off or on. The caller should not rely on this kind of side effects, but use
start()orstop(), instead.- Parameters:
frequency (int) – Positive int value giving the new frequency in Hertz [Hz].
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- setRunLevel(level)[source]¶
Select the power-saving operation mode.
Switches the instance to one of the power-saving modes or recovers from these modes. Situation-aware deployment of these modes can greatly reduce the system’s total power consumption.
- start(duty=None)[source]¶
Switch output of the PWM signal on.
If the status is currently OFF, the output starts immediately and the status turns to ON. If no parameter is given, the configured duty value is used. Alternatively, the new duty percentage can be specified as a parameter. If the PWM is already running (ON), the output signal is just updated. If a new duty value is given, it will apply to the relative pulse width. Otherwise, the output signal will not change.
Note that setting the duty value to zero or 100 will effectively turn the PWM off.
- Parameters:
duty (int) – The new relative pulse width as a percentage in [0, 100].
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.pwm_micropython module¶
philander.pwm_periphery module¶
Implementation of the PWM API for the Periphery lib.
An application should never use this module directly. Instead, the system factory will provide suitable instances.
philander.pwm_rpi module¶
philander.sensor module¶
Abstract sensor interface.
Provide an API to abstract from any type of sensors. Only a very basic set of common types and functions is provided.
- class Calibration(scheme: CalibrationType = CalibrationType.default, data: CalibrationData = None)[source]¶
Bases:
objectContainer to wrap calibration scheme and data at the top level.
This structure is to be passed in calls to
Sensor.calibrate(). The interpretation of the data particles depends on the scheme of the calibration as follows.CalibrationType
CalibrationData particle
default
none
zero
none
one
none
hundred
none
trueValue
trueValue
expose1
trueValue
expose2
trueValue
expose3
trueValue
offset
offset, iOffset
shiftOffset
offset, iOffset
linear
linear, iLinear
linearRel
linear, iLinear
param
param
paramRel
param
trueMeasurement
trueMeasurement
trueMeasurement2
trueMeasurement2
knownMeasurement
knownMeasurement
knownMeasurement1
knownMeasurement
knonwMeasurement2
knownMeasurement
knonwMeasurement3
knownMeasurement
temperature
temp
- data: CalibrationData = None¶
- scheme: CalibrationType = 1¶
- class CalibrationData(trueValue: object = None, offset: object = None, iOffset: int = 0, linear: _CalibrationData_linear = None, iLinear: _CalibrationData_iLinear = None, param: object = None, trueMeasurement: _CalibrationData_trueMeasurement = None, trueMeasurement2: _CalibrationData_trueMeasurement = None, knownMeasurement: object = None, temp: _CalibrationData_iLinear = None)[source]¶
Bases:
objectContainer type to encapsulate a calibrations pure data structure.
- iLinear: _CalibrationData_iLinear = None¶
Either new linear calibration parameters to replace the current ones, or corrective numbers to adjust the calibration parameters in effect, both given in abstract integer units. To be used with
CalibrationType.linearandCalibrationType.linearRel.
- iOffset: int = 0¶
Either a new absolute offset, or the shift to correct the current offset, given in analogue, digitised or abstract integer units. To be used with
CalibrationType.offsetandCalibrationType.shiftOffset.
- knownMeasurement: object = None¶
Up to 3 pairs of raw measure and true value to support a multi-point-calibration. The source (x)- values measure are meant as ADC ticks or milli Volts. Up to 3 inputs are supported (x,y,z or real/imaginary etc.). The target (y)- values trueValue are given in measurement units. To be used with
CalibrationType.knownMeasurement,CalibrationType.knownMeasurement1,CalibrationType.calibKnownMeasurement2,CalibrationType.calibKnownMeasuremen3.
- linear: _CalibrationData_linear = None¶
Either new linear calibration parameters to replace the current ones, or corrective numbers to adjust the calibration parameters in effect, both given in measurement units. To be used with
CalibrationType.linearandCalibrationType.linearRel.
- offset: object = None¶
Either a new absolute offset, or the shift to correct the current offset, given in measurement units. To be used with
CalibrationType.offsetandCalibrationType.shiftOffset.
- param: object = None¶
Generic set of parameters, stored separately. To be used with
CalibrationType.paramandCalibrationType.paramRel.
- temp: _CalibrationData_iLinear = None¶
Temperature calibration data. To be used with
CalibrationType.temperature.
- trueMeasurement: _CalibrationData_trueMeasurement = None¶
Pair of measured and true value to support a one-point-calibration. Both values are given in measurement units. Note that the values do not relate to the current exposure. To be used with
CalibrationType.trueMeasurement.
- trueMeasurement2: _CalibrationData_trueMeasurement = None¶
Two pairs of measured and true value to support a two-point- calibration. All values are given in measurement units. To be used with
CalibrationType.trueMeasurement2.
- trueValue: object = None¶
True measurement value related to the current exposure. Should be used with
CalibrationType.trueValue,CalibrationType.expose1,CalibrationType.expose2andCalibrationType.expose3.
- class CalibrationType(*values)[source]¶
Bases:
EnumMnemonic type to identify a specific calibration procedure.
This is part of the information to be passed to a sensor when calling its
Sensor.calibrate()method.- default = 1¶
Default calibration procedure. This may be a special procedure of the sensor hardware, or simply the use of hard-coded default calibration parameters. Depends on the sensor hardware and/or driver implementation.
- expose1 = 6¶
The first point in a two- or three point calibration, depending on what the sensor implementation actually supports. The true measurement value at this point is either given implicitly or explicitly by further data of the calibration data structure. The calibration procedure cannot be finished at this time. Instead, the driver’s calibration routine should expect to be called again with one of the other
calibExposecalibration types.
- expose2 = 7¶
The second point in a two- or three point calibration, depending on what the sensor implementation actually supports. The true measurement value at this point is either given implicitly or explicitly by further data of the calibration data structure. A two-point calibration finishes at this point, while a 3-point calibration should expect to be called once more.
- expose3 = 8¶
The last point in a three point calibration. The true measurement value at this point is either given implicitly or explicitly by further data of the calibration data structure.
- hundred = 4¶
Single fix point hundred calibration. No further calibration data is needed. The current sensory exposure should map to exactly hundred (100) measurement units. For qualitative sensors, may also be interpreted as everything detected or 100%.
- knonwMeasurement2 = 19¶
The same as
knownMeasurement. Two data points are used.
- knonwMeasurement3 = 20¶
The same as
knownMeasurement. Three data points are used.
- knownMeasurement = 17¶
In contrast to
trueMeasurement, calibration uses one or more points(r,v)on the transfer function, whereris the analogue or digitized raw value or voltage equivalent andvis the true, resulting data. This is similar toexpose3etc. except, the primary measure is not given implicitly by the current exposure, but is provided explicitly, instead. All this data must be part of the calibration data structure. This is a generic mnemonics. The actual number of points is given implicitly / at the discretion of the implementation.
- knownMeasurement1 = 18¶
The same as
knownMeasurement. One data point is used.
- linear = 11¶
Provides a new pair of total offset and sensitivity/skew for translating raw (analogue) values into measurement units. These parameters must be given as part of the calibration data structure.
- linearRel = 12¶
Gives a pair of relative correctives to the current offset and skew/sensitivity. This data must be part of the calibration data structure. Note that the offset corrective must be given in either analogue, digitised or measurement units and will be added to the current offset. The sensitivity corrective is interpreted as a signed percentage. It will be added to 100% and then applied to (multiplied with) the current sensitivity. This is to allow the current sensitivity being, e.g. increased by 3% or 5% and alike.
- offset = 9¶
Provides the new, total offset, given in either analogue, digitized or measurement units as part of the calibration data structure.
- one = 3¶
Single fix point one calibration. No further calibration data needed. The current sensory exposure should map to exactly one (1) measurement unit. For binary sensors, may also be interpreted as something detected.
- param = 13¶
Generic calibration type to allow for a transfer of calibration parameters. With this, the current parameters are no longer in effect, but will be replaced by the data provided in the calibration data structure.
- paramRel = 14¶
Shift or skew the current calibration parameters by the correctives provided in the calibration data structure.
- shiftOffset = 10¶
The current offset is corrected by the shift given in analogue, digitised or measurement units as part of the calibration data structure. The shift adds to the current offset.
- temperature = 21¶
Re-calibrate the temperature measurement, e.g. for sensors involving temperature compensation.
- trueMeasurement = 15¶
Provide a pair of
(m,v)measured and true value to calculate necessary corrections. This is a calibration with one fix point similar totrueValue. The difference is, that the measured value is not implicitly given by the current exposure, but can be provided explicitly as part of the calibration data structure.
- trueMeasurement2 = 16¶
Provides two pairs of
(m,v)measured and true values to calculate necessary corrections. This is a two-point calibration and both points are given in the calibration data structure.
- trueValue = 5¶
Single point calibration. The true measurement value of the current exposure must be given as part of the calibration data structure. The current sensory exposure should map to exactly the value given in the calibration data and meant as measurement units.
- zero = 2¶
Single fix point zero calibration. No further calibration data is needed. The current sensory exposure should map to exactly zero (0) measurement units. May also be interpreted as nothing detected or 0%.
- class SelfTest(*values)[source]¶
Bases:
FlagBit mask type to designate the different types of self tests.
- CONNECTION = 1¶
Test physical connection, possibly by reading the chip ID
- FUNCTIONAL = 2¶
Functional test, subject to the implementation.
- SELFTEST_ALL = 65535¶
All possible self tests.
- class Sensor[source]¶
Bases:
Module,ConfigurableThis class is meant to be sub-classed to define interfaces for more-specific categories of sensors.
- classmethod Params_init(paramDict)[source]¶
Initializes parameters to their default values. Supported key names and their meanings / expected keys are:
Sensor.dataRange: Upper/lower limit of expected measurements. Defaults to 1.Sensor.dataRate: Measurement frequency, given in Hz. Default is 1.
Also see
module.Module.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary mapping option names to their respective values.
- Returns:
none
- Return type:
None
- calibrate(calib)[source]¶
Calibrates the sensor device according to the given calibration data.
Calibration may, for example, provide static offsets to adjust the measurement’s zero point or some sort of corrective coefficients to account for the sensor’s temperature drift. The exact type of calibration along with additional data that is possibly necessary, is passed in via the
calibparameter. Also see:Calibration.- Parameters:
calib (Calibration) – The calibration data for that sensor.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- configure(configData)[source]¶
Configures the sensor device as described by the given configuration data.
Note that the type of the provided data and its interpretation will depend on the sensor implementation. Also see:
Configuration.- Parameters:
configData (.sensor.Configuration) – Specific configuration information.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getInfo()[source]¶
Retrieves an information block from the sensor device.
Typically, this kind of information is rather static in that, it does not change (much) over time. Usually, it further describes the sensor origin, manufacturing date, hardware/firmware revision, product/model ID, self-identifying numbers and alike. Also, the general operating mode or working conditions may be part of the info block.
For more dynamic meta-information see
getStatus().The method returns both, an instance of
Info, carrying the information block as well as an error code, indicating success or failure. The info block shall be evaluated only, if the method returned successfully. Even then, the caller should still evaluate thevalidityattribute of the returned info block to find out, which of the information is actually valid.
- getLatestData()[source]¶
Retrieves the most recent data available and returns immediately.
This function will never block, but may read data that has been read before, already. More precisely, the data returned was valid / taken at a moment in the past, which is as close as possible to the current point in time, (including right NOW).
For sensors which deliver measurements continuously in time, there is no semantic difference to
getNextData().In contrast, for sensors, which provide measurements discretely at certain time intervals, this function is expected to deliver the last measurement point - without any waiting. Typically, this requires some kind of buffering. at the sensor or driver side.
The method is synchronous in that, it hands out the resulting data to the caller upon return. In fact, this method returns both, the measurement result and an error code signaling success or failure. The measurement data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the returned measurement data is specific to the individual sensor and driver implementation. The application may rely on values scaled to reasonable units, such as temperatures in degree Celsius, distances in meters and pressures in Pascal - or multiples and fractions thereof.
Also see:
getNextData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getNextData()[source]¶
Retrieves the next data, possibly waiting for the current measurement interval to expire.
This function may introduce a blocking wait, but always returns with fresh, new data never read before. The measurement is taken / valid either immediately or as early as possible in the future.
For sensors, that deliver data continuously in time, there is no difference to
getLatestData().For sensors that sample data at certain time intervals, this function very likely includes some waiting delay until the next measurement is due.
In either case, this function blocks until the measurement is retrieved and hands out data to the application upon return. In that sense, this is a synchronous function.
The return is twofold: the measurement result and an error code signaling success or failure. The measurement data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the returned measurement data is specific to the individual sensor and driver implementation. The application may rely on values scaled to reasonable units or multiples and fractions thereof.
Also see:
getLatestData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getStatus(statusID)[source]¶
Retrieves status data from the sensor device.
Typically, this kind of information is more dynamic in that, it changes (much) over time. Usually, it further describes the sensor’s current shape and condition, such as the availability of new measurement data, the cause of an interrupt or the status of certain hardware functions. Also, secondary measurements such as the die temperature could be subject to status data.
For more static meta-information see
getInfo().The given
statusIDparameter specifies, exactly which status information should be retrieved. Its type and interpretation depends on the sensor implementation.The method returns both, resulting status data and an error code indicating success or failure. The status data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the status data depends on the specific sensor implementation.
- Parameters:
statusID (int) – Identifies the status information to be retrieved.
- Returns:
The status object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Opens an instance and puts it into a usable state.
Configures the sensor by reading the supported parameters or applying default values and calling
configure(). Also see:module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Soft resets the sensor.
Depending on the actual sensor type, configuration may get lost. So, the device is in some default state, afterwards and must be re-configured according to the application’s needs.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- selfTest(tests)[source]¶
Carry out a sensor self test.
The aim of such tests is to verify the integrity and well-functioning of the sensor device. The nature of these tests is solely specific to the sensor type and implementation. So, a test may be a built-in hardware test or some stress test or spot-check implemented in software or a combination of both. Depending on the underlying sensor type, a test may or may not be finished when returning from this function.
If the test finishes upon return, the test result is communicated to the application via the return value. In that case, the sensor device is assumed to be in the same or similar operating condition as before entering this method.
If, in the other case, the test is not finished before returning, the sensor is assumed to be put in test mode and further action of the application is necessary to elicit the test result. This action could, for example, include reading sample data or retrieve the information block. How to leave the self-test mode, depends on the sensor implementation. Calling this function with the same or complementing
testsparameter or invokingSensor.reset()orSensor.configure()are just a few examples.- Parameters:
tests (int) – A bit mask to select the tests to be executed, in case several tests are available. Interpretation of this parameter is up to the specific sensor type and may include starting and stopping a certain test mode.
- Returns:
An error code either indicating the test result or that starting/stopping test mode was successful or the reason why it failed.
- Return type:
philander.serialbus module¶
Serial bus convergence layer for smbus, smbus2, periphery or simulative implementation.
Provide a common API for serial bus communication (I2C / SPI). This interface is to to abstract from details of the implementation.
Basically, there are two main classes: SerialBus and SerialBusDevice.
The SerialBus class unifies the implementations like smbus or periphery
by providing similar communication functions, such as read/write byte,
word and buffer data.
The SerialBusDevice carries specific information for a specific bus
participant, such as its address.
For that reason, every read or write function of the SerialBus class needs
an SerialBusDevice instance as a parameter. For convenience, read and
write functions are also available at the SerialBusDevice class,
delegating their calls to the matching functions in SerialBus along
with their self-reference.
For the sake of consistency, each SerialBusDevice must be mated with
a certain SerialBus in order to work, properly. This process is called
attaching a device to a bus. Several devices may be attached to the
same bus. However, a single device may only attached to at most one bus.
After attaching, the bus and device are double-linked to each other:
The bus has a list of attached devices, while a device has a reference
to the bus it is attached to.
- class SerialBus[source]¶
Bases:
ModuleConvergence layer to abstract from multiple implementations of serial communication (I2C, SPI), such as smbus or periphery.
This class represents the serial bus as such, without any participating device. For communicating with a specific device, a corresponding instance of
SerialBusDevicemust be provided to the read/write method of interest.A sub class must overwrite at least the methods for reading and writing a single byte and buffer.
- DEFAULT_DESGINATOR = '/dev/i2c-1'¶
- DEFAULT_I2C_SPEED = 400000¶
- DEFAULT_SPEED = 400000¶
- DEFAULT_SPI_BITS_PER_WORD = 8¶
- DEFAULT_SPI_BIT_ORDER = 'MSB'¶
- DEFAULT_SPI_MODE = 3¶
- DEFAULT_SPI_SPEED = 1000000¶
- DEFAULT_TYPE = 10¶
- MODULE_PARAM_PREFIX = 'SerialBus'¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with default values.
Supported key names and their meanings are:
Key
Range
Default
SerialBus.provider
SysProviderto select implementationSysProvider.AUTO.SerialBus.type
SerialBusTypeto indicate the protocol.SerialBus.designator
[string | number]: bus port, “/dev/i2c-3” or 1.
“/dev/i2c-1”.
SerialBus.speed
[int|float] maximum bus clock frequency in Hz.
SerialBus.SPI.mode
SPIModemode; only for SPI.SerialBus.SPI.bitorder
[“msb”|”lsb”] bit transmission order.
SerialBus.SPI.bpw
int; bits per word
- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
none
- Return type:
None
- attach(device)[source]¶
Attaches a device to this serial bus.
If this bus is not open, yet, then it will get opened, now. If the same device has been attached before, the method will just return successfully.
- Param:
SerialBusDevice device: The device to be attached.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- close()[source]¶
Shut down this bus and release associated hardware resources.
If this bus has some devices attached, they get detached, before the method returns.
Also see:
module.Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- detach(device)[source]¶
Detach a device from this serial bus.
If this is the last device on the bus, the bus is closed, automatically.
- Param:
SerialBusDevice device: The device to be detached.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- detachAll()[source]¶
Detaches all devices from this serial bus.
Note that this will not close the bus automatically.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- static getSerialBus(provider=SysProvider.AUTO)[source]¶
Generates a serial bus implementation according to the requested provider.
- Parameters:
provider (SysProvider) – The low-level lib to rely on, or AUTO for automatic detection.
- Returns:
A serial bus implementation object, or None in case of an error.
- Return type:
- isAnyAttached()[source]¶
Determines, if there is any device attached to this bus implementation.
- Returns:
An error code.
ErrorCode.errOk, if there is at least one device attached to this bus;ErrorCode.errUnavailable, if no device has been attached before; Any other value to indicate the failure or reason, why this information could not be retrieved.- Return type:
- isAttached(device)[source]¶
Determines, if the given device is already attached to this bus.
Also see:
SerialBusDevice.isAttached().- Returns:
An error code.
ErrorCode.errOk, if the device is already attached to some bus;ErrorCode.errUnavailable, if it has not been attached before; Any other value to indicate the failure or reason, why this information could not be retrieved.- Return type:
- isOpen()[source]¶
Determine, if the given bus is already open.
- Returns:
ErrorCode.errOk, if the bus is already open;ErrorCode.errUnavailable, if it has not been opened before; Any other value to indicate the failure or reason, why this information could not be retrieved.- Return type:
- open(paramDict)[source]¶
Open a new serial bus and apply the given configuration.
If this instance was opened before, already, this method returns an error code. The same is true, when the same physical bus was opened before, possible using another instance.
Also see:
Params_init(),module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- readBuffer(device, length)[source]¶
Directly reads multiple bytes from the given device.
Also see:
SerialBusDevice.readBuffer().- Parameters:
device (SerialBusDevice) – The device to communicate with.
length (int) – The number of bytes to read from the device. Should be greater than zero.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- readBufferRegister(device, reg, length)[source]¶
Multi-byte read access to a register-type serial bus device.
After sending one byte of command or register address, a number of bytes is read back and returned.
For SPI, the byte received during transmission of the
regbyte is discarded. It does not appear in the response buffer. Then, enough dummy traffic is generated to receivelengthnumber of bytes.Also see:
SerialBusDevice.readBufferRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The byte to send. May be a command or register address, depending on the protocol of the addressed device.
length (int) – The number of bytes to read from the device. Should be greater than zero.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- readByteRegister(device, reg)[source]¶
This method provides 8 bit register read access to a device.
First, the
regbyte is sent to the device. This may address the register to be read out or be some sort of command. Then, one byte is read back from the device. Depending on the device protocol semantics, this may be the register content or the command response.Also see:
SerialBusDevice.readByteRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The data to write to this device. This may be a register identification or some sort of command.
- Returns:
A one-byte integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readDWordRegister(device, reg)[source]¶
Read a 32-bit word from the given register.
After the
regbyte is sent, four bytes are read from the device. The 32 bit double-word is always read in little endian order, i.e. the least significant low-byte first, the highes-significant high-byte last.Also see:
SerialBusDevice.readDWordRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register identification or command to write to this device.
- Returns:
A 32-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readWordRegister(device, reg)[source]¶
Provide register read access for 16 bit data words.
After a byte is sent, two bytes are read from the device. The word is always read in little endian order, i.e. the least significant low-byte first, the highes-significant high-byte second.
Also see:
SerialBusDevice.readByteRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register identification or command to write to this device.
- Returns:
A 16-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- setRunLevel(level)[source]¶
Switch the bus into some operating or power-saving mode.
Also see:
module.Module.setRunLevel().
- writeBuffer(device, buffer)[source]¶
Writes the given data to the device specified.
The buffer is not interpreted any further but is written as such, no matter of a register information being present, or not.
Also see:
SerialBusDevice.writeBuffer().- Parameters:
device (SerialBusDevice) – The device to communicate with.
buffer (int[]) – The data to write.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeBufferRegister(device, reg, buffer)[source]¶
Assuming a register-type access, this function writes a buffer to a register.
The register
regvalue is written first, followed by the givenbuffercontent.Also see:
SerialBusDevice.writeBufferRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
buffer (int) – The data to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeByteRegister(device, reg, data8)[source]¶
Assuming a register-type access, this function writes a byte register.
The register value is written first, followed by the given data parameter.
Also see:
SerialBusDevice.writeByteRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data8 (int) – The data to write to the addressed register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeDWordRegister(device, reg, data32)[source]¶
Write a 32 bit double-word to the given register.
The register
regvalue is written first, followed by the givendata32parameter in little-endian order.Also see:
SerialBusDevice.writeDWordRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data32 (int) – The dword to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeReadBuffer(device, outBuffer, inLength)[source]¶
Writes and reads a number of bytes simultaneously, if possible.
The output buffer is written. The last
inLengthnumber of bytes of the resulting input buffer are returned. E.g.inLength=2will the method make return the last two bytes (one word) of the buffer retrieved while/after writing the givenoutBuffer.If data can be read simultaneously while writing (SPI), that input is considered. Again,
inLengthis counted from the end of the buffer. If that number is larger the givenoutBuffer``´s length, dummy bytes are written, accordingly. So, the total traffic caused in this case is ``max( len(outBuffer), inLength )bytes.If reading simultaneously is impossible (I2C), the given number of bytes are read by a separate message. The total traffic caused in this case is
len(outBuffer) + inLengthbytes.Also see:
SerialBusDevice.writeReadBuffer().- Parameters:
device (SerialBusDevice) – The device to communicate with.
inLength (int) – The number of bytes to read from the device. Should be greater than zero.
outBuffer (int[]) – The data to write to the device.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- writeWordRegister(device, reg, data16)[source]¶
Assuming a register-type access, this function writes a word register.
The register
regvalue is written first, followed by the givendata16parameter in little-endian order.Also see:
SerialBusDevice.writeWordRegister().- Parameters:
device (SerialBusDevice) – The device to communicate with.
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data16 (int) – The word to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- class SerialBusDevice[source]¶
Bases:
ModuleReflect a specific device communicating over a serial bus.
As its main information, an instance of
SerialBusDeviceis to hold specific information of that single device, such as its unique bus address. This class is meant to be sub-classed by implementations for real devices.Before using a device for communication, it must be attached to a bus by calling
SerialBus.attach(). However, a device’sisAttached()function may be used to check, whether it has been attached to a bus, already.- DEFAULT_ADDRESS = 33¶
- MODULE_PARAM_PREFIX = 'SerialBusDevice'¶
- classmethod Params_init(paramDict)[source]¶
Initialize the set of configuration parameters with supported options. Supported configuration key names and their meanings are:
Key
Range, meaning and default
SerialBusDevice.address
int; I2C address of the device;
DEFAULT_ADDRESSSerialBusDevice.CS.gpio.*
SPI chip select pin configuration; See
GPIO.Params_init().SerialBusDevice.bus
SerialBus instance to attach the new device to; None, to be created
SerialBus.*
SerialBus configuration; see
SerialBus.Params_init()Also see
module.Module.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary mapping option names to their respective values.
- Returns:
none
- Return type:
None
- close()[source]¶
Shut down this instance and release associated hardware resources.
If this instance is attached to some bus, it gets detached, before the method returns.
Also see:
module.Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- isAttached()[source]¶
Determines, if this instance is attached to some bus.
Also see:
SerialBus.isAttached().- Returns:
An error code.
ErrorCode.errOk, if the device is already attached to some bus;ErrorCode.errUnavailable, if it has not been attached before; Any other value to indicate the failure or reason, why this information could not be retrieved.- Return type:
- open(paramDict)[source]¶
Opens this serial device and puts it into a usable state.
If this device has been attached to some bus, already, this method returns an error code. Otherwise, it tries to do this attachment as follows:
If the
paramDictconfiguration parameters contain theSerialBusDevice.buskey, the associated value object is checked to be an instance ofSerialBus. If successful, this device is attached to that bus. Otherwise, an error code is returned.If no bus instance is passed in, one is created and opened using the same
paramDictdictionary of options. If successful, this device gets attached to that new bus. Upon return, the caller might retrieve a reference to the new bus from the parameter dictionary entry with keySerialBusDevice.bus, or by reading theSerialBusDevice.serialBusattribute.
Also see:
module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- readBuffer(length)[source]¶
Directly reads multiple bytes from the given device.
The call is delegated to the corresponding method at the bus that this device is attached to.
Differently from
readBufferRegister(), this method does not write any register information beforehand, but just starts reading.Also see:
SerialBus.readBuffer(),readBufferRegister().- Parameters:
length (int) – The number of bytes to read from the device. Should be greater than zero.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- readBufferRegister(reg, length)[source]¶
Multi-byte read access to a register-type serial bus device.
The call is delegated to the corresponding method at the bus that this device is attached to.
After sending one byte of command or register address, a number of bytes is read back and returned.
For SPI, the byte received during transmission of the
regbyte is discarded. It does not appear in the response buffer. Then, enough dummy traffic is generated to receivelengthnumber of bytes.Also see:
SerialBus.readBufferRegister().- Parameters:
reg (int) – The byte to send. May be a command or register address, depending on the protocol of the addressed device.
length (int) – The number of bytes to read from the device. Should be greater than zero.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- readByteRegister(reg)[source]¶
This method provides 8 bit register read access to a device.
The call is delegated to the corresponding method at the bus that this device is attached to.
Also see:
SerialBus.readByteRegister().- Parameters:
reg (int) – The data to write to this device. This may be a register identification or some sort of command.
- Returns:
A one-byte integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readDWordRegister(reg)[source]¶
Provide register read access for 32 bit data words.
The call is delegated to the corresponding method at the bus that this device is attached to. After a byte is sent, four bytes are read from the device in little endian order.
Also see:
SerialBus.readDWordRegister().- Parameters:
reg (int) – The register identification or command to write to this device.
- Returns:
A 32-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readWordRegister(reg)[source]¶
Provide register read access for 16 bit data words.
The call is delegated to the corresponding method at the bus that this device is attached to. After a byte is sent, two bytes are read from the device in little endian order.
Also see:
SerialBus.readWordRegister().- Parameters:
reg (int) – The register identification or command to write to this device.
- Returns:
A 16-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- writeBuffer(buffer)[source]¶
Writes the given data to the device specified.
The call is delegated to the corresponding method at the bus that this device is attached to. The buffer is not interpreted any further but is written as such, no matter of a register information being present, or not. In SPI mode, the data received during transmission, is discarded.
Also see:
SerialBus.writeBuffer(),writeBufferRegister().- Parameters:
buffer (int[]) – The data to store.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeBufferRegister(reg, buffer)[source]¶
Assuming a register-type access, this function writes a buffer to a register.
The call is delegated to the corresponding method at the bus that this device is attached to. The register
regvalue is written first, followed by the givenbuffercontent.Also see:
SerialBus.writeBufferRegister().- Parameters:
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
buffer (int[]) – The data to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeByteRegister(reg, data8)[source]¶
Assuming a register-type access, this function writes a byte register.
The call is delegated to the corresponding method at the bus that this device is attached to. The register value is written first, followed by the given data parameter.
Also see:
SerialBus.writeByteRegister().- Parameters:
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data8 (int) – The data to write to the addressed register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeDWordRegister(reg, data32)[source]¶
Assuming a register-type access, this function writes a dword register.
The call is delegated to the corresponding method at the bus that this device is attached to. The register
regvalue is written first, followed by the givendata32parameter in little-endian order.Also see:
SerialBus.writeDWordRegister().- Parameters:
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data32 (int) – The double-word to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeReadBuffer(outBuffer, inLength)[source]¶
Writes and reads a number of bytes.
The call is delegated to the corresponding method at the bus that this device is attached to.
Also see:
SerialBus.writeReadBuffer().- Parameters:
outBuffer (int[]) – The data to write to the device.
inLength (int) – The number of bytes to read from the device. Should be greater than zero.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- writeWordRegister(reg, data16)[source]¶
Assuming a register-type access, this function writes a word register.
The call is delegated to the corresponding method at the bus that this device is attached to. The register
regvalue is written first, followed by the givendata16parameter in little-endian order.Also see:
SerialBus.writeWordRegister().- Parameters:
reg (int) – The register number. This addresses the place where to put the content. Depending on the device, this could also be some kind of command.
data16 (int) – The word to store to the given register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
philander.serialbus_micropython module¶
philander.serialbus_periphery module¶
Provide the serial bus API while relying on the periphery package.
An application should never use this module directly. Instead, the system factory will provide suitable instances.
philander.serialbus_sim module¶
Provide the serial bus API while simulating a virtual serial bus.
An application should never use this module directly. Instead, the system factory will provide suitable instances.
philander.serialbus_smbus2 module¶
Provide the serial bus API while relying on the SMBus2 package.
An application should never use this module directly. Instead, the system factory will provide suitable instances.
philander.shiftreg module¶
Module to control a shift register.
A shift register is a micro-electronic device providing a series of flip-flops, where the output of one flip-flop is connected to the input of the next one. Although there are different types of shifts registers, those which are addressed by this module, are configured as serial-in, parallel-out (SIPO).
Data is shifted in serially through DIN by each cycle of the clock DCLK and can be read in parallel from all outputs Q0, Q1, Q2, … simultaneously. The highest significant bit (Q7’) shifted out may be available as QOVR. The content of the flip-flops may be cleared by DCLR. Further, there are implementations with buffered outputs (latches). Those may involve additional lines to copy (latch) the current content of the flip-flops into the buffer by RCLK and to clear the buffer by cycling RCLR. Finally, there may be an enabling line ENA. In some devices, this enables or disables the whole chip. This is useful e.g. for putting the device into a deep sleep mode in power-critical applications. Upon recovery from sleep, the content of the flip-flops may get lost. Other implementations interpret ENA to just mute or un-mute the outputs Q while still allowing to alter the register contents. Finally, ENA might de-couple the serial communication DIN/DCLK. These implementations preserve the content but pause further feeding of the shift register while ENA is inactive.
A symbolic visualization of a shift register could look like this:
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | |
+-----------------------+
DIN -->| |--> QOVR
DCLK -->| |<-- RCLK
DCLR -->| |<-- RCLR
ENA -->| |
+-----------------------+
Typical implementations of such devices are the TI SN74HC594, ST M74HC595, and ST HCF4094.
Note that handling the output Q0, Q1, …, QOVR is beyond the scope of this module.
- class ShiftReg[source]¶
Bases:
ModuleDriver class for a shift register device.
The implementation provided here, does not assume a specific size of the shift register, i.e. number of flip-flops. Although it provides an implementation for controlling the DIN and DCLK lines, i.e. the process of shifting bits into the register, it is meant to be derived for more sophisticated / efficient implementations.
Note that for all GPIO lines configured, the actual physical effect may be inverted by using the GPIO’s inverted configuratio parameter. This may be necessary to semantically match the chip’s implementation and behavior.
- ITEM_PARAM_PREFIX = ('dclr', 'enable', 'rclk', 'rclr', 'din', 'dclk')¶
- MODULE_PARAM_PREFIX = 'shiftreg'¶
- PIN_IDX_DCLK = 5¶
- PIN_IDX_DCLR = 0¶
- PIN_IDX_DIN = 4¶
- PIN_IDX_ENA = 1¶
- PIN_IDX_RCLK = 2¶
- PIN_IDX_RCLR = 3¶
- PIN_MAXNUM = 6¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
General or global GPIO adjustments or defaults can be set using the shiftreg.gpio.* keys. They can be pin-wise overridden by specific e.g. shiftreg.ena.gpio.* settings.
The following settings are supported:
Key name
Value type, meaning and default
shiftreg.gpio.provider
Global setting: GPIO provider
shiftreg.gpio.pinNumbering
Global setting: numbering scheme
shiftreg.gpio.inverted
Global setting: True if low-active
shiftreg.gpio.level
Global setting: initial logic level
shiftreg.din.gpio.pinNumbering
DIN pin: Numbering scheme
shiftreg.din.gpio.pinDesignator
DIN pin: Name or number of the pin
shiftreg.din.gpio.inverted
DIN pin: True, if pin is low-active
shiftreg.din.gpio.level
DIN pin: Initial logic level
shiftreg.dclk.gpio.pinNumbering
DCLK pin: Numbering scheme
shiftreg.dclk.gpio.pinDesignator
DCLK pin: Name or number of the pin
shiftreg.dclk.gpio.inverted
DCLK pin: True, if pin is low-active
shiftreg.dclk.gpio.level
DCLK pin: Initial logic level
shiftreg.dclr.gpio.pinNumbering
DCLR pin: Numbering scheme
shiftreg.dclr.gpio.pinDesignator
DCLR pin: Name or number of the pin
shiftreg.dclr.gpio.inverted
DCLR pin: True, if pin is low-active
shiftreg.dclr.gpio.level
DCLR pin: Initial logic level
shiftreg.rclk.gpio.pinNumbering
RCLK pin: Numbering scheme
shiftreg.rclk.gpio.pinDesignator
RCLK pin: Name or number of the pin
shiftreg.rclk.gpio.inverted
RCLK pin: True, if pin is low-active
shiftreg.rclk.gpio.level
RCLK pin: Initial logic level
shiftreg.rclr.gpio.pinNumbering
RCLR pin: Numbering scheme
shiftreg.rclr.gpio.pinDesignator
RCLR pin: Name or number of the pin
shiftreg.rclr.gpio.inverted
RCLR pin: True, if pin is low-active
shiftreg.rclr.gpio.level
RCLR pin: Initial logic level
shiftreg.enable.gpio.pinNumbering
ENA pin: Numbering scheme
shiftreg.enable.gpio.pinDesignator
ENA pin: Name or number of the pin
shiftreg.enable.gpio.inverted
ENA pin: True, if pin is low-active
shiftreg.enable.gpio.level ENA pin: Initial logic level
If the shiftreg.*.pinDesignator is not given, the driver assumes, the corresponding line is not present or implemented.
Also see:
Module.Params_init(),GPIO.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary of configuration settings.
- Returns:
none
- Return type:
None
- clear()[source]¶
Clear the register and buffer content.
If supported by the underlying hardware, use DCLR and RCLR to reset. Otherwise, the implementation may write a number of zeroes to the register to approximate a similar result.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- clearData()[source]¶
Use DCLR to reset the register content.
If supported by the driven chip, clears the contents of the flip-flops by cycling DCLR. That is, the line is set to logic high and reset back to logic low.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- clearLatch()[source]¶
Use RCLR to reset the buffer (latch) content.
If supported by the driven chip, clears the contents of the buffer by cycling RCLR. That is, the line is set to logic high and reset back to logic low.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disable()[source]¶
Disable the device, if supported by the underlying chip.
Also see:
enable().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enable(activate=True)[source]¶
Set the ENA line to activate the device as given.
If supported by the driven chip, enables or disables the devices, as given by the activate parameter. If activate`is `True, the ENA line is set to the logic high level. Otherwise, it is set to logic low. Remember that the physical effect may be inverted by using the GPIO’s inverted configuration parameter.
The actual semantic effect or meaning depends on the underlying device. In some rare implementations, disabling puts the chip into a deep sleep mode, which may be advantageous in power- critical applications. However, upon recovery from sleep, the content of the flip-flops may be lost. More frequently, de-activating ENA just de-couples the serial communication DIN/DCLK. These implementations preserve the content but pause further feeding of the shift register while ENA is inactive. This behavior is similar to the chip-select (CS) line in SPI communication.
- Parameters:
activate (bool) – Whether to activate (default) or deactivate the device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- latch()[source]¶
Use RCLK to copy the register flip-flop content to the buffer.
If supported by the driven chip, copies the contents of the shift register to the buffer by cycling RCLK. That is, the line is set to logic high and reset back to logic low.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- write(data, numBits=1, autoLatch=True)[source]¶
Feed data into the first stage of the shift register.
The lowest significant number of bits as given by the numBits parameter is written to DIN sequentially, starting with the highest-significant bit, first. If, for example, data = 141 = 0x8d = 10001101b and numBits=4, the sequence 1-1-0-1´ is written in that order. For each bit written, DIN is set correspondingly and DCLK is cycled once to logic `high`and back to logic `low.
This implementation is GPIO based and accepts single bits to be shifted in - at the price of dedicated GPIO lines for DIN and DCLK. Implementations in derived classes may depend on SPI or other mechanisms and, hence, put restrictions on what numBits can be.
If autoLatch is True and depending on the underlying hardware, the resulting content of the shift register is latched into the buffer.
- Parameters:
data (int) – The data to send to the shift register.
numBits (int) – Non-negative number of least-significant bits in ‘data’ to shift-in. Usually 1, 4 or multiple of 8.
autoLatch (bool) – Whether to automatically latch the result into the buffer.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.shiftreg_spi module¶
Module to control a shift register by means of an SPI bus.
- class ShiftRegSPI[source]¶
Bases:
ShiftRegDriver class for a shift register device using SPI.
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
General or global GPIO adjustments or defaults can be set using the shiftreg.gpio.* keys. They can be pin-wise overridden by specific e.g. shiftreg.ena.gpio.* settings.
The following settings are supported:
Key name
Value type, meaning and default
shiftreg.*
Shift register configuration; See
ShiftReg.Params_init().shiftreg.SerialBusDevice.*
Serial bus device config; See
SerialBusDevice.Params_init().shiftreg.SerialBus.* Serial bus configuration; See
SerialBus.Params_init().Also see:
Module.Params_init(),ShiftReg.Params_init(),SerialBusDevice.Params_init(). :param dict(str, object) paramDict: Dictionary of configuration settings. :return: none :rtype: None
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Open the instance and set it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- write(data, numBits=8, autoLatch=True)[source]¶
Feed data into the shift register.
As the underlying mechanism is SPI, only full bytes can be written to the register. So, ‘numBits’ must be a multiple of 8. At maximum, four bytes can be written at once, so numBits must be one of numBits={8 | 16 | 24 | 32}. The highest-significant byte selected is written first. If, for example, data = 0xa4b3c2d1 and numBits=24, the sequence shifted into the register is b3-c2-d1.
If autoLatch is True and depending on the underlying hardware, the resulting content of the shift register is latched into the buffer.
- Parameters:
data (int) – The data to send to the shift register.
numBits (int) – Non-negative number of least-significant bits in ‘data’ to shift-in. One of {8 | 16 | 24 | 32}.
autoLatch (bool) – Whether to automatically latch the result into the buffer.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.simBMA456 module¶
Simulation of the BMA456 accelerometer device.
This module provides a pure software implementation of the device to virtualize its serial communication behavior. This is to support cross-platform development and debugging.
- class SimDevBMA456[source]¶
Bases:
SimDevMemoryA software simulation of the BMA456. The current implementation is incomplete and imperfect to some extent. The status is as follows.
Working¶
simulation of its bare existence by responding properly in serial communication
all registers are present, accessible and constructed with correct reset values.
register
CHIP_IDSTATUS:DRDY_ACC/AUXcleared at each read-access toACC_X/Y/ZorAUX_X/Y/Z/R
Limitations¶
ACC_X/Y/Zget just incremented after each read access.STATUS:DRDY_ACC/AUXget set after polling (reading)STATUSfor 10 times.SENSOR_TIME[0:1:2]incremented after each read-accessinitialization sequence is satisfied by writing
LOAD_CFG_FILEfollowed bySTART_INITto theINIT_CTRLregister. This will setINTERNAL_STATUS:MSGtoINIT_OK. Otherwise, these bits are set toINIT_ERR.
Missing¶
Simulation of acceleration flow, e.g. as read from an input file
Feature simulation (step counter etc.)
Simulation of the chip status and behavior, such as
ERRORandSTATUSpower modes
interrupts
NVM
- readBufferRegister(aReg, length)[source]¶
Read a block of data starting from the given register.
Do not auto-increment destination address when reading from
BMA456_REG_FEATURES.- Parameters:
aReg (int) – The address of the first register to be read.
length (int) – The number of bytes to read.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
list(int), ErrorCode
- writeBufferRegister(aReg, data)[source]¶
Write a block of byte data into registers.
Do not auto-increment destination address when writing to
BMA456_REG_FEATURES.- Parameters:
aReg (int) – The address of the first register to receive the block of data.
data (list) – List of bytes to be written. The length of the list determines the number of bytes to write. So, all values in the list will be transferred to the device.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
philander.simdev module¶
Serial device simulation module to support debugging and cross-platform development.
This module provides a fake serial device implementation to virtualize serial communication.
- class MemoryType(*values)[source]¶
Bases:
EnumEnumeration to reflect the different types of memory.
- NVM = 3¶
- RAM = 2¶
- ROM = 1¶
- VOLATILE = 4¶
- class Register(address: int = 0, content: int = 0, type: MemoryType = MemoryType.RAM)[source]¶
Bases:
objectSimulate a memory-based register.
Depending on the type of memory, the register content can or cannot be changed by simply writing to it. Volatile registers are not writable. They may change their content spontaneously or by mechanisms that cannot be controlled by the user.
- address: int = 0¶
The address to identify this register during read/write operations.
- content: int = 0¶
The register content. Can be initialized, independently of the memory type of that register.
- type: MemoryType = 2¶
The type of memory for that register.
- class SimDev[source]¶
Bases:
objectAbstract base class to define the functionality of a simulated serial device.
A sub class must overwrite at least the methods for reading and writing a single byte. Implementation should use as least as possible dependencies to other modules. Use of hardware-dependent drivers must be completely avoided!
Objects of this type (and its derivatives) shall be stored as the
simattribute of a matchingserialbus.SerialDeviceobject. Remember that eachserialbus.SerialDevicemust be registered with aserialbus.SerialBusby calling itsserialbus.SerialBus.attach()method. The simulative serial bus implementation uses theserialbus.SerialDevice.addressattribute to identify the addressed device and then looks up itsSerialBusDevice.simattribute to retrieve the serial simulation for that device.For that reason, implementations do not have to care about the address of the device - it’s always the right one.
- readBuffer(length)[source]¶
Directly read the given number of bytes.
- Parameters:
length (int) – The number of bytes to read.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- readBufferRegister(aReg, length)[source]¶
Read a block of data starting from the given register.
Starting with the given Register address,
lengthbytes are read and returned. As withreadWordRegister()andreadDWordRegister(), this implementation assumes an auto-increment behavior of the target register. So, the returned data buffer is read as follows:data[0] -> aReg data[1] -> aReg + 1 …
If this doesn’t match the actual chip behavior, a sub-class should overwrite this method.
- Parameters:
aReg (int) – The address of the first register to be read.
length (int) – The number of bytes to read.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
list(int), ErrorCode
- readByteRegister(aReg)[source]¶
Read a single byte from a certain register. A sub-class must overwrite this method.
The method is expected to deliver a register’s content to the caller.
- Parameters:
aReg (int) – The address of the register to be read.
- Returns:
A one-byte integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readDWordRegister(aReg)[source]¶
Read a double word from a certain register.
The dword is formed in little-endian order from the content of the four registers, starting with the given address
aReg(low-byte of the low-word) and its successorsaReg+1(high-byte of the low-word),aReg+2(low-byte of the high-word) andaReg+3(high-byte of the high-word).- Parameters:
aReg (int) – The address of the first (lowest-byte) register to be read.
- Returns:
A 32-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- readWordRegister(aReg)[source]¶
Read a word from a certain register.
The word is formed in little-endian order from the content of the given register (low) and the content of the immediate successor
aReg+1of that register (high).- Parameters:
aReg (int) – The address of the low-byte register to be read.
- Returns:
A 16-bit integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- writeBuffer(buffer)[source]¶
Write out a block of data.
The buffer is not interpreted any further but is written as such, no matter of a register information being present, or not.
- Parameters:
buffer (int[]) – The data to write.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeBufferRegister(aReg, data)[source]¶
Write a block of byte data into registers.
As with
readBufferRegister()an auto-increment applies for the target register. The first byte - at index zero - is stored at the given registeraReg, the next byte - at index 1 - is stored ataReg+1and so on. More formally:data[0] -> aReg data[1] -> aReg + 1 ...
The number of bytes written is determined implicitly by the length of the
datalist. If the auto-increment feature doesn’t match the actual chip, a sub-class should overwrite this method.- Parameters:
aReg (int) – The address of the first register to receive the block of data.
data (list) – List of bytes to be written. The length of the list determines the number of bytes to write. So, all values in the list will be transferred to the device.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeByteRegister(aReg, data)[source]¶
Write a single byte value into a certain register. A sub-class must overwrite this method.
The method is expected to store the given value to a register.
- Parameters:
aReg (int) – The address of the register to receive the new value.
data (int) – The new value to store to that register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeDWordRegister(aReg, data32)[source]¶
Write a double-word (four bytes) value into a certain register.
The method is expected to store the given value to a quadruple of registers in little-endian order. The low-byte of the low word is stored at the given register
aReg. The high-byte of the low-word goes toaReg+1. The low-part of the high-word is stored toaReg+2and the high-part of the high-word is put ataReg+3.- Parameters:
aReg (int) – The address of the first (lowest byte) register to receive part of the new value.
data32 (int) – The new value to store to that quadruple of registers.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- writeReadBuffer(outBuffer, inLength)[source]¶
Writes and reads a number of bytes simultaneously, if possible.
Also see:
SerialBus.writeReadBuffer().- Parameters:
inLength (int) – The number of bytes to read.
outBuffer (int[]) – The data to write.
- Returns:
A buffer of the indicated length holding the response and an error code indicating success or the reason of failure.
- Return type:
int[], ErrorCode
- writeWordRegister(aReg, data16)[source]¶
Write a double-byte (word) value into a certain register.
The method is expected to store the given value to a register or pair of registers in little-endian order. The low-part of the data16 item is stored at the given register, while the high-part is put at
aReg+1.- Parameters:
aReg (int) – The address of the register to receive the low-part of the new value.
data16 (int) – The new value to store to that (pair of) registers.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- class SimDevMemory(regs)[source]¶
Bases:
SimDevAbstract base class for the simulation of memory-based register devices.
Pretend a device that can be accessed through a set of memory-based registers. Implementations must provide the list of registers during instantiation.
- readByteRegister(aReg)[source]¶
Retrieves a register’s content. To also simulate side effects of reading, the following steps are executed in sequence, no matter what the memory type of the given register is:
calling
_onPreRead()reading the register content
calling
_onPostRead()
Note that the return value is solely determined by what is read from the register in step #2. It cannot be altered by
_onPostRead(), anymore.Also see
simbus.SimDev.readByteRegister().- Parameters:
aReg (int) – The address of the register to be read.
- Returns:
A one-byte integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- writeByteRegister(aReg, data)[source]¶
Write a single byte value into a certain register.
Write attempts to registers with non-writable memory are ignored. For registers with writable memory, the following sequence is executed in order to give sub-classes the opportunity to simulate side effects:
calling
_onPreWrite(), may alter the intended data and returns the actual new content to write.writing the new register content
calling
_onPostWrite()
- Parameters:
aReg (int) – The address of the register to receive the new value.
data (int) – The new value to store to that register.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
- class SimDevNull(reading=58)[source]¶
Bases:
SimDevSlim-line serial device simulation. Reading retrieves always the same constant value, while writing is simply ignored.
- DEFAULT_READING = 58¶
- readByteRegister(aReg)[source]¶
Read a single byte.
Independent of the given register, the delivered value will always be the same. That delivered reading can be configured using the SimDevNull.reading option when calling
open().- Parameters:
aReg (int) – The address of the register to be read. Actually ignored.
- Returns:
A one-byte integer representing the response of the device and an error code indicating success or the reason of failure.
- Return type:
int, ErrorCode
- writeByteRegister(aReg, data)[source]¶
Write a single byte.
Actually, does nothing. Also see
SimDev.writeByteRegister().- Parameters:
aReg (int) – The address of the register. Ignored.
data (int) – The new value to store to that register. Ignored.
- Returns:
An error code indicating success or the reason of failure.
- Return type:
philander.ssd1803a module¶
Display driver module for text LCDs driven by the SSD1803A controller.
- class SSD1803A[source]¶
Bases:
TextDisplayDriver class for a text LCD driven by SSD1803A.
Although, this module aims at being generic beyond the controller hardware, clearly the DOGM204-A text display by Display Visions was in mind when developing this driver.
The DOGM204 is a 4x20 characters chip-on-glass display module driven by the SSD1803A display controller by Solomon Systech. The module can be controlled via SPI or I2C. More information on that hardware can be found at: https://www.lcd-module.de/fileadmin/pdf/doma/dogm204.pdf
The SSD1803A supports display sizes of up to 80 characters (max. total). Character format may be 5x8 or 6x8. Detailed technical information on the controller can be found at: https://www.solomon-systech.com/product/SSD1803A
- ADDRESSES_ALLOWED = [60, 61]¶
- PART_ID = 26¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with default values.
Supported key names and their meanings are:
Key
Meaning, Range, Default
display.SerialBusDevice.*
Serial bus device config; See
SerialBusDevice.Params_init().display.SerialBus.*
Serial bus configuration; See
SerialBus.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary of configuration settings.
- Returns:
none
- Return type:
None
- REG_CMD = 0¶
- REG_DATA = 1¶
philander.stadc1283 module¶
ADC implementation for the ADC1283 A/D converter chip by ST micro.
More information on this chip can be found at https://www.st.com/en/data-converters/adc1283.html
philander.stc3115 module¶
A module to provide base classes and data types for gas gauge driver implementations.
- class STC3115[source]¶
Bases:
STC311xDriver implementation for the stc3115 gas gauge.
Info about this chip can be found at ST microelectronics https://www.st.com/en/power-management/stc3115.html
- MODEL_ID = 3115¶
philander.stc3115_reg module¶
Register definitions for the STC311x family battery gas gauges.
Definition of registers and default values for the above-mentioned chips. Externalized, just for clarity of the source code.
- class STC3115_Reg[source]¶
Bases:
STC311x_RegDefinition of the STC3115 exclusive registers and values.
Registers and content interpretation specific to this chip. It complements those definitions inherited from the base class.
- CHIP_ID = 20¶
- MODE_CLR_CC_ADJ = 4¶
- MODE_CLR_VM_ADJ = 2¶
- OCV_DEFAULT = 0¶
- REG_ACC_CC_ADJ = 27¶
- REG_ACC_CC_ADJ_H = 28¶
- REG_ACC_CC_ADJ_L = 27¶
- REG_ACC_VM_ADJ = 29¶
- REG_ACC_VM_ADJ_H = 30¶
- REG_ACC_VM_ADJ_L = 29¶
- REG_CC_ADJ_H = 11¶
- REG_CC_ADJ_L = 25¶
- REG_OCVTAB0 = 48¶
- REG_OCVTAB1 = 49¶
- REG_OCVTAB10 = 58¶
- REG_OCVTAB11 = 59¶
- REG_OCVTAB12 = 60¶
- REG_OCVTAB13 = 61¶
- REG_OCVTAB14 = 62¶
- REG_OCVTAB15 = 63¶
- REG_OCVTAB2 = 50¶
- REG_OCVTAB3 = 51¶
- REG_OCVTAB4 = 52¶
- REG_OCVTAB5 = 53¶
- REG_OCVTAB6 = 54¶
- REG_OCVTAB7 = 55¶
- REG_OCVTAB8 = 56¶
- REG_OCVTAB9 = 57¶
- REG_RELAX_COUNT = 22¶
- REG_RELAX_MAX = 23¶
- REG_VM_ADJ_H = 12¶
- REG_VM_ADJ_L = 26¶
- RELAX_MAX_DEFAULT = 120¶
philander.stc3117 module¶
A module to provide base classes and data types for gas gauge driver implementations.
- class STC3117[source]¶
Bases:
STC311xDriver implementation for the stc3117 gas gauge.
Info about this chip can be found at ST microelectronics https://www.st.com/en/power-management/stc3117.html
- MODEL_ID = 3117¶
- getBatteryCurrentAvg()[source]¶
Retrieves the average battery current.
The average is taken over some time interval, e.g. 2 seconds. The length of the time window is at the discretion of the implementation and cannot be adjusted by the caller.
See also:
getBatteryCurrent()- Returns:
A non-negative integer value [micro A] or
Current.invalidto indicate that this information could not be retrieved.- Return type:
- getChangeRate()[source]¶
Retrieves the SOC change rate in milli C.
Remember that 1C = 100% in 1 hour. This information may be used to estimate the remaining stamina or how long the charging process will still take. :return: A SOC change rate (non-negative) or :attr:’SOCChangeRate.invalid` to indicate that this information could not be retrieved. :rtype: SOCChangeRate
philander.stc3117_reg module¶
Register definitions for the STC311x family battery gas gauges.
Definition of registers and default values for the above-mentioned chips. Externalized, just for clarity of the source code.
- class STC3117_Reg[source]¶
Bases:
STC311x_RegDefinition of the STC3115 exclusive registers and values.
Registers and content interpretation specific to this chip. It complements those definitions inherited from the base class.
- CHIP_ID = 22¶
- CMONIT_MAX_DEFAULT = 120¶
- CTRL_UVLOD = 128¶
- MODE_BATD_PU = 2¶
- MODE_DEFAULT = 11¶
- MODE_FORCE_CD = 4¶
- MODE_OFF = 2¶
- OCV0_DEFAULT = 6000¶
- OCV10_DEFAULT = 7024¶
- OCV11_DEFAULT = 7089¶
- OCV12_DEFAULT = 7144¶
- OCV13_DEFAULT = 7256¶
- OCV14_DEFAULT = 7411¶
- OCV15_DEFAULT = 7593¶
- OCV1_DEFAULT = 6438¶
- OCV2_DEFAULT = 6578¶
- OCV3_DEFAULT = 6651¶
- OCV4_DEFAULT = 6718¶
- OCV5_DEFAULT = 6765¶
- OCV6_DEFAULT = 6813¶
- OCV7_DEFAULT = 6838¶
- OCV8_DEFAULT = 6869¶
- OCV9_DEFAULT = 6913¶
- REG_AVG_CURRENT = 11¶
- REG_AVG_CURRENT_H = 12¶
- REG_AVG_CURRENT_L = 11¶
- REG_CC_ADJ = 27¶
- REG_CC_ADJ_H = 28¶
- REG_CC_ADJ_L = 27¶
- REG_CMONIT_COUNT = 22¶
- REG_CMONIT_MAX = 23¶
- REG_OCVTAB0 = 48¶
- REG_OCVTAB0_H = 49¶
- REG_OCVTAB0_L = 48¶
- REG_OCVTAB1 = 50¶
- REG_OCVTAB10 = 68¶
- REG_OCVTAB10_H = 69¶
- REG_OCVTAB10_L = 68¶
- REG_OCVTAB11 = 70¶
- REG_OCVTAB11_H = 71¶
- REG_OCVTAB11_L = 70¶
- REG_OCVTAB12 = 72¶
- REG_OCVTAB12_H = 73¶
- REG_OCVTAB12_L = 72¶
- REG_OCVTAB13 = 74¶
- REG_OCVTAB13_H = 75¶
- REG_OCVTAB13_L = 74¶
- REG_OCVTAB14 = 76¶
- REG_OCVTAB14_H = 77¶
- REG_OCVTAB14_L = 76¶
- REG_OCVTAB15 = 78¶
- REG_OCVTAB15_H = 79¶
- REG_OCVTAB15_L = 78¶
- REG_OCVTAB1_H = 51¶
- REG_OCVTAB1_L = 50¶
- REG_OCVTAB2 = 52¶
- REG_OCVTAB2_H = 53¶
- REG_OCVTAB2_L = 52¶
- REG_OCVTAB3 = 54¶
- REG_OCVTAB3_H = 55¶
- REG_OCVTAB3_L = 54¶
- REG_OCVTAB4 = 56¶
- REG_OCVTAB4_H = 57¶
- REG_OCVTAB4_L = 56¶
- REG_OCVTAB5 = 58¶
- REG_OCVTAB5_H = 59¶
- REG_OCVTAB5_L = 58¶
- REG_OCVTAB6 = 60¶
- REG_OCVTAB6_H = 61¶
- REG_OCVTAB6_L = 60¶
- REG_OCVTAB7 = 62¶
- REG_OCVTAB7_H = 63¶
- REG_OCVTAB7_L = 62¶
- REG_OCVTAB8 = 64¶
- REG_OCVTAB8_H = 65¶
- REG_OCVTAB8_L = 64¶
- REG_OCVTAB9 = 66¶
- REG_OCVTAB9_H = 67¶
- REG_OCVTAB9_L = 66¶
- REG_SOCTAB0 = 80¶
- REG_SOCTAB1 = 81¶
- REG_SOCTAB10 = 90¶
- REG_SOCTAB11 = 91¶
- REG_SOCTAB12 = 92¶
- REG_SOCTAB13 = 93¶
- REG_SOCTAB14 = 94¶
- REG_SOCTAB15 = 95¶
- REG_SOCTAB2 = 82¶
- REG_SOCTAB3 = 83¶
- REG_SOCTAB4 = 84¶
- REG_SOCTAB5 = 85¶
- REG_SOCTAB6 = 86¶
- REG_SOCTAB7 = 87¶
- REG_SOCTAB8 = 88¶
- REG_SOCTAB9 = 89¶
- REG_VM_ADJ = 29¶
- REG_VM_ADJ_H = 30¶
- REG_VM_ADJ_L = 29¶
- SOC0_DEFAULT = 0¶
- SOC10_DEFAULT = 123¶
- SOC11_DEFAULT = 130¶
- SOC12_DEFAULT = 140¶
- SOC13_DEFAULT = 160¶
- SOC14_DEFAULT = 180¶
- SOC15_DEFAULT = 200¶
- SOC1_DEFAULT = 6¶
- SOC2_DEFAULT = 12¶
- SOC3_DEFAULT = 20¶
- SOC4_DEFAULT = 30¶
- SOC5_DEFAULT = 40¶
- SOC6_DEFAULT = 50¶
- SOC7_DEFAULT = 60¶
- SOC8_DEFAULT = 80¶
- SOC9_DEFAULT = 100¶
philander.stc311x module¶
A module to provide base classes and data types for ST gas gauge driver implementations.
- class OperatingMode(*values)[source]¶
Bases:
Enum- opModeMixed = 4¶
- opModeStandby = 2¶
- opModeUnknown = 1¶
- opModeVoltage = 3¶
- class STC311x[source]¶
Bases:
GasGauge,SerialBusDevice,InterruptableBase implementation for the stc311x gas gauge chip family.
A gas gauge allows to keep track of the state of charge (SOC), remaining capacity, current voltage etc. of a battery. Info about the specific gas gauge ICs can be found at https://www.st.com/en/power-management/stc3115.html or https://www.st.com/en/power-management/stc3117.html
- ADDRESSES_ALLOWED = [112]¶
- ALARM_SOC_DEFAULT = 1¶
- ALARM_VOLTAGE_DEFAULT = 3000¶
- BAT_CAPACITY_DEFAULT = 800¶
- BAT_IMPEDANCE_DEFAULT = 200¶
- MODEL_ID = None¶
- POR_TIMEOUT = 3¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address; default isADDRESSES_ALLOWED[0].Gasgauge.SenseResistor
intCurrent sense resistor Rs in mOhm [5…50]; default isRSENSE_DEFAULTGasgauge.battery.capacity
intBattery capacity in mAh; default isBAT_CAPACITY_DEFAULTGasgauge.battery.impedance
intBattery impedance in mOhm; default isBAT_IMPEDANCE_DEFAULTGasgauge.alarm.soc
intSOC alarm threshold [%]; default isALARM_SOC_DEFAULTGasgauge.alarm.voltage
intVoltage alarm threshold [mV]; default isALARM_VOLTAGE_DEFAULTGasgauge.relax.current
intCurrent monitoring threshold [uA]; default isRELAX_CURRENT_DEFAULTGasgauge.relax.timer
intCurrent monitoring timer count [s]; default isRELAX_TIMER_DEFAULTGasgauge.int.gpio.* ALM pin configuration; See
GPIO.Params_init().Also see:
Gasgauge.Params_init(),SerialBusDevice.Params_init(),GPIO.Params_init().
- RELAX_CURRENT_DEFAULT = 5000¶
- RELAX_TIMER_DEFAULT = 480¶
- RSENSE_DEFAULT = 10¶
- close()[source]¶
Shut down the device after usage.
This method should be called when the device is not used, anymore, e.g. as part of the application exit procedure. The following steps are executed:
close I2C-Bus connection
close GPIO pin for interrupts
After return, the device can still be re-used, by calling
open()again.Also see:
GPIO.close(),Module.close().
- disableInterrupt()[source]¶
Disables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableInterrupt()[source]¶
Enables the interrupt(s) of the implementing device.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getBatteryCurrent()[source]¶
Retrieves the battery current in micro Ampere at the time this function is executed.
See also:
getBatteryCurrentAvg()- Returns:
A non-negative integer value [micro A] or
Current.invalidto indicate that this information could not be retrieved.- Return type:
- getBatteryVoltage()[source]¶
Retrieves the battery voltage in milli Volt.
- Returns:
A on-negative integer value [mV] or
Voltage.invalidto indicate that this information could not be retrieved.- Return type:
- getInfo()[source]¶
Retrieves an information block from the gas gauge device.
Typically, this kind of information is rather static in that, it does not change over time. Usually, this information is somewhat unique for the charger origin, manufacturing date, hardware/firmware revision, product/model ID, chip series and alike. For that reason, this function can be used to see, if communication works reliably.
For more dynamic meta-information see
getStatus().The method returns both, an instance of
Info, carrying the information block as well as an error code, indicating success or failure. The info block shall be evaluated only, if the method returned successfully. Even then, the caller should still evaluate thevalidityattribute of the returned info block to find out, which of the information is actually valid.
- getStateOfCharge()[source]¶
Retrieves the state of charge.
That is the fraction of electric energy from the total capacity, that is still or already stored in the battery. This information is valid for both, the charging as well as the discharging process.
- Returns:
A percentage [0…100] value or
Percentage.invalidto indicate that this information could not be retrieved.- Return type:
- getStatus(statusID)[source]¶
Retrieves status data from the device.
Typically, this kind of information is more dynamic in that, it changes (much) over time. Usually, it further describes the IC’s current shape and condition, such as the availability of new data, the cause of an interrupt or the status of certain hardware functions. Also, secondary measurements such as the die temperature could be subject to status data.
For more static meta-information see
getInfo().The given
statusIDparameter specifies, exactly which status information should be retrieved. Its type and interpretation depends on the implementation.The method returns both, resulting status data and an error code indicating success or failure. The status data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the status data depends on the specific implementation.
- Parameters:
statusID (int) – Identifies the status information to be retrieved.
- Returns:
The status object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Opens the instance and sets it in a usable state.
Allocate necessary hardware resources and configure user-adjustable parameters to meaningful defaults. In this case the registers for the specific chip are defined and optionally the GPIO-Pin for interrupts is initialized. This function must be called prior to any further usage of the instance. Involving it in the system ramp-up procedure could be a good choice. After usage of this instance is finished, the application should call
close().- Parameters:
paramDict (paramDict(str, object)) – Configuration parameters as obtained from
Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- registerInterruptHandler(onEvent='EventInt1', callerFeedBack=None, handler=None)[source]¶
Registers a handling routine for interrupt notification.
The caller feedback will be directly passed to the handling routine. In case that multiple different interrupts are handled by the same routine, this parameter may be used to distinguish them and remember the source of interrupt.
The handler should be a method or function that expects at least one argument. That first argument will be the
callerFeedBackobject given as the above-mentioned parameter. Further parameters may follow, as they were handed in to the_fire()method. The handler’s signature should look like this:def handlingRoutine( feedback, *args) -> None:Note that the
onEventparameter is not passed to the handler. It is eaten up by_fire()and just controls the selection of the handling routine called.Depending on the parameter, this method behaves as follows:
onEvent
handler
semantics and action
Event.evtNone
None
All interrupts are disabled and all registrations cleared.
Event.evtNone
valid
De-register the given handler from all events {Event.evtInt1|2|Any}.
Event.evtInt1|2|*
None
De-register all handlers from the given event.
Event.evtInt1|2|*
valid
Enable interrupt and register this handler for the given event.
Event.evtAny
None
Clear the
Event.evtAnyregistrations, only!Event.evtAny
valid
Register the handler for any event {Event.evtInt1|2}.
For this method,
Event.evtNoneis a semantic equivalent toNone.- Parameters:
onEvent (int) – Exactly one of the event mnemonics defined by the
interruptable.Eventenumeration.callerFeedBack (object) – Arbitrary object not evaluated here, but passed on to the handler when an event is fired.
handler – The handling routine to be called as an immediate response to an event.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- reset()[source]¶
Soft resets the device.
The device is in some default state, afterwards and must be re-configured according to the application’s needs. :return: An error code indicating either success or the reason of failure. :rtype: ErrorCode
philander.stc311x_reg module¶
Register definitions for the STC311x family battery gas gauges.
Definition of registers and default values for the above-mentioned chips. Externalized, just for clarity of the source code.
- class STC311x_Reg[source]¶
Bases:
objectDefinition of common registers and values.
Base class to define register addresses and content values common to all members of the chip family.
- CC_CNF_DEFAULT = 395¶
- CHIP_ID = None¶
- CTRL_ALM_SOC = 32¶
- CTRL_ALM_VOLT = 64¶
- CTRL_BATFAIL = 8¶
- CTRL_DEFAULT = 1¶
- CTRL_GG_RST = 2¶
- CTRL_GG_VM = 4¶
- CTRL_IO0DATA = 1¶
- CTRL_PORDET = 16¶
- IDX_RAM_CC_CNF = 3¶
- IDX_RAM_CC_CNF_H = 4¶
- IDX_RAM_CC_CNF_L = 3¶
- IDX_RAM_CRC = 15¶
- IDX_RAM_SOC = 1¶
- IDX_RAM_SOC_H = 2¶
- IDX_RAM_SOC_L = 1¶
- IDX_RAM_TEST = 0¶
- IDX_RAM_UNUSED_BEGIN = 7¶
- IDX_RAM_UNUSED_END = 14¶
- IDX_RAM_VM_CNF = 5¶
- IDX_RAM_VM_CNF_H = 6¶
- IDX_RAM_VM_CNF_L = 5¶
- MODE_ALM_ENA = 8¶
- MODE_DEFAULT = 9¶
- MODE_FORCE_CC = 32¶
- MODE_FORCE_VM = 64¶
- MODE_GG_RUN = 16¶
- MODE_OFF = 0¶
- MODE_VMODE = 1¶
- RAM_SIZE = 16¶
- RAM_TEST = 178¶
- REG_ALARM_SOC = 19¶
- REG_ALARM_VOLTAGE = 20¶
- REG_CC_CNF = 15¶
- REG_CC_CNF_H = 16¶
- REG_CC_CNF_L = 15¶
- REG_COUNTER = 4¶
- REG_COUNTER_H = 5¶
- REG_COUNTER_L = 4¶
- REG_CTRL = 1¶
- REG_CURRENT = 6¶
- REG_CURRENT_H = 7¶
- REG_CURRENT_L = 6¶
- REG_CURRENT_THRES = 21¶
- REG_ID = 24¶
- REG_MODE = 0¶
- REG_OCV = 13¶
- REG_OCV_H = 14¶
- REG_OCV_L = 13¶
- REG_RAM0 = 32¶
- REG_RAM1 = 33¶
- REG_RAM10 = 42¶
- REG_RAM11 = 43¶
- REG_RAM12 = 44¶
- REG_RAM13 = 45¶
- REG_RAM14 = 46¶
- REG_RAM15 = 47¶
- REG_RAM2 = 34¶
- REG_RAM3 = 35¶
- REG_RAM4 = 36¶
- REG_RAM5 = 37¶
- REG_RAM6 = 38¶
- REG_RAM7 = 39¶
- REG_RAM8 = 40¶
- REG_RAM9 = 41¶
- REG_RAM_FIRST = 32¶
- REG_RAM_LAST = 47¶
- REG_SOC = 2¶
- REG_SOC_H = 3¶
- REG_SOC_L = 2¶
- REG_TEMPERATURE = 10¶
- REG_VM_CNF = 17¶
- REG_VM_CNF_H = 18¶
- REG_VM_CNF_L = 17¶
- REG_VOLTAGE = 8¶
- REG_VOLTAGE_H = 9¶
- REG_VOLTAGE_L = 8¶
- VM_CNF_DEFAULT = 321¶
philander.sysfactory module¶
A system convergence layer for smbus, smbus2, periphery or simulative implementation.
The factory class provides implementations for hardware resources like serial bus or GPIO pins. This unifies the APIs provided by packages like smbus, smbus2, periphery or gpiozero etc.
- class SysFactory[source]¶
Bases:
objectAs a factory, provide implementations for specific hardware resources.
- static autoDetectProvider(dependencies, fallback=SysProvider.NONE)[source]¶
Automatically detect a eligible provider.
Test the given dependencies and for the first available, return the associated provider mnemonic.
The dependencies are given as a list of constellations to check. Each entry of that list is a tuple of (SysProvider Mnemonics, module name, class name) such as in (SysProvider.PERIPHERY, “periphery”, “I2C”).
The fallback parameter is to override SysProvider.NONE in case none of the dependencies is fulfilled.
- Parameters:
dependencies (list) – List of tuples describing the supported libs.
fallback (SysProvider) – Value to be returned, if none of the dependencies is fulfilled.
- Returns:
Mnemonic to identify the first dependency fulfilled. SysProvider.NONE or the given fallback, if no matching dependency could be found.
- Return type:
- static createInstance(provider, implementations)[source]¶
Instantiate a certain implementation.
Create an instance of an implementation identified by a provider mnemonics.
The given provider parameter is the key argument into the dictionary of the implementations. It could be the result of calling
autoDetectProvider().The implementations are given as a dictionary translating a SysProvider type key into a tuple (pair) -value comprised of module name and class name. For example:
SysProvider.PERIPHERY: (“philander.serialbus_periphery”, “_SerialBus_Periphery”)
Instantiation is done by calling the empty constructor of the identified class.
- Parameters:
provider (SysProvider) – The provider mnemonics identifying the implementation to be instantiated.
implementations (dict) – The dictionary describing where to find the specific class that must be instantiated, for a given provider key.
- Returns:
An object, which is an instance of the specific implementation or None in case of an error.
- Return type:
object
- class SysProvider(*values)[source]¶
Bases:
EnumMnemonic designator for a lower-level lib, package or system environment to rely the implementation on.
- AUTO = 2¶
Auto-detect best matching lib/package.
- COMPOSITE = 4¶
Supported by a matching upper-level driver API, such as ADC via SPI.
- GPIOZERO = 5¶
GPIO zero implementation for raspberry pi (https://gpiozero.readthedocs.io/en/latest/).
- MICROPYTHON = 6¶
MicroPython environment (https://docs.micropython.org).
- NONE = 1¶
No low-level API available.
- PERIPHERY = 7¶
Python periphery lib (https://pypi.org/project/python-periphery/).
- RPIGPIO = 8¶
RaspberryPi GPIO lib (https://pypi.org/project/RPi.GPIO/).
- SIM = 3¶
Built-in hardware simulation.
- SMBUS2 = 9¶
System Management Bus v2 (SMBUS2) implementation (https://pypi.org/project/smbus2/).
philander.systypes module¶
Data types commonly used throughout the system and not associated with any specific module.
- class ErrorCode(*values)[source]¶
Bases:
EnumData type to indicate either a successful completion or the reason why some function or operation failed.
- errBusy = 9¶
- errCancelled = 18¶
- errCorruptData = 13¶
- errExhausted = 8¶
- errFailure = 20¶
- errFewData = 7¶
- errInadequate = 2¶
- errInitFailed = 23¶
- errInternal = 5¶
- errInvalidParameter = 1¶
- errLowLevelFail = 24¶
- errMalfunction = 21¶
- errMoreData = 6¶
- errNotImplemented = 3¶
- errNotInited = 22¶
- errNotSupported = 4¶
- errOk = 0¶
- errOverflow = 14¶
- errPostProc = 17¶
- errPreProc = 16¶
- errResourceConflict = 12¶
- errSpecRange = 11¶
- errStopped = 25¶
- errSuspended = 19¶
- errUnderrun = 15¶
- class Info[source]¶
Bases:
objectContainer type to wrap chip information data as retrieved from calls of
Sensor.getInfo().This is rather static information not changing too much over time.
- validAnything = 255¶
- validChipID = 1¶
- validManufacID = 16¶
- validModelID = 8¶
- validNothing = 0¶
- validRevMajor = 2¶
- validRevMinor = 4¶
- validSerialNum = 32¶
- class RunLevel(*values)[source]¶
Bases:
EnumOperating mode that the CPU may run in.
Includes the normal (active) mode as well as a bunch of power-saving run levels.
- active = 0¶
- deepSleep = 6¶
- idle = 1¶
- leastFunctional = 7¶
- leastPowerSave = 1¶
- mostFunctional = 1¶
- mostPowerSave = 7¶
- nap = 4¶
- relax = 2¶
- shutdown = 7¶
- sleep = 5¶
- snooze = 3¶
- standby = 3¶
philander.thermometer module¶
Abstract interface for temperature sensors accessible via serial communication.
Provide an API to abstract from temperature measurement devices.
- class Data(temperature: PreciseTemperature = 0)[source]¶
Bases:
objectContainer type to wrap a thermometer’s primary measurement result.
Measurement data should always be expressed as a signed value in degree Celsius.
- temperature: PreciseTemperature = 0¶
philander.vibrasense module¶
Support module for the Mikro-e Vibra sense click board.
This board carries a Sencera 801S vibration spring device as its core element.
- class VibraSense[source]¶
Bases:
EventEmitter,Sensor,InterruptableVibra sense driver implementation.
More information on the Mikroelektronika Vibra sense click (MIKROE-1927) board are available at: https://www.mikroe.com/vibra-sense-click
The functional core element is a Sencera 801S vibration spring. More information on that device can be found at: https://www.tme.eu/de/details/sens-801s/drucksensoren/sencera/801s/
- DEBOUNCE_MS = 0¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
Sensor.dataRate
intData rate in Hz; default is set bySensor.Params_init().VibraSense.int.gpio.*
configuration of the INT pin, as documented at
GPIO.Params_init(), overrides VibraSense.slotVibraSense.enable.gpio.*
configuration of the EN pin, as documented at
GPIO.Params_init(), optional.VibraSense.slot
int=[1|2]the click board’s slot, alternative for int+enable pin configuration;SLOT_DEFAULT.Also see:
Sensor.Params_init(),SerialBusDevice.Params_init().
- SLOT1_PIN_ENABLE = 29¶
- SLOT1_PIN_SIGNAL = 31¶
- SLOT2_PIN_ENABLE = 32¶
- SLOT2_PIN_SIGNAL = 37¶
- SLOT_DEFAULT = 1¶
- close()[source]¶
Close this instance and release associated hardware resources.
This is the counterpart of
open(). Upon return, further usage of this instance is prohibited and may lead to unexpected results. The instance can be re-activated by callingopen(), again.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getLatestData()[source]¶
Retrieves the most recent data available and returns immediately.
This function will never block, but may read data that has been read before, already. More precisely, the data returned was valid / taken at a moment in the past, which is as close as possible to the current point in time, (including right NOW).
For sensors which deliver measurements continuously in time, there is no semantic difference to
getNextData().In contrast, for sensors, which provide measurements discretely at certain time intervals, this function is expected to deliver the last measurement point - without any waiting. Typically, this requires some kind of buffering. at the sensor or driver side.
The method is synchronous in that, it hands out the resulting data to the caller upon return. In fact, this method returns both, the measurement result and an error code signaling success or failure. The measurement data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the returned measurement data is specific to the individual sensor and driver implementation. The application may rely on values scaled to reasonable units, such as temperatures in degree Celsius, distances in meters and pressures in Pascal - or multiples and fractions thereof.
Also see:
getNextData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getNextData()[source]¶
Retrieves the next data, possibly waiting for the current measurement interval to expire.
This function may introduce a blocking wait, but always returns with fresh, new data never read before. The measurement is taken / valid either immediately or as early as possible in the future.
For sensors, that deliver data continuously in time, there is no difference to
getLatestData().For sensors that sample data at certain time intervals, this function very likely includes some waiting delay until the next measurement is due.
In either case, this function blocks until the measurement is retrieved and hands out data to the application upon return. In that sense, this is a synchronous function.
The return is twofold: the measurement result and an error code signaling success or failure. The measurement data should be considered valid only, if the error code indicates a successful execution of this method.
The type and interpretation of the returned measurement data is specific to the individual sensor and driver implementation. The application may rely on values scaled to reasonable units or multiples and fractions thereof.
Also see:
getLatestData().- Returns:
The measurement data object and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Opens an instance and puts it into a usable state.
Configures the sensor by reading the supported parameters or applying default values and calling
configure(). Also see:module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as obtained from
module.Module.Params_init(), possibly.- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.vibrasense2 module¶
Support module for the Mikro-e Vibra sense 2 click board.
This board carries a TE LDT0-028K Piezo Film sensor as its core element.
- class VibraSense2[source]¶
Bases:
EventEmitter,Sensor,Interruptable,SerialBusDeviceVibra sense 2 driver implementation.
More information on the Mikroelektronika Vibra sense 2 click (MIKROE-4355) board are available at: https://www.mikroe.com/vibra-sense-2-click
The functional core element is a TE LDT0-028K Piezo Film sensor. More information on that device can be found at: https://www.te.com/deu-de/product-CAT-PFS0006.html
- ADDRESSES_ALLOWED = [77]¶
- classmethod Params_init(paramDict)[source]¶
Initializes configuration parameters with defaults.
The following settings are supported:
Key name
Value type, meaning and default
SerialBusDevice.address
intI2C serial device address, must beADDRESS; default isADDRESS.Also see:
Sensor.Params_init(),SerialBusDevice.Params_init().
- close()[source]¶
Close this instance and release associated hardware resources.
Also see:
philander.module.Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- getLatestData()[source]¶
Retrieve the latest data available, immediately.
The measurement data is a single 12 bit integer value in the range [0…4095]. It is proportional to the sensor element’s (LDT0) output voltage and can be interpreted as the vibration intensity or bending deflection. Note that a rest condition does not necessarily correspond to a value of zero.
Also see:
philander.sensor.Sensor.getLatestData().- Returns:
The measurement data as a 16bit integer and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- getNextData()[source]¶
Retrieve the next data, possibly with a delay.
Also see:
philander.sensor.Sensor.getNextData().- Returns:
The measurement data as a 16bit integer and an error code indicating either success or the reason of failure.
- Return type:
Object, ErrorCode
- open(paramDict)[source]¶
Opens an instance and puts it into a usable state.
Also see:
philander.module.Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.voltmeter module¶
Driver implementation for a simple ADC-based voltage monitor and gas-gauge.
- class Voltmeter(paramDict)[source]¶
-
Driver for a generic ADC-based voltmeter.
- DEFAULT_RANGE_MAX = 3300¶
- DEFAULT_RANGE_MIN = 2500¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
The following settings are supported:
Key name
Value type, meaning and default
Voltmeter.range.max
intMaximum voltage in mV, maps to 100%; default isDEFAULT_RANGE_MAX.Voltmeter.range.min
intMinimum voltage in mV, mapped to 0%; default isDEFAULT_RANGE_MIN.Voltmeter.gpio.direction
see
GPIO.Params_init(); default isGPIO.DIRECTION_IN.Voltmeter.gpio.trigger
see
GPIO.Params_init(); default isGPIO.TRIGGER_EDGE_FALLING.Voltmeter.gpio.bounce
see
GPIO.Params_init(); default isGPIO.BOUNCE_NONE.All other Voltmeter.gpio.*
as documented at
GPIO.Params_init().Also see:
Module.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary of settings.
- Returns:
none
- Return type:
None
- close()[source]¶
Close this instance and release hardware resources.
Also see:
Module.close().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- open(paramDict)[source]¶
Initialize an instance and prepare it for use.
Also see:
Module.open().- Parameters:
paramDict (dict(str, object)) – Configuration parameters as possibly obtained from
Params_init().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
philander.watchdog module¶
Module to describe objects that provide wath dog capabilities.
- class Watchdog[source]¶
Bases:
objectInterface to define watch dog related methods.
- INTERVAL_MS_DEFAULT = 1000¶
- classmethod Params_init(paramDict)[source]¶
Initialize parameters with their defaults.
If the implementing class supports the
Moduleinterface, it can use this method to fill commonly supported options.The following settings are supported:
Key name
Value type, meaning and default
Watchdog.Interval
intWatch dog interval in milliseconds; default isINTERVAL_MS_DEFAULT.Also see:
Module.Params_init().- Parameters:
paramDict (dict(str, object)) – Dictionary mapping option names to their respective values.
- Returns:
none
- Return type:
None
- clearWatchdog()[source]¶
Clear the watch dog.
This is the implementation of the acknowledge mechanism. Calling this function is necessary for an application to prevent the watch dog from elapsing. Note that this method does not start the watch dog, when it is disabled.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- clearWatchdogElapsed()[source]¶
Clear the elapsed flag.
The application should call this function after it observed that the watch dog interval time expired.
Also see:
isWatchdogElapsed().- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- disableWatchdog()[source]¶
Disable the watch dog and stop it from running, immediately.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- enableWatchdog()[source]¶
Enable and restart the watch dog.
- Returns:
An error code indicating either success or the reason of failure.
- Return type:
- isWatchdogElapsed()[source]¶
Check, whether the configured time interval has expired, or not.
By calling this function, an application may observe the expiration without using the interrupt mechanism. Note, that this flag is not cleared automatically. The caller would have to use
clearWatchdogElapsed()for this purpose.Returns
ErrorCode.errOk, if the watch dog has elapsed,ErrorCode.errUnavailable, if it is not elapsed, yet, and any other value to indicate the reason, why this information could not be retrieved.- Returns:
An error code indicating the result.
- Return type:
- isWatchdogRunning()[source]¶
Check, whether the watchdog is currently running or not.
Returns
ErrorCode.errOk, if the watch dog is running,ErrorCode.errUnavailable, if it is not running and any other value to indicate the reason, why this information could not be retrieved.- Returns:
An error code indicating the result.
- Return type:
Module contents¶
A driver collection for embedded system components, such as sensors or battery chargers.