philander package

Subpackages

Submodules

philander.accelerometer module

Abstract interface for accelerometer sensors accessible via serial communication.

Provide an API to abstract from acceleration measurement devices.

class Accelerometer[source]

Bases: Sensor

Abstract base class for digital accelerometers.

class Activity(value)[source]

Bases: Enum

Identifies 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(value)[source]

Bases: Flag

Data 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(type: ConfigItem, value: int = 1, fifo: Optional[CfgFifo] = None, rateMode: Optional[CfgRateMode] = None, eventCondition: Optional[CfgInterrupt] = None)[source]

Bases: Configuration

Data class to describe common configuration settings.

Use the parental class sensor.Configuration.type attribute 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

axes: AxesSign = 4
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, y: int, z: int)[source]

Bases: object

Container 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
y: int
z: int
class EventContext(control: EventContextControl = EventContextControl.evtCtxtCtrl_getFirst, remainInt: int = 0, source: EventSource = EventSource.none, data: Data = (0, 0, 0), status: int = 0)[source]

Bases: EventContext

Data class holding the context information of an event (interrupt).

Use the source attribute to de-multiplex the inner data items.

data: Data = (0, 0, 0)
source: EventSource = 0
status: int = 0
class EventSource(value)[source]

Bases: Flag

Data 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(value)[source]

Bases: Enum

Data 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(value)[source]

Bases: Enum

Mnemonic type to identify different types of sampling techniques, such as averaging, normal or over-sampling.

OSR2 = 3
OSR4 = 4
average = 1
normal = 2
class StatusID(value)[source]

Bases: Enum

Data class to comprise different types of status information.

NVM = 12
activity = 6
dataReady = 2
dieTemp = 1
error = 5
fifo = 4
highG = 8
highSlope = 9
interrupt = 3
orientation = 10
sensorTime = 13
stepCount = 7
tap = 11
class Tap(value)[source]

Bases: Flag

Data class to identify different types of tap.

A tap should be understood as a quick finger tip onto some touch screen to simulate the click of a mouse.

double = 2
none = 0
single = 1
triple = 4

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: object

Unified 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 pattern parameter. 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:

ErrorCode

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 direction parameter may be used to indicate the direction of the operation. Interpretation of left/right or positive/negative etc. is up to the implementation.

The strengthIntensity parameter 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 onSpeedDuty may 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 ctrlInterval parameter 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 durationLengthCycles is 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:

ErrorCode

stopOperation()[source]

Immediately stops the current operation.

See also: startOperation().

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

class Direction(value)[source]

Bases: Enum

Data class to represent the direction that an actuator can move to.

back = -1
clockwise = -1
counterclockwise = 1
down = -1
forth = 1
left = 1
negative = -1
positive = 1
right = -1
up = 1

philander.battery module

A module t reflect capabilities and properties of re-chargeable batteries.

class Capacity[source]

Bases: int

Absolute capacity of a battery in mAh

invalid = 65535
class Level(value)[source]

Bases: Enum

Level of a battery in [0…100]%

deepDischarge = 0
empty = 5
full = 90
good = 70
invalid = 255
low = 20
max = 100
medium = 40
min = 0
class Status(value)[source]

Bases: Flag

Container 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.ble module

Abstract interface for sub-systems connected via BlueTooth Low Energy (BLE).

Provide an API to abstract from any type of BLE subsystem.

class BLE[source]

Bases: Module, Interruptable

Implementation of an BLE device or subsystem.

DISCOVERY_TIMEOUT = 5.0

Timeout for the discovery phase, given in seconds.

classmethod Params_init(paramDict)[source]

Initialize parameters with their defaults.

The following settings are supported:

Key name

Value type, meaning and default

BLE.discovery.timeout

int or float Timeout for the BLE discovery phase, given in seconds. DISCOVERY_TIMEOUT

BLE.client.name

string Name of the client device to connect to, given as a string. No default.

BLE.characteristic.uuid

string UUID of the client characteristic, given as a string. No default.

Also see: Module.Params_init().

Parameters:

paramDict (dict(str, object)) – The configuration dictionary.

Returns:

none

Return type:

None

WRITE_NOTIFICATION_TIMEOUT = 0.5

Timeout for a notification response after a GATT write, given in seconds.

close()[source]

Shuts down the instance safely.

Also see: Module.close().

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

couple()[source]

Trigger the procedure to establish a BLE connection.

Return quickly with a success-or-failure indicator for this triggering. Notice on the result of the coupling is given via subscription on the Event.bleDiscovering and Event.bleConnected event.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

decouple()[source]

Trigger the procedure to close a BLE connection.

Return quickly with a success-or-failure indicator for this triggering, i.e. gives ErrorCode.errOk, if the procedure launched, and a failure e.g. when the AU is not coupled. Notice on the result of the decoupling is given via subscription to the Event.bleDisconnected event.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

disableInterrupt()[source]

Disables the interrupt(s) of the implementing device.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

enableInterrupt()[source]

Enables the interrupt(s) of the implementing device.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

getConnectionState()[source]

Retrieve the current BLE connection state.

Returns:

The current connection state.

Return type:

ConnectionState

getEventContext(event, context)[source]

Retrieves more detailed information on an interrupt / event.

isCoupled()[source]

Tell the current coupling status of this instance.

Informs the caller on whether or not the connection with the actuator unit has been established via BLE and is still intact.

Returns ErrorCode.errOk if the unit is coupled, ErrorCode.errUnavailable if it is not coupled and any other value to indicate the reason, why this information could not be retrieved.

Returns:

An error code to indicate, if the remote device is coupled or not.

Return type:

ErrorCode

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:

ErrorCode

setDiscoveryTimeout(timeOut)[source]

Set the BLE discovery timeout.

Discovery phase will definitely end, after the given time has elapsed.

Parameters:

timeOut (int or float) – The timeout, given in seconds.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

writeCharacteristic(data: bytearray, readResponse=False)[source]

Write data to the remote BLE characteristic.

The instance must be coupled to a device, before using this function. The notification content is only valid if requested by readResponse=True and the error code indicates a successful operation.

Parameters:
  • data (bytearray) – The content to write to the characteristic.

  • readResponse (bool) – Whether or not to read back the response notification.

Returns:

A tuple of an error code indicating either success or the reason of failure and the notification data.

Return type:

ErrorCode, bytearray

class ConnectionState(value)[source]

Bases: Enum

Data class to represent BLE connection states

connected = 3
disconnected = 1
discovering = 2
class Event[source]

Bases: object

Data class to represent events, emitted by the BLE device.

bleConnected = 'ble.connected'
bleDisconnected = 'ble.disconnected'
bleDiscovering = 'ble.discovering'

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, _BMA456_Feature, SerialBusDevice, Accelerometer, Interruptable

BMA456 driver implementation.

ADRESSES_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

int I2C serial device address, one of ADRESSES_ALLOWED; default is ADRESSES_ALLOWED [0].

Sensor.dataRange

int Measurement range in milli-g; default corresponds to BMA456_CNT_ACC_RANGE_DEFAULT.

Sensor.dataRate

int Data rate in Hz; default corresponds to BMA456_CNT_ACC_CONF_ODR_DEFAULT.

BMA456.INT1_IO_CTRL

int Content of the INT1_IO_CTRL register; default is BMA456_CNT_INT1_IO_CTRL_DEFAULT.

BMA456.INT2_IO_CTRL

int Content of the INT2_IO_CTRL register; default is BMA456_CNT_INT2_IO_CTRL_DEFAULT.

BMA456.INT1_MAP

int Content of the INT1_MAP register; default is BMA456_CNT_INTX_MAP_DEFAULT.

