reformatted code
This commit is contained in:
@@ -388,8 +388,6 @@ typedef struct REMOTE_AC_STATUS
|
||||
typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 function_code);
|
||||
|
||||
|
||||
|
||||
|
||||
#define TAG_AC_BOOT_CODE 1
|
||||
#define TAG_AC_ZERO 2
|
||||
#define TAG_AC_ONE 3
|
||||
@@ -587,7 +585,9 @@ 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 /////////////////////////////////////////////////
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -125,154 +145,229 @@ 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) {
|
||||
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;
|
||||
if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i],
|
||||
context->power1.comp_data,
|
||||
AC_POWER_MAX,
|
||||
AC_PARAMETER_TYPE_1)) {
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
} else if (tags[i].tag == TAG_AC_TEMP_1) // temperature tag type 1
|
||||
AC_PARAMETER_TYPE_1))
|
||||
{
|
||||
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_TEMP_1) // temperature tag type 1
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
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) {
|
||||
}
|
||||
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) {
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,9 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
|
||||
};
|
||||
|
||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||
|
||||
void ir_lib_free_inner_buffer();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user