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
Having to type the sensor capability descriptor by hand every time functions like
get_capabilityorhas_capabilityare 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
the user could type something like:
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