BMA456.INT2_MAP

int Content of the INT2_MAP register; default is BMA456_CNT_INTX_MAP_DEFAULT.

BMA456.INT_MAP_DATA

int Content of the INT_MAP_DATA register; default is BMA456_CNT_INT_MAP_DATA_DEFAULT.

BMA456.int1.gpio.direction

see GPIO.Params_init(); default is GPIO.DIRECTION_IN.

BMA456.int2.gpio.direction

see GPIO.Params_init(); default is GPIO.DIRECTION_IN.

BMA456.int1.gpio.trigger

see GPIO.Params_init(); default is GPIO.TRIGGER_EDGE_FALLING.

BMA456.int2.gpio.trigger

see GPIO.Params_init(); default is GPIO.TRIGGER_EDGE_FALLING.

BMA456.int1.gpio.bounce

see GPIO.Params_init(); default is GPIO.BOUNCE_NONE.

BMA456.int2.gpio.bounce

see GPIO.Params_init(); default is GPIO.BOUNCE_NONE.

All other BMA456.int1.gpio.* and BMA456.int1.gpio.* settings as documented at GPIO.Params_init().

For the SerialBusDevice.address value, also 0 or 1 can be specified alternatively to the absolute addresses to reflect the level of the SDO pin. 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 calib parameter.

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:

ErrorCode

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.shutdown

  • close 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 config parameter.

Remember, the config parameter should be an instance of accelerometer.Configuration. Its attributes are de-multiplexed by sensor.Configuration.type. The following configuration types are supported:

ConfigItem.rate: The data rate given as an integer value in Hz is expected in Configuration.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 the Configuration.rateMode attribute. 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 in Configuration.rateMode.mValue.

ConfigItem.range: The Configuration.value attribute 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:

  1. Interrupts must be enabled. See enableInterrupt().

  2. That interrupt (event source) must be armed - using this method.

  3. The corresponding interrupt condition must be true.

Note that the armed events are always configured to fire on both interrupt lines interruptable.Event.evtInt1 and interruptable.Event.evtInt2. The bit mask of events to be armed is expected in accelerometer.Configuration.value as an equivalent of accelerometer.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 as tap or lowGTime. The details, such as thresholds and delays, are expected in the given config ‘s accelerometer.Configuration.eventCondition attribute, which is de-multiplexed by its accelerometer.Configuration.CfgInterrupt.event attribute.

Note that the event sources dataReady, fifoWatermark, fifoFull and error are 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:

ErrorCode

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>
dictConfigLength = <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:

ErrorCode

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, see configure() and registerInterruptHandler().

Also see Interruptable.enableInterrupt().

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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 event parameter is an input to tell, which of the two interrupt lined actually fired. On return, the context parameter carries the resulting information. It must be an instance of accelerometer.EventContext, which is semantically multiplexed by its accelerometer.EventContext.source attribute. Depending on that event source indicator, the rest of the structure is filled as follows:

Event source (flag)

Context attribute and data

dataReady

data latest measurement as retrieved by getLatestData()

fifoWatermark, fifoFull

status fifo status retrieved from getStatus() and StatusID.fifo

activity

status activity status retrieved from getStatus() and StatusID.activity

step

status step count retrieved from getStatus() and StatusID.stepCount

highGTime

status high-G status retrieved from getStatus() and StatusID.highG

orientation

status orientation retrieved from getStatus() and StatusID.orientation

tap

status Tap instance depending on feature set and interrupt

A 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.control attribute must be set to interruptable.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

ErrorCode.errOk

Success. Last context info. No more data to retrieve.

ErrorCode.errMoreData

Success. Context is valid. More data to be retrieved.

ErrorCode.errFewData

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:

ErrorCode

getInfo()[source]

Retrieve static information from the sensor chip.

Supported information is Info.validModelID and Info.validChipID.

Also see: Sensor.getInfo().

Returns:

The information object and an error code indicating either success or the reason of failure.

Return type:

Info, ErrorCode

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 3x1 list of signed integers, representing the acceleration in milli-G in the x, y and z direction, respectively.

Also see: Sensor.getLatestData().

Returns:

The measurement data list and an error code indicating either success or the reason of failure.

Return type:

List(int), ErrorCode

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 list of integers representing the acceleration in x, y and z direction in milli-G.

Also see: Sensor.getNextData().

Returns:

The measurement data list and an error code indicating either success or the reason of failure.

Return type:

List(int), ErrorCode

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 register BMA456_REG_TEMPERATURE is 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 the DRDY_ACC bit in BMA456_REG_STATUS

accelerometer.StatusID.interrupt: Give the pending interrupts by reading BMA456_REG_INT_STATUS. This information is cleared until interrupt conditions are fulfilled anew. The result is given as an acceleroometer.EventSource bit 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 reading BMA456_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 registers BMA456_REG_INTERNAL_ERR: BMA456_REG_INTERNAL_STATUS: BMA456_REG_EVENT: BMA456_REG_ERROR in that order.

accelerometer.StatusID.activity: For the wearable and hearable feature set, read the current activity from the BMA456_FSWBL_REG_ACTIVITY_TYPE register and return the result as an instance of Activity. 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 register BMA456_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 the BMA456_FSMM_REG_HIGH_G_OUTPUT register. The result is passed back as an AxesSign bit mask.

accelerometer.StatusID.orientation: For the MM feature set, retrieve the current orientation of the device as read from the BMA456_FSMM_REG_ORIENT_OUTPUT register. The result is given as an Orientation bit mask.

accelerometer.StatusID.tap: For the hearable and MM feature set, give the type of the recently detected tap (single, double etc.) as a Tap bit mask after reading that information from the BMA456_FSHBL_REG_FEAT_OUT and BMA456_FSMM_REG_MULTITAP_OUTPUT registers, 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 at GPIO.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 callerFeedBack object given as the previous parameter. Further parameters may follow, as they were handed in to the _fire() method.

  • If the handler is None then
    • if onEvent is None or .interruptable.Event.evtNone, then the interrupt is disabled and all registrations cleared.

    • otherwise, the callerFeedBack replaces what was previously set for this type of onEvent.

  • If the handler is valid but onEvent is still None or .interruptable.Event.evtNone, then this handler is de-registered. If that was the last/only handler registered, interrupts are disabled.

  • If both, the handler and the onEvent parameters are valid, then the interrupt is enabled and the handler gets registered.

Parameters:
  • onEvent (int) – Exactly one of the event mnemonics defined by the interruptable.Event enumeration.

  • 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:

ErrorCode

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:

ErrorCode

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 to BMA456_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:

ErrorCode

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_CONF and BMA456_REG_ACC_CONF and, 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().

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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.button module

Module to provide access to and control over push buttons.

class Button[source]

Bases: Module, EventEmitter

Generic push button driver class.

LABEL_DEFAULT = 'Button'
classmethod Params_init(paramDict)[source]

Initializes configuration parameters with defaults.

The following settings are supported:

Key name

Value type, meaning and default

Button.label

str; A descriptive string label; LABEL_DEFAULT.

All Button.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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

get()[source]
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:

ErrorCode

setLabel(label)[source]
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.

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

philander.charger module

Abstract base types for implementations of battery chargers.

class Charger[source]

Bases: object

Abstract 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.Status values to indicate battery voltage level or presence or health state.

Returns:

The battery state.

Return type:

battery.Status

getBatteryTempStatus()[source]

Retrieves the battery’s temperature status.

Returns:

A rating code to indicate the temperature rating of the battery element.

Return type:

TemperatureRating

getChargerTempStatus()[source]

Retrieves the charger’s temperature state.

Returns:

A rating code to indicate the temperature rating of the charger chip.

Return type:

TemperatureRating

getChgStatus()[source]

Retrieves the charging phase or status.

Returns:

A charger status code to indicate the current charger status.

Return type:

charger.Status

getDCStatus()[source]

Retrieves the DC supply status.

Returns:

A status code to indicate the DC supply status.

Return type:

DCStatus

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:

ChargerError

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.

Returns:

The information object and an error code indicating either success or the reason of failure.

Return type:

Info, ErrorCode

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:

PowerSrc

isBatteryPresent()[source]

Checks, if the battery is present.

This does not tell anything about whether the battery is charged or not.

Returns ErrorCode.errOk if a battery is present, ErrorCode.errUnavailable if 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:

ErrorCode

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:

ErrorCode

class ChargerError(value)[source]

Bases: Enum

A 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 = 51
class DCStatus(value)[source]

Bases: Enum

Wrapper to hold status information of a DC supply.

off = 1
overvoltage = 4
undervoltage = 2
unknown = 5
valid = 3
class EventContext(control: EventContextControl = EventContextControl.evtCtxtCtrl_getFirst, remainInt: int = 0, source: EventSource = EventSource.none)[source]

Bases: EventContext

Data class holding the context information of an event (interrupt).

Use the source attribute to de-multiplex the inner data items.

source: EventSource = 0
class EventSource(value)[source]

Bases: Flag

Event 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(value)[source]

Bases: Flag

A 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(value)[source]

Bases: Enum

Data 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
class TemperatureRating(value)[source]

Bases: Enum

This type qualitatively describes a temperature, e.g. of a chip.

cold = 2
coldOrHot = 34
cool = 1
coolOrWarm = 17
hot = 32
ok = 0
unknown = 255
warm = 16

philander.configurable module

Module to provide helper classes related to configuration.

class ConfigItem(value)[source]

Bases: Enum

Mnemonic 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: object

Generic 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:

ErrorCode

class Configuration(type: ConfigItem, value: int = 1, fifo: Optional[CfgFifo] = None)[source]

Bases: object

Container type to hold common configuration data.

Instances of this class will be passed to the Configurable.configure() method. Use the type attribute to de-multiplex the inner data attributes.

class CfgFifo(watermark: int = 4, control: int = 0)[source]

Bases: object

control: int = 0
watermark: int = 4
fifo: CfgFifo = None
type: ConfigItem

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: object

A 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 mode attribute.

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 dictiionary 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.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)[source]

Bases: object

Event context type to detail the context information for an interrupt occurrence.

batStatus: Status = 65535
soc: Percentage = 255
source: EventSource = (<enum.auto object>,)
voltage: Voltage = 65535
class EventSource(value)[source]

Bases: Enum

  • Event source type to detail the reason for an interrupt occurrence.

Not all implementations will support all types of interrupt.

batFail = (<enum.auto object>,)

General battery failure, e.g. battery swapped

hardReset = (<enum.auto object>,)

Power-on reset detected

highSOC = (<enum.auto object>,)

SOC reached a high/full info level

lowSOC = (<enum.auto object>,)

SOC dropped below a threshold

lowVolt = (<enum.auto object>,)

Battery voltage dropped below a threshold

none = (<enum.auto object>,)

No event reason

undervoltage = (<enum.auto object>,)

Brown-out/Lockout due to low voltage

unknown = (<enum.auto object>,)

Unknown event reason

class GasGauge[source]

Bases: object

This 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.invalid to indicate that this information could not be retrieved.

Return type:

Current

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.invalid to indicate that this information could not be retrieved.

Return type:

Current

getBatteryVoltage()[source]

Retrieves the battery voltage in milli Volt.

Returns:

A on-negative integer value [mV] or Voltage.invalid to indicate that this information could not be retrieved.

Return type:

Voltage

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 the validity attribute of the returned info block to find out, which of the information is actually valid.

Returns:

The information object and an error code indicating either success or the reason of failure.

Return type:

Info, ErrorCode

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:

battery.Level

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.invalid to indicate that this information could not be retrieved.

Return type:

Percentage

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 statusID parameter 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

rateSOC(soc)[source]

Convert a continuous SOC percentage into its next-lower battery level predicate.

Does not retrieve any information from the underlying hardware.

Parameters:

soc (Percentage) – The state of charge, given in percent.

Returns:

The next-lower battery level mnemonic.

Return type:

battery.Level

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

class SOCChangeRate[source]

Bases: int

State of charge (SOC) change rate, given in milli-C rate [mC].

Remember 1C = 100% per 1 hour.

invalid = 65535
class StatusID(value)[source]

Bases: Enum

Data class to comprise different types of status information.

batTemp = 1
dieTemp = 2

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, Interruptable

General-purpose I/O abstraction class.

Provide access to and control over the underlying GPIO hardware. For that, an implementing driver module is used. Currently, RPi.GPIO, gpiozero and periphery are supported. 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.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.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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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

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:

ErrorCode

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:

ErrorCode

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.

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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, temperature: PreciseTemperature)[source]

Bases: Data, Data

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

temperature: PreciseTemperature
class HTU21D[source]

Bases: Sensor, SerialBusDevice

HTU21D 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

int I2C serial device address, must be ADDRESS; default is ADDRESS.

Sensor.dataRate

int Data rate in Hz; default is set by Sensor.Params_init().

HTU21D.resolution

int Resolution in bits; default is CFG_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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

class StatusID(value)[source]

Bases: Enum

Data class to comprise different types of status information.

powerOk = 1

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)[source]

Bases: object

Container type to wrap a hygrometer’s primary measurement result.

Measurement data should always be expressed as percentage.

humidity: Percentage

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 represent 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(value)[source]

Bases: Enum

Generic 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 = 2
evtInt1 = 3
evtInt2 = 4
evtNone = 1
class EventContext(control: EventContextControl = EventContextControl.evtCtxtCtrl_getFirst, remainInt: int = 0)[source]

Bases: object

Details or quantifies the reason for an interrupt occurrence.

Will probably be sub-classed to represent specifics of the implementing Interruptable device.

control: EventContextControl = 2
remainInt: int = 0
class EventContextControl(value)[source]

Bases: Enum

Control data to navigate through the list of event context items.

evtCtxtCtrl_clearAll = 1
evtCtxtCtrl_getFirst = 2
evtCtxtCtrl_getLast = 4
evtCtxtCtrl_getNext = 3
evtCtxtCtrl_getPrevious = 5
class Interruptable[source]

Bases: object

Generic 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:

ErrorCode

enableInterrupt()[source]

Enables the interrupt(s) of the implementing device.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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.control attribute must be set to interruptable.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

ErrorCode.errOk

Success. Last context info. No more data to retrieve.

ErrorCode.errMoreData

Success. Context is valid. More data to be retrieved.

ErrorCode.errFewData

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 control attribute must be set to either one of evtCtxtCtrl_[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:

ErrorCode

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 callerFeedBack object given as the previous parameter. Further parameters may follow, as they were handed in to the _fire() method.

  • If the handler is None then
    • if onEvent is None or .interruptable.Event.evtNone, then the interrupt is disabled and all registrations cleared.

    • otherwise, the callerFeedBack replaces what was previously set for this type of onEvent.

  • If the handler is valid but onEvent is still None or .interruptable.Event.evtNone, then this handler is de-registered. If that was the last/only handler registered, interrupts are disabled.

  • If both, the handler and the onEvent parameters are valid, then the interrupt is enabled and the handler gets registered.

Parameters:
  • onEvent (int) – Exactly one of the event mnemonics defined by the interruptable.Event enumeration.

  • 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:

ErrorCode

philander.led module

Module to provide access to and control over LEDs.

class LED[source]

Bases: Module

Generic LED driver class.

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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

off()[source]
on()[source]
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:

ErrorCode

set(brightness)[source]
stop_blinking()[source]

philander.max77960 module

Support module for the MAX77960 USB battery charger.

class MAX77960[source]

Bases: MAX77960_Reg, SerialBusDevice, Charger, Configurable, Interruptable, Watchdog

Driver 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

ADRESSES_ALLOWED = [105]
CFG_B2SOVRC = 'Charger.Current.Batt2Sys'
CFG_B2SOVRC_10000 = 15
CFG_B2SOVRC_3000 = 1
CFG_B2SOVRC_3500 = 2
CFG_B2SOVRC_4000 = 3
CFG_B2SOVRC_4500 = 4
CFG_B2SOVRC_5000 = 5
CFG_B2SOVRC_5500 = 6
CFG_B2SOVRC_6000 = 7
CFG_B2SOVRC_6500 = 8
CFG_B2SOVRC_7000 = 9
CFG_B2SOVRC_7500 = 10
CFG_B2SOVRC_8000 = 11
CFG_B2SOVRC_8500 = 12
CFG_B2SOVRC_9000 = 13
CFG_B2SOVRC_9500 = 14
CFG_B2SOVRC_DEFAULT = 4
CFG_B2SOVRC_DISABLED = 0
CFG_CHGCC = 'Charger.Current.FastCharge'
CFG_CHGCC_100 = 0
CFG_CHGCC_1000 = 13
CFG_CHGCC_1100 = 14
CFG_CHGCC_1200 = 15
CFG_CHGCC_1300 = 16
CFG_CHGCC_1400 = 17
CFG_CHGCC_150 = 1
CFG_CHGCC_1500 = 18
CFG_CHGCC_1600 = 19
CFG_CHGCC_1700 = 20
CFG_CHGCC_1800 = 21
CFG_CHGCC_1900 = 22
CFG_CHGCC_200 = 2
CFG_CHGCC_2000 = 23
CFG_CHGCC_2100 = 24
CFG_CHGCC_2200 = 25
CFG_CHGCC_2300 = 26
CFG_CHGCC_2400 = 27
CFG_CHGCC_250 = 3
CFG_CHGCC_2500 = 28
CFG_CHGCC_2600 = 29
CFG_CHGCC_2700 = 30
CFG_CHGCC_2800 = 31
CFG_CHGCC_2900 = 32
CFG_CHGCC_300 = 4
CFG_CHGCC_3000 = 33
CFG_CHGCC_3100 = 34
CFG_CHGCC_3200 = 35
CFG_CHGCC_3300 = 36
CFG_CHGCC_3400 = 37
CFG_CHGCC_350 = 5
CFG_CHGCC_3500 = 38
CFG_CHGCC_3600 = 39
CFG_CHGCC_3700 = 40
CFG_CHGCC_3800 = 41
CFG_CHGCC_3900 = 42
CFG_CHGCC_400 = 6
CFG_CHGCC_4000 = 43
CFG_CHGCC_4100 = 44
CFG_CHGCC_4200 = 45
CFG_CHGCC_4300 = 46
CFG_CHGCC_4400 = 47
CFG_CHGCC_450 = 7
CFG_CHGCC_4500 = 48
CFG_CHGCC_4600 = 49
CFG_CHGCC_4700 = 50
CFG_CHGCC_4800 = 51
CFG_CHGCC_4900 = 52
CFG_CHGCC_500 = 8
CFG_CHGCC_5000 = 53
CFG_CHGCC_5100 = 54
CFG_CHGCC_5200 = 55
CFG_CHGCC_5300 = 56
CFG_CHGCC_5400 = 57
CFG_CHGCC_5500 = 58
CFG_CHGCC_5600 = 59
CFG_CHGCC_5700 = 60
CFG_CHGCC_5800 = 61
CFG_CHGCC_5900 = 62
CFG_CHGCC_600 = 9
CFG_CHGCC_6000 = 63
CFG_CHGCC_700 = 10
CFG_CHGCC_800 = 11
CFG_CHGCC_900 = 12
CFG_CHGCC_DEFAULT = 7
CFG_CHGIN_ILIM = 'Charger.Current.Input'
CFG_CHGIN_ILIM_DEFAULT = 500
CFG_CHG_CV_PRM = 'Charger.Voltage.ChargeTermination'
CFG_CHG_CV_PRM_2C_8000 = 0
CFG_CHG_CV_PRM_2C_8020 = 1
CFG_CHG_CV_PRM_2C_8040 = 2
CFG_CHG_CV_PRM_2C_8060 = 3
CFG_CHG_CV_PRM_2C_8080 = 4
CFG_CHG_CV_PRM_2C_8100 = 5
CFG_CHG_CV_PRM_2C_8120 = 6
CFG_CHG_CV_PRM_2C_8130 = 7
CFG_CHG_CV_PRM_2C_8140 = 8
CFG_CHG_CV_PRM_2C_8150 = 9
CFG_CHG_CV_PRM_2C_8200 = 10
CFG_CHG_CV_PRM_2C_8220 = 11
CFG_CHG_CV_PRM_2C_8240 = 12
CFG_CHG_CV_PRM_2C_8260 = 13
CFG_CHG_CV_PRM_2C_8280 = 14
CFG_CHG_CV_PRM_2C_8300 = 15
CFG_CHG_CV_PRM_2C_8320 = 16
CFG_CHG_CV_PRM_2C_8340 = 17
CFG_CHG_CV_PRM_2C_8360 = 18
CFG_CHG_CV_PRM_2C_8380 = 19
CFG_CHG_CV_PRM_2C_8400 = 20
CFG_CHG_CV_PRM_2C_8420 = 21
CFG_CHG_CV_PRM_2C_8440 = 22
CFG_CHG_CV_PRM_2C_8460 = 23
CFG_CHG_CV_PRM_2C_8480 = 24
CFG_CHG_CV_PRM_2C_8500 = 25
CFG_CHG_CV_PRM_2C_8520 = 26
CFG_CHG_CV_PRM_2C_8540 = 27
CFG_CHG_CV_PRM_2C_8560 = 28
CFG_CHG_CV_PRM_2C_8580 = 29
CFG_CHG_CV_PRM_2C_8600 = 30
CFG_CHG_CV_PRM_2C_8620 = 31
CFG_CHG_CV_PRM_2C_8640 = 32
CFG_CHG_CV_PRM_2C_8660 = 33
CFG_CHG_CV_PRM_2C_8680 = 34
CFG_CHG_CV_PRM_2C_8700 = 35
CFG_CHG_CV_PRM_2C_8720 = 36
CFG_CHG_CV_PRM_2C_8740 = 37
CFG_CHG_CV_PRM_2C_8760 = 38
CFG_CHG_CV_PRM_2C_8780 = 39
CFG_CHG_CV_PRM_2C_8800 = 40
CFG_CHG_CV_PRM_2C_8820 = 41
CFG_CHG_CV_PRM_2C_8840 = 42
CFG_CHG_CV_PRM_2C_8860 = 43
CFG_CHG_CV_PRM_2C_8880 = 44
CFG_CHG_CV_PRM_2C_8900 = 45
CFG_CHG_CV_PRM_2C_8920 = 46
CFG_CHG_CV_PRM_2C_8940 = 47
CFG_CHG_CV_PRM_2C_8960 = 48
CFG_CHG_CV_PRM_2C_8980 = 49
CFG_CHG_CV_PRM_2C_9000 = 50
CFG_CHG_CV_PRM_2C_9020 = 51
CFG_CHG_CV_PRM_2C_9040 = 52
CFG_CHG_CV_PRM_2C_9060 = 53
CFG_CHG_CV_PRM_2C_9080 = 54
CFG_CHG_CV_PRM_2C_9100 = 55
CFG_CHG_CV_PRM_2C_9120 = 56
CFG_CHG_CV_PRM_2C_9140 = 57
CFG_CHG_CV_PRM_2C_9160 = 58
CFG_CHG_CV_PRM_2C_9180 = 59
CFG_CHG_CV_PRM_2C_9200 = 60
CFG_CHG_CV_PRM_2C_9220 = 61
CFG_CHG_CV_PRM_2C_9240 = 62
CFG_CHG_CV_PRM_2C_9260 = 63
CFG_CHG_CV_PRM_3C_12000 = 0
CFG_CHG_CV_PRM_3C_12030 = 1
CFG_CHG_CV_PRM_3C_12060 = 2
CFG_CHG_CV_PRM_3C_12090 = 3
CFG_CHG_CV_PRM_3C_12120 = 4
CFG_CHG_CV_PRM_3C_12150 = 5
CFG_CHG_CV_PRM_3C_12180 = 6
CFG_CHG_CV_PRM_3C_12210 = 7
CFG_CHG_CV_PRM_3C_12240 = 8
CFG_CHG_CV_PRM_3C_12270 = 9
CFG_CHG_CV_PRM_3C_12300 = 10
CFG_CHG_CV_PRM_3C_12330 = 11
CFG_CHG_CV_PRM_3C_12360 = 12
CFG_CHG_CV_PRM_3C_12390 = 13
CFG_CHG_CV_PRM_3C_12420 = 14
CFG_CHG_CV_PRM_3C_12450 = 15
CFG_CHG_CV_PRM_3C_12480 = 16
CFG_CHG_CV_PRM_3C_12510 = 17
CFG_CHG_CV_PRM_3C_12540 = 18
CFG_CHG_CV_PRM_3C_12570 = 19
CFG_CHG_CV_PRM_3C_12600 = 20
CFG_CHG_CV_PRM_3C_12630 = 21
CFG_CHG_CV_PRM_3C_12660 = 22
CFG_CHG_CV_PRM_3C_12690 = 23
CFG_CHG_CV_PRM_3C_12720 = 24
CFG_CHG_CV_PRM_3C_12750 = 25
CFG_CHG_CV_PRM_3C_12780 = 26
CFG_CHG_CV_PRM_3C_12810 = 27
CFG_CHG_CV_PRM_3C_12840 = 28
CFG_CHG_CV_PRM_3C_12870 = 29
CFG_CHG_CV_PRM_3C_12900 = 30
CFG_CHG_CV_PRM_3C_12930 = 31
CFG_CHG_CV_PRM_3C_12960 = 32
CFG_CHG_CV_PRM_3C_12990 = 33
CFG_CHG_CV_PRM_3C_13020 = 34
CFG_CHG_CV_PRM_3C_13050 = 35
CFG_CHG_CV_PRM_DEFAULT = 0
CFG_CHG_RSTRT = 'Charger.Restart'
CFG_CHG_RSTRT_100 = 0
CFG_CHG_RSTRT_150 = 16
CFG_CHG_RSTRT_200 = 32
CFG_CHG_RSTRT_DEFAULT = 16
CFG_CHG_RSTRT_DISABLED = 48
CFG_COMM_MODE = 'Charger.Comm.Mode'
CFG_COMM_MODE_AUTO = 0
CFG_COMM_MODE_DEFAULT = 0
CFG_COMM_MODE_I2C = 128
CFG_DISIBS = 'Charger.DisIBS'
CFG_DISIBS_DEFAULT = 0
CFG_DISIBS_FET_OFF = 64
CFG_DISIBS_FET_PPSM = 0
CFG_FCHGTIME = 'Charger.Timer.FastCharge'
CFG_FCHGTIME_10H = 7
CFG_FCHGTIME_3H = 1
CFG_FCHGTIME_4H = 2
CFG_FCHGTIME_5H = 3
CFG_FCHGTIME_6H = 4
CFG_FCHGTIME_7H = 5
CFG_FCHGTIME_8H = 6
CFG_FCHGTIME_DEFAULT = 1
CFG_FCHGTIME_DISABLED = 0
CFG_ICHGCC_COOL = 'Charger.Current.Jeita.FastCharge'
CFG_ICHGCC_COOL_DEFAULT = 2
CFG_ICHGCC_COOL_NORMAL = 0
CFG_ICHGCC_COOL_REDUCED = 2
CFG_ITRICKLE = 'Charger.Current.Trickle'
CFG_ITRICKLE_100 = 0
CFG_ITRICKLE_200 = 16
CFG_ITRICKLE_300 = 32
CFG_ITRICKLE_400 = 48
CFG_ITRICKLE_DEFAULT = 0
CFG_JEITA_EN = 'Charger.Jeita'
CFG_JEITA_EN_DEFAULT = 0
CFG_JEITA_EN_OFF = 0
CFG_JEITA_EN_ON = 128
CFG_MINVSYS = 'Charger.Voltage.MinVSys'
CFG_MINVSYS_2C_5535 = 0
CFG_MINVSYS_2C_5740 = 1
CFG_MINVSYS_2C_5945 = 2
CFG_MINVSYS_2C_6150 = 3
CFG_MINVSYS_2C_6355 = 4
CFG_MINVSYS_2C_6560 = 5
CFG_MINVSYS_2C_6765 = 6
CFG_MINVSYS_2C_6970 = 7
CFG_MINVSYS_3C_10148 = 6
CFG_MINVSYS_3C_10455 = 7
CFG_MINVSYS_3C_8303 = 0
CFG_MINVSYS_3C_8610 = 1
CFG_MINVSYS_3C_8918 = 2
CFG_MINVSYS_3C_9225 = 3
CFG_MINVSYS_3C_9533 = 4
CFG_MINVSYS_3C_9840 = 5
CFG_MINVSYS_DEFAULT = 3
CFG_MODE = 'Charger.Mode'
CFG_MODE_ALL_OFF = 0
CFG_MODE_CHRG_DCDC = 5
CFG_MODE_DCDC_ONLY = 4
CFG_MODE_DEFAULT = 5
CFG_MODE_OTG_ONLY = 10
CFG_OTG_ILIM = 'Charger.Current.OTG'
CFG_OTG_ILIM_1200 = 16
CFG_OTG_ILIM_1500 = 24
CFG_OTG_ILIM_2000 = 32
CFG_OTG_ILIM_2250 = 40
CFG_OTG_ILIM_2500 = 48
CFG_OTG_ILIM_3000 = 56
CFG_OTG_ILIM_500 = 0
CFG_OTG_ILIM_900 = 8
CFG_OTG_ILIM_DEFAULT = 24
CFG_PQEN = 'Charger.Prequal'
CFG_PQEN_DEFAULT = 128
CFG_PQEN_OFF = 0
CFG_PQEN_ON = 128
CFG_REGTEMP = 'Charger.Temp.Reg'
CFG_REGTEMP_100 = 24
CFG_REGTEMP_105 = 32
CFG_REGTEMP_110 = 40
CFG_REGTEMP_115 = 48
CFG_REGTEMP_120 = 56
CFG_REGTEMP_125 = 64
CFG_REGTEMP_130 = 72
CFG_REGTEMP_85 = 0
CFG_REGTEMP_90 = 8
CFG_REGTEMP_95 = 16
CFG_REGTEMP_DEFAULT = 48
CFG_STAT_EN = 'Charger.Stat'
CFG_STAT_EN_DEFAULT = 8
CFG_STAT_EN_OFF = 0
CFG_STAT_EN_ON = 8
CFG_TO_ITH = 'Charger.Current.Topoff'
CFG_TO_ITH_100 = 0
CFG_TO_ITH_200 = 1
CFG_TO_ITH_300 = 2
CFG_TO_ITH_400 = 3
CFG_TO_ITH_500 = 4
CFG_TO_ITH_600 = 5
CFG_TO_ITH_DEFAULT = 0
CFG_TO_TIME = 'Charger.Timer.Topoff'
CFG_TO_TIME_10_MIN = 8
CFG_TO_TIME_20_MIN = 16
CFG_TO_TIME_30_MIN = 24
CFG_TO_TIME_30_SEC = 0
CFG_TO_TIME_40_MIN = 32
CFG_TO_TIME_50_MIN = 40
CFG_TO_TIME_60_MIN = 48
CFG_TO_TIME_70_MIN = 56
CFG_TO_TIME_DEFAULT = 24
CFG_VCHGCV_COOL = 'Charger.Voltage.Jeita.Term'
CFG_VCHGCV_COOL_DEFAULT = 0
CFG_VCHGCV_COOL_NORMAL = 0
CFG_VCHGCV_COOL_REDUCED = 4
CFG_VCHGIN_REG = 'Charger.Voltage.ChargeIn'
CFG_VCHGIN_REG_10150 = 30
CFG_VCHGIN_REG_10675 = 32
CFG_VCHGIN_REG_10950 = 34
CFG_VCHGIN_REG_11550 = 36
CFG_VCHGIN_REG_12150 = 38
CFG_VCHGIN_REG_12750 = 40
CFG_VCHGIN_REG_13350 = 42
CFG_VCHGIN_REG_13950 = 44
CFG_VCHGIN_REG_14550 = 46
CFG_VCHGIN_REG_15150 = 48
CFG_VCHGIN_REG_15750 = 50
CFG_VCHGIN_REG_16350 = 52
CFG_VCHGIN_REG_16950 = 54
CFG_VCHGIN_REG_17550 = 56
CFG_VCHGIN_REG_18150 = 58
CFG_VCHGIN_REG_18750 = 60
CFG_VCHGIN_REG_19050 = 62
CFG_VCHGIN_REG_4025 = 0
CFG_VCHGIN_REG_4200 = 2
CFG_VCHGIN_REG_4375 = 4
CFG_VCHGIN_REG_4550 = 6
CFG_VCHGIN_REG_4725 = 8
CFG_VCHGIN_REG_4900 = 10
CFG_VCHGIN_REG_5425 = 12
CFG_VCHGIN_REG_5950 = 14
CFG_VCHGIN_REG_6475 = 16
CFG_VCHGIN_REG_7000 = 18
CFG_VCHGIN_REG_7525 = 20
CFG_VCHGIN_REG_8050 = 22
CFG_VCHGIN_REG_8575 = 24
CFG_VCHGIN_REG_9100 = 26
CFG_VCHGIN_REG_9625 = 28
CFG_VCHGIN_REG_DEFAULT = 8
classmethod Params_init(paramDict)[source]

Initializes configuration parameters with defaults.

The following settings are supported:

Key name

Value type, meaning and default

SerialBusDevice.address

int I2C serial device address; default is ADDRESSES_ALLOWED [0].

Charger.Comm.Mode

int Communication mode; default is CFG_COMM_MODE_DEFAULT.

Charger.DisIBS

int ; default is CFG_DISIBS_DEFAULT.

Charger.Mode

int ; default is CFG_MODE_DEFAULT.

Charger.Prequal

int ; default is CFG_PQEN_DEFAULT.

Charger.Restart

int ; default is CFG_CHG_RSTRT_DEFAULT.

Charger.Stat

int ; default is CFG_STAT_EN_DEFAULT.

Charger.Timer.FastCharge

int ; default is CFG_FCHGTIME_DEFAULT.

Charger.Current.FastCharge

int ; default is CFG_CHGCC_DEFAULT.

Charger.Timer.Topoff

int ; default is CFG_TO_TIME_DEFAULT.

Charger.Current.Topoff

int ; default is CFG_TO_ITH_DEFAULT.

Charger.Voltage.ChargeTermination

int ; default is CFG_CHG_CV_PRM_DEFAULT.

Charger.Current.Trickle

int ; default is CFG_ITRICKLE_DEFAULT.

Charger.Current.Batt2Sys

int ; default is CFG_B2SOVRC_DEFAULT.

Charger.Jeita

int ; default is CFG_JEITA_EN_DEFAULT.

Charger.Temp.Reg

int ; default is CFG_REGTEMP_DEFAULT.

Charger.Voltage.Jeita.Term

int ; default is CFG_VCHGCV_COOL_DEFAULT.

Charger.Current.Jeita.FastCharge

int ; default is CFG_ICHGCC_COOL_DEFAULT.

Charger.Current.Input

int ; default is CFG_CHGIN_ILIM_DEFAULT.

Charger.Current.OTG

int ; default is CFG_OTG_ILIM_DEFAULT.

Charger.Voltage.MinVSys

int ; default is CFG_MINVSYS_DEFAULT.

Charger.Voltage.ChargeIn

int ; default is CFG_VCHGIN_REG_DEFAULT.

All MAX77960.int.gpio.* settings as documented at GPIO.Params_init().

Also see: Charger.Params_init(), SerialBusDevice.Params_init(), GPIO.Params_init().

WATCHDOG_INTERVAL_MS = 80000
checkID()[source]

Reads the chip ID and verifies it against the expected value.

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

disableInterrupt()[source]

Disables the interrupt(s) of the implementing device.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

enableInterrupt()[source]

Enables the interrupt(s) of the implementing device.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

enableWatchdog()[source]

Enable and restart the watch dog.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

getAllRegistersStr()[source]
getBatStatus()[source]

Get the battery status to tell about the health and state of the battery.

Returns one of the battery.Status values to indicate battery voltage level or presence or health state.

Returns:

The battery state.

Return type:

battery.Status

getBatteryTempStatus()[source]

Retrieves the battery’s temperature status.

Returns:

A rating code to indicate the temperature rating of the battery element.

Return type:

TemperatureRating

getChargerTempStatus()[source]

Retrieves the charger’s temperature state.

Returns:

A rating code to indicate the temperature rating of the charger chip.

Return type:

TemperatureRating

getChgStatus()[source]

Retrieves the charging phase or status.

Returns:

A charger status code to indicate the current charger status.

Return type:

charger.Status

getDCStatus()[source]

Retrieves the DC supply status.

Returns:

A status code to indicate the DC supply status.

Return type:

DCStatus

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:

ChargerError

getEventContext(event, context)[source]

Retrieve more detailed information on an event.

The event parameter should be interruptable.Event.evtInt1, as there is only this one interrupt line. On return, the context parameter carries the resulting information. It must be an instance of charger.EventContext, which is semantically multiplexed by its charger.EventContext.source attribute.

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:

ErrorCode

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.

Returns:

The information object and an error code indicating either success or the reason of failure.

Return type:

Info, ErrorCode

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:

PowerSrc

getRegContentStr(regDescr, content)[source]
getRegisterMap()[source]
isBatteryPresent()[source]

Checks, if the battery is present.

This does not tell anything about whether the battery is charged or not.

Returns ErrorCode.errOk if a battery is present, ErrorCode.errUnavailable if 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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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 paramDict configuration parameters contain the SerialBusDevice.bus key, the associated value object is checked to be an instance of SerialBus. 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 paramDict dictionary 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 key SerialBusDevice.bus, or by reading the SerialBusDevice.serialBus attribute.

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:

ErrorCode

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 callerFeedBack object given as the previous parameter. Further parameters may follow, as they were handed in to the _fire() method.

  • If the handler is None then
    • if onEvent is None or .interruptable.Event.evtNone, then the interrupt is disabled and all registrations cleared.

    • otherwise, the callerFeedBack replaces what was previously set for this type of onEvent.

  • If the handler is valid but onEvent is still None or .interruptable.Event.evtNone, then this handler is de-registered. If that was the last/only handler registered, interrupts are disabled.

  • If both, the handler and the onEvent parameters are valid, then the interrupt is enabled and the handler gets registered.

Parameters:
  • onEvent (int) – Exactly one of the event mnemonics defined by the interruptable.Event enumeration.

  • 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:

ErrorCode

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:

ErrorCode

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.

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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

REG_CID = 0

philander.module module

Module to provide the Module base class.

class Module[source]

Bases: object

Generic 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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

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.

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

philander.primitives module

A module t reflect fundamental physical units and scales.

class Current[source]

Bases: int

Current [-1A…+1A] in micro Amp [µA]

invalid = -1
class Percentage[source]

Bases: int

Percentage [0…100%] in percent [%]

invalid = 255
class PreciseTemperature[source]

Bases: int

Temperature [-70…+125]in degree Celsius [°C], given a s a Q8.8 fixed-point number with 8-bit decimals.

invalid = -32768
max = 32767
min = -32767
class Temperature[source]

Bases: int

Temperature [-70…+125] in full degree Celsius [°C]

invalid = -128
class Voltage[source]

Bases: int

Voltage [0…60V] in milli Volt [mV]

invalid = 65535

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(type: CalibrationType = CalibrationType.default, data: CalibrationData = CalibrationData(trueValue=None, offset=None, iOffset=0, linear=_CalibrationData_linear(offset=None, sensitivity=None), iLinear=_CalibrationData_iLinear(offset=0, sensitivity=0), param=None, trueMeasurement=_CalibrationData_trueMeasurement(measurement=None, trueValue=None), trueMeasurement2=_CalibrationData_trueMeasurement(measurement=None, trueValue=None), knownMeasurement=[_CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None), _CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None), _CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None)], temp=_CalibrationData_iLinear(offset=0, sensitivity=0)))[source]

Bases: object

Container to wrap calibration type 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 type 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 = CalibrationData(trueValue=None, offset=None, iOffset=0, linear=_CalibrationData_linear(offset=None, sensitivity=None), iLinear=_CalibrationData_iLinear(offset=0, sensitivity=0), param=None, trueMeasurement=_CalibrationData_trueMeasurement(measurement=None, trueValue=None), trueMeasurement2=_CalibrationData_trueMeasurement(measurement=None, trueValue=None), knownMeasurement=[_CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None), _CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None), _CalibrationData_knownMeasurement(measure=[0, 0, 0], trueValue=None)], temp=_CalibrationData_iLinear(offset=0, sensitivity=0))
type: CalibrationType = 1
class CalibrationData(trueValue: ~typing.Optional[object] = None, offset: ~typing.Optional[object] = None, iOffset: int = 0, linear: ~philander.sensor._CalibrationData_linear = _CalibrationData_linear(offset=None, sensitivity=None), iLinear: ~philander.sensor._CalibrationData_iLinear = _CalibrationData_iLinear(offset=0, sensitivity=0), param: ~typing.Optional[object] = None, trueMeasurement: ~philander.sensor._CalibrationData_trueMeasurement = _CalibrationData_trueMeasurement(measurement=None, trueValue=None), trueMeasurement2: ~philander.sensor._CalibrationData_trueMeasurement = _CalibrationData_trueMeasurement(measurement=None, trueValue=None), knownMeasurement: ~typing.List[~philander.sensor._CalibrationData_knownMeasurement] = <factory>, temp: ~philander.sensor._CalibrationData_iLinear = _CalibrationData_iLinear(offset=0, sensitivity=0))[source]

