fixed decode issue for new API 0.1.1

This commit is contained in:
2017-05-09 20:56:01 +08:00
parent a51640d037
commit 97e3292d97
12 changed files with 267 additions and 201 deletions

View File

@@ -2,9 +2,9 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Android.iml" filepath="$PROJECT_DIR$/Android.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/decodesdk/decodesdk.iml" filepath="$PROJECT_DIR$/decodesdk/decodesdk.iml" />
<module fileurl="file://$PROJECT_DIR$/irext-example-android.iml" filepath="$PROJECT_DIR$/irext-example-android.iml" />
</modules>
</component>
</project>

View File

@@ -76,7 +76,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
* Method: irClose
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_net_irext_decodesdk_IRDecode_irACLibClose
JNIEXPORT void JNICALL Java_net_irext_decodesdk_IRDecode_irClose
(JNIEnv *, jobject);
/*

View File

@@ -22,6 +22,7 @@ extern "C"
#define TAG_COUNT_FOR_PROTOCOL 29
#define TAG_INVALID 0xffff
#define MAX_DELAYCODE_NUM 16
#define MAX_BITNUM 16
@@ -368,11 +369,11 @@ struct ir_bin_buffer
typedef struct REMOTE_AC_STATUS
{
UINT8 acPower;
UINT8 acTemp;
UINT8 acMode;
UINT8 acWindDir;
UINT8 acWindSpeed;
ac_power acPower;
ac_temperature acTemp;
ac_mode acMode;
ac_swing acWindDir;
ac_wind_speed acWindSpeed;
UINT8 acDisplay;
UINT8 acSleep;
UINT8 acTimer;

View File

@@ -25,170 +25,134 @@ extern "C"
#define IR_DECODE_FAILED (-1)
#define IR_DECODE_SUCCEEDED (0)
#define EXPECTED_MEM_SIZE 1024
#define IR_CATEGORY_AC 1
#define IR_CATEGORY_TV 2
#define IR_TYPE_STATUS 0
#define IR_TYPE_COMMANDS 1
/* exported functions */
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
/*
* function ir_ac_file_open
#define SUB_CATEGORY_QUATERNARY 0
#define SUB_CATEGORY_HEXADECIMAL 1
// exported functions
/**
* function ir_file_open
*
* parameters: file name of remote binary
* description: open IR binary code from file
*
* parameters: category (in) - category ID get from indexing API
* sub_category (in) - subcategory ID get from indexing API
* file_name (in) - file name of IR binary
*
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 ir_ac_file_open(const char *file_name);
extern INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name);
/*
* function ir_ac_lib_open
/**
* function ir_binary_open
*
* parameters: binary (in) binary content
* binary_length (in) length of binary content
* description: open IR binary code from buffer
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* parameters: category (in) - category ID get from indexing API
* sub_category (in) - subcategory ID get from indexing API
* binary (in) - pointer to binary buffer
* binary_length (in) - binary buffer size
*
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length);
extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length);
/*
* function ir_ac_lib_parse
/**
* function ir_decode
*
* parameters:
* description: decode IR binary into INT16 array which indicates the IR levels
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* parameters: key_code (in) - the code of pressed key
* user_data (out) - output decoded data in INT16 array format
* ac_status(in) - pointer to AC status (optional)
* change_wind_direction (in) - if control changes wind direction for AC (for AC only)
*
* returns: length of decoded data (0 indicates decode failure)
*/
extern INT8 ir_ac_lib_parse();
extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction);
/*
* function ir_ac_lib_control
/**
* function ir_close
*
* parameters: ac_status (in) indicates the current status of air conditioner to be controlled
* user_data (out) wave code array to be transmitted
* function_code (in) indicates the AC function to be updated
* change_wind_direction (in) indicates if the wind direction need to be changed
* description: close IR binary code
*
* return: length of wave code array
* parameters: N/A
*
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction);
extern INT8 ir_close();
/*
* function ir_ac_lib_close
/**
* function get_temperature_range
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 ir_ac_lib_close();
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
/*
* function ir_tv_file_open
*
* parameters: file name of remote binary
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
INT8 ir_tv_file_open(const char *file_name);
/*
* function ir_tv_lib_open
*
* parameters: binary (in) binary content
* binary_length (in) length of binary content
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length);
/*
* function ir_tv_lib_parse
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 ir_tv_lib_parse(UINT8 ir_hex_encode);
/*
* function ir_tv_lib_control
*
* parameters: key_code (in) indicates the number of pressed key
* user_data (out) wave code array to be transmitted
*
* return: length of wave code array
*/
extern UINT16 ir_tv_lib_control(UINT8 key_code, UINT16 *user_data);
/*
* function ir_tv_lib_close
*
* parameters:
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 ir_tv_lib_close();
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
/*
* function get_temperature_range
* description: get the supported temperature range [min, max] for the opened AC IR binary
*
* parameters: ac_mode (in) specify in which AC mode the application need to get temperature info
* temp_min (out) the min temperature supported in a specified AC mode
* temp_max (out) the max temperature supported in a specified AC mode
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max);
/*
* function get_supported_mode
/**
* function get_supported_mode
*
* description: get supported mode for the opened AC IR binary
*
* parameters: supported_mode (out) mode supported by the remote in lower 5 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_mode(UINT8 *supported_mode);
/*
* function get_supported_wind_speed
/**
* function get_supported_wind_speed
*
* description: get supported wind speed levels for the opened AC IR binary in certain mode
*
* parameters: ac_mode (in) specify in which AC mode the application need to get wind speed info
* supported_wind_speed (out) wind speed supported by the remote in lower 4 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed);
/*
* function get_supported_swing
/**
* function get_supported_swing
*
* description: get supported swing functions for the opened AC IR binary in certain mode
*
* parameters: ac_mode (in) specify in which AC mode the application need to get swing info
* supported_swing (out) swing supported by the remote in lower 2 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing);
/*
* function get_supported_wind_direction
/**
* function get_supported_wind_direction
*
* description: get supported wind directions for the opened AC IR binary in certain mode
*
* parameters: supported_wind_direction (out) swing supported by the remote in lower 2 bits
*
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
*/
extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction);
// private extern function
#if (defined BOARD_PC || defined BOARD_PC_DLL)
extern void ir_lib_free_inner_buffer();
#endif
///////////////////////////////////////////////// Utils End /////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif

View File

@@ -204,6 +204,8 @@ extern BOOL tv_lib_parse(UINT8 encode_type);
extern UINT16 tv_lib_control(UINT8 key, UINT16 *user_data);
extern UINT8 tv_lib_close();
#ifdef __cplusplus
}
#endif

View File

@@ -21,11 +21,11 @@ extern struct tag_head *tags;
UINT8 tag_count = 0;
const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] =
{
1, 2, 3, 4, 5, 6, 7,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
41, 42, 43, 44, 45, 46, 47, 48
};
{
1, 2, 3, 4, 5, 6, 7,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
41, 42, 43, 44, 45, 46, 47, 48
};
INT8 binary_parse_offset()
{
@@ -50,6 +50,7 @@ INT8 binary_parse_offset()
{
tags[i].tag = tag_index[i];
tags[i].offset = *(phead + i);
if (tags[i].offset == TAG_INVALID)
{
tags[i].len = 0;

View File

@@ -394,6 +394,7 @@ INT8 ir_ac_lib_parse()
/* in case of running with test - begin */
#if (defined BOARD_PC || defined BOARD_PC_DLL)
ir_lib_free_inner_buffer();
ir_printf("AC parse done\n");
#endif
/* in case of running with test - end */

View File

@@ -18,8 +18,6 @@ Revision log:
#include "../include/ir_utils.h"
#include "../include/ir_ac_build_frame.h"
#include "../include/ir_ac_apply.h"
#include "../include/ir_ac_control.h"
#include "../include/ir_tv_control.h"
struct ir_bin_buffer binary_file;
struct ir_bin_buffer *p_ir_buffer = &binary_file;
@@ -34,29 +32,166 @@ UINT8 byteArray[PROTOCOL_SIZE] = {0};
size_t binary_length = 0;
UINT8 *binary_content = NULL;
UINT8 ir_binary_type = IR_TYPE_STATUS;
UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
protocol *context = (protocol *) byteArray;
lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
{
apply_power,
apply_mode,
apply_temperature,
apply_temperature,
apply_wind_speed,
apply_swing,
apply_swing
};
// static functions declarations
static INT8 ir_ac_file_open(const char *file_name);
static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length);
static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction);
static INT8 ir_ac_lib_close();
static INT8 ir_tv_file_open(const char *file_name);
static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length);
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode);
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data);
static INT8 ir_tv_lib_close();
// pubic function definitions
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
{
INT8 ret = IR_DECODE_SUCCEEDED;
if (category == IR_CATEGORY_AC)
{
ir_binary_type = IR_TYPE_STATUS;
ret = ir_ac_file_open(file_name);
if (IR_DECODE_SUCCEEDED == ret)
{
apply_power,
apply_mode,
apply_temperature,
apply_temperature,
apply_wind_speed,
apply_swing,
apply_swing
};
return ir_ac_lib_parse();
}
else
{
return ret;
}
}
else
{
ir_binary_type = IR_TYPE_COMMANDS;
if (1 == sub_category)
{
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
}
else if (2 == sub_category)
{
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
}
else
{
return IR_DECODE_FAILED;
}
ret = ir_tv_file_open(file_name);
if (IR_DECODE_SUCCEEDED == ret)
{
return ir_tv_lib_parse(ir_hexadecimal);
}
else
{
return ret;
}
}
}
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
{
INT8 ret = IR_DECODE_SUCCEEDED;
if (category == IR_CATEGORY_AC)
{
ir_binary_type = IR_TYPE_STATUS;
ret = ir_ac_lib_open(binary, binary_length);
if (IR_DECODE_SUCCEEDED == ret)
{
return ir_ac_lib_parse();
}
else
{
return ret;
}
}
else
{
ir_binary_type = IR_TYPE_COMMANDS;
if (1 == sub_category)
{
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
}
else if (2 == sub_category)
{
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
}
else
{
return IR_DECODE_FAILED;
}
ret = ir_tv_lib_open(binary, binary_length);
if (IR_DECODE_SUCCEEDED == ret)
{
return ir_tv_lib_parse(ir_hexadecimal);
}
else
{
return ret;
}
}
}
UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction)
{
if (IR_TYPE_COMMANDS == ir_binary_type)
{
return ir_tv_lib_control(key_code, user_data);
}
else
{
if (NULL == ac_status)
{
return 0;
}
return ir_ac_lib_control(*ac_status, user_data, key_code, change_wind_direction);
}
}
INT8 ir_close()
{
if (IR_TYPE_COMMANDS == ir_binary_type)
{
return ir_tv_lib_close();
}
else
{
return ir_ac_lib_close();
}
}
#if (defined BOARD_PC || defined BOARD_PC_DLL)
void ir_lib_free_inner_buffer();
#endif
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
INT8 ir_ac_file_open(const char *file_name)
// static function definitions
//////// AC Begin ////////
static INT8 ir_ac_file_open(const char *file_name)
{
#if !defined NO_FS
size_t ret = 0;
@@ -106,7 +241,7 @@ INT8 ir_ac_file_open(const char *file_name)
return IR_DECODE_SUCCEEDED;
}
INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
{
// it is recommended that the parameter binary pointing to
// a global memory block in embedded platform environment
@@ -116,7 +251,7 @@ INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
return IR_DECODE_SUCCEEDED;
}
UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction)
{
UINT16 time_length = 0;
@@ -228,7 +363,7 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8
return time_length;
}
INT8 ir_ac_lib_close()
static INT8 ir_ac_lib_close()
{
// free context
if (NULL != tags)
@@ -383,10 +518,10 @@ INT8 get_supported_wind_direction(UINT8 *supported_wind_direction)
}
}
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
//////// AC End ////////
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
INT8 ir_tv_file_open(const char *file_name)
//////// TV Begin ////////
static INT8 ir_tv_file_open(const char *file_name)
{
#if !defined NO_FS
size_t ret = 0;
@@ -437,12 +572,12 @@ INT8 ir_tv_file_open(const char *file_name)
return IR_DECODE_SUCCEEDED;
}
INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length)
static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length)
{
return tv_lib_open(binary, binary_length);
}
INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
{
if (FALSE == tv_lib_parse(ir_hex_encode))
{
@@ -452,7 +587,7 @@ INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
return IR_DECODE_SUCCEEDED;
}
UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
{
#if defined BOARD_PC
UINT16 print_index = 0;
@@ -463,30 +598,27 @@ UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
#if defined BOARD_PC
// have some debug
ir_printf("=============================\n");
ir_printf("length of IRDA code = %d\n", ir_code_length);
ir_printf("length of IR code = %d\n", ir_code_length);
for (print_index = 0; print_index < ir_code_length; print_index++)
{
ir_printf("%d ", l_user_data[print_index]);
}
ir_printf("\n=============================\n\n");
#endif
return ir_code_length;
}
INT8 ir_tv_lib_close()
static INT8 ir_tv_lib_close()
{
#if (defined BOARD_PC || defined BOARD_PC_DLL)
ir_lib_free_inner_buffer();
#endif
return IR_DECODE_SUCCEEDED;
}
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
//////// TV End ////////
#if (defined BOARD_PC || defined BOARD_PC_DLL)
void ir_lib_free_inner_buffer()
{
if (NULL != binary_content)
@@ -495,5 +627,4 @@ void ir_lib_free_inner_buffer()
binary_content = NULL;
}
}
#endif

View File

@@ -45,7 +45,7 @@ static BOOL get_ir_protocol(UINT8 encode_type);
static BOOL get_ir_keymap(void);
static void print_ir_time(ir_data_t *data, UINT8 keyindex, UINT16 *ir_time);
static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time);
static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time);
@@ -181,12 +181,12 @@ static BOOL get_ir_keymap(void)
return FALSE;
}
static void print_ir_time(ir_data_t *data, UINT8 keyindex, UINT16 *ir_time)
static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
{
UINT8 i = 0;
UINT8 cycles_num = 0;
ir_cycles_t *pcycles = NULL;
UINT8 keycode = 0;
UINT8 key_code = 0;
if (NULL == data || NULL == ir_time)
{
@@ -194,7 +194,7 @@ static void print_ir_time(ir_data_t *data, UINT8 keyindex, UINT16 *ir_time)
}
pcycles = prot_cycles_data[data->index];
keycode = remote_pdata[remote_p->per_keycode_bytes * keyindex + data->index - 1];
key_code = remote_pdata[remote_p->per_keycode_bytes * key_index + data->index - 1];
if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1)
{
@@ -305,22 +305,22 @@ static void print_ir_time(ir_data_t *data, UINT8 keyindex, UINT16 *ir_time)
{
// mode: inverse
if (data->mode == 1)
keycode = ~keycode;
key_code = ~key_code;
if (ir_decode_flag == IRDA_DECODE_1_BIT)
{
// for binary formatted code
process_decode_number(keycode, data, 1, ir_time);
process_decode_number(key_code, data, 1, ir_time);
}
else if (ir_decode_flag == IRDA_DECODE_2_BITS)
{
// for quanternary formatted code
process_decode_number(keycode, data, 2, ir_time);
process_decode_number(key_code, data, 2, ir_time);
}
else if (ir_decode_flag == IRDA_DECODE_4_BITS)
{
// for hexadecimal formatted code
process_decode_number(keycode, data, 4, ir_time);
process_decode_number(key_code, data, 4, ir_time);
}
}
}

View File

@@ -175,7 +175,8 @@ static void IRext_processState()
{
if (IR_TYPE_TV == dccb.ir_type)
{
if (IR_DECODE_SUCCEEDED == ir_tv_lib_open(dccb.source_code, dccb.source_code_length))
if (IR_DECODE_SUCCEEDED ==
ir_binary_open(IR_CATEGORY_TV, 1, dccb.source_code, dccb.source_code_length))
{
LCD_WRITE_STRING("IR OPENED", LCD_PAGE7);
HalLedSet(HAL_LED_1, HAL_LED_MODE_ON);
@@ -188,7 +189,8 @@ static void IRext_processState()
}
else if (IR_TYPE_AC == dccb.ir_type)
{
if (IR_DECODE_SUCCEEDED == ir_ac_lib_open(dccb.source_code, dccb.source_code_length))
if (IR_DECODE_SUCCEEDED ==
ir_binary_open(IR_CATEGORY_AC, 1, dccb.source_code, dccb.source_code_length))
{
LCD_WRITE_STRING("IR OPENED", LCD_PAGE7);
HalLedSet(HAL_LED_1, HAL_LED_MODE_ON);
@@ -206,41 +208,7 @@ static void IRext_processState()
}
else if (IR_STATE_OPENED == dccb.ir_state)
{
if (IR_TYPE_TV == dccb.ir_type)
{
if (IR_DECODE_SUCCEEDED == ir_tv_lib_parse(0))
{
LCD_WRITE_STRING("IR PARSED", LCD_PAGE7);
HalLedSet(HAL_LED_2, HAL_LED_MODE_ON);
dccb.ir_state = IR_STATE_PARSED;
}
else
{
LCD_WRITE_STRING("PARSE TV ERROR", LCD_PAGE7);
}
}
else if (IR_TYPE_AC == dccb.ir_type)
{
if (IR_DECODE_SUCCEEDED == ir_ac_lib_parse())
{
LCD_WRITE_STRING("IR PARSED", LCD_PAGE7);
HalLedSet(HAL_LED_2, HAL_LED_MODE_ON);
dccb.ir_state = IR_STATE_PARSED;
}
else
{
LCD_WRITE_STRING("PARSE AC ERROR", LCD_PAGE7);
}
}
else
{
LCD_WRITE_STRING("TYPE ERROR", LCD_PAGE7);
}
}
else if (IR_STATE_PARSED == dccb.ir_state)
{
if ((dccb.ir_type == IR_TYPE_TV && IR_DECODE_SUCCEEDED == ir_tv_lib_close()) ||
(dccb.ir_type == IR_TYPE_AC && IR_DECODE_SUCCEEDED == ir_ac_lib_close()))
if (IR_DECODE_SUCCEEDED == ir_close())
{
LCD_WRITE_STRING("IR READY", LCD_PAGE7);
HalLedSet(HAL_LED_1 | HAL_LED_2, HAL_LED_MODE_OFF);
@@ -252,15 +220,15 @@ static void IRext_processState()
// KEY operation
static void IRext_processKey(uint8_t ir_type, uint8_t ir_key, char* key_display)
{
if (IR_STATE_PARSED == dccb.ir_state)
if (IR_STATE_OPENED == dccb.ir_state)
{
if (IR_TYPE_TV == dccb.ir_type)
{
dccb.decoded_length = ir_tv_lib_control(ir_key, dccb.ir_decoded);
dccb.decoded_length = ir_decode(ir_key, dccb.ir_decoded, NULL, 0);
}
else if (IR_TYPE_AC == dccb.ir_type)
{
dccb.decoded_length = ir_ac_lib_control(ac_status, dccb.ir_decoded, ir_key, 0);
dccb.decoded_length = ir_decode(ir_key, dccb.ir_decoded, &ac_status, 0);
}
else
{
@@ -387,7 +355,7 @@ static void ParseCommand(uint8_t* data, uint16_t len)
uint8 key_code = 0;
uint8 ac_function = 0;
if (IR_STATE_PARSED != dccb.ir_state)
if (IR_STATE_OPENED != dccb.ir_state)
{
// feek back error state
WriteBytes("11", 2);
@@ -400,12 +368,12 @@ static void ParseCommand(uint8_t* data, uint16_t len)
{
// decode as TV
key_code = data[1] - 0x30;
dccb.decoded_length = ir_tv_lib_control(key_code, dccb.ir_decoded);
dccb.decoded_length = ir_decode(key_code, dccb.ir_decoded, NULL, 0);
}
else if (IR_TYPE_AC == dccb.ir_type && 0x32 == ir_type)
{
ac_function = data[1] - 0x30;
dccb.decoded_length = ir_ac_lib_control(ac_status, dccb.ir_decoded, ac_function, 0);
dccb.decoded_length = ir_decode(ac_function, dccb.ir_decoded, &ac_status, 0);
}
if (dccb.decoded_length > 0)

View File

@@ -53,7 +53,6 @@ extern "C"
#define IR_KEY_VOL_UP 7
#define IR_KEY_VOL_DOWN 8
typedef enum
{
IR_TYPE_NONE = 0,
@@ -68,7 +67,6 @@ typedef enum
IR_STATE_NONE,
IR_STATE_READY,
IR_STATE_OPENED,
IR_STATE_PARSED,
IR_STATE_MAX
} ir_state_t;