aligned decode algorithm sources to core project

This commit is contained in:
2019-01-16 13:06:20 +08:00
parent 08e2c75cb3
commit 883d037d2a
5 changed files with 49 additions and 46 deletions

View File

@@ -199,11 +199,11 @@ typedef struct ir_data_tv
} t_ir_data_tv; } t_ir_data_tv;
extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); extern INT8 tv_binary_open(UINT8 *binary, UINT16 binary_length);
extern BOOL tv_lib_parse(UINT8 encode_type); extern BOOL tv_binary_parse(UINT8 encode_type);
extern UINT16 tv_lib_control(UINT8 key, UINT16 *user_data); extern UINT16 tv_binary_decode(UINT8 key, UINT16 *user_data);
extern UINT8 tv_lib_close(); extern UINT8 tv_lib_close();

View File

@@ -57,7 +57,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
UINT16 user_data[USER_DATA_SIZE]; UINT16 user_data[USER_DATA_SIZE];
int i = 0; int i = 0;
jint copy_array[USER_DATA_SIZE] = {0}; jint copy_array[USER_DATA_SIZE] = {0};
remote_ac_status_t ac_status; t_remote_ac_status ac_status;
jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status); jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status);
@@ -78,14 +78,14 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
jfieldID ac_wind_speed_fid = (*env)->GetFieldID(env, n_ac_status, "acWindSpeed", "I"); jfieldID ac_wind_speed_fid = (*env)->GetFieldID(env, n_ac_status, "acWindSpeed", "I");
jint i_ac_wind_speed = (*env)->GetIntField(env, jni_ac_status, ac_wind_speed_fid); jint i_ac_wind_speed = (*env)->GetIntField(env, jni_ac_status, ac_wind_speed_fid);
ac_status.acDisplay = 0; ac_status.ac_display = 0;
ac_status.acSleep = 0; ac_status.ac_sleep = 0;
ac_status.acTimer = 0; ac_status.ac_timer = 0;
ac_status.acPower = i_ac_power; ac_status.ac_power = i_ac_power;
ac_status.acMode = i_ac_mode; ac_status.ac_mode = i_ac_mode;
ac_status.acTemp = i_ac_temp; ac_status.ac_temp = i_ac_temp;
ac_status.acWindDir = i_ac_wind_dir; ac_status.ac_wind_dir = i_ac_wind_dir;
ac_status.acWindSpeed = i_ac_wind_speed; ac_status.ac_wind_speed = i_ac_wind_speed;
} }
int wave_code_length = ir_decode(key_code, user_data, &ac_status, change_wind_direction); int wave_code_length = ir_decode(key_code, user_data, &ac_status, change_wind_direction);

View File

@@ -141,5 +141,3 @@ UINT16 create_ir_frame()
return context->code_cnt; return context->code_cnt;
} }

View File

@@ -54,15 +54,15 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
// static functions declarations // static functions declarations
static INT8 ir_ac_file_open(const char *file_name); static INT8 ir_ac_file_open(const char *file_name);
static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length); static INT8 ir_ac_binary_open(UINT8 *binary, UINT16 binary_length);
static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction); BOOL change_wind_direction);
static INT8 ir_ac_lib_close(); static INT8 ir_ac_binary_close();
static INT8 ir_tv_file_open(const char *file_name); 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_binary_open(UINT8 *binary, UINT16 binary_length);
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode); static INT8 ir_tv_binary_parse(UINT8 ir_hex_encode);
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data); static UINT16 ir_tv_control(UINT8 key, UINT16 *l_user_data);
static INT8 ir_tv_lib_close(); static INT8 ir_tv_binary_close();
void noprint(const char *fmt, ...) void noprint(const char *fmt, ...)
@@ -71,7 +71,7 @@ void noprint(const char *fmt, ...)
} }
// pubic function definitions // pubic function definitions
#if (!defined BOARD_51 && !defined BOARD_CC26XX)
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name) INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
{ {
INT8 ret = IR_DECODE_SUCCEEDED; INT8 ret = IR_DECODE_SUCCEEDED;
@@ -107,7 +107,7 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
ret = ir_tv_file_open(file_name); ret = ir_tv_file_open(file_name);
if (IR_DECODE_SUCCEEDED == ret) if (IR_DECODE_SUCCEEDED == ret)
{ {
return ir_tv_lib_parse(ir_hexadecimal); return ir_tv_binary_parse(ir_hexadecimal);
} }
else else
{ {
@@ -115,7 +115,12 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
} }
} }
} }
#else
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
{
return IR_DECODE_SUCCESS;
}
#endif
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length) INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
{ {
@@ -124,7 +129,7 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar
if (category == IR_CATEGORY_AC) if (category == IR_CATEGORY_AC)
{ {
ir_binary_type = IR_TYPE_STATUS; ir_binary_type = IR_TYPE_STATUS;
ret = ir_ac_lib_open(binary, binary_length); ret = ir_ac_binary_open(binary, binary_length);
if (IR_DECODE_SUCCEEDED == ret) if (IR_DECODE_SUCCEEDED == ret)
{ {
return ir_ac_lib_parse(); return ir_ac_lib_parse();
@@ -150,10 +155,10 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar
return IR_DECODE_FAILED; return IR_DECODE_FAILED;
} }
ret = ir_tv_lib_open(binary, binary_length); ret = ir_tv_binary_open(binary, binary_length);
if (IR_DECODE_SUCCEEDED == ret) if (IR_DECODE_SUCCEEDED == ret)
{ {
return ir_tv_lib_parse(ir_hexadecimal); return ir_tv_binary_parse(ir_hexadecimal);
} }
else else
{ {
@@ -167,7 +172,7 @@ UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_statu
{ {
if (IR_TYPE_COMMANDS == ir_binary_type) if (IR_TYPE_COMMANDS == ir_binary_type)
{ {
return ir_tv_lib_control(key_code, user_data); return ir_tv_control(key_code, user_data);
} }
else else
{ {
@@ -175,7 +180,7 @@ UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_statu
{ {
return 0; return 0;
} }
return ir_ac_lib_control(*ac_status, user_data, key_code, change_wind_direction); return ir_ac_control(*ac_status, user_data, key_code, change_wind_direction);
} }
} }
@@ -184,11 +189,11 @@ INT8 ir_close()
{ {
if (IR_TYPE_COMMANDS == ir_binary_type) if (IR_TYPE_COMMANDS == ir_binary_type)
{ {
return ir_tv_lib_close(); return ir_tv_binary_close();
} }
else else
{ {
return ir_ac_lib_close(); return ir_ac_binary_close();
} }
} }
@@ -241,7 +246,7 @@ static INT8 ir_ac_file_open(const char *file_name)
fclose(stream); fclose(stream);
if (IR_DECODE_FAILED == ir_ac_lib_open(binary_content, (UINT16) binary_length)) if (IR_DECODE_FAILED == ir_ac_binary_open(binary_content, (UINT16) binary_length))
{ {
ir_free(binary_content); ir_free(binary_content);
binary_length = 0; binary_length = 0;
@@ -251,7 +256,7 @@ static INT8 ir_ac_file_open(const char *file_name)
return IR_DECODE_SUCCEEDED; return IR_DECODE_SUCCEEDED;
} }
static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length) static INT8 ir_ac_binary_open(UINT8 *binary, UINT16 binary_length)
{ {
// it is recommended that the parameter binary pointing to // it is recommended that the parameter binary pointing to
// a global memory block in embedded platform environment // a global memory block in embedded platform environment
@@ -261,7 +266,7 @@ static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
return IR_DECODE_SUCCEEDED; return IR_DECODE_SUCCEEDED;
} }
static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code,
BOOL change_wind_direction) BOOL change_wind_direction)
{ {
UINT16 time_length = 0; UINT16 time_length = 0;
@@ -377,7 +382,7 @@ static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data,
return time_length; return time_length;
} }
static INT8 ir_ac_lib_close() static INT8 ir_ac_binary_close()
{ {
#if defined USE_DYNAMIC_TAG #if defined USE_DYNAMIC_TAG
// free context // free context
@@ -579,7 +584,7 @@ static INT8 ir_tv_file_open(const char *file_name)
fclose(stream); fclose(stream);
if (IR_DECODE_FAILED == ir_tv_lib_open(binary_content, (UINT16) binary_length)) if (IR_DECODE_FAILED == ir_tv_binary_open(binary_content, (UINT16) binary_length))
{ {
ir_free(binary_content); ir_free(binary_content);
binary_length = 0; binary_length = 0;
@@ -589,14 +594,14 @@ static INT8 ir_tv_file_open(const char *file_name)
return IR_DECODE_SUCCEEDED; return IR_DECODE_SUCCEEDED;
} }
static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length) static INT8 ir_tv_binary_open(UINT8 *binary, UINT16 binary_length)
{ {
return tv_lib_open(binary, binary_length); return tv_binary_open(binary, binary_length);
} }
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode) static INT8 ir_tv_binary_parse(UINT8 ir_hex_encode)
{ {
if (FALSE == tv_lib_parse(ir_hex_encode)) if (FALSE == tv_binary_parse(ir_hex_encode))
{ {
ir_printf("parse irda binary failed\n"); ir_printf("parse irda binary failed\n");
return IR_DECODE_FAILED; return IR_DECODE_FAILED;
@@ -604,14 +609,14 @@ static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
return IR_DECODE_SUCCEEDED; return IR_DECODE_SUCCEEDED;
} }
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data) static UINT16 ir_tv_control(UINT8 key, UINT16 *l_user_data)
{ {
#if defined BOARD_PC #if defined BOARD_PC
UINT16 print_index = 0; UINT16 print_index = 0;
#endif #endif
UINT16 ir_code_length = 0; UINT16 ir_code_length = 0;
memset(l_user_data, 0x00, USER_DATA_SIZE); memset(l_user_data, 0x00, USER_DATA_SIZE);
ir_code_length = tv_lib_control(key, l_user_data); ir_code_length = tv_binary_decode(key, l_user_data);
#if defined BOARD_PC #if defined BOARD_PC
// have some debug // have some debug
@@ -625,7 +630,7 @@ static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
return ir_code_length; return ir_code_length;
} }
static INT8 ir_tv_lib_close() static INT8 ir_tv_binary_close()
{ {
#if (defined BOARD_PC || defined BOARD_PC_DLL) #if (defined BOARD_PC || defined BOARD_PC_DLL)
ir_lib_free_inner_buffer(); ir_lib_free_inner_buffer();

View File

@@ -53,7 +53,7 @@ static void convert_to_ir_time(UINT8 value, UINT16 *ir_time);
static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time); static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time);
INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length) INT8 tv_binary_open(UINT8 *binary, UINT16 binary_length)
{ {
// load binary to buffer // load binary to buffer
pbuffer->data = binary; pbuffer->data = binary;
@@ -62,7 +62,7 @@ INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length)
return IR_DECODE_SUCCEEDED; return IR_DECODE_SUCCEEDED;
} }
BOOL tv_lib_parse(UINT8 encode_type) BOOL tv_binary_parse(UINT8 encode_type)
{ {
if (FALSE == get_ir_protocol(encode_type)) if (FALSE == get_ir_protocol(encode_type))
{ {
@@ -72,7 +72,7 @@ BOOL tv_lib_parse(UINT8 encode_type)
return get_ir_keymap(); return get_ir_keymap();
} }
UINT16 tv_lib_control(UINT8 key, UINT16 *user_data) UINT16 tv_binary_decode(UINT8 key, UINT16 *user_data)
{ {
UINT16 i = 0; UINT16 i = 0;