Moto Mods Firmware: Lights Protocol¶
Overview¶
The Lights protocol is used to control various light output devices. Currently, the Moto Mods platform only supports a display backlight. For your application to adjust a Moto Mod’s backlight, see Moto Z Software: Mod Display.
Hardware Manifest¶
; Lights interface on CPort XX
[cport-descriptor XX]
bundle = YY
protocol = 0x0f
; Lights Bundle YY
[bundle-descriptor YY]
class = 0x0f
XX is a unique integer (within your hardware manifest) defining which CPort is used for the Lights Interface.
YY is a unique integer (within your hardware manifest) which Bundle the Lights CPort is a member of.
Implementation¶
Files¶
nuttx/include/nuttx/device_lights.h
Structures¶
light_config¶
| Parameters | |
channel_count |
Number of Lights channels. |
name |
Unique name for this configuration. |
channel_config¶
struct channel_config {
uint8_t max_brightness;
uint32_t flags;
uint32_t color;
char color_name[NAME_LENGTH];
uint32_t mode;
char mode_name[NAME_LENGTH];
}
| Parameters | |
max_brightness |
Sets supported max brightness. |
flags |
Light channel behavior flag bitmask. |
color |
Color code value. |
color_name |
Color name, 31 characters with null character. |
mode |
Only Mode Vendor channel supported at this time.LIGHTS_CHANNEL_MODE_VENDOR |
mode_name |
Mode name, 31 characters with null character. |
*See usage for specific Light channel configurations.
Methods¶
get_lights¶
| Parameters | |
dev |
Matches dev passed to the probe function. |
lights |
Returns the number of light configurations. |
get_light_config¶
| Parameters | |
dev |
Matches dev passed to the probe function. |
cfg |
Returns an array of light configurations. |
get_channel_config¶
int (*get_channel_config)(struct device *dev, uint8_t light_id, uint8_t channel_id, struct channel_config *cfg);
| Parameters | |
dev |
Matches dev passed to the probe function. |
light_id |
Index for which caller is requesting information. |
channel_id |
Channel Number for which the caller is requesting information. |
channel_config |
The configuration as documented above. |
set_brightness¶
int (*set_brightness)(struct device *dev, uint8_t light_id, uint8_t channel_id, uint8_t brightness);
| Parameters | |
dev |
Matches dev passed to the probe function. |
light_id |
Index for which caller is requesting information. |
channel_id |
Channel Number for which the caller is requesting information. |
brightness |
Brightness level between 0 and max_brightness. |
Usage¶
Backlight¶
The backlight channel of the Lights protocol uses mode LIGHTS_CHANNEL_MODE_VENDOR with a mode_name of “backlight” as follows:
channel_config¶
struct channel_config {
uint8_t max_brightness;
uint32_t flags;
uint32_t color;
char color_name[NAME_LENGTH];
uint32_t mode;
char mode_name[NAME_LENGTH];
}
| Parameters (specifically for Display Backlight) | |
max_brightness |
For display backlight should be set to 1. |
flags |
No flags (set to 0). |
color |
No colors (set to 0). |
color_name |
Set to empty string. |
mode |
LIGHTS_CHANNEL_MODE_VENDOR |
mode_name |
“backlight” |