Refactor LED packet constructor

refactor
PgSocks 2 years ago
parent c1bb243211
commit 9ccc5cbca0

@ -61,6 +61,19 @@ set_sdk_connection_req_new (
const Message const Message
set_system_led_req_new ( set_system_led_req_new (
Client session, Client session,
struct SetSystemLedReq* msg ) { uint8_t red,
return message_new(session, 0x3F, SET_SYSTEM_LED_CMDID, sizeof(struct SetSystemLedReq), msg); uint8_t green,
uint8_t blue,
enum LEDCOMP comp,
uint16_t led_mask,
enum LEDEFFECT effect,
uint16_t t1,
uint16_t t2 ) {
const struct SetSystemLedReq msg = {
comp, led_mask,
{ effect, 7 },
red, green, blue,
0, t1, t2
};
return message_new(session, 0x3F, SET_SYSTEM_LED_CMDID, sizeof(msg), &msg);
} }

@ -149,36 +149,47 @@ const Message get_version_req_new(Client session);
static const uint8_t SET_SYSTEM_LED_CMDID = 0x33; static const uint8_t SET_SYSTEM_LED_CMDID = 0x33;
enum LEDCOMP { enum LEDCOMP {
LEDCOMP_BOTTOM_BACK = 0x1; LEDCOMP_BOTTOM_BACK = 0x1,
LEDCOMP_BOTTOM_FRONT = 0x2; LEDCOMP_BOTTOM_FRONT = 0x2,
LEDCOMP_BOTTOM_LEFT = 0x4; LEDCOMP_BOTTOM_LEFT = 0x4,
LEDCOMP_BOTTOM_RIGHT = 0x8; LEDCOMP_BOTTOM_RIGHT = 0x8,
LEDCOMP_BOTTOM_ALL = 0xf; LEDCOMP_BOTTOM_ALL = 0xf,
LEDCOMP_TOP_LEFT = 0x10; LEDCOMP_TOP_LEFT = 0x10,
LEDCOMP_TOP_RIGHT = 0x20; LEDCOMP_TOP_RIGHT = 0x20,
LEDCOMP_TOP_ALL = 0x30; LEDCOMP_TOP_ALL = 0x30,
LEDCOMP_ALL = 0x3f; LEDCOMP_ALL = 0x3f
}; };
enum LEDEFFECT { enum LEDEFFECT {
LEDEFFECT_OFF = 0; LEDEFFECT_OFF = 0,
LEDEFFECT_ON = 1; LEDEFFECT_ON = 1,
LEDEFFECT_BREATH = 2; LEDEFFECT_BREATH = 2,
LEDEFFECT_FLASH = 3; LEDEFFECT_FLASH = 3,
LEDEFFECT_SCROLLING = 4; LEDEFFECT_SCROLLING = 4
}; };
struct PACKED SetSystemLedReq { struct PACKED SetSystemLedReq {
// Which LEDs on which component to control
uint32_t comp_mask; uint32_t comp_mask;
uint16_t led_mask; uint16_t led_mask;
struct { struct {
// off, on, flashing, etc.
uint8_t effect_mode : 4; uint8_t effect_mode : 4;
// Always 7
uint8_t control_mode : 4; uint8_t control_mode : 4;
}; };
// RGB values for the LED color
uint8_t red; uint8_t red;
uint8_t green; uint8_t green;
uint8_t blue; uint8_t blue;
// Always 0
uint8_t loop; uint8_t loop;
// These time intervals have different meaning depending on effect
uint16_t t1; uint16_t t1;
uint16_t t2; uint16_t t2;
}; };
@ -187,4 +198,14 @@ struct PACKED SetSystemLedResp {
uint8_t retcode; uint8_t retcode;
}; };
const Message set_system_led_req_new(Client session, struct SetSystemLedReq* msg); const Message
set_system_led_req_new (
Client session,
uint8_t red,
uint8_t green,
uint8_t blue,
enum LEDCOMP comp,
uint16_t led_mask,
enum LEDEFFECT effect,
uint16_t t1,
uint16_t t2 );

Loading…
Cancel
Save