Skip to content

Provide easier access to sensor capability names #7

Description

@RealWhimsy

Having to type the sensor capability descriptor by hand every time functions like get_capability or has_capability are called can get tedious and is prone to typos / errors.

I suggest adding some way to access these capabilities via constant values (such as a class or enum).

This would mean that instead of

if sensor.has_capability('accelerometer'):
    print(sensor.get_value('accelerometer')

the user could type something like:

if sensor.has_capability(SensorCapabilities.ACCELEROMETER):
    print(sensor.get_value(SensorCapabilites.ACCELEROMETER

This would also be supported by auto-completion in most IDEs.

Furthermore the user could see at a glance what kind of sensors are supported by looking at the constants.
A sample implementation that I used for my assignment can be found in my commit here: 16e0598

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions