|
|
#include "Handler.h"
|
|
|
|
|
|
void Handler::ZigBeeRx_Handler(uint8_t* mar)
|
|
|
{
|
|
|
switch (mar[1])
|
|
|
{
|
|
|
case 0x02: //主车
|
|
|
MainCarRx_Handler(mar); //主车命令相应函数
|
|
|
break;
|
|
|
case 0x03: //道闸标志物
|
|
|
break;
|
|
|
case 0x04: //LED显示标志物(暂无返回)
|
|
|
break;
|
|
|
case 0x05: //立体车库标志物B
|
|
|
break;
|
|
|
case 0x06: //语音播报标志物
|
|
|
break;
|
|
|
case 0x07: //红外报警标志物
|
|
|
break;
|
|
|
case 0x08: //TFT显示标志物B
|
|
|
break;
|
|
|
case 0x09: //调光标志物
|
|
|
break;
|
|
|
case 0x0A: //磁悬浮无线充电标志物
|
|
|
break;
|
|
|
case 0x0B: //TFT显示标志物A
|
|
|
break;
|
|
|
case 0x0C: //ETC系统标志物
|
|
|
break;
|
|
|
case 0x0D: //立体车库标志物A
|
|
|
break;
|
|
|
case 0x0E: //交通灯标注物A
|
|
|
break;
|
|
|
case 0x0F: //交通灯标志物B
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Handler::OpenMVRx_Handler(uint8_t* mac)
|
|
|
{
|
|
|
switch (mac[2])
|
|
|
{
|
|
|
case 0x91: //保留
|
|
|
|
|
|
break;
|
|
|
case 0x92: //二维码识别
|
|
|
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Handler::MainCarRx_Handler(uint8_t* com)
|
|
|
{
|
|
|
switch (com[2])
|
|
|
{
|
|
|
case 0x01: //停止
|
|
|
DCMotor.Stop();
|
|
|
break;
|
|
|
case 0x02: //前进
|
|
|
DCMotor.Go(com[3], (com[4] + (com[5] << 8)));
|
|
|
ZigBee_back[2] = 0x03;
|
|
|
break;
|
|
|
case 0x03: //后退
|
|
|
DCMotor.Back(com[3], (com[4] + (com[5] << 8)));
|
|
|
ZigBee_back[2] = 0x03;
|
|
|
break;
|
|
|
case 0x04: //左转
|
|
|
DCMotor.TurnLeft(com[3]);
|
|
|
ZigBee_back[2] = 0x02;
|
|
|
break;
|
|
|
case 0x05: //右转
|
|
|
DCMotor.TurnRight(com[3]);
|
|
|
ZigBee_back[2] = 0x02;
|
|
|
break;
|
|
|
case 0x06: //循迹
|
|
|
DCMotor.CarTrack(com[3]);
|
|
|
ZigBee_back[2] = 0x00;
|
|
|
break;
|
|
|
case 0x07: //码盘清零
|
|
|
Command.Judgment(Command.command01); //计算校验和
|
|
|
ExtSRAMInterface.ExMem_Write_Bytes(Command.command01, 8); //码盘清零
|
|
|
break;
|
|
|
case 0x10: //保存红外数据
|
|
|
infrare_com[0] = com[3];
|
|
|
infrare_com[1] = com[4];
|
|
|
infrare_com[2] = com[5];
|
|
|
break;
|
|
|
case 0x11: //保存红外数据
|
|
|
infrare_com[3] = com[3];
|
|
|
infrare_com[4] = com[4];
|
|
|
infrare_com[5] = com[5];
|
|
|
break;
|
|
|
case 0x12: //发送红外数据
|
|
|
Infrare.Transmition(infrare_com, 6);
|
|
|
break;
|
|
|
case 0x20: //左右转向灯
|
|
|
if (com[3] == 0x01)
|
|
|
LED.LeftTurnOn();
|
|
|
else
|
|
|
LED.LeftTurnOff();
|
|
|
if (com[4] == 0x01)
|
|
|
LED.RightTurnOn();
|
|
|
else
|
|
|
LED.RightTurnOff();
|
|
|
break;
|
|
|
case 0x30: //蜂鸣器
|
|
|
if (com[3] == 0x01)
|
|
|
BEEP.TurnOn();
|
|
|
else
|
|
|
BEEP.TurnOff();
|
|
|
break;
|
|
|
case 0x40: //保留
|
|
|
break;
|
|
|
case 0x50: //LCD图片上翻页
|
|
|
Command.Judgment(Command.command13);
|
|
|
ExtSRAMInterface.ExMem_Write_Bytes(Command.command13, 8);
|
|
|
break;
|
|
|
case 0x51: //LCD图片下翻页
|
|
|
Command.Judgment(Command.command14);
|
|
|
ExtSRAMInterface.ExMem_Write_Bytes(Command.command14, 8);
|
|
|
break;
|
|
|
case 0x61: //光源加一档
|
|
|
Infrare.Transmition(Command.HW_Dimming1, 4);
|
|
|
break;
|
|
|
case 0x62: //光源加二挡
|
|
|
Infrare.Transmition(Command.HW_Dimming2, 4);
|
|
|
break;
|
|
|
case 0x63: //光源加三挡
|
|
|
Infrare.Transmition(Command.HW_Dimming3, 4);
|
|
|
break;
|
|
|
case 0x80: //从车返回数据切换
|
|
|
if (com[3] == 0x01)
|
|
|
{
|
|
|
sendflag = 0x01; //上传从车数据
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sendflag = 0x00; //关闭上从车数据
|
|
|
}
|
|
|
case 0x91:
|
|
|
if (com[3] == 0x03) //舵机控制
|
|
|
{
|
|
|
//Servoangle_control(com[4]);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Handler::Key_0()
|
|
|
{
|
|
|
BEEP.TurnOn();
|
|
|
delay(50);
|
|
|
BEEP.TurnOff();
|
|
|
OpenMVOpt::Servo_Control(-60);
|
|
|
OpenMVOpt::OpenMV_Track(50);
|
|
|
DCMotor.TurnLeft_Code(80, 760);
|
|
|
}
|
|
|
|
|
|
void Handler::Key_1()
|
|
|
{
|
|
|
BEEP.TurnOn();
|
|
|
delay(50);
|
|
|
BEEP.TurnOff();
|
|
|
delay(50);
|
|
|
OpenMVOpt::Servo_Control(0);
|
|
|
}
|
|
|
|
|
|
void Handler::Key_2()
|
|
|
{
|
|
|
DebugOpt::DebugRun();
|
|
|
}
|
|
|
|
|
|
void Handler::Key_3()
|
|
|
{
|
|
|
DebugOpt::DebugServo();
|
|
|
}
|
|
|
|
|
|
void Handler::KEY_Handler(uint8_t k_value)
|
|
|
{
|
|
|
switch (k_value)
|
|
|
{
|
|
|
case 1:
|
|
|
Key_0();
|
|
|
break;
|
|
|
case 2:
|
|
|
Key_1();
|
|
|
break;
|
|
|
case 3:
|
|
|
Key_2();
|
|
|
break;
|
|
|
case 4:
|
|
|
Key_3();
|
|
|
break;
|
|
|
}
|
|
|
}
|