Bases: object

Container type to encapsulate a calibrations pure data structure.

iLinear: _CalibrationData_iLinear = _CalibrationData_iLinear(offset=0, sensitivity=0)

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.linear and CalibrationType.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.offset and CalibrationType.shiftOffset.

knownMeasurement: List[_CalibrationData_knownMeasurement]

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 = _CalibrationData_linear(offset=None, sensitivity=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.linear and CalibrationType.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.offset and CalibrationType.shiftOffset.

param: object = None

Generic set of parameters, stored separately. To be used with CalibrationType.param and CalibrationType.paramRel.

temp: _CalibrationData_iLinear = _CalibrationData_iLinear(offset=0, sensitivity=0)

Temperature calibration data. To be used with CalibrationType.temperature.

trueMeasurement: _CalibrationData_trueMeasurement = _CalibrationData_trueMeasurement(measurement=None, trueValue=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 = _CalibrationData_trueMeasurement(measurement=None, trueValue=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.expose2 and CalibrationType.expose3.

class CalibrationType(value)[source]

Bases: Enum

Mnemonic 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 calibExpose calibration 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, where r is the analogue or digitized raw value or voltage equivalent and v is the true, resulting data. This is similar to expose3 etc. 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 to trueValue. 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(value)[source]

Bases: Enum

Bit 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, Configurable

This 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 calib parameter. 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:

ErrorCode

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:

ErrorCode

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 the validity attribute of the returned info block to find out, which of the information is actually valid.

Returns:

The information object and an error code indicating either success or the reason of failure.

Return type:

Info, ErrorCode

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 statusID parameter 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:

ErrorCode

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:

ErrorCode

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 tests parameter or invoking Sensor.reset() or Sensor.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:

ErrorCode

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: _SerialBusIface

Convergence 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 SerialBusDevice must be provided to the read/write method of interest.

The implementation currently supports the following serial communication packages in the given order of priority:

  • smbus2

  • smbus

  • periphery

  • simulated devices

classmethod Params_init(paramDict)[source]

Initialize parameters with default values. Supported key names and their meanings are:

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

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 reg byte is discarded. It does not appear in the response buffer. Then, enough dummy traffic is generated to receive length number 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 reg byte 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 reg byte 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

readWriteBuffer(device, inLength, outBuffer)[source]

Writes and reads a number of bytes.

Also see: SerialBusDevice.readWriteBuffer().

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

setRunLevel(level)[source]

Switch the bus into some operating or power-saving mode.

Also see: module.Module.setRunLevel().

Parameters:

level (RunLevel) – The level to switch to.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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 store.

Returns:

An error code indicating success or the reason of failure.

Return type:

ErrorCode

writeBufferRegister(device, reg, buffer)[source]

Assuming a register-type access, this function writes a buffer to a register.

The register reg value is written first, followed by the given buffer content.

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:

ErrorCode

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:

ErrorCode

writeDWordRegister(device, reg, data32)[source]

Write a 32 bit double-word to the given register.

The register reg value is written first, followed by the given data32 parameter 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:

ErrorCode

writeWordRegister(device, reg, data16)[source]

Assuming a register-type access, this function writes a word register.

The register reg value is written first, followed by the given data16 parameter 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:

ErrorCode

class SerialBusDevice[source]

Bases: Module

Reflect a specific device communicating over a serial bus.

As its main information, an instance of SerialBusDevice is 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’s isAttached() function may be used to check, whether it has been attached to a bus, already.

DEFAULT_ADDRESS = 33
classmethod Params_init(paramDict)[source]

Initialize the set of configuration parameters with supported options. Supported configuration key names and their meanings are:

  • SerialBusDevice.address: The address of the device. The value should be given as an integer number. Must be unique in that, a serial bus does not allow two devices with the same address being attached. Defaults to DEFAULT_ADDRESS.

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:

ErrorCode

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:

ErrorCode

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 paramDict configuration parameters contain the SerialBusDevice.bus key, the associated value object is checked to be an instance of SerialBus. 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 paramDict dictionary 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 key SerialBusDevice.bus, or by reading the SerialBusDevice.serialBus attribute.

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:

ErrorCode

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 reg byte is discarded. It does not appear in the response buffer. Then, enough dummy traffic is generated to receive length number 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

readWriteBuffer(inLength, outBuffer)[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.readWriteBuffer().

Parameters:
  • 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

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:

ErrorCode

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 reg value is written first, followed by the given buffer content.

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:

ErrorCode

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:

ErrorCode

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 reg value is written first, followed by the given data32 parameter 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:

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 reg value is written first, followed by the given data16 parameter 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:

ErrorCode

class SerialBusProvider(value)[source]

Bases: Enum

An enumeration.

AUTO = 2
NONE = 1
PERIPHERY = 5
SIM = 6
SMBUS = 3
SMBUS2 = 4
class SerialBusType(value)[source]

Bases: Enum

An enumeration.

I2C = 10
SPI = 20
UART = 30

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: SimDevMemory

A 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_ID

  • STATUS:DRDY_ACC/AUX cleared at each read-access to ACC_X/Y/Z or AUX_X/Y/Z/R

Limitations

  • ACC_X/Y/Z get just incremented after each read access.

  • STATUS:DRDY_ACC/AUX get set after polling (reading) STATUS for 10 times.

  • SENSOR_TIME[0:1:2] incremented after each read-access

  • initialization sequence is satisfied by writing LOAD_CFG_FILE followed by START_INIT to the INIT_CTRL register. This will set INTERNAL_STATUS:MSG to INIT_OK. Otherwise, these bits are set to INIT_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 ERROR and STATUS

  • power modes

  • interrupts

  • NVM

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(value)[source]

Bases: Enum

Enumeration to reflect the different types of memory.

NVM = 3
RAM = 2
ROM = 1
VOLATILE = 4
class Register(address: int, content: int = 0, type: MemoryType = MemoryType.RAM)[source]

Bases: object

Simulate 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

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: object

Abstract 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 sim attribute of a matching serialbus.SerialDevice object. Remember that each serialbus.SerialDevice must be registered with a serialbus.SerialBus by calling its serialbus.SerialBus.attach() method. The simulative serial bus implementation uses the serialbus.SerialDevice.address attribute to identify the addressed device and then looks up its SerialBusDevice.sim attribute 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.

readBufferRegister(aReg, length)[source]

Read a block of data starting from the given register.

Starting with the given Register address, length bytes are read and returned. As with readWordRegister() and readDWordRegister(), 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 successors aReg+1 (high-byte of the low-word), aReg+2 (low-byte of the high-word) and aReg+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+1 of 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

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 register aReg, the next byte - at index 1 - is stored at aReg+1 and so on. More formally:

data[0] -> aReg
data[1] -> aReg + 1
...

The number of bytes written is determined implicitly by the length of the data list. 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:

ErrorCode

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:

ErrorCode

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 to aReg+1. The low-part of the high-word is stored to aReg+2 and the high-part of the high-word is put at aReg+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:

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:

ErrorCode

class SimDevMemory(regs)[source]

Bases: SimDev

Serial bus implementation to simulate a device that can be accessed through a set of memory-based registers. The list of registers must be provided 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:

  1. calling _onPreRead()

  2. reading the register content

  3. 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:

  1. calling _onPreWrite(), may alter the intended data and returns the actual new content to write.

  2. writing the new register content

  3. 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:

ErrorCode

class SimDevNull[source]

Bases: SimDev, Module

Slim-line serial device simulation. Reading retrieves always the same constant value, while writing is simply ignored.

DEFAULT_READING = 58
classmethod Params_init(paramDict)[source]

Initialize configuration parameters.

Any supported option missed in the dictionary handed in, will be added upon return. Also see module.Module.Params_init(). The following options are supported.

Key

Range

Default

SimDevNull.reading

integer

SimDevNull.DEFAULT_READING

Parameters:

paramDict (dict(str, object)) – Dictionary mapping option names to their respective values.

Returns:

none

Return type:

None

open(paramDict)[source]

Open the instance and prepare it for use.

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:

ErrorCode

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:

ErrorCode

philander.systypes module

Data types commonly used throughout the system and not associated with any specific module.

class ErrorCode(value)[source]

Bases: Enum

Data 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
errInternal = 5
errInvalidParameter = 1
errMalfunction = 21
errMoreData = 6
errNotImplemented = 3
errNotSupported = 4
errOk = 0
errOverflow = 14
errPostProc = 17
errPreProc = 16
errResourceConflict = 12
errSpecRange = 11
errSuspended = 19
errUnavailable = 10
errUnderrun = 15
class Info[source]

Bases: object

Container 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(value)[source]

Bases: Enum

Operating 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)[source]

Bases: object

Container type to wrap a thermometer’s primary measurement result.

Measurement data should always be expressed as a signed value in degree Celsius.

temperature: PreciseTemperature

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, Interruptable

Vibra 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 = 10
classmethod Params_init(paramDict)[source]

Initializes configuration parameters with defaults.

The following settings are supported:

Key name

Value type, meaning and default

Sensor.dataRate

int Data rate in Hz; default is set by Sensor.Params_init().

VibraSense.slot

int=[1|2] the slot that this board is plugged in. 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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

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(*, delimiter: str = '.', wildcard: bool = False, new_listener: bool = False, max_listeners: int = -1)[source]

Bases: EventEmitter, Sensor, Interruptable, SerialBusDevice

Vibra 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

int I2C serial device address, must be ADDRESS; default is ADDRESS.

Sensor.dataRate

int Data rate in Hz; default is set by Sensor.Params_init().

Also see: Sensor.Params_init(), SerialBusDevice.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 calling open(), again.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

philander.voltmeter module

Driver implementation for a simple ADC-based voltage monitor and gas-gauge.

class Voltmeter(paramDict)[source]

Bases: Module, GasGauge

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

int Maximum voltage in mV, maps to 100%; default is DEFAULT_RANGE_MAX.

Voltmeter.range.min

int Minimum voltage in mV, mapped to 0%; default is DEFAULT_RANGE_MIN.

Voltmeter.gpio.direction

see GPIO.Params_init(); default is GPIO.DIRECTION_IN.

Voltmeter.gpio.trigger

see GPIO.Params_init(); default is GPIO.TRIGGER_EDGE_FALLING.

Voltmeter.gpio.bounce

see GPIO.Params_init(); default is GPIO.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:

ErrorCode

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:

ErrorCode

philander.watchdog module

Module to describe objects that provide wath dog capabilities.

class Watchdog[source]

Bases: object

Interface 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 Module interface, it can use this method to fill commonly supported options.

The following settings are supported:

Key name

Value type, meaning and default

Watchdog.Interval

int Watch dog interval in milliseconds; default is INTERVAL_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:

ErrorCode

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:

ErrorCode

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:

ErrorCode

enableWatchdog()[source]

Enable and restart the watch dog.

Returns:

An error code indicating either success or the reason of failure.

Return type:

ErrorCode

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:

ErrorCode

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:

ErrorCode

Module contents

A driver collection for embedded system components, such as sensors or battery chargers.