📄 necdecode.h
字号:
#include "decode.h"
#include "ircommand.h"
class NEC_Decode : public IR_Decode
{
class DecodeGroup
{
public:
BOOLEAN isLongSpace(BYTE bit, BYTE bit_count);
BOOLEAN isShortSpace(BYTE bit, BYTE bit_count);
BOOLEAN isLeaderCode(BYTE bit, BYTE bit_count);
BOOLEAN isShortRepeat(BYTE bit, BYTE bit_count);
BOOLEAN isRepeatSpace(BYTE bit, BYTE bit_count);
private:
//long space (for a 1)
static const BYTE _min_long_space;
static const BYTE _max_long_space;
//short space (for a 0)
static const BYTE _min_short_space;
static const BYTE _max_short_space;
//leader code, and long pulse of repeat code
static const BYTE _min_leader_code;
static const BYTE _max_leader_code;
//short pulse of repeat code
static const BYTE _min_short_repeat;
static const BYTE _max_short_repeat;
//short pulse of repeat code
static const BYTE _min_repeat_space;
static const BYTE _max_repeat_space;
};
public:
NEC_Decode(DWORD ir_command_table);
virtual ULONG submitSample(DWORD sample);
virtual IR_Command* getIrCommand();
protected:
ULONG getCommand();
ULONG processShortRepeat();
VOID processLeaderCode();
VOID processLongSpace();
VOID processShortSpace();
VOID reset();
private:
BYTE _current_bit;
BYTE _bit_count;
//Keeps track of which bit we are on currently.
BYTE _bit_index;
//This is where we store the bit's found,
BYTE _address;
BYTE _inverse_address;
BYTE _command;
BYTE _inverse_command;
BOOLEAN _found_leader_code;
BOOLEAN _found_repeat_space;
BOOLEAN _command_is_valid;
DecodeGroup _decode_group;
IR_Command _nec_command;
};
inline VOID NEC_Decode::reset()
{
_address = 0;
_inverse_address = 0;
_command = 0;
_inverse_command = 0;
_command_is_valid = FALSE;
}
inline VOID NEC_Decode::processShortSpace()
{
//Reset if this is the first bit since the command started.
//This initializes all command fields to zero
if(_bit_index == 0)
{
reset();
}
_bit_index++;
}
inline VOID NEC_Decode::processLeaderCode()
{
_found_leader_code = TRUE;
//Reset the bit index
_bit_index = 0;
}
inline BOOLEAN NEC_Decode::DecodeGroup::isLongSpace(
BYTE bit,
BYTE bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_long_space) &&
(bit_count <= _max_long_space));
}
inline BOOLEAN NEC_Decode::DecodeGroup::isShortSpace(
BYTE bit,
BYTE bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_short_space) &&
(bit_count <= _max_short_space));
}
inline BOOLEAN NEC_Decode::DecodeGroup::isLeaderCode(
BYTE bit,
BYTE bit_count)
{
return ((bit == 0) &&
(bit_count >= _min_leader_code) &&
(bit_count <= _max_leader_code));
}
inline BOOLEAN NEC_Decode::DecodeGroup::isShortRepeat(
BYTE bit,
BYTE bit_count)
{
return ((bit == 0) &&
(bit_count >= _min_short_repeat) &&
(bit_count <= _max_short_repeat));
}
inline BOOLEAN NEC_Decode::DecodeGroup::isRepeatSpace(
BYTE bit,
BYTE bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_repeat_space) &&
(bit_count <= _max_repeat_space));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -