|
1、串口协议
2、智能宠物屋_gokit_2_STM源码的修改内容
文件Protocol.h:
(1)修改productkey
(2)在修改是否设置标志设置位
typedef enum
{
SetLED_R =0x01,
SetLED_G =0x02,
SetLED_B =0x04,
}Attr_FlagsTypeDef;
(3)查看可写设置列表是否已经有Led_Cmd选项
__packed typedef struct
{
uint8_t LED_Cmd;
uint8_t LED_R;
uint8_t LED_G;
uint8_t LED_B;
uint16_t Motor;
}Device_WirteTypeDef;
(4)数据值的填写
typedef enum
{
LED_OnOff =0x00,
LED_R =0x01,
LED_G =0x02,
LED_B =0x04,
}LED_ColorTypeDef;
3、更改功能,
文件Protocol:更改Pro_W2D_Control_DevceHandle函数
void Pro_W2D_Control_DevceHandle(void)
{
Pro_P0_ControlTypeDef Pro_P0_ControlStruct;
Pro_W2D_CommonCmdHandle();
memcpy(&Pro_P0_ControlStruct, UART_HandleStruct.Message_Buf, sizeof(Pro_P0_ControlStruct));
switch (Pro_P0_ControlStruct.Attr_Flags)
{
case SetLED_R:
Device_WirteStruct.LED_Cmd = Pro_P0_ControlStruct.Device_Wirte.LED_Cmd ;
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_OnOff )
{
LED_RGB_Control(0,0,0);
printf("SetLED_Off \r\n");
}
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_R )
{
LED_RGB_Control(254,0,0);
printf("SetLED_Off \r\n");
}
break;
case SetLED_G:
Device_WirteStruct.LED_Cmd = Pro_P0_ControlStruct.Device_Wirte.LED_Cmd ;
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_OnOff )
{
LED_RGB_Control(0,0,0);
printf("SetLED_Off \r\n");
}
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_G )
{
LED_RGB_Control(0,254,0);
printf("SetLED_Off \r\n");
}
break;
case SetLED_B:
Device_WirteStruct.LED_Cmd = Pro_P0_ControlStruct.Device_Wirte.LED_Cmd ;
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_OnOff )
{
LED_RGB_Control(0,0,0);
printf("SetLED_Off \r\n");
}
if(Pro_P0_ControlStruct.Device_Wirte.LED_Cmd==LED_B )
{
LED_RGB_Control(0,0,254);
printf("SetLED_Off \r\n");
}
break;
|
-
2.png
(2.06 KB, 下载次数: 90)
|