📄 ir_decode.h
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#ifndef _IR_DECODE_H_
#define _IR_DECODE_H_
extern "C"
{
#include <wdm.h>
}
#include <windef.h>
#include <ks.h>
#include <ksmedia.h>
#define DECODE_REPEAT_COMMAND 0x00010000
class IR_Decode
{
class DecodeGroup
{
public:
BOOLEAN isLongSpace(BYTE bit, DWORD bit_count);
BOOLEAN isShortSpace(BYTE bit, DWORD bit_count);
BOOLEAN isLeaderCode(BYTE bit, DWORD bit_count);
BOOLEAN isShortRepeat(BYTE bit, DWORD bit_count);
BOOLEAN isRepeatSpace(BYTE bit, DWORD bit_count);
private:
//long space (for a 1)
static const DWORD _min_long_space;
static const DWORD _max_long_space;
//short space (for a 0)
static const DWORD _min_short_space;
static const DWORD _max_short_space;
//leader code, and long pulse of repeat code
static const DWORD _min_leader_code;
static const DWORD _max_leader_code;
//short pulse of repeat code
static const DWORD _min_short_repeat;
static const DWORD _max_short_repeat;
//short pulse of repeat code
static const DWORD _min_repeat_space;
static const DWORD _max_repeat_space;
};
public:
IR_Decode();
~IR_Decode();
ULONG submitSample(WORD sample, DWORD* p_address);
protected:
ULONG getCommand(DWORD* p_address);
ULONG processShortRepeat();
VOID processLeaderCode();
VOID processLongSpace();
VOID processShortSpace();
VOID reset();
private:
//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* _p_decode_group;
};
inline VOID IR_Decode::reset()
{
_address = 0;
_inverse_address = 0;
_command = 0;
_inverse_command = 0;
_command_is_valid = FALSE;
}
inline VOID IR_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 IR_Decode::processLeaderCode()
{
_found_leader_code = TRUE;
//Reset the bit index
_bit_index = 0;
}
inline BOOLEAN IR_Decode::DecodeGroup::isLongSpace(
BYTE bit,
DWORD bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_long_space) &&
(bit_count <= _max_long_space));
}
inline BOOLEAN IR_Decode::DecodeGroup::isShortSpace(
BYTE bit,
DWORD bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_short_space) &&
(bit_count <= _max_short_space));
}
inline BOOLEAN IR_Decode::DecodeGroup::isLeaderCode(
BYTE bit,
DWORD bit_count)
{
return ((bit == 0) &&
(bit_count >= _min_leader_code) &&
(bit_count <= _max_leader_code));
}
inline BOOLEAN IR_Decode::DecodeGroup::isShortRepeat(
BYTE bit,
DWORD bit_count)
{
return ((bit == 0) &&
(bit_count >= _min_short_repeat) &&
(bit_count <= _max_short_repeat));
}
inline BOOLEAN IR_Decode::DecodeGroup::isRepeatSpace(
BYTE bit,
DWORD bit_count)
{
return ((bit == 1) &&
(bit_count >= _min_repeat_space) &&
(bit_count <= _max_repeat_space));
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -