From d4e18177932bb87453b5a1dc445e1770ed47e2e3 Mon Sep 17 00:00:00 2001 From: PgSocks Date: Sat, 24 Dec 2022 22:31:01 -0600 Subject: [PATCH] Add LED control packet --- src/robomaster.c | 7 +++++++ src/robomaster.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/robomaster.c b/src/robomaster.c index 73f3eb0..f7f87a9 100644 --- a/src/robomaster.c +++ b/src/robomaster.c @@ -61,3 +61,10 @@ set_sdk_connection_req_new ( struct Message* message = message_new(session, 0x3F, SET_SDK_CONNECTION_CMDID, sizeof(struct SetSdkConnectionReq), msg); return message; } + +const Message +set_system_led_req_new ( + Session session, + struct SetSystemLedReq* msg ) { + return message_new(session, 0x3F, SET_SYSTEM_LED_CMDID, sizeof(struct SetSystemLedReq), msg); +} diff --git a/src/robomaster.h b/src/robomaster.h index bf5ad1c..ca4db06 100644 --- a/src/robomaster.h +++ b/src/robomaster.h @@ -147,3 +147,46 @@ struct PACKED GetVersionResp { }; const Message get_version_req_new(Session session); + +static const uint8_t SET_SYSTEM_LED_CMDID = 0x33; + +enum LEDCOMP { + LEDCOMP_BOTTOM_BACK = 0x1; + LEDCOMP_BOTTOM_FRONT = 0x2; + LEDCOMP_BOTTOM_LEFT = 0x4; + LEDCOMP_BOTTOM_RIGHT = 0x8; + LEDCOMP_BOTTOM_ALL = 0xf; + LEDCOMP_TOP_LEFT = 0x10; + LEDCOMP_TOP_RIGHT = 0x20; + LEDCOMP_TOP_ALL = 0x30; + LEDCOMP_ALL = 0x3f; +}; + +enum LEDEFFECT { + LEDEFFECT_OFF = 0; + LEDEFFECT_ON = 1; + LEDEFFECT_BREATH = 2; + LEDEFFECT_FLASH = 3; + LEDEFFECT_SCROLLING = 4; +}; + +struct PACKED SetSystemLedReq { + uint32_t comp_mask; + uint16_t led_mask; + struct { + uint8_t effect_mode : 4; + uint8_t control_mode : 4; + }; + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t loop; + uint16_t t1; + uint16_t t2; +}; + +struct PACKED SetSystemLedResp { + uint8_t retcode; +}; + +const Message set_system_led_req_new(Session session, struct SetSystemLedReq* msg);