From b045e7f7c30af0060bf3f5007d14170ffd0ab292 Mon Sep 17 00:00:00 2001 From: strawmanbobi Date: Thu, 16 Mar 2017 21:26:53 +0800 Subject: [PATCH] reformatted code --- src/ir_decoder/include/ir_decode.h | 20 +- src/ir_decoder/include/ir_tv_control.h | 4 +- src/ir_decoder/include/ir_utils.h | 2 +- src/ir_decoder/src/ir_ac_apply.c | 92 +++--- src/ir_decoder/src/ir_ac_binary_parse.c | 16 +- src/ir_decoder/src/ir_ac_build_frame.c | 24 +- src/ir_decoder/src/ir_ac_control.c | 276 ++++++++++++------ .../src/ir_ac_parse_forbidden_info.c | 18 +- src/ir_decoder/src/ir_ac_parse_frame_info.c | 42 +-- src/ir_decoder/src/ir_ac_parse_parameter.c | 78 ++--- src/ir_decoder/src/ir_decode.c | 79 ++--- src/ir_decoder/src/ir_test_main.c | 18 +- src/ir_decoder/src/ir_tv_control.c | 7 +- src/ir_decoder/src/ir_utils.c | 20 +- 14 files changed, 402 insertions(+), 294 deletions(-) diff --git a/src/ir_decoder/include/ir_decode.h b/src/ir_decoder/include/ir_decode.h index 994350a..6b0fdf5 100644 --- a/src/ir_decoder/include/ir_decode.h +++ b/src/ir_decoder/include/ir_decode.h @@ -385,9 +385,7 @@ typedef struct REMOTE_AC_STATUS } remote_ac_status_t; // function polymorphism -typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 function_code); - - +typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 function_code); #define TAG_AC_BOOT_CODE 1 @@ -428,9 +426,9 @@ typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 funct #define PROTOCOL_SIZE (sizeof(protocol)) /* exported variables */ -extern UINT8* ir_hex_code; +extern UINT8 *ir_hex_code; extern UINT8 ir_hex_len; -extern protocol* context; +extern protocol *context; /* exported functions */ @@ -545,7 +543,7 @@ extern INT8 ir_tv_lib_close(); * * return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED */ -extern INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max); +extern INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max); /* * function get_supported_mode @@ -554,7 +552,7 @@ extern INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max) * * return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED */ -extern INT8 get_supported_mode(UINT8* supported_mode); +extern INT8 get_supported_mode(UINT8 *supported_mode); /* * function get_supported_wind_speed @@ -564,7 +562,7 @@ extern INT8 get_supported_mode(UINT8* supported_mode); * * return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED */ -extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8* supported_wind_speed); +extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed); /* * function get_supported_swing @@ -574,7 +572,7 @@ extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8* supported_wind_speed) * * return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED */ -extern INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing); +extern INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing); /* * function get_supported_wind_direction @@ -583,11 +581,13 @@ extern INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing); * * return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED */ -extern INT8 get_supported_wind_direction(UINT8* supported_wind_direction); +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 ///////////////////////////////////////////////// diff --git a/src/ir_decoder/include/ir_tv_control.h b/src/ir_decoder/include/ir_tv_control.h index 6eb0140..d483972 100644 --- a/src/ir_decoder/include/ir_tv_control.h +++ b/src/ir_decoder/include/ir_tv_control.h @@ -71,7 +71,7 @@ typedef struct ir_data UINT8 lsb; UINT8 mode; UINT8 index; -} ir_data_t; +} ir_data_t; #if !defined BOARD_51 #pragma pack(1) @@ -198,7 +198,7 @@ typedef struct ir_data_tv } ir_data_tv_t; -extern INT8 tv_lib_open(UINT8* binary, UINT16 binary_length); +extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); extern BOOL tv_lib_parse(UINT8 encode_type); diff --git a/src/ir_decoder/include/ir_utils.h b/src/ir_decoder/include/ir_utils.h index 7f7994f..2f036ae 100644 --- a/src/ir_decoder/include/ir_utils.h +++ b/src/ir_decoder/include/ir_utils.h @@ -30,7 +30,7 @@ extern void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len); extern BOOL isin(UINT8 array[], UINT8 value, UINT8 len); -extern void hex_byte_to_double_char(char* dest, UINT8 length, UINT8 src); +extern void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src); #ifdef __cplusplus } diff --git a/src/ir_decoder/src/ir_ac_apply.c b/src/ir_decoder/src/ir_ac_apply.c index fd54c2e..7206bcc 100644 --- a/src/ir_decoder/src/ir_ac_apply.c +++ b/src/ir_decoder/src/ir_ac_apply.c @@ -146,7 +146,7 @@ static INT8 apply_ac_power(struct ac_protocol *protocol, UINT8 power_status) } for (i = 0; i < protocol->power1.comp_data[power_status].seg_len; i += 2) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->power1.comp_data[power_status]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->power1.comp_data[power_status]), (UINT8) i, FALSE); } return IR_DECODE_SUCCEEDED; } @@ -167,7 +167,7 @@ static INT8 apply_ac_mode(struct ac_protocol *protocol, UINT8 mode_status) for (i = 0; i < protocol->mode1.comp_data[mode_status].seg_len; i += 2) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->mode1.comp_data[mode_status]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->mode1.comp_data[mode_status]), (UINT8) i, FALSE); } // get return here since wind mode 1 is already applied @@ -187,8 +187,8 @@ static INT8 apply_ac_mode(struct ac_protocol *protocol, UINT8 mode_status) for (i = 0; i < protocol->mode2.comp_data[mode_status].seg_len; i += 3) { apply_ac_parameter_type_2(ir_hex_code, - &(protocol->mode2.comp_data[mode_status]), - (UINT8)i, FALSE); + &(protocol->mode2.comp_data[mode_status]), + (UINT8) i, FALSE); } return IR_DECODE_SUCCEEDED; } @@ -209,7 +209,7 @@ static INT8 apply_ac_wind_speed(struct ac_protocol *protocol, UINT8 wind_speed) for (i = 0; i < protocol->speed1.comp_data[wind_speed].seg_len; i += 2) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->speed1.comp_data[wind_speed]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->speed1.comp_data[wind_speed]), (UINT8) i, FALSE); } // get return here since wind speed 1 is already applied @@ -229,8 +229,8 @@ static INT8 apply_ac_wind_speed(struct ac_protocol *protocol, UINT8 wind_speed) for (i = 0; i < protocol->speed2.comp_data[wind_speed].seg_len; i += 3) { apply_ac_parameter_type_2(ir_hex_code, - &(protocol->speed2.comp_data[wind_speed]), - (UINT8)i, FALSE); + &(protocol->speed2.comp_data[wind_speed]), + (UINT8) i, FALSE); } return IR_DECODE_SUCCEEDED; } @@ -253,11 +253,11 @@ static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temp_diff) { if (TEMP_TYPE_DYNAMIC == protocol->temp1.type) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->temp1.comp_data[temp_diff]), (UINT8)i, TRUE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->temp1.comp_data[temp_diff]), (UINT8) i, TRUE); } else if (TEMP_TYPE_STATIC == protocol->temp1.type) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->temp1.comp_data[temp_diff]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->temp1.comp_data[temp_diff]), (UINT8) i, FALSE); } } @@ -277,15 +277,15 @@ static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temp_diff) for (i = 0; i < protocol->temp2.comp_data[temp_diff].seg_len; i += 3) { - if(0 != protocol->temp2.comp_data[temp_diff].seg_len) + if (0 != protocol->temp2.comp_data[temp_diff].seg_len) { if (TEMP_TYPE_DYNAMIC == protocol->temp2.type) { - apply_ac_parameter_type_2(ir_hex_code, &(protocol->temp2.comp_data[temp_diff]), (UINT8)i, TRUE); + apply_ac_parameter_type_2(ir_hex_code, &(protocol->temp2.comp_data[temp_diff]), (UINT8) i, TRUE); } else if (TEMP_TYPE_STATIC == protocol->temp2.type) { - apply_ac_parameter_type_2(ir_hex_code, &(protocol->temp2.comp_data[temp_diff]), (UINT8)i, FALSE); + apply_ac_parameter_type_2(ir_hex_code, &(protocol->temp2.comp_data[temp_diff]), (UINT8) i, FALSE); } } } @@ -314,7 +314,7 @@ static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode) for (i = 0; i < protocol->swing1.comp_data[swing_mode].seg_len; i += 2) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->swing1.comp_data[swing_mode]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->swing1.comp_data[swing_mode]), (UINT8) i, FALSE); } // get return here since temperature 1 is already applied @@ -340,8 +340,8 @@ static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode) for (i = 0; i < protocol->swing2.comp_data[swing_mode].seg_len; i += 3) { apply_ac_parameter_type_2(ir_hex_code, - &(protocol->swing2.comp_data[swing_mode]), - (UINT8)i, FALSE); + &(protocol->swing2.comp_data[swing_mode]), + (UINT8) i, FALSE); } return IR_DECODE_SUCCEEDED; } @@ -499,15 +499,15 @@ static UINT8 has_function(struct ac_protocol *protocol, UINT8 function) { if (0 != protocol->function1.len) { - if(0 != protocol->function1.comp_data[function - 1].seg_len) + if (0 != protocol->function1.comp_data[function - 1].seg_len) { return TRUE; } } - if(0 != protocol->function2.len) + if (0 != protocol->function2.len) { - if(0 != protocol->function2.comp_data[function - 1].seg_len) + if (0 != protocol->function2.comp_data[function - 1].seg_len) { return TRUE; } @@ -534,7 +534,7 @@ INT8 apply_function(struct ac_protocol *protocol, UINT8 function) for (i = 0; i < protocol->function1.comp_data[function - 1].seg_len; i += 2) { - apply_ac_parameter_type_1(ir_hex_code, &(protocol->function1.comp_data[function - 1]), (UINT8)i, FALSE); + apply_ac_parameter_type_1(ir_hex_code, &(protocol->function1.comp_data[function - 1]), (UINT8) i, FALSE); } // get return here since function 1 is already applied @@ -554,8 +554,8 @@ INT8 apply_function(struct ac_protocol *protocol, UINT8 function) for (i = 0; i < protocol->function2.comp_data[function - 1].seg_len; i += 3) { apply_ac_parameter_type_2(ir_hex_code, - &(protocol->function2.comp_data[function - 1]), - (UINT8)i, FALSE); + &(protocol->function2.comp_data[function - 1]), + (UINT8) i, FALSE); } return IR_DECODE_SUCCEEDED; } @@ -569,7 +569,7 @@ INT8 apply_checksum(struct ac_protocol *protocol) return IR_DECODE_SUCCEEDED; } - for(i = 0; i < protocol->checksum.count; i++) + for (i = 0; i < protocol->checksum.count; i++) { switch (protocol->checksum.checksum_data[i].type) { @@ -631,12 +631,12 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) if (FALSE == context->n_mode[ac_status.acMode].allspeed) { // if this level is not in black list - if(!isin(context->n_mode[ac_status.acMode].speed, - ac_status.acWindSpeed, - context->n_mode[ac_status.acMode].speed_cnt)) + if (!isin(context->n_mode[ac_status.acMode].speed, + ac_status.acWindSpeed, + context->n_mode[ac_status.acMode].speed_cnt)) { - if(IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.acWindSpeed) && - function_code == AC_FUNCTION_WIND_SPEED) + if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.acWindSpeed) && + function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -649,7 +649,7 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) else { // if this level is in black list, do not send IR wave if user want to apply this function - if(function_code == AC_FUNCTION_WIND_SPEED) + if (function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -663,7 +663,7 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) else { // if this level is in black list, do not send IR wave if user want to apply this function - if(function_code == AC_FUNCTION_WIND_SPEED) + if (function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -678,17 +678,17 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) { - if(function_code == AC_FUNCTION_WIND_FIX) + if (function_code == AC_FUNCTION_WIND_FIX) { // adjust fixed wind direction according to current status - if(context->si.type == SWING_TYPE_NORMAL && context->si.mode_count > 1) + if (context->si.type == SWING_TYPE_NORMAL && context->si.mode_count > 1) { if (TRUE == context->change_wind_direction) { context->si.dir_index++; } - if(context->si.dir_index == context->si.mode_count) + if (context->si.dir_index == context->si.mode_count) { // reset dir index context->si.dir_index = 1; @@ -696,7 +696,7 @@ INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) context->swing_status = context->si.dir_index; } } - else if(function_code == AC_FUNCTION_WIND_SWING) + else if (function_code == AC_FUNCTION_WIND_SWING) { context->swing_status = 0; } @@ -705,13 +705,13 @@ INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) // do nothing } - if(IR_DECODE_FAILED == apply_ac_swing(context, context->swing_status)) + if (IR_DECODE_FAILED == apply_ac_swing(context, context->swing_status)) { - if(function_code == AC_FUNCTION_WIND_SWING && FALSE == has_function(context, AC_FUNCTION_WIND_SWING)) + if (function_code == AC_FUNCTION_WIND_SWING && FALSE == has_function(context, AC_FUNCTION_WIND_SWING)) { return IR_DECODE_FAILED; } - else if(function_code == AC_FUNCTION_WIND_FIX && FALSE == has_function(context, AC_FUNCTION_WIND_FIX)) + else if (function_code == AC_FUNCTION_WIND_FIX && FALSE == has_function(context, AC_FUNCTION_WIND_FIX)) { return IR_DECODE_FAILED; } @@ -723,18 +723,18 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) { if (FALSE == context->n_mode[ac_status.acMode].alltemp) { - if(!isin(context->n_mode[ac_status.acMode].temp, - ac_status.acTemp, - context->n_mode[ac_status.acMode].temp_cnt)) + if (!isin(context->n_mode[ac_status.acMode].temp, + ac_status.acTemp, + context->n_mode[ac_status.acMode].temp_cnt)) { - if(IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp)) + if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp)) { - if(function_code == AC_FUNCTION_TEMPERATURE_UP + if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) { return IR_DECODE_FAILED; } - else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN + else if (function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/) { return IR_DECODE_FAILED; @@ -744,12 +744,12 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) else { // if this level is in black list, do not send IR wave if user want to apply this function - if(function_code == AC_FUNCTION_TEMPERATURE_UP + if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) { return IR_DECODE_FAILED; } - else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN + else if (function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/) { return IR_DECODE_FAILED; @@ -759,12 +759,12 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) else { // if this level is in black list, do not send IR wave if user want to apply this function - if(function_code == AC_FUNCTION_TEMPERATURE_UP + if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) { return IR_DECODE_FAILED; } - else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN + else if (function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/) { return IR_DECODE_FAILED; diff --git a/src/ir_decoder/src/ir_ac_binary_parse.c b/src/ir_decoder/src/ir_ac_binary_parse.c index 8bbb16e..4230008 100644 --- a/src/ir_decoder/src/ir_ac_binary_parse.c +++ b/src/ir_decoder/src/ir_ac_binary_parse.c @@ -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() { @@ -33,12 +33,12 @@ INT8 binary_parse_offset() UINT16 *phead = (UINT16 *) &p_ir_buffer->data[1]; tag_count = p_ir_buffer->data[0]; - if(TAG_COUNT_FOR_PROTOCOL != tag_count) + if (TAG_COUNT_FOR_PROTOCOL != tag_count) { return IR_DECODE_FAILED; } - tag_head_offset = (UINT16)((tag_count << 1) + 1); + tag_head_offset = (UINT16) ((tag_count << 1) + 1); tags = (t_tag_head *) ir_malloc(tag_count * sizeof(t_tag_head)); if (NULL == tags) @@ -68,7 +68,7 @@ INT8 binary_parse_len() continue; } - for (j = (UINT16)(i + 1); j < tag_count; j++) + for (j = (UINT16) (i + 1); j < tag_count; j++) { if (tags[j].offset != TAG_INVALID) { diff --git a/src/ir_decoder/src/ir_ac_build_frame.c b/src/ir_decoder/src/ir_ac_build_frame.c index f605537..1cf2b75 100644 --- a/src/ir_decoder/src/ir_ac_build_frame.c +++ b/src/ir_decoder/src/ir_ac_build_frame.c @@ -12,7 +12,7 @@ Revision log: #include "../include/ir_ac_build_frame.h" #include "../include/ir_decode.h" -extern protocol* context; +extern protocol *context; //return bit number per byte,default value is 8 @@ -27,12 +27,12 @@ UINT8 bits_per_byte(UINT8 index) if (context->bitnum_cnt >= MAX_BITNUM) size = MAX_BITNUM; else - size = (UINT8)context->bitnum_cnt; + size = (UINT8) context->bitnum_cnt; for (i = 0; i < size; i++) { if (context->bitnum[i].pos == index) - return (UINT8)context->bitnum[i].bits; + return (UINT8) context->bitnum[i].bits; if (context->bitnum[i].pos > index) return 8; } @@ -46,9 +46,9 @@ UINT16 add_delaycode(UINT8 index) UINT8 tail_delaycode = 0; UINT16 tail_pos = 0; - if(context->dc_cnt != 0) + if (context->dc_cnt != 0) { - size = (UINT8)context->dc_cnt; + size = (UINT8) context->dc_cnt; for (i = 0; i < size; i++) { @@ -59,7 +59,7 @@ UINT16 add_delaycode(UINT8 index) context->time[context->code_cnt++] = context->dc[i].time[j]; } } - else if(context->dc[i].pos == -1) + else if (context->dc[i].pos == -1) { tail_delaycode = 1; tail_pos = i; @@ -72,9 +72,9 @@ UINT16 add_delaycode(UINT8 index) context->time[context->code_cnt++] = context->one.low; //high } - if(context->dc_cnt != 0) + if (context->dc_cnt != 0) { - if((index == (ir_hex_len - 1)) && (tail_delaycode == 1)) + if ((index == (ir_hex_len - 1)) && (tail_delaycode == 1)) { for (i = 0; i < context->dc[tail_pos].time_cnt; i++) { @@ -105,13 +105,13 @@ UINT16 create_ir_frame() for (i = 0; i < ir_hex_len; i++) { - bitnum = bits_per_byte((UINT8)i); + bitnum = bits_per_byte((UINT8) i); for (j = 0; j < bitnum; j++) { if (context->endian == 0) - mask = (UINT8)((1 << (bitnum - 1)) >> j); + mask = (UINT8) ((1 << (bitnum - 1)) >> j); else - mask = (UINT8)(1 << j); + mask = (UINT8) (1 << j); if (irdata[i] & mask) { @@ -126,7 +126,7 @@ UINT16 create_ir_frame() context->time[context->code_cnt++] = context->zero.high; } } - add_delaycode((UINT8)i); + add_delaycode((UINT8) i); } framelen = context->code_cnt; diff --git a/src/ir_decoder/src/ir_ac_control.c b/src/ir_decoder/src/ir_ac_control.c index 7bf5a68..e0edd6b 100644 --- a/src/ir_decoder/src/ir_ac_control.c +++ b/src/ir_decoder/src/ir_ac_control.c @@ -35,20 +35,24 @@ static INT8 ir_context_init() } -INT8 ir_ac_lib_parse() { +INT8 ir_ac_lib_parse() +{ UINT8 i = 0; // suggest not to call init function here for de-couple purpose ir_context_init(); - if (IR_DECODE_FAILED == binary_parse_offset()) { + if (IR_DECODE_FAILED == binary_parse_offset()) + { return IR_DECODE_FAILED; } - if (IR_DECODE_FAILED == binary_parse_len()) { + if (IR_DECODE_FAILED == binary_parse_len()) + { return IR_DECODE_FAILED; } - if (IR_DECODE_FAILED == binary_parse_data()) { + if (IR_DECODE_FAILED == binary_parse_data()) + { return IR_DECODE_FAILED; } @@ -58,7 +62,8 @@ INT8 ir_ac_lib_parse() { context->lastbit = 0; context->repeat_times = 1; - for (i = 0; i < N_MODE_MAX; i++) { + for (i = 0; i < N_MODE_MAX; i++) + { context->n_mode[i].enable = TRUE; context->n_mode[i].allspeed = FALSE; context->n_mode[i].alltemp = FALSE; @@ -69,11 +74,16 @@ INT8 ir_ac_lib_parse() { } // parse TAG 46 in first priority - for (i = 0; i < tag_count; i++) { - if (tags[i].tag == TAG_AC_SWING_INFO) { - if (tags[i].len != 0) { + for (i = 0; i < tag_count; i++) + { + if (tags[i].tag == TAG_AC_SWING_INFO) + { + if (tags[i].len != 0) + { parse_swing_info(&tags[i], &(context->si)); - } else { + } + else + { context->si.type = SWING_TYPE_NORMAL; context->si.mode_count = 2; } @@ -81,19 +91,24 @@ INT8 ir_ac_lib_parse() { } } - for (i = 0; i < tag_count; i++) { - if (tags[i].len == 0) { + for (i = 0; i < tag_count; i++) + { + if (tags[i].len == 0) + { continue; } // then parse TAG 26 or 33 - if (context->si.type == SWING_TYPE_NORMAL) { + if (context->si.type == SWING_TYPE_NORMAL) + { UINT16 swing_space_size = 0; - if (tags[i].tag == TAG_AC_SWING_1) { + if (tags[i].tag == TAG_AC_SWING_1) + { context->swing1.count = context->si.mode_count; context->swing1.len = (UINT8) tags[i].len >> 1; swing_space_size = sizeof(tag_comp) * context->si.mode_count; context->swing1.comp_data = (tag_comp *) ir_malloc(swing_space_size); - if (NULL == context->swing1.comp_data) { + if (NULL == context->swing1.comp_data) + { return IR_DECODE_FAILED; } @@ -101,22 +116,27 @@ INT8 ir_ac_lib_parse() { if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->swing1.comp_data, context->si.mode_count, - AC_PARAMETER_TYPE_1)) { + AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_SWING_2) { + } + else if (tags[i].tag == TAG_AC_SWING_2) + { context->swing2.count = context->si.mode_count; context->swing2.len = (UINT8) tags[i].len >> 1; swing_space_size = sizeof(tag_comp) * context->si.mode_count; context->swing2.comp_data = (tag_comp *) ir_malloc(swing_space_size); - if (NULL == context->swing2.comp_data) { + if (NULL == context->swing2.comp_data) + { return IR_DECODE_FAILED; } ir_memset(context->swing2.comp_data, 0x00, swing_space_size); if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->swing2.comp_data, context->si.mode_count, - AC_PARAMETER_TYPE_2)) { + AC_PARAMETER_TYPE_2)) + { return IR_DECODE_FAILED; } } @@ -124,155 +144,230 @@ INT8 ir_ac_lib_parse() { if (tags[i].tag == TAG_AC_DEFAULT_CODE) // default code TAG { - context->default_code.data = (UINT8 *) ir_malloc(((size_t)tags[i].len - 2) >> 1); - if (NULL == context->default_code.data) { + context->default_code.data = (UINT8 *) ir_malloc(((size_t) tags[i].len - 2) >> 1); + if (NULL == context->default_code.data) + { return IR_DECODE_FAILED; } - if (IR_DECODE_FAILED == parse_default_code(&tags[i], &(context->default_code))) { + if (IR_DECODE_FAILED == parse_default_code(&tags[i], &(context->default_code))) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_POWER_1) // power tag + } + else if (tags[i].tag == TAG_AC_POWER_1) // power tag { - context->power1.len = (UINT8)tags[i].len >> 1; + context->power1.len = (UINT8) tags[i].len >> 1; if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->power1.comp_data, AC_POWER_MAX, - AC_PARAMETER_TYPE_1)) { + AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_TEMP_1) // temperature tag type 1 + } + else if (tags[i].tag == TAG_AC_TEMP_1) // temperature tag type 1 { - if (IR_DECODE_FAILED == parse_temp_1(&tags[i], &(context->temp1))) { + if (IR_DECODE_FAILED == parse_temp_1(&tags[i], &(context->temp1))) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_MODE_1) // mode tag + } + else if (tags[i].tag == TAG_AC_MODE_1) // mode tag { - context->mode1.len = (UINT8)tags[i].len >> 1; + context->mode1.len = (UINT8) tags[i].len >> 1; if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->mode1.comp_data, AC_MODE_MAX, - AC_PARAMETER_TYPE_1)) { + AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_SPEED_1) // wind speed tag + } + else if (tags[i].tag == TAG_AC_SPEED_1) // wind speed tag { - context->speed1.len = (UINT8)tags[i].len >> 1; + context->speed1.len = (UINT8) tags[i].len >> 1; if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->speed1.comp_data, AC_WS_MAX, - AC_PARAMETER_TYPE_1)) { + AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_CHECKSUM_TYPE) { - if (IR_DECODE_FAILED == parse_checksum(&tags[i], &(context->checksum))) { + } + else if (tags[i].tag == TAG_AC_CHECKSUM_TYPE) + { + if (IR_DECODE_FAILED == parse_checksum(&tags[i], &(context->checksum))) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_MODE_2) { - context->mode2.len = (UINT8)tags[i].len >> 1; + } + else if (tags[i].tag == TAG_AC_MODE_2) + { + context->mode2.len = (UINT8) tags[i].len >> 1; if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], - context->mode2.comp_data, AC_MODE_MAX, AC_PARAMETER_TYPE_1)) { + context->mode2.comp_data, AC_MODE_MAX, AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_SPEED_2) { - context->speed2.len = (UINT8)tags[i].len >> 1; + } + else if (tags[i].tag == TAG_AC_SPEED_2) + { + context->speed2.len = (UINT8) tags[i].len >> 1; if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], - context->speed2.comp_data, AC_WS_MAX, AC_PARAMETER_TYPE_1)) { + context->speed2.comp_data, AC_WS_MAX, AC_PARAMETER_TYPE_1)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_TEMP_2) { - if (IR_DECODE_FAILED == parse_temp_2(&tags[i], &(context->temp2))) { + } + else if (tags[i].tag == TAG_AC_TEMP_2) + { + if (IR_DECODE_FAILED == parse_temp_2(&tags[i], &(context->temp2))) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_SOLO_FUNCTION) { - if (IR_DECODE_FAILED == parse_solo_code(&tags[i], &(context->sc))) { + } + else if (tags[i].tag == TAG_AC_SOLO_FUNCTION) + { + if (IR_DECODE_FAILED == parse_solo_code(&tags[i], &(context->sc))) + { return IR_DECODE_FAILED; } context->solo_function_mark = 1; - } else if (tags[i].tag == TAG_AC_FUNCTION_1) { - if (IR_DECODE_FAILED == parse_function_1_tag29(&tags[i], &(context->function1))) { + } + else if (tags[i].tag == TAG_AC_FUNCTION_1) + { + if (IR_DECODE_FAILED == parse_function_1_tag29(&tags[i], &(context->function1))) + { ir_printf("\nfunction code parse error\n"); return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_FUNCTION_2) { - if (IR_DECODE_FAILED == parse_function_2_tag34(&tags[i], &(context->function2))) { + } + else if (tags[i].tag == TAG_AC_FUNCTION_2) + { + if (IR_DECODE_FAILED == parse_function_2_tag34(&tags[i], &(context->function2))) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_FRAME_LENGTH) { - if (IR_DECODE_FAILED == parse_frame_len(&tags[i], tags[i].len)) { + } + else if (tags[i].tag == TAG_AC_FRAME_LENGTH) + { + if (IR_DECODE_FAILED == parse_frame_len(&tags[i], tags[i].len)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_ZERO) { - if (IR_DECODE_FAILED == parse_zero(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_ZERO) + { + if (IR_DECODE_FAILED == parse_zero(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_ONE) { - if (IR_DECODE_FAILED == parse_one(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_ONE) + { + if (IR_DECODE_FAILED == parse_one(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BOOT_CODE) { - if (IR_DECODE_FAILED == parse_boot_code(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_BOOT_CODE) + { + if (IR_DECODE_FAILED == parse_boot_code(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_REPEAT_TIMES) { - if (IR_DECODE_FAILED == parse_repeat_times(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_REPEAT_TIMES) + { + if (IR_DECODE_FAILED == parse_repeat_times(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BITNUM) { - if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_BITNUM) + { + if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_ENDIAN) { - if (IR_DECODE_FAILED == parse_endian(&tags[i])) { + } + else if (tags[i].tag == TAG_AC_ENDIAN) + { + if (IR_DECODE_FAILED == parse_endian(&tags[i])) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_COOL_MODE) { - if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_COOL)) { + } + else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_COOL_MODE) + { + if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_COOL)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_HEAT_MODE) { - if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_HEAT)) { + } + else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_HEAT_MODE) + { + if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_HEAT)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_AUTO_MODE) { - if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_AUTO)) { + } + else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_AUTO_MODE) + { + if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_AUTO)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_FAN_MODE) { - if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_FAN)) { + } + else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_FAN_MODE) + { + if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_FAN)) + { return IR_DECODE_FAILED; } - } else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_DRY_MODE) { - if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_DRY)) { + } + else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_DRY_MODE) + { + if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_DRY)) + { return IR_DECODE_FAILED; } } } - for (i = 0; i < tag_count; i++) { - if (tags[i].len == 0) { + for (i = 0; i < tag_count; i++) + { + if (tags[i].len == 0) + { continue; } - if (tags[i].tag == TAG_AC_DELAY_CODE) { - if (IR_DECODE_FAILED == parse_delay_code(&tags[i])) { + if (tags[i].tag == TAG_AC_DELAY_CODE) + { + if (IR_DECODE_FAILED == parse_delay_code(&tags[i])) + { return IR_DECODE_FAILED; } } - if (tags[i].tag == TAG_AC_LASTBIT) { - if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) { + if (tags[i].tag == TAG_AC_LASTBIT) + { + if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) + { return IR_DECODE_FAILED; } } } - if (NULL != tags) { + if (NULL != tags) + { ir_free(tags); tags = NULL; } ir_hex_code = (UINT8 *) ir_malloc(context->default_code.len); - if (NULL == ir_hex_code) { + if (NULL == ir_hex_code) + { // warning: this AC bin contains no default code return IR_DECODE_FAILED; } @@ -281,11 +376,14 @@ INT8 ir_ac_lib_parse() { ir_memset(ir_hex_code, 0x00, ir_hex_len); // pre-calculate solo function status after parse phase - if (1 == context->solo_function_mark) { + if (1 == context->solo_function_mark) + { context->solo_function_mark = 0x00; // bit order from right to left : power, mode, temp+, temp-, wind_speed, swing, fix - for (i = AC_FUNCTION_POWER; i < AC_FUNCTION_MAX; i++) { - if (isin(context->sc.solo_function_codes, i, context->sc.solo_func_count)) { + for (i = AC_FUNCTION_POWER; i < AC_FUNCTION_MAX; i++) + { + if (isin(context->sc.solo_function_codes, i, context->sc.solo_func_count)) + { context->solo_function_mark |= (1 << (i - 1)); } } @@ -413,28 +511,28 @@ INT8 free_ac_context() } // free composite data for swing1 and swing 2 - if(context->swing1.comp_data != NULL) + if (context->swing1.comp_data != NULL) { ir_free(context->swing1.comp_data); context->swing1.comp_data = NULL; } - if(context->swing2.comp_data != NULL) + if (context->swing2.comp_data != NULL) { ir_free(context->swing2.comp_data); context->swing2.comp_data = NULL; } - for(i = 0; i < context->checksum.count; i++) + for (i = 0; i < context->checksum.count; i++) { - if(context->checksum.checksum_data != NULL && - context->checksum.checksum_data[i].spec_pos != NULL) + if (context->checksum.checksum_data != NULL && + context->checksum.checksum_data[i].spec_pos != NULL) { ir_free(context->checksum.checksum_data[i].spec_pos); context->checksum.checksum_data[i].len = 0; context->checksum.checksum_data[i].spec_pos = NULL; } } - if(context->checksum.checksum_data != NULL) + if (context->checksum.checksum_data != NULL) { ir_free(context->checksum.checksum_data); context->checksum.checksum_data = NULL; diff --git a/src/ir_decoder/src/ir_ac_parse_forbidden_info.c b/src/ir_decoder/src/ir_ac_parse_forbidden_info.c index 70dc561..d7c8c3a 100644 --- a/src/ir_decoder/src/ir_ac_parse_forbidden_info.c +++ b/src/ir_decoder/src/ir_ac_parse_forbidden_info.c @@ -17,7 +17,7 @@ Revision log: #include "../include/ir_ac_parse_forbidden_info.h" -extern protocol* context; +extern protocol *context; INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) @@ -34,10 +34,10 @@ INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) index++; } ir_memcpy(buf, pdata + pos, index - pos); - pos = (UINT16)(index + 1); + pos = (UINT16) (index + 1); index = pos; - context->n_mode[seq].speed[cnt++] = (UINT8)atoi(buf); - context->n_mode[seq].speed_cnt = (UINT8)cnt; + context->n_mode[seq].speed[cnt++] = (UINT8) atoi(buf); + context->n_mode[seq].speed_cnt = (UINT8) cnt; ir_memset(buf, 0, 16); } @@ -59,10 +59,10 @@ INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) index++; } ir_memcpy(buf, pdata + pos, index - pos); - pos = (UINT16)(index + 1); + pos = (UINT16) (index + 1); index = pos; - context->n_mode[seq].temp[cnt++] = (UINT8)(atoi(buf) - 16); - context->n_mode[seq].temp_cnt = (UINT8)cnt; + context->n_mode[seq].temp[cnt++] = (UINT8) (atoi(buf) - 16); + context->n_mode[seq].temp_cnt = (UINT8) cnt; ir_memset(buf, 0, 16); } return IR_DECODE_SUCCEEDED; @@ -98,7 +98,7 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) { parse_nmode_data_speed(data, index); } - else + else { parse_nmode_data_temp(data, index); } @@ -130,7 +130,7 @@ INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) if (tag->pdata[i] == '|') { ir_memcpy(buf, tag->pdata + preindex, i - preindex); - preindex = (UINT16)(i + 1); + preindex = (UINT16) (i + 1); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); } diff --git a/src/ir_decoder/src/ir_ac_parse_frame_info.c b/src/ir_decoder/src/ir_ac_parse_frame_info.c index 5310dd8..5a20932 100644 --- a/src/ir_decoder/src/ir_ac_parse_frame_info.c +++ b/src/ir_decoder/src/ir_ac_parse_frame_info.c @@ -42,9 +42,9 @@ INT8 parse_boot_code(struct tag_head *tag) index++; } ir_memcpy(buf, tag->pdata + pos, index - pos); - pos = (UINT16)(index + 1); + pos = (UINT16) (index + 1); index = pos; - context->bootcode.data[cnt++] = (UINT16)(atoi((char *) buf)); + context->bootcode.data[cnt++] = (UINT16) (atoi((char *) buf)); ir_memset(buf, 0, 16); } context->bootcode.len = cnt; @@ -75,10 +75,10 @@ INT8 parse_zero(struct tag_head *tag) } ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t)(tag->len - index - 1)); + ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); - context->zero.low = (UINT16)(atoi((char *) low)); - context->zero.high = (UINT16)(atoi((char *) high)); + context->zero.low = (UINT16) (atoi((char *) low)); + context->zero.high = (UINT16) (atoi((char *) high)); return IR_DECODE_SUCCEEDED; } @@ -105,10 +105,10 @@ INT8 parse_one(struct tag_head *tag) index++; } ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t)(tag->len - index - 1)); + ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); - context->one.low = (UINT16)(atoi((char *) low)); - context->one.high = (UINT16)(atoi((char *) high)); + context->one.low = (UINT16) (atoi((char *) low)); + context->one.high = (UINT16) (atoi((char *) high)); return IR_DECODE_SUCCEEDED; } @@ -133,9 +133,9 @@ INT8 parse_delay_code_data(UINT8 *pdata) index++; } ir_memcpy(buf, pdata + pos, index - pos); - pos = (UINT16)(index + 1); + pos = (UINT16) (index + 1); index = pos; - context->dc[context->dc_cnt].time[cnt++] = (UINT16)(atoi((char *) buf)); + context->dc[context->dc_cnt].time[cnt++] = (UINT16) (atoi((char *) buf)); context->dc[context->dc_cnt].time_cnt = cnt; ir_memset(buf, 0, 16); } @@ -163,7 +163,7 @@ INT8 parse_delay_code_pos(UINT8 *buf) } } parse_delay_code_data(data); - context->dc[context->dc_cnt].pos = (UINT16)(atoi((char *) start)); + context->dc[context->dc_cnt].pos = (UINT16) (atoi((char *) start)); context->dc_cnt++; return IR_DECODE_SUCCEEDED; @@ -186,7 +186,7 @@ INT8 parse_delay_code(struct tag_head *tag) if (tag->pdata[i] == '|') { ir_memcpy(buf, tag->pdata + preindex, i - preindex); - preindex = (UINT16)(i + 1); + preindex = (UINT16) (i + 1); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); } @@ -208,7 +208,7 @@ INT8 parse_frame_len(struct tag_head *tag, UINT16 len) return IR_DECODE_FAILED; } - temp = (UINT8 *)ir_malloc(len + 1); + temp = (UINT8 *) ir_malloc(len + 1); if (NULL == temp) { @@ -220,7 +220,7 @@ INT8 parse_frame_len(struct tag_head *tag, UINT16 len) ir_memcpy(temp, tag->pdata, len); temp[len] = '\0'; - context->frame_length = (UINT16)(atoi((char *) temp)); + context->frame_length = (UINT16) (atoi((char *) temp)); ir_free(temp); return IR_DECODE_SUCCEEDED; @@ -235,7 +235,7 @@ INT8 parse_endian(struct tag_head *tag) return IR_DECODE_FAILED; } ir_memcpy(buf, tag->pdata, tag->len); - context->endian = (UINT8)(atoi((char *) buf)); + context->endian = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -248,7 +248,7 @@ INT8 parse_lastbit(struct tag_head *tag) return IR_DECODE_FAILED; } ir_memcpy(buf, tag->pdata, tag->len); - context->lastbit = (UINT8)(atoi((char *) buf)); + context->lastbit = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -262,7 +262,7 @@ INT8 parse_repeat_times(struct tag_head *tag) ir_memcpy(asc_code, tag->pdata, tag->len); - context->repeat_times = (UINT16)(atoi((char *) asc_code)); + context->repeat_times = (UINT16) (atoi((char *) asc_code)); return IR_DECODE_SUCCEEDED; } @@ -287,8 +287,8 @@ INT8 parse_delay_code_tag48_pos(UINT8 *buf) } } - context->bitnum[context->bitnum_cnt].pos = (UINT16)(atoi((char *) start)); - context->bitnum[context->bitnum_cnt].bits = (UINT16)(atoi((char *) data)); + context->bitnum[context->bitnum_cnt].pos = (UINT16) (atoi((char *) start)); + context->bitnum[context->bitnum_cnt].bits = (UINT16) (atoi((char *) data)); context->bitnum_cnt++; return IR_DECODE_SUCCEEDED; } @@ -310,7 +310,7 @@ INT8 parse_bit_num(struct tag_head *tag) if (tag->pdata[i] == '|') { ir_memcpy(buf, tag->pdata + preindex, i - preindex); - preindex = (UINT16)(i + 1); + preindex = (UINT16) (i + 1); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); } @@ -323,7 +323,7 @@ INT8 parse_bit_num(struct tag_head *tag) for (i = 0; i < context->bitnum_cnt; i++) { if (context->bitnum[i].pos == -1) - context->bitnum[i].pos = (UINT16)(context->default_code.len - 1); //convert -1 to last data pos + context->bitnum[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos } return IR_DECODE_SUCCEEDED; } diff --git a/src/ir_decoder/src/ir_ac_parse_parameter.c b/src/ir_decoder/src/ir_ac_parse_parameter.c index c5041ec..39b03b7 100644 --- a/src/ir_decoder/src/ir_ac_parse_parameter.c +++ b/src/ir_decoder/src/ir_ac_parse_parameter.c @@ -179,7 +179,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to power1 data structure - power1->len = (UINT8)hex_len; + power1->len = (UINT8) hex_len; for (seg_index = AC_POWER_ON; seg_index < AC_POWER_MAX; seg_index++) { @@ -229,7 +229,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) { // dynamic temperature tag temp1->type = TEMP_TYPE_DYNAMIC; - temp1->len = (UINT8)hex_len; + temp1->len = (UINT8) hex_len; UINT8 seg_len = hex_data[0]; for (seg_index = AC_TEMP_16; seg_index < AC_TEMP_MAX; seg_index++) @@ -248,14 +248,14 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) temp1->comp_data[seg_index].segment[i - 1] = hex_data[i]; // get the default value of temperature - temp1->comp_data[seg_index].segment[i] = (UINT8)(hex_data[i + 1] * seg_index); + temp1->comp_data[seg_index].segment[i] = (UINT8) (hex_data[i + 1] * seg_index); } } } else { // static temperature tag - temp1->len = (UINT8)hex_len; + temp1->len = (UINT8) hex_len; temp1->type = TEMP_TYPE_STATIC; for (seg_index = AC_TEMP_16; seg_index < AC_TEMP_MAX; seg_index++) { @@ -299,7 +299,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to mode1 data structure - mode1->len = (UINT8)hex_len; + mode1->len = (UINT8) hex_len; for (seg_index = AC_MODE_COOL; seg_index < AC_MODE_MAX; seg_index++) { @@ -343,7 +343,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to speed1 data structure - speed1->len = (UINT8)hex_len; + speed1->len = (UINT8) hex_len; for (seg_index = AC_WS_AUTO; seg_index < AC_WS_MAX; seg_index++) { @@ -388,7 +388,7 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) // parse hex data to swing1 data structure swing1->count = swing_count; - swing1->len = (UINT8)hex_len; + swing1->len = (UINT8) hex_len; swing1->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); if (NULL == swing1->comp_data) { @@ -462,7 +462,7 @@ INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *check * Thus the specified half byte checksum only affects 4 bits of a position * of half byte specified by check_sum_byte_pos property. */ - UINT16 spec_pos_size = (UINT16)(len - 4); + UINT16 spec_pos_size = (UINT16) (len - 4); checksum->checksum_byte_pos = csdata[2]; checksum->checksum_plus = csdata[3]; @@ -491,9 +491,9 @@ INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) } } - checksum->len = (UINT8)((tag->len - cnt) >> 1); - checksum->count = (UINT16)(cnt + 1); - checksum->checksum_data = (tag_checksum_data*) ir_malloc(sizeof(tag_checksum_data) * checksum->count); + checksum->len = (UINT8) ((tag->len - cnt) >> 1); + checksum->count = (UINT16) (cnt + 1); + checksum->checksum_data = (tag_checksum_data *) ir_malloc(sizeof(tag_checksum_data) * checksum->count); if (NULL == checksum->checksum_data) { @@ -590,7 +590,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) return IR_DECODE_FAILED; } - if(IR_DECODE_FAILED == parse_checksum_malloc(tag, checksum)) + if (IR_DECODE_FAILED == parse_checksum_malloc(tag, checksum)) { return IR_DECODE_FAILED; } @@ -599,20 +599,20 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) { if (tag->pdata[i] == '|') { - if(IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, - checksum->checksum_data + num, - (UINT8)(i - preindex) >> 1)) + if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + checksum->checksum_data + num, + (UINT8) (i - preindex) >> 1)) { return IR_DECODE_FAILED; } - preindex = (UINT16)(i + 1); + preindex = (UINT16) (i + 1); num++; } } - if(IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, - checksum->checksum_data + num, - (UINT8)(i - preindex) >> 1)) + if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + checksum->checksum_data + num, + (UINT8) (i - preindex) >> 1)) { return IR_DECODE_FAILED; } @@ -644,7 +644,7 @@ INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) (*trav_offset)++; // function id starts from 1 (POWER) - UINT8 function_id = (UINT8)(data[*trav_offset] - 1); + UINT8 function_id = (UINT8) (data[*trav_offset] - 1); if (function_id > AC_FUNCTION_MAX - 1) { @@ -674,13 +674,13 @@ INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) if (TRUE == valid_function_id) { - mode_seg[function_id].seg_len = (UINT8)(seg_len - 1); - mode_seg[function_id].segment = (UINT8 *) ir_malloc((size_t)(seg_len - 1)); + mode_seg[function_id].seg_len = (UINT8) (seg_len - 1); + mode_seg[function_id].segment = (UINT8 *) ir_malloc((size_t) (seg_len - 1)); if (NULL == mode_seg[function_id].segment) { return IR_DECODE_FAILED; } - ir_memcpy(mode_seg[function_id].segment, &data[*trav_offset], (size_t)(seg_len - 1)); + ir_memcpy(mode_seg[function_id].segment, &data[*trav_offset], (size_t) (seg_len - 1)); } *trav_offset += seg_len - 1; @@ -715,7 +715,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to mode1 data structure - function1->len = (UINT8)hex_len; + function1->len = (UINT8) hex_len; // seg_index in TAG only refers to functional count for (seg_index = AC_FUNCTION_POWER; seg_index < AC_FUNCTION_MAX; seg_index++) @@ -776,7 +776,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) { // dynamic temperature tag temp2->type = TEMP_TYPE_DYNAMIC; - temp2->len = (UINT8)hex_len; + temp2->len = (UINT8) hex_len; UINT8 seg_len = hex_data[0]; for (seg_index = AC_TEMP_16; seg_index < AC_TEMP_MAX; seg_index++) @@ -795,14 +795,14 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) temp2->comp_data[seg_index].segment[i - 1] = hex_data[i]; // for this second type (TAG 30) temperature update, apply the change in run time. - temp2->comp_data[seg_index].segment[i] = (UINT8)(hex_data[i + 1] * seg_index); + temp2->comp_data[seg_index].segment[i] = (UINT8) (hex_data[i + 1] * seg_index); } } } else { // static temperature tag - temp2->len = (UINT8)hex_len; + temp2->len = (UINT8) hex_len; temp2->type = TEMP_TYPE_STATIC; for (seg_index = AC_TEMP_16; seg_index < AC_TEMP_MAX; seg_index++) { @@ -851,7 +851,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to mode1 data structure - mode2->len = (UINT8)hex_len; + mode2->len = (UINT8) hex_len; for (seg_index = AC_MODE_COOL; seg_index < AC_MODE_MAX; seg_index++) { @@ -900,7 +900,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to speed1 data structure - speed2->len = (UINT8)hex_len; + speed2->len = (UINT8) hex_len; for (seg_index = AC_WS_AUTO; seg_index < AC_WS_MAX; seg_index++) { @@ -950,7 +950,7 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) // parse hex data to swing2 data structure swing2->count = swing_count; - swing2->len = (UINT8)hex_len; + swing2->len = (UINT8) hex_len; swing2->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); if (NULL == swing2->comp_data) { @@ -1001,7 +1001,7 @@ INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) (*trav_offset)++; // function id starts from 1 (POWER) - UINT8 function_id = (UINT8)(data[*trav_offset] - 1); + UINT8 function_id = (UINT8) (data[*trav_offset] - 1); if (function_id > AC_FUNCTION_MAX - 1) { // ignore unsupported function ID @@ -1030,15 +1030,15 @@ INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) if (TRUE == valid_function_id) { - mode_seg[function_id].seg_len = (UINT8)(seg_len - 1); - mode_seg[function_id].segment = (UINT8 *) ir_malloc((size_t)(seg_len - 1)); + mode_seg[function_id].seg_len = (UINT8) (seg_len - 1); + mode_seg[function_id].segment = (UINT8 *) ir_malloc((size_t) (seg_len - 1)); if (NULL == mode_seg[function_id].segment) { return IR_DECODE_FAILED; } - ir_memcpy(mode_seg[function_id].segment, &data[*trav_offset], (size_t)(seg_len - 1)); + ir_memcpy(mode_seg[function_id].segment, &data[*trav_offset], (size_t) (seg_len - 1)); } *trav_offset += seg_len - 1; @@ -1073,7 +1073,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to mode1 data structure - function2->len = (UINT8)hex_len; + function2->len = (UINT8) hex_len; // seg_index in TAG only refers to functional count for (seg_index = AC_FUNCTION_POWER; seg_index < AC_FUNCTION_MAX; seg_index++) @@ -1140,7 +1140,7 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) */ // count how many swing types are there si->type = SWING_TYPE_NORMAL; - si->mode_count = (UINT8)((tag->len + 1) >> 1); + si->mode_count = (UINT8) ((tag->len + 1) >> 1); return IR_DECODE_SUCCEEDED; } @@ -1163,7 +1163,7 @@ INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) hex_len = tag->len >> 1; - if(hex_len > AC_FUNCTION_MAX) + if (hex_len > AC_FUNCTION_MAX) { ir_printf("\nsolo function code exceeded!!\n"); return IR_DECODE_FAILED; @@ -1178,8 +1178,8 @@ INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) string_to_hex_common(tag->pdata, hex_data, hex_len); // parse hex data to mode1 data structure - sc->len = (UINT8)hex_len; - sc->solo_func_count = (UINT8)(hex_len - 1); + sc->len = (UINT8) hex_len; + sc->solo_func_count = (UINT8) (hex_len - 1); // per each function takes just 1 byte of length sc->solo_func_count = hex_data[0]; diff --git a/src/ir_decoder/src/ir_decode.c b/src/ir_decoder/src/ir_decode.c index 29a5eff..935b495 100644 --- a/src/ir_decoder/src/ir_decode.c +++ b/src/ir_decoder/src/ir_decode.c @@ -22,14 +22,14 @@ Revision log: #include "../include/ir_tv_control.h" struct ir_bin_buffer binary_file; -struct ir_bin_buffer* p_ir_buffer = &binary_file; +struct ir_bin_buffer *p_ir_buffer = &binary_file; struct tag_head *tags; -UINT8* ir_hex_code = NULL; +UINT8 *ir_hex_code = NULL; UINT8 ir_hex_len = 0; -UINT8 byteArray[PROTOCOL_SIZE] = { 0 }; +UINT8 byteArray[PROTOCOL_SIZE] = {0}; size_t binary_length = 0; UINT8 *binary_content = NULL; @@ -38,18 +38,20 @@ UINT8 *binary_content = NULL; 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 -}; + { + apply_power, + apply_mode, + apply_temperature, + apply_temperature, + apply_wind_speed, + apply_swing, + apply_swing + }; #if (defined BOARD_PC || defined BOARD_PC_DLL) + void ir_lib_free_inner_buffer(); + #endif @@ -72,7 +74,7 @@ INT8 ir_ac_file_open(const char *file_name) fseek(stream, 0, SEEK_END); binary_length = (size_t) ftell(stream); - binary_content = (UINT8*) ir_malloc(binary_length); + binary_content = (UINT8 *) ir_malloc(binary_length); if (NULL == binary_content) { @@ -145,7 +147,7 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 } } #else - if(ac_status.acPower == AC_POWER_OFF) + if (ac_status.acPower == AC_POWER_OFF) { // otherwise, power should always be applied apply_power(ac_status, function_code); @@ -153,7 +155,7 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 else { // check the mode as the first priority, despite any other status - if(TRUE == context->n_mode[ac_status.acMode].enable) + if (TRUE == context->n_mode[ac_status.acMode].enable) { if (is_solo_function(function_code)) { @@ -162,12 +164,12 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 } else { - if(!is_solo_function(AC_FUNCTION_POWER)) + if (!is_solo_function(AC_FUNCTION_POWER)) { apply_power(ac_status, function_code); } - if(!is_solo_function(AC_FUNCTION_MODE)) + if (!is_solo_function(AC_FUNCTION_MODE)) { if (IR_DECODE_FAILED == apply_mode(ac_status, function_code)) { @@ -175,7 +177,7 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 } } - if(!is_solo_function(AC_FUNCTION_WIND_SPEED)) + if (!is_solo_function(AC_FUNCTION_WIND_SPEED)) { if (IR_DECODE_FAILED == apply_wind_speed(ac_status, function_code)) { @@ -183,8 +185,8 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 } } - if(!is_solo_function(AC_FUNCTION_WIND_SWING) && - !is_solo_function(AC_FUNCTION_WIND_FIX)) + if (!is_solo_function(AC_FUNCTION_WIND_SWING) && + !is_solo_function(AC_FUNCTION_WIND_FIX)) { if (IR_DECODE_FAILED == apply_swing(ac_status, function_code)) { @@ -192,8 +194,8 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 } } - if(!is_solo_function(AC_FUNCTION_TEMPERATURE_UP) && - !is_solo_function(AC_FUNCTION_TEMPERATURE_DOWN)) + if (!is_solo_function(AC_FUNCTION_TEMPERATURE_UP) && + !is_solo_function(AC_FUNCTION_TEMPERATURE_DOWN)) { if (IR_DECODE_FAILED == apply_temperature(ac_status, function_code)) { @@ -239,7 +241,7 @@ INT8 ir_ac_lib_close() } // utils -INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max) +INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) { UINT8 i = 0; @@ -262,9 +264,9 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max) *temp_max = -1; for (i = 0; i < AC_TEMP_MAX; i++) { - if(isin(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || - (context->temp1.len != 0 && 0 == context->temp1.comp_data[i].seg_len) || - (context->temp2.len != 0 && 0 == context->temp2.comp_data[i].seg_len)) + if (isin(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || + (context->temp1.len != 0 && 0 == context->temp1.comp_data[i].seg_len) || + (context->temp2.len != 0 && 0 == context->temp2.comp_data[i].seg_len)) { continue; } @@ -280,7 +282,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8* temp_min, INT8* temp_max) return IR_DECODE_SUCCEEDED; } -INT8 get_supported_mode(UINT8* supported_mode) +INT8 get_supported_mode(UINT8 *supported_mode) { UINT8 i = 0; if (NULL == supported_mode) @@ -292,8 +294,8 @@ INT8 get_supported_mode(UINT8* supported_mode) for (i = 0; i < AC_MODE_MAX; i++) { if (0 == context->n_mode[i].enable || - (context->mode1.len != 0 && 0 == context->mode1.comp_data[i].seg_len) || - (context->mode2.len != 0 && 0 == context->mode2.comp_data[i].seg_len)) + (context->mode1.len != 0 && 0 == context->mode1.comp_data[i].seg_len) || + (context->mode2.len != 0 && 0 == context->mode2.comp_data[i].seg_len)) { *supported_mode &= ~(1 << i); } @@ -302,7 +304,7 @@ INT8 get_supported_mode(UINT8* supported_mode) return IR_DECODE_SUCCEEDED; } -INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8* supported_wind_speed) +INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) { UINT8 i = 0; if (ac_mode >= AC_MODE_MAX) @@ -336,7 +338,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8* supported_wind_speed) return IR_DECODE_SUCCEEDED; } -INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing) +INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing) { if (ac_mode >= AC_MODE_MAX) { @@ -367,11 +369,11 @@ INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing) return IR_DECODE_SUCCEEDED; } -INT8 get_supported_wind_direction(UINT8* supported_wind_direction) +INT8 get_supported_wind_direction(UINT8 *supported_wind_direction) { if (NULL != context) { - *supported_wind_direction = (UINT8)(context->si.mode_count - 1); + *supported_wind_direction = (UINT8) (context->si.mode_count - 1); return IR_DECODE_SUCCEEDED; } else @@ -402,9 +404,9 @@ INT8 ir_tv_file_open(const char *file_name) } fseek(stream, 0, SEEK_END); - binary_length = (size_t)ftell(stream); + binary_length = (size_t) ftell(stream); - binary_content = (UINT8*) ir_malloc(binary_length); + binary_content = (UINT8 *) ir_malloc(binary_length); if (NULL == binary_content) { ir_printf("\nfailed to alloc memory for binary\n"); @@ -462,7 +464,7 @@ UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data) // have some debug ir_printf("=============================\n"); ir_printf("length of IRDA code = %d\n", ir_code_length); - for(print_index = 0; print_index < ir_code_length; print_index++) + for (print_index = 0; print_index < ir_code_length; print_index++) { ir_printf("%d ", l_user_data[print_index]); } @@ -483,11 +485,14 @@ INT8 ir_tv_lib_close() #if (defined BOARD_PC || defined BOARD_PC_DLL) + void ir_lib_free_inner_buffer() { - if (NULL != binary_content) { + if (NULL != binary_content) + { ir_free(binary_content); binary_content = NULL; } } + #endif \ No newline at end of file diff --git a/src/ir_decoder/src/ir_test_main.c b/src/ir_decoder/src/ir_test_main.c index bbbd30d..cfe4a12 100644 --- a/src/ir_decoder/src/ir_test_main.c +++ b/src/ir_decoder/src/ir_test_main.c @@ -22,7 +22,7 @@ UINT16 user_data[USER_DATA_SIZE]; INT8 ir_tv_file_open(const char *file_name); -INT8 decode_as_ac(char* file_name) +INT8 decode_as_ac(char *file_name) { // keyboard input int in_char = 0; @@ -66,17 +66,17 @@ INT8 decode_as_ac(char* file_name) in_char = getchar(); op_match = TRUE; need_control = TRUE; - switch(in_char) + switch (in_char) { case 'w': case 'W': // temperature plus - ac_status.acTemp = (UINT8)((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1)); + ac_status.acTemp = (UINT8) ((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1)); function_code = AC_FUNCTION_TEMPERATURE_UP; break; case 's': case 'S': - ac_status.acTemp = (UINT8)((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1)); + ac_status.acTemp = (UINT8) ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1)); function_code = AC_FUNCTION_TEMPERATURE_DOWN; // temperature minus break; @@ -89,7 +89,7 @@ INT8 decode_as_ac(char* file_name) break; case 'd': case 'D': - ac_status.acWindDir = (UINT8)((ac_status.acWindDir == 0) ? 1 : 0); + ac_status.acWindDir = (UINT8) ((ac_status.acWindDir == 0) ? 1 : 0); function_code = AC_FUNCTION_WIND_SWING; // wind swing loop break; @@ -155,7 +155,7 @@ INT8 decode_as_ac(char* file_name) break; } - if(TRUE == op_match && TRUE == need_control) + if (TRUE == op_match && TRUE == need_control) { ir_printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d\n", ac_status.acPower, @@ -167,7 +167,7 @@ INT8 decode_as_ac(char* file_name) ir_ac_lib_control(ac_status, user_data, function_code, TRUE); } - } while('0' != in_char); + } while ('0' != in_char); ir_ac_lib_close(); @@ -210,7 +210,7 @@ INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode) { // do nothing } - } while('Q' != in_char); + } while ('Q' != in_char); return IR_DECODE_SUCCEEDED; } @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) } function = argv[1][0]; - ir_hex_encode = (UINT8)(argv[3][0] - '0'); + ir_hex_encode = (UINT8) (argv[3][0] - '0'); ir_printf("decode functionality = %c\n", function); switch (function) diff --git a/src/ir_decoder/src/ir_tv_control.c b/src/ir_decoder/src/ir_tv_control.c index 720ab88..b6b902a 100644 --- a/src/ir_decoder/src/ir_tv_control.c +++ b/src/ir_decoder/src/ir_tv_control.c @@ -42,10 +42,15 @@ static UINT8 cycles_num_size = 0; 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 process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time); + static void convert_to_ir_time(UINT8 value, UINT16 *ir_time); + static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time); @@ -327,7 +332,7 @@ static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bi UINT8 bit_num = data->bits / valid_bits; UINT8 valid_value = 0; - valid_value = (UINT8)((valid_bits == 1) ? 1 : (valid_bits * valid_bits - 1)); + valid_value = (UINT8) ((valid_bits == 1) ? 1 : (valid_bits * valid_bits - 1)); if (data->lsb == IRDA_LSB) { diff --git a/src/ir_decoder/src/ir_utils.c b/src/ir_decoder/src/ir_utils.c index 5e0d383..bbe78c6 100644 --- a/src/ir_decoder/src/ir_utils.c +++ b/src/ir_decoder/src/ir_utils.c @@ -15,11 +15,11 @@ UINT8 char_to_hex(char chr) { UINT8 value = 0; if (chr >= '0' && chr <= '9') - value = (UINT8)(chr - '0'); + value = (UINT8) (chr - '0'); if (chr >= 'a' && chr <= 'f') - value = (UINT8)(chr - 'a' + 10); + value = (UINT8) (chr - 'a' + 10); if (chr >= 'A' && chr <= 'F') - value = (UINT8)(chr - 'A' + 10); + value = (UINT8) (chr - 'A' + 10); return value; } @@ -61,15 +61,15 @@ char hex_half_byte_to_single_char(UINT8 length, UINT8 half_byte) } if (half_byte >= 10 && half_byte < 16) { - return (char)(half_byte - 10 + 0x41); + return (char) (half_byte - 10 + 0x41); } else { - return (char)(half_byte + 0x30); + return (char) (half_byte + 0x30); } } -void hex_byte_to_double_char(char* dest, UINT8 length, UINT8 src) +void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src) { UINT8 hi_num = 0; UINT8 lo_num = 0; @@ -77,8 +77,8 @@ void hex_byte_to_double_char(char* dest, UINT8 length, UINT8 src) { return; } - hi_num = (UINT8)((src >> 4) & 0x0F); - lo_num = (UINT8)(src & 0x0F); + hi_num = (UINT8) ((src >> 4) & 0x0F); + lo_num = (UINT8) (src & 0x0F); dest[0] = hex_half_byte_to_single_char(1, hi_num); dest[1] = hex_half_byte_to_single_char(1, lo_num); @@ -87,9 +87,9 @@ void hex_byte_to_double_char(char* dest, UINT8 length, UINT8 src) BOOL isin(UINT8 array[], UINT8 value, UINT8 len) { UINT16 i = 0; - for(i = 0; i < len; i++) + for (i = 0; i < len; i++) { - if(array[i] == value) + if (array[i] == value) { return TRUE; }