update item commuation
parent
6884cf2df8
commit
7b44f752ff
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// ±êÖ¾ÎïͨÐÅ - ·é»ð̨ - ZigBee/IR
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AlarmTowerCommand.h"
|
||||||
|
|
||||||
|
AlarmTowerCommand::AlarmTowerCommand()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::AlarmTower);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* AlarmTowerCommand::CMD_DefaultIRAlarm()
|
||||||
|
{
|
||||||
|
SetCommand(0x03, 0x05, 0x14, 0x45, 0xDE, 0x92);
|
||||||
|
return GetIRCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* AlarmTowerCommand::CMD_IRAlarm(byte d1, byte d2, byte d3, byte d4, byte d5, byte d6)
|
||||||
|
{
|
||||||
|
SetCommand(d1, d2, d3, d4, d5, d6);
|
||||||
|
return GetIRCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* AlarmTowerCommand::CMD_ChangeOpenCode_1to3(byte d1, byte d2, byte d3)
|
||||||
|
{
|
||||||
|
SetCommand(0x10, d1, d2, d3);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* AlarmTowerCommand::CMD_ChangeOpenCode_4to6(byte d4, byte d5, byte d6)
|
||||||
|
{
|
||||||
|
SetCommand(0x11, d4, d5, d6);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* AlarmTowerCommand::CMD_QueryRescuePosition()
|
||||||
|
{
|
||||||
|
SetCommand(0x09);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AlarmTowerCommand::IsAlarmTowerCommand(byte* cmd)
|
||||||
|
{
|
||||||
|
return ((cmd[1] == CommandData::Devices::AlarmTower) && (cmd[2] == 0x01));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte AlarmTowerCommand::ReadRescuePosition(byte* cmd)
|
||||||
|
{
|
||||||
|
if (!IsAlarmTowerCommand(cmd))
|
||||||
|
return 0xFF;
|
||||||
|
return cmd[3];
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
// AlarmTowerCommand.h
|
||||||
|
|
||||||
|
#ifndef _ALARMTOWERCOMMAND_h
|
||||||
|
#define _ALARMTOWERCOMMAND_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
class AlarmTowerCommand : private CommandEncoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlarmTowerCommand();
|
||||||
|
public:
|
||||||
|
byte* CMD_DefaultIRAlarm();
|
||||||
|
byte* CMD_IRAlarm(byte d1, byte d2, byte d3, byte d4, byte d5, byte d6);
|
||||||
|
byte* CMD_ChangeOpenCode_1to3(byte d1, byte d2, byte d3);
|
||||||
|
byte* CMD_ChangeOpenCode_4to6(byte d4, byte d5, byte d6);
|
||||||
|
byte* CMD_QueryRescuePosition();
|
||||||
|
public:
|
||||||
|
bool IsAlarmTowerCommand(byte* cmd);
|
||||||
|
byte ReadRescuePosition(byte* cmd);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// ±êÖ¾ÎïͨÐÅ - µÀÕ¢ - ZigBee
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "BarrierCommand.h"
|
||||||
|
|
||||||
|
BarrierCommand::BarrierCommand()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::Barrier);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_GateOn()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_GateOff()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x02);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_GateUp()
|
||||||
|
{
|
||||||
|
SetCommand(0x09, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_GateDown()
|
||||||
|
{
|
||||||
|
SetCommand(0x09, 0x02);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_RequireStatus()
|
||||||
|
{
|
||||||
|
SetCommand(0x20, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_CarLicense_1to3(byte _1, byte _2, byte _3)
|
||||||
|
{
|
||||||
|
SetCommand(0x10, _1, _2, _3);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* BarrierCommand::CMD_CarLicense_4to6(byte _4, byte _5, byte _6)
|
||||||
|
{
|
||||||
|
SetCommand(0x11, _4, _5, _6);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
// BarrierCommand.h
|
||||||
|
|
||||||
|
#ifndef _BARRIERCOMMAND_h
|
||||||
|
#define _BARRIERCOMMAND_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
class BarrierCommand : private CommandEncoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BarrierCommand();
|
||||||
|
public:
|
||||||
|
byte* CMD_GateOn();
|
||||||
|
byte* CMD_GateOff();
|
||||||
|
byte* CMD_GateUp();
|
||||||
|
byte* CMD_GateDown();
|
||||||
|
byte* CMD_RequireStatus();
|
||||||
|
byte* CMD_CarLicense_1to3(byte _1, byte _2, byte _3);
|
||||||
|
byte* CMD_CarLicense_4to6(byte _4, byte _5, byte _6);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "CommandDecoder.h"
|
||||||
|
|
||||||
|
byte CommandDecoder::_CheckSUM(byte main, byte data1, byte data2, byte data3)
|
||||||
|
{
|
||||||
|
return ((byte)((main + data1 + data2 + data3) % 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandDecoder::CommandDecoder()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandDecoder::CommandDecoder(byte* arr)
|
||||||
|
{
|
||||||
|
cmd[0] = arr[0];
|
||||||
|
cmd[1] = arr[1];
|
||||||
|
cmd[2] = arr[2];
|
||||||
|
cmd[3] = arr[3];
|
||||||
|
cmd[4] = arr[4];
|
||||||
|
cmd[5] = arr[5];
|
||||||
|
cmd[6] = arr[6];
|
||||||
|
cmd[7] = arr[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommandDecoder::CommandValidate()
|
||||||
|
{
|
||||||
|
if ((cmd[0] != CommandData::FrameHead) || (cmd[7] != CommandData::FrameEnd))
|
||||||
|
return false;
|
||||||
|
byte checksum = _CheckSUM(cmd[2], cmd[3], cmd[4], cmd[5]);
|
||||||
|
if (cmd[6] != checksum)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte CommandDecoder::GetDevice()
|
||||||
|
{
|
||||||
|
return cmd[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte CommandDecoder::GetMainCommand()
|
||||||
|
{
|
||||||
|
return cmd[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte CommandDecoder::GetDataBit(byte num)
|
||||||
|
{
|
||||||
|
if ((num < 1) || (num > 3))
|
||||||
|
return -1;
|
||||||
|
return cmd[2 + num];
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
// CommandDecoder.h
|
||||||
|
|
||||||
|
#ifndef _COMMANDDECODER_h
|
||||||
|
#define _COMMANDDECODER_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "GlobalDatas.h"
|
||||||
|
|
||||||
|
class CommandDecoder
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
byte cmd[8] = { 0 };
|
||||||
|
private:
|
||||||
|
byte _CheckSUM(byte main, byte data1, byte data2, byte data3);
|
||||||
|
public:
|
||||||
|
CommandDecoder();
|
||||||
|
CommandDecoder(byte* arr);
|
||||||
|
CommandDecoder(const CommandDecoder& obj) = delete;
|
||||||
|
public:
|
||||||
|
bool CommandValidate();
|
||||||
|
public:
|
||||||
|
byte GetDevice();
|
||||||
|
byte GetMainCommand();
|
||||||
|
byte GetDataBit(byte num); //1 - 3
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
byte CommandEncoder::CheckSUM(byte main, byte data1, byte data2, byte data3)
|
||||||
|
{
|
||||||
|
uint16_t sum = ((uint16_t)main + (uint16_t)data1 + (uint16_t)data2 + (uint16_t)data3);
|
||||||
|
return ((byte)(sum % 256));
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandEncoder::CommandEncoder()
|
||||||
|
{
|
||||||
|
cmd[0] = CommandData::FrameHead;
|
||||||
|
cmd[7] = CommandData::FrameEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandEncoder::CommandEncoder(byte ir1, byte ir2, byte ir3, byte ir4, byte ir5, byte ir6)
|
||||||
|
{
|
||||||
|
ir_cmd[0] = ir1;
|
||||||
|
ir_cmd[1] = ir2;
|
||||||
|
ir_cmd[2] = ir3;
|
||||||
|
ir_cmd[3] = ir4;
|
||||||
|
ir_cmd[4] = ir5;
|
||||||
|
ir_cmd[5] = ir6;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandEncoder::CommandEncoder(byte device, byte main, byte data1, byte data2, byte data3)
|
||||||
|
{
|
||||||
|
cmd[0] = CommandData::FrameHead;
|
||||||
|
cmd[1] = device;
|
||||||
|
cmd[2] = main;
|
||||||
|
cmd[3] = data1;
|
||||||
|
cmd[4] = data2;
|
||||||
|
cmd[5] = data3;
|
||||||
|
cmd[6] = CheckSUM(main, data1, data2, data3);
|
||||||
|
cmd[7] = CommandData::FrameEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandEncoder::SetDevice(byte device)
|
||||||
|
{
|
||||||
|
cmd[1] = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandEncoder::OverrideFrameHead(byte h1, byte h2)
|
||||||
|
{
|
||||||
|
cmd[0] = h1;
|
||||||
|
cmd[1] = h2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandEncoder::SetCommand(byte ir1, byte ir2, byte ir3, byte ir4, byte ir5, byte ir6)
|
||||||
|
{
|
||||||
|
ir_cmd[0] = ir1;
|
||||||
|
ir_cmd[1] = ir2;
|
||||||
|
ir_cmd[2] = ir3;
|
||||||
|
ir_cmd[3] = ir4;
|
||||||
|
ir_cmd[4] = ir5;
|
||||||
|
ir_cmd[5] = ir6;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandEncoder::SetCommand(byte main, byte data1, byte data2, byte data3)
|
||||||
|
{
|
||||||
|
cmd[2] = main;
|
||||||
|
cmd[3] = data1;
|
||||||
|
cmd[4] = data2;
|
||||||
|
cmd[5] = data3;
|
||||||
|
cmd[6] = CheckSUM(main, data1, data2, data3);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* CommandEncoder::GetCommandArray()
|
||||||
|
{
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* CommandEncoder::GetIRCommandArray()
|
||||||
|
{
|
||||||
|
return ir_cmd;
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
// CommandEncoder.h
|
||||||
|
|
||||||
|
#ifndef _COMMANDENCODER_h
|
||||||
|
#define _COMMANDENCODER_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
#include "GlobalDatas.h"
|
||||||
|
|
||||||
|
class CommandEncoder
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
byte cmd[8];
|
||||||
|
byte ir_cmd[6];
|
||||||
|
private:
|
||||||
|
byte CheckSUM(byte main, byte data1, byte data2, byte data3);
|
||||||
|
public:
|
||||||
|
CommandEncoder();
|
||||||
|
CommandEncoder(const CommandEncoder& obj) = delete;
|
||||||
|
CommandEncoder(byte ir1, byte ir2, byte ir3, byte ir4, byte ir5, byte ir6);
|
||||||
|
CommandEncoder(byte device, byte main = 0x00, byte data1 = 0x00, byte data2 = 0x00, byte data3 = 0x00);
|
||||||
|
public:
|
||||||
|
void SetDevice(byte device);
|
||||||
|
void OverrideFrameHead(byte h1, byte h2);
|
||||||
|
void SetCommand(byte ir1, byte ir2, byte ir3, byte ir4, byte ir5, byte ir6);
|
||||||
|
void SetCommand(byte main, byte data1 = 0x00, byte data2 = 0x00, byte data3 = 0x00);
|
||||||
|
byte* GetCommandArray();
|
||||||
|
byte* GetIRCommandArray();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,92 @@
|
|||||||
|
//
|
||||||
|
// ±êÖ¾ÎïͨÐÅ - ³µ¿â£¨A/B£© - ZigBee
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "GarageCommand.h"
|
||||||
|
|
||||||
|
GarageCommand::GarageCommand()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::Garage_A);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GarageCommand::UsingA()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::Garage_A);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GarageCommand::UsingB()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::Garage_B);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_PositionReset()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_SetToFloor2()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x02);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_SetToFloor3()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x03);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_SetToFloor4()
|
||||||
|
{
|
||||||
|
SetCommand(0x01, 0x04);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_QueryCurrentPos()
|
||||||
|
{
|
||||||
|
SetCommand(0x02, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* GarageCommand::CMD_QueryIRStatus()
|
||||||
|
{
|
||||||
|
SetCommand(0x02, 0x02);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GarageCommand::IsGarageCommand(byte* data)
|
||||||
|
{
|
||||||
|
if ((data[1] == CommandData::Devices::Garage_A) || (data[1] == CommandData::Devices::Garage_B))
|
||||||
|
return (data[2] == ReturnMainCommand);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GarageCommand::IsPositionData(byte* data)
|
||||||
|
{
|
||||||
|
if (!IsGarageCommand(data))
|
||||||
|
return false;
|
||||||
|
return (data[3] == 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GarageCommand::IsIRData(byte* data)
|
||||||
|
{
|
||||||
|
if (!IsGarageCommand(data))
|
||||||
|
return false;
|
||||||
|
return (data[3] == 0x02);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte GarageCommand::CurrentPos(byte* data)
|
||||||
|
{
|
||||||
|
return data[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GarageCommand::FrontIRTiggered(byte* data)
|
||||||
|
{
|
||||||
|
return (data[4] == 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GarageCommand::BackIRTiggered(byte* data)
|
||||||
|
{
|
||||||
|
return (data[5] == 0x01);
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
// GarageCommand.h
|
||||||
|
|
||||||
|
#ifndef _GARAGECOMMAND_h
|
||||||
|
#define _GARAGECOMMAND_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
class GarageCommand : private CommandEncoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const byte ReturnMainCommand = 0x03;
|
||||||
|
public:
|
||||||
|
GarageCommand();
|
||||||
|
public:
|
||||||
|
void UsingA();
|
||||||
|
void UsingB();
|
||||||
|
public:
|
||||||
|
byte* CMD_PositionReset();
|
||||||
|
byte* CMD_SetToFloor2();
|
||||||
|
byte* CMD_SetToFloor3();
|
||||||
|
byte* CMD_SetToFloor4();
|
||||||
|
byte* CMD_QueryCurrentPos();
|
||||||
|
byte* CMD_QueryIRStatus();
|
||||||
|
public:
|
||||||
|
//需要使用CommandDecoder进行指令合法性校验
|
||||||
|
bool IsGarageCommand(byte* data);
|
||||||
|
bool IsPositionData(byte* data);
|
||||||
|
bool IsIRData(byte* data);
|
||||||
|
byte CurrentPos(byte* data);
|
||||||
|
bool FrontIRTiggered(byte* data);
|
||||||
|
bool BackIRTiggered(byte* data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// ±êÖ¾ÎïͨÐÅ - LEDÏÔʾÆ÷ - ZigBee
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "LEDDisplayCommand.h"
|
||||||
|
|
||||||
|
LEDDisplayCommand::LEDDisplayCommand()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::LED_Display);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_StartTimer()
|
||||||
|
{
|
||||||
|
SetCommand(0x03, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_StopTimer()
|
||||||
|
{
|
||||||
|
SetCommand(0x03, 0x00);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_ClearTimer()
|
||||||
|
{
|
||||||
|
SetCommand(0x03, 0x02);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_FirstLineDisplay(uint32_t num)
|
||||||
|
{
|
||||||
|
if (num >= 0xFFFFFF)
|
||||||
|
SetCommand(0x01, 0xFF, 0xFF, 0xFF);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte d1 = ((num > 0xFFFF) ? (num / 0x10000) : 0x00);
|
||||||
|
num -= (d1 * 0x10000);
|
||||||
|
byte d2 = ((num > 0xFF) ? (num / 0x100) : 0x00);
|
||||||
|
byte d3 = num % 0x100;
|
||||||
|
SetCommand(0x01, d1, d2, d3);
|
||||||
|
}
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_SecondLineDisplay(uint32_t num)
|
||||||
|
{
|
||||||
|
if (num >= 0xFFFFFF)
|
||||||
|
SetCommand(0x02, 0xFF, 0xFF, 0xFF);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte d1 = ((num > 0xFFFF) ? (num / 0x10000) : 0x00);
|
||||||
|
num -= (d1 * 0x10000);
|
||||||
|
byte d2 = ((num > 0xFF) ? (num / 0x100) : 0x00);
|
||||||
|
byte d3 = num % 0x100;
|
||||||
|
SetCommand(0x02, d1, d2, d3);
|
||||||
|
}
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* LEDDisplayCommand::CMD_DisplayDistence(uint16_t dis)
|
||||||
|
{
|
||||||
|
if (dis >= 0xFFF)
|
||||||
|
SetCommand(0x04, 0x00, 0x0F, 0xFF);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte d1 = ((dis > 0xFF) ? (dis / 0x100) : 0x00);
|
||||||
|
dis -= (d1 * 0x100);
|
||||||
|
byte d2 = dis % 0x100;
|
||||||
|
SetCommand(0x04, 0x00, d1, d2);
|
||||||
|
}
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
// LEDDisplayCommand.h
|
||||||
|
|
||||||
|
#ifndef _LEDDISPLAYCOMMAND_h
|
||||||
|
#define _LEDDISPLAYCOMMAND_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
class LEDDisplayCommand : private CommandEncoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LEDDisplayCommand();
|
||||||
|
public:
|
||||||
|
byte* CMD_StartTimer();
|
||||||
|
byte* CMD_StopTimer();
|
||||||
|
byte* CMD_ClearTimer();
|
||||||
|
byte* CMD_FirstLineDisplay(uint32_t num);
|
||||||
|
byte* CMD_SecondLineDisplay(uint32_t num);
|
||||||
|
byte* CMD_DisplayDistence(uint16_t dis);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
// TFTCommand.h
|
||||||
|
|
||||||
|
#ifndef _TFTCOMMAND_h
|
||||||
|
#define _TFTCOMMAND_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CommandEncoder.h"
|
||||||
|
|
||||||
|
class TFTCommand : private CommandEncoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TFTCommand();
|
||||||
|
public:
|
||||||
|
void UsingA();
|
||||||
|
void UsingB();
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,110 @@
|
|||||||
|
//
|
||||||
|
// ±êÖ¾ÎïͨÐÅ - ÓïÒô²¥±¨ - ZigBee
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "VoiceRepotCommand.h"
|
||||||
|
|
||||||
|
VoiceReportCommand::VoiceReportCommand()
|
||||||
|
{
|
||||||
|
SetDevice(CommandData::Devices::VoiceReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_ReportSpecVoice(VoiceCmd type)
|
||||||
|
{
|
||||||
|
SetCommand(0x10, (byte)type);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_ReportRandomVoice()
|
||||||
|
{
|
||||||
|
SetCommand(0x20, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_SetRTCStartDate(uint16_t year, byte month, byte day)
|
||||||
|
{
|
||||||
|
byte two_bit_year = year - 2000;
|
||||||
|
SetCommand(0x30, two_bit_year, month, day);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_ReadRTCDate()
|
||||||
|
{
|
||||||
|
SetCommand(0x31, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_SetRTCStartTime(byte hour, byte minute, byte second)
|
||||||
|
{
|
||||||
|
SetCommand(0x40, hour, minute, second);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_ReadRTCTime()
|
||||||
|
{
|
||||||
|
SetCommand(0x41, 0x01);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_SetWeatherAndTemperature(WeatherCmd weather, byte temp)
|
||||||
|
{
|
||||||
|
SetCommand(0x42, (byte)weather, temp);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* VoiceReportCommand::CMD_QueryWeatherAndTemperator()
|
||||||
|
{
|
||||||
|
SetCommand(0x43);
|
||||||
|
return GetCommandArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VoiceReportCommand::IsVoiceCommand(byte* cmd)
|
||||||
|
{
|
||||||
|
return ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_VoiceCommand));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VoiceReportCommand::IsVoiceAvailable(byte* cmd)
|
||||||
|
{
|
||||||
|
if (!IsVoiceCommand(cmd))
|
||||||
|
return false;
|
||||||
|
return (cmd[3] == 0x4F);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VoiceReportCommand::ReadRTCDate(byte* cmd, uint16_t& year, byte& month, byte& day)
|
||||||
|
{
|
||||||
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_DateCommand))
|
||||||
|
{
|
||||||
|
year = 2000 + cmd[3];
|
||||||
|
month = cmd[4];
|
||||||
|
day = cmd[5];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VoiceReportCommand::ReadRTCTime(byte* cmd, byte& hour, byte& minute, byte& second)
|
||||||
|
{
|
||||||
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_TimeCommand))
|
||||||
|
{
|
||||||
|
hour = cmd[3];
|
||||||
|
minute = cmd[4];
|
||||||
|
second = cmd[5];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VoiceReportCommand::ReadWeatherAndTemperature(byte* cmd, WeatherCmd& weather, byte& temp)
|
||||||
|
{
|
||||||
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_WeatherTempCommand))
|
||||||
|
{
|
||||||
|
weather = (WeatherCmd)cmd[3];
|
||||||
|
temp = cmd[4];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ZigBeeOperator.h"
|
||||||
|
|
||||||
|
void ZigBeeOperatorClass::Initialization()
|
||||||
|
{
|
||||||
|
ExtSRAMInterface.Initialization();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigBeeOperatorClass::SendCommand(uint8_t* cmd, uint16_t siz)
|
||||||
|
{
|
||||||
|
ExtSRAMInterface.ExMem_Write_Bytes(zigbee_address, cmd, siz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ZigBeeOperatorClass ZigBeeOperator;
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
// ZigBeeOperator.h
|
||||||
|
|
||||||
|
#ifndef _ZIGBEEOPERATOR_h
|
||||||
|
#define _ZIGBEEOPERATOR_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include "arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ExtSRAMInterface.h>
|
||||||
|
|
||||||
|
class ZigBeeOperatorClass
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const uint16_t zigbee_address = 0x6008;
|
||||||
|
public:
|
||||||
|
void Initialization();
|
||||||
|
public:
|
||||||
|
void SendCommand(uint8_t* cmd, uint16_t siz = 8);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern ZigBeeOperatorClass ZigBeeOperator;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue