Reorganize messages into module groups

This commit is contained in:
2023-02-02 01:14:29 -06:00
parent f0befa0b7b
commit 60673a5283
16 changed files with 271 additions and 314 deletions
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
static const uint8_t CHASSIS_HOST = 3;
static const uint8_t CHASSIS_INDEX = 6;
static const uint8_t SET_WHEEL_SPEED_CMDID = 0x20;
void
set_wheel_speed (
Client session,
int16_t w1,
int16_t w2,
int16_t w3,
int16_t w4 );
static const uint8_t CHASSIS_SPEED_MODE_CMDID = 0x21;
void
chassis_speed_mode (
Client session,
float x,
float y,
float z );
-39
View File
@@ -1,39 +0,0 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
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
};
void set_system_led (
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 );
+11 -4
View File
@@ -5,10 +5,8 @@ struct Client;
typedef struct Client* Client;
#include "message.h"
#include "led.h"
#include "sdk_connection.h"
#include "sdk_mode.h"
#include "wheel.h"
#include "chassis.h"
#include "sdk.h"
// SIMPLE
// Create a client
@@ -20,3 +18,12 @@ Client client_new();
void client_connect(Client client);
void poll_message(Client client, union Message* message);
static inline uint8_t host2byte(uint8_t host, uint8_t index) {
return index * 32 + host;
}
static inline void byte2host(uint8_t b, uint8_t* host, uint8_t* index) {
*host = (b & 0x1F);
*index = b >> 5;
}
+96
View File
@@ -0,0 +1,96 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
static const uint8_t SDK_HOST = 9;
static const uint8_t SDK_INDEX = 0;
static const uint8_t SET_SDK_CONNECTION_CMDID = 0xD4;
enum CONNECTION {
CONNECTION_WIFI_AP = 0,
CONNECTION_WIFI_STA = 1,
CONNECTION_USB_RNDIS = 2
};
void
set_sdk_connection(
Client session,
enum CONNECTION connection_type,
uint32_t ip_address,
uint16_t port );
static const uint8_t SDK_HEARTBEAT_CMDID = 0xD5;
void
sdk_heartbeat(
Client session );
static const uint8_t SET_SDK_MODE_CMDID = 0xd1;
void
set_sdk_mode(Client session, bool enable);
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
};
void set_system_led (
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 );
static const uint8_t SET_ROBOT_MODE_CMDID = 0x46;
enum MOVEMENTMODE {
MOVEMENTMODE_FREE,
MOVEMENTMODE_GIMBAL_LEAD,
MOVEMENTMODE_CHASSIS_LEAD
};
void
set_robot_mode (
Client session,
enum MOVEMENTMODE mode );
// cmdset 0x48
static const uint8_t SUBNODE_RESET_CMDID = 0x02;
void
subnode_reset (
Client session );
// cmdset 0x48
static const uint8_t SUBSCRIBE_ADD_NODE_CMDID = 0x01;
void
subscribe_add_node (
Client session );
-27
View File
@@ -1,27 +0,0 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
static const uint8_t SET_SDK_CONNECTION_CMDID = 0xD4;
enum CONNECTION {
CONNECTION_WIFI_AP = 0,
CONNECTION_WIFI_STA = 1,
CONNECTION_USB_RNDIS = 2
};
void
set_sdk_connection(
Client session,
enum CONNECTION connection_type,
uint32_t ip_address,
uint16_t port );
static const uint8_t SDK_HEARTBEAT_CMDID = 0xD5;
void
sdk_heartbeat(
Client session );
-11
View File
@@ -1,11 +0,0 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
static const uint8_t SET_SDK_MODE_CMDID = 0xd1;
void
set_sdk_mode(Client session, bool enable);
-62
View File
@@ -1,62 +0,0 @@
#pragma once
#include "message.h"
#include <stdbool.h>
#include <stdint.h>
static const uint8_t SET_WHEEL_SPEED_CMDID = 0x20;
void
set_wheel_speed (
Client session,
int16_t w1,
int16_t w2,
int16_t w3,
int16_t w4 );
static const uint8_t SET_CHASSIS_WHEEL_SPEED_CMDID = 0x26;
void
set_chassis_wheel_speed (
Client session,
int8_t w1,
int8_t w2,
int8_t w3,
int8_t w4 );
static const uint8_t CHASSIS_SPEED_MODE_CMDID = 0x21;
void
chassis_speed_mode (
Client session,
float x,
float y,
float z );
static const uint8_t SET_ROBOT_MODE_CMDID = 0x46;
enum MOVEMENTMODE {
MOVEMENTMODE_FREE,
MOVEMENTMODE_GIMBAL_LEAD,
MOVEMENTMODE_CHASSIS_LEAD
};
void
set_robot_mode (
Client session,
enum MOVEMENTMODE mode );
// cmdset 0x48
static const uint8_t SUBNODE_RESET_CMDID = 0x02;
void
subnode_reset (
Client session );
// cmdset 0x48
static const uint8_t SUBSCRIBE_ADD_NODE_CMDID = 0x01;
void
subscribe_add_node (
Client session );