Add range features

This commit is contained in:
Javier Torres 2016-06-09 19:41:31 +02:00
parent f1fad2d16b
commit 2fdce2f938
1 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,7 @@ from .settings import (
FeatureRW as _FeatureRW, FeatureRW as _FeatureRW,
BooleanValidator as _BooleanV, BooleanValidator as _BooleanV,
ChoicesValidator as _ChoicesV, ChoicesValidator as _ChoicesV,
RangeValidator as _RangeV,
) )
_DK = _hidpp10.DEVICE_KIND _DK = _hidpp10.DEVICE_KIND
@ -99,6 +100,17 @@ def feature_choices_dynamic(name, feature, choices_callback,
return setting(device) return setting(device)
return instantiate return instantiate
def feature_range(name, feature, min_value, max_value,
read_function_id=_FeatureRW.default_read_fnid,
write_function_id=_FeatureRW.default_write_fnid,
rw=None,
bytes_count=None,
label=None, description=None, device_kind=None):
validator = _RangeV(min_value, max_value, bytes_count=bytes_count)
if rw is None:
rw = _FeatureRW(feature, read_function_id, write_function_id)
return _Setting(name, rw, validator, kind=_KIND.range, label=label, description=description, device_kind=device_kind)
# #
# common strings for settings # common strings for settings
# #