rgbgradientv2
Note
This is a variation of the rgbgradient handler that supports devices like the Rival 700, 710.
The “rgbgradientv2” type handles RGB color gradients. Simple RGB color can also be used.
RGB gradient syntax example:
rgbgradient(duration=1000; colors=0%: #ff0000, 33%: #00ff00, 66%: #0000ff)
rgbgradient(colors=0%: red, 33%: lime, 66%: blue)
It supports both hexadecimal colors:
#FF0000
FF0000
#F00
F00
and named colors:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A Python dict
can also be used (Python API only):
{
"duration": 1000, # ms
"colors": [
{"pos": 0, "color": "red"},
{"pos": 33, "color": "#00FF00"},
{"pos": 66, "color": (0, 0, 255)},
]
}
Note
A maximum of 14 color stops can be defined in a gradient.
Device Profile
Example of a rgbgradient value type in a device profile:
profile = {
# ...
"settings": {
"logo_color": {
"label": "Logo LED colors and effects",
"description": "Set the colors and the effects of the logo LED",
"cli": ["-c", "--logo-color"],
"report_type": usbhid.HID_REPORT_TYPE_FEATURE,
"command": [0x05, 0x00],
"value_type": "rgbgradientv2",
"rgbgradient_header": {
"color_field_length": 139, # Index of length of color field (used for padding)
"duration_length": 2, # Length of the "duration" field (in Bytes)
"maxgradient": 14, # Max numbers of color stop (probably 14)
},
"led_id": 0x01,
"default": "rgbgradient(duration=1000; colors=0%: #ff00e1, 33%: #ffea00, 66%: #00ccff)",
},
},
# ...
}
CLI
Example of CLI option generated with this handler:
-c LOGO_COLOR, --logo-color LOGO_COLOR
Set the colors and the effects of the logo LED (default:
rgbgradient(duration=1000; colors=0%: #ff00e1, 33%: #ffea00, 66%: #00ccff))
Example of CLI usage:
rivalcfg --logo-color="rgbgradient(duration=1000; colors=0%: #ff00e1, 33%: #ffea00, 66%: #00ccff)"
rivalcfg --logo-color=red
rivalcfg --logo-color=FF1800
Functions
- rivalcfg.handlers.rgbgradientv2.add_cli_option(cli_parser, setting_name, setting_info)
Add the given “rgbgradientv2” type setting to the given CLI arguments parser.
- Parameters:
cli_parser (ArgumentParser) – An
ArgumentParser
instance.setting_name (str) – The name of the setting.
setting_info (dict) – The information dict of the setting from the device profile.
- rivalcfg.handlers.rgbgradientv2.process_value(setting_info, colors)
Called by the
rivalcfg.mouse.Mouse
class when processing a “rgbgradientv2” type setting.- Parameters:
setting_info (dict) – The information dict of the setting from the device profile.
colors (str,tuple,list,dict) – The color(s).
- Return type:
[int]