From 40d1a7053c97e7afe78849f4b36a3d670afbcd7c Mon Sep 17 00:00:00 2001 From: strawmanbobi Date: Fri, 13 Oct 2017 15:24:37 +0800 Subject: [PATCH] formalized code --- src/ir_decoder/CMakeLists.txt | 3 +- src/ir_decoder/include/ir_ac_apply.h | 13 +- src/ir_decoder/include/ir_ac_control.h | 190 +++++++++--------- .../include/ir_ac_parse_forbidden_info.h | 2 +- .../include/ir_ac_parse_parameter.h | 32 +-- src/ir_decoder/include/ir_decode.h | 2 +- src/ir_decoder/include/ir_tv_control.h | 17 +- src/ir_decoder/include/ir_utils.h | 8 +- src/ir_decoder/ir_decoder.vcxproj | 4 +- src/ir_decoder/src/ir_ac_apply.c | 88 ++++---- src/ir_decoder/src/ir_ac_binary_parse.c | 2 +- src/ir_decoder/src/ir_ac_build_frame.c | 22 +- src/ir_decoder/src/ir_ac_control.c | 22 +- .../src/ir_ac_parse_forbidden_info.c | 22 +- src/ir_decoder/src/ir_ac_parse_frame_info.c | 54 ++--- src/ir_decoder/src/ir_ac_parse_parameter.c | 98 ++++----- src/ir_decoder/src/ir_decode.c | 22 +- src/ir_decoder/src/ir_test_main.c | 58 +++--- src/ir_decoder/src/ir_tv_control.c | 43 ++-- src/ir_decoder/src/ir_utils.c | 37 +--- 20 files changed, 347 insertions(+), 392 deletions(-) diff --git a/src/ir_decoder/CMakeLists.txt b/src/ir_decoder/CMakeLists.txt index a219116..6bc310a 100644 --- a/src/ir_decoder/CMakeLists.txt +++ b/src/ir_decoder/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.2) ######################################################## project(irda_decoder) # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -add_definitions(-DBOARD_PC -DBOARD_PC_JNI) +add_definitions(-DBOARD_PC) +# add_definitions(-DBOARD_PC -DBOARD_PC_JNI) IF (CMAKE_SYSTEM_NAME MATCHES "Linux") MESSAGE("compile platform : Linux") diff --git a/src/ir_decoder/include/ir_ac_apply.h b/src/ir_decoder/include/ir_ac_apply.h index 4c3db32..0e8b5a4 100644 --- a/src/ir_decoder/include/ir_ac_apply.h +++ b/src/ir_decoder/include/ir_ac_apply.h @@ -19,18 +19,15 @@ extern "C" #include "ir_decode.h" -#define MIN_TAG_LENGTH_TYPE_1 4 -#define MIN_TAG_LENGTH_TYPE_2 6 +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code); - -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code); INT8 apply_function(struct ac_protocol *protocol, UINT8 function); diff --git a/src/ir_decoder/include/ir_ac_control.h b/src/ir_decoder/include/ir_ac_control.h index 6d297c0..6eeee04 100644 --- a/src/ir_decoder/include/ir_ac_control.h +++ b/src/ir_decoder/include/ir_ac_control.h @@ -19,22 +19,22 @@ extern "C" #include "ir_defs.h" -#define TAG_COUNT_FOR_PROTOCOL 29 +#define TAG_COUNT_FOR_PROTOCOL 29 -#define TAG_INVALID 0xffff +#define TAG_INVALID 0xffff -#define MAX_DELAYCODE_NUM 16 -#define MAX_BITNUM 16 +#define MAX_DELAYCODE_NUM 16 +#define MAX_BITNUM 16 -#define AC_PARAMETER_TYPE_1 0 -#define AC_PARAMETER_TYPE_2 1 +#define AC_PARAMETER_TYPE_1 0 +#define AC_PARAMETER_TYPE_2 1 typedef enum { AC_POWER_ON = 0, AC_POWER_OFF, AC_POWER_MAX -} ac_power; +} t_ac_power; typedef enum { @@ -54,7 +54,7 @@ typedef enum AC_TEMP_29, AC_TEMP_30, AC_TEMP_MAX -} ac_temperature; +} t_ac_temperature; typedef enum { @@ -64,7 +64,7 @@ typedef enum AC_MODE_FAN, AC_MODE_DRY, AC_MODE_MAX -} ac_mode; +} t_ac_mode; typedef enum { @@ -76,7 +76,7 @@ typedef enum AC_FUNCTION_WIND_SWING, AC_FUNCTION_WIND_FIX, AC_FUNCTION_MAX, -} ac_function; +} t_ac_function; typedef enum { @@ -85,14 +85,14 @@ typedef enum AC_WS_MEDIUM, AC_WS_HIGH, AC_WS_MAX -} ac_wind_speed; +} t_ac_wind_speed; typedef enum { AC_SWING_ON = 0, AC_SWING_OFF, AC_SWING_MAX -} ac_swing; +} t_ac_swing; typedef enum { @@ -107,7 +107,7 @@ typedef enum TEMP_TYPE_DYNAMIC = 0, TEMP_TYPE_STATIC, TEMP_TYPE_MAX, -} temp_type; +} t_temp_type; // enumeration for application polymorphism typedef enum @@ -120,32 +120,32 @@ typedef enum AC_APPLY_WIND_SWING, AC_APPLY_WIND_FIX, AC_APPLY_MAX -} ac_apply; +} t_ac_apply; typedef struct _ac_hex { UINT8 len; UINT8 *data; -} ac_hex; +} t_ac_hex; typedef struct _ac_level { UINT16 low; UINT16 high; -} ac_level; +} t_ac_level; typedef struct _ac_bootcode { UINT16 len; UINT16 data[16]; -} ac_bootcode; +} t_ac_bootcode; typedef struct _ac_delaycode { INT16 pos; UINT16 time[8]; UINT16 time_cnt; -} ac_delaycode; +} t_ac_delaycode; /* * the array of tag_100X application data @@ -157,78 +157,78 @@ typedef struct _tag_comp_type_1 { UINT8 seg_len; UINT8 *segment; -} tag_comp; +} t_tag_comp; typedef struct _tag_swing_info { swing_type type; UINT8 mode_count; UINT8 dir_index; -} swing_info; +} t_swing_info; typedef struct _tag_power_1 { UINT8 len; - tag_comp comp_data[AC_POWER_MAX]; -} power_1; + t_tag_comp comp_data[AC_POWER_MAX]; +} t_power_1; typedef struct _tag_temp_1 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_1; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_1; typedef struct tag_mode_1 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_1; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_1; typedef struct tag_speed_1 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_1; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_1; typedef struct tag_swing_1 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_1; + t_tag_comp *comp_data; +} t_swing_1; typedef struct tag_temp_2 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_2; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_2; typedef struct tag_mode_2 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_2; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_2; typedef struct tag_speed_2 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_2; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_2; typedef struct tag_swing_2 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_2; + t_tag_comp *comp_data; +} t_swing_2; #if defined SUPPORT_HORIZONTAL_SWING typedef struct tag_horiswing_1 { UINT16 len; - tag_comp comp_data[AC_HORI_SWING_MAX]; + t_tag_comp comp_data[AC_HORI_SWING_MAX]; } hori_swing_1; #endif @@ -241,39 +241,39 @@ typedef struct _tag_checksum_data UINT8 checksum_byte_pos; UINT8 checksum_plus; UINT8 *spec_pos; -} tag_checksum_data; +} t_tag_checksum_data; typedef struct tag_checksum { UINT8 len; UINT16 count; - tag_checksum_data *checksum_data; -} tchecksum; + t_tag_checksum_data *checksum_data; +} t_checksum; typedef struct tag_function_1 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_1; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_1; typedef struct tag_function_2 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_2; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_2; typedef struct tag_solo_code { UINT8 len; UINT8 solo_func_count; UINT8 solo_function_codes[AC_FUNCTION_MAX - 1]; -} solo_code; +} t_solo_code; typedef struct _ac_bitnum { INT16 pos; UINT16 bits; -} ac_bitnum; +} t_ac_bit_num; typedef enum { @@ -283,7 +283,7 @@ typedef enum N_FAN, N_DRY, N_MODE_MAX, -} ac_n_mode; +} t_ac_n_mode; typedef enum { @@ -296,68 +296,69 @@ typedef enum CHECKSUM_TYPE_SPEC_HALF_BYTE_ONE_BYTE, CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE_ONE_BYTE, CHECKSUM_TYPE_MAX, -} checksum_type; +} t_checksum_type; typedef struct _ac_n_mode_info { UINT8 enable; - UINT8 allspeed; - UINT8 alltemp; + UINT8 all_speed; + UINT8 all_temp; UINT8 temp[AC_TEMP_MAX]; UINT8 temp_cnt; UINT8 speed[AC_WS_MAX]; UINT8 speed_cnt; -} ac_n_mode_info; +} t_ac_n_mode_info; typedef struct ac_protocol { UINT8 endian; - // ac_hex default_code; - ac_hex default_code; - ac_level zero; - ac_level one; - ac_bootcode bootcode; - ac_delaycode dc[MAX_DELAYCODE_NUM]; - power_1 power1; - temp_1 temp1; - mode_1 mode1; - speed_1 speed1; - swing_1 swing1; - tchecksum checksum; + // t_ac_hex default_code; + t_ac_hex default_code; + t_ac_level zero; + t_ac_level one; + t_ac_bootcode boot_code; + t_ac_delaycode dc[MAX_DELAYCODE_NUM]; + t_power_1 power1; + t_temp_1 temp1; + t_mode_1 mode1; + t_speed_1 speed1; + t_swing_1 swing1; + t_checksum checksum; - function_1 function1; - function_2 function2; + t_function_1 function1; + t_function_2 function2; - temp_2 temp2; - mode_2 mode2; - speed_2 speed2; - swing_2 swing2; + t_temp_2 temp2; + t_mode_2 mode2; + t_speed_2 speed2; + t_swing_2 swing2; - swing_info si; - solo_code sc; + t_swing_info si; + t_solo_code sc; UINT8 swing_status; BOOL change_wind_direction; UINT16 dc_cnt; - ac_bitnum bitnum[MAX_BITNUM]; - UINT16 bitnum_cnt; + t_ac_bit_num bit_num[MAX_BITNUM]; + UINT16 bit_num_cnt; UINT16 repeat_times; - UINT16 frame_length; - ac_n_mode_info n_mode[N_MODE_MAX]; + t_ac_n_mode_info n_mode[N_MODE_MAX]; UINT16 code_cnt; - UINT8 lastbit; + UINT8 last_bit; UINT16 *time; UINT8 solo_function_mark; -} protocol; + + UINT16 frame_length; +} t_ac_protocol; typedef struct tag_head { UINT16 tag; UINT16 len; unsigned short offset; - UINT8 *pdata; + UINT8 *p_data; } t_tag_head; struct ir_bin_buffer @@ -369,19 +370,18 @@ struct ir_bin_buffer typedef struct REMOTE_AC_STATUS { - ac_power acPower; - ac_temperature acTemp; - ac_mode acMode; - ac_swing acWindDir; - ac_wind_speed acWindSpeed; - UINT8 acDisplay; - UINT8 acSleep; - UINT8 acTimer; -} remote_ac_status_t; + t_ac_power ac_power; + t_ac_temperature ac_temp; + t_ac_mode ac_mode; + t_ac_swing ac_wind_dir; + t_ac_wind_speed ac_wind_speed; + UINT8 ac_display; + UINT8 ac_sleep; + UINT8 ac_timer; +} t_remote_ac_status; // function polymorphism -typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 function_code); - +typedef INT8 (*lp_apply_ac_parameter)(t_remote_ac_status ac_status, UINT8 function_code); #define TAG_AC_BOOT_CODE 1 #define TAG_AC_ZERO 2 @@ -389,7 +389,7 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_DELAY_CODE 4 #define TAG_AC_FRAME_LENGTH 5 #define TAG_AC_ENDIAN 6 -#define TAG_AC_LASTBIT 7 +#define TAG_AC_LAST_BIT 7 #define TAG_AC_POWER_1 21 #define TAG_AC_DEFAULT_CODE 22 @@ -413,17 +413,17 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 45 #define TAG_AC_SWING_INFO 46 #define TAG_AC_REPEAT_TIMES 47 -#define TAG_AC_BITNUM 48 +#define TAG_AC_BIT_NUM 48 // definition about size -#define PROTOCOL_SIZE (sizeof(protocol)) +#define PROTOCOL_SIZE (sizeof(t_ac_protocol)) /* exported variables */ extern UINT8 *ir_hex_code; extern UINT8 ir_hex_len; -extern protocol *context; +extern t_ac_protocol *context; extern INT8 ir_ac_lib_parse(); diff --git a/src/ir_decoder/include/ir_ac_parse_forbidden_info.h b/src/ir_decoder/include/ir_ac_parse_forbidden_info.h index c0cce82..8f0f5b1 100644 --- a/src/ir_decoder/include/ir_ac_parse_forbidden_info.h +++ b/src/ir_decoder/include/ir_ac_parse_forbidden_info.h @@ -19,7 +19,7 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_nmode(struct tag_head *tag, ac_n_mode index); +extern INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index); #ifdef __cplusplus } diff --git a/src/ir_decoder/include/ir_ac_parse_parameter.h b/src/ir_decoder/include/ir_ac_parse_parameter.h index 1da7132..6d53e89 100644 --- a/src/ir_decoder/include/ir_ac_parse_parameter.h +++ b/src/ir_decoder/include/ir_ac_parse_parameter.h @@ -19,37 +19,37 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type); +extern INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type); -extern INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code); +extern INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code); -extern INT8 parse_power_1(struct tag_head *tag, power_1 *power1); +extern INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1); -extern INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1); +extern INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1); -extern INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1); +extern INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1); -extern INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1); +extern INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1); -extern INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count); +extern INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count); -extern INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum); +extern INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum); -extern INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1); +extern INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1); -extern INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2); +extern INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2); -extern INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2); +extern INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2); -extern INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2); +extern INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2); -extern INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count); +extern INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count); -extern INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2); +extern INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2); -extern INT8 parse_swing_info(struct tag_head *tag, swing_info *si); +extern INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si); -extern INT8 parse_solo_code(struct tag_head *tag, solo_code *sc); +extern INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc); #ifdef __cplusplus } diff --git a/src/ir_decoder/include/ir_decode.h b/src/ir_decoder/include/ir_decode.h index 5ae4b17..b2fff07 100644 --- a/src/ir_decoder/include/ir_decode.h +++ b/src/ir_decoder/include/ir_decode.h @@ -75,7 +75,7 @@ extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8 * * returns: length of decoded data (0 indicates decode failure) */ -extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction); +extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction); /** * function ir_close diff --git a/src/ir_decoder/include/ir_tv_control.h b/src/ir_decoder/include/ir_tv_control.h index a4e1661..9e86741 100644 --- a/src/ir_decoder/include/ir_tv_control.h +++ b/src/ir_decoder/include/ir_tv_control.h @@ -63,7 +63,7 @@ typedef enum ir_flags IRDA_E, IRDA_F, IRDA_MAX = 20, -} ir_flags_t; +} t_ir_flags; typedef struct ir_data { @@ -71,7 +71,7 @@ typedef struct ir_data UINT8 lsb; UINT8 mode; UINT8 index; -} ir_data_t; +} t_ir_data; #if !defined BOARD_51 #pragma pack(1) @@ -81,7 +81,8 @@ typedef struct ir_cycles UINT8 flag; UINT16 mask; UINT16 space; -} ir_cycles_t; +} t_ir_cycles; + #if !defined BOARD_51 #pragma pack() #endif @@ -113,7 +114,7 @@ typedef enum tv_key_value TV_8, TV_9, TV_KEY_MAX, -} tv_key_value_t; +} t_tv_key_value; typedef enum stb_key_value @@ -143,7 +144,7 @@ typedef enum stb_key_value STB_8, STB_9, STB_KEY_MAX, -} stb_key_value_t; +} t_stb_key_value; typedef enum nw_key_value { @@ -169,7 +170,7 @@ typedef enum nw_key_value NW_8, NW_9, NW_KEY_MAX, -} nw_key_value_t; +} t_nw_key_value; typedef enum cm_key_value { @@ -189,13 +190,13 @@ typedef enum cm_key_value CM_MENU, CM_MODE, CM_KEY_MAX, -} cm_key_value_t; +} t_cm_key_value; typedef struct ir_data_tv { char magic[4]; UINT8 per_keycode_bytes; -} ir_data_tv_t; +} t_ir_data_tv; extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); diff --git a/src/ir_decoder/include/ir_utils.h b/src/ir_decoder/include/ir_utils.h index 2f036ae..33871a3 100644 --- a/src/ir_decoder/include/ir_utils.h +++ b/src/ir_decoder/include/ir_utils.h @@ -22,15 +22,11 @@ extern "C" #include -extern void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len); - -extern void string_to_intArray(UINT8 *p, UINT8 *binary_code, UINT16 len); +extern void string_to_hex(UINT8 *p, t_ac_hex *pac_hex); 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 BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len); #ifdef __cplusplus } diff --git a/src/ir_decoder/ir_decoder.vcxproj b/src/ir_decoder/ir_decoder.vcxproj index 5ceed47..63d44bd 100644 --- a/src/ir_decoder/ir_decoder.vcxproj +++ b/src/ir_decoder/ir_decoder.vcxproj @@ -22,7 +22,7 @@ {8ACC347D-023C-4939-B371-C193EEA210F8} Win32Proj ir_decoder - 8.1 + 10.0.15063.0 @@ -34,7 +34,7 @@ DynamicLibrary false - v140_xp + v141 true Unicode diff --git a/src/ir_decoder/src/ir_ac_apply.c b/src/ir_decoder/src/ir_ac_apply.c index 7206bcc..905ddc8 100644 --- a/src/ir_decoder/src/ir_ac_apply.c +++ b/src/ir_decoder/src/ir_ac_apply.c @@ -17,16 +17,16 @@ static INT8 apply_ac_power(struct ac_protocol *protocol, UINT8 power_status); static INT8 apply_ac_mode(struct ac_protocol *protocol, UINT8 mode_status); -static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temperature); +static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temp_diff); static INT8 apply_ac_wind_speed(struct ac_protocol *protocol, UINT8 wind_speed); -static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_status); +static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode); static UINT8 has_function(struct ac_protocol *protocol, UINT8 function); -INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_1(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { if (0 != (comp_data->seg_len & 0x01)) { @@ -45,7 +45,7 @@ INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_SUCCEEDED; } -INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_2(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { UINT8 start_bit = 0; UINT8 end_bit = 0; @@ -59,11 +59,10 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_FAILED; } - // TODO: to be validated start_bit = comp_data->segment[current_seg]; end_bit = comp_data->segment[current_seg + 1]; cover_byte_pos_hi = start_bit >> 3; - cover_byte_pos_lo = (end_bit - 1) >> 3; + cover_byte_pos_lo = (UINT8) (end_bit - 1) >> 3; if (cover_byte_pos_hi == cover_byte_pos_lo) { // cover_byte_pos_hi or cover_bytes_pos_lo is target byte to be applied with AC parameter @@ -72,12 +71,12 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren UINT8 int_start_bit = start_bit - (cover_byte_pos_hi << 3); UINT8 int_end_bit = end_bit - (cover_byte_pos_lo << 3); UINT8 bit_range = end_bit - start_bit; - UINT8 mask = (0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit); + UINT8 mask = (UINT8) ((0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit)); UINT8 origin = dc_data[cover_byte_pos_lo]; if (TRUE == is_temp) { - move_bit = 8 - int_end_bit; + move_bit = (UINT8) (8 - int_end_bit); value = (origin & mask) | (((((origin & ~mask) >> move_bit) + raw_value) << move_bit) & ~mask); } else @@ -88,14 +87,13 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren } else { - UINT8 value = 0x00; - UINT8 origin_hi = 0x00; - UINT8 origin_lo = 0x00; - UINT8 mask_hi = 0x00; - UINT8 mask_lo = 0x00; - UINT8 raw_value = 0x00; - UINT8 int_start_bit = 0x00; - UINT8 int_end_bit = 0x00; + UINT8 origin_hi = 0; + UINT8 origin_lo = 0; + UINT8 mask_hi = 0; + UINT8 mask_lo = 0; + UINT8 raw_value = 0; + UINT8 int_start_bit = 0; + UINT8 int_end_bit = 0; if (cover_byte_pos_hi > cover_byte_pos_lo) { @@ -111,8 +109,8 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren int_start_bit = start_bit - (cover_byte_pos_hi << 3); int_end_bit = end_bit - (cover_byte_pos_lo << 3); - mask_hi = 0xFF << (8 - int_start_bit); - mask_lo = 0xFF >> int_end_bit; + mask_hi = (UINT8) 0xFF << (8 - int_start_bit); + mask_lo = (UINT8) 0xFF >> int_end_bit; value = ((origin_hi & ~mask_hi) << int_end_bit) | ((origin_lo & ~mask_lo) >> (8 - int_end_bit)); @@ -121,11 +119,11 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren raw_value += value; } - dc_data[cover_byte_pos_hi] = (origin_hi & mask_hi) | - (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit); + dc_data[cover_byte_pos_hi] = (UINT8) ((origin_hi & mask_hi) | + (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit)); - dc_data[cover_byte_pos_lo] = (origin_lo & mask_lo) | - (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit)); + dc_data[cover_byte_pos_lo] = (UINT8) ((origin_lo & mask_lo) | + (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit))); } return IR_DECODE_SUCCEEDED; @@ -346,7 +344,7 @@ static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode) return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -374,7 +372,7 @@ static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inver return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_halfbyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -402,7 +400,7 @@ static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL i return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -442,18 +440,18 @@ static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL if (0 == (cs.checksum_byte_pos & 0x01)) { // save low bits and add checksum as high bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0x0F) | (checksum << 4); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0x0F) | (checksum << 4)); } else { // save high bits and add checksum as low bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F)); } return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -605,15 +603,15 @@ INT8 apply_checksum(struct ac_protocol *protocol) return IR_DECODE_SUCCEEDED; } -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code) { - apply_ac_power(context, ac_status.acPower); + apply_ac_power(context, ac_status.ac_power); return IR_DECODE_SUCCEEDED; } -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code) { - if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.acMode)) + if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.ac_mode)) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -626,16 +624,16 @@ INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].allspeed) + if (FALSE == context->n_mode[ac_status.ac_mode].all_speed) { // 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 (!is_in(context->n_mode[ac_status.ac_mode].speed, + ac_status.ac_wind_speed, + context->n_mode[ac_status.ac_mode].speed_cnt)) { - if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.acWindSpeed) && + if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.ac_wind_speed) && function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind @@ -676,7 +674,7 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code) { if (function_code == AC_FUNCTION_WIND_FIX) { @@ -719,15 +717,15 @@ INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].alltemp) + if (FALSE == context->n_mode[ac_status.ac_mode].all_temp) { - if (!isin(context->n_mode[ac_status.acMode].temp, - ac_status.acTemp, - context->n_mode[ac_status.acMode].temp_cnt)) + if (!is_in(context->n_mode[ac_status.ac_mode].temp, + ac_status.ac_temp, + context->n_mode[ac_status.ac_mode].temp_cnt)) { - if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp)) + if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.ac_temp)) { if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) diff --git a/src/ir_decoder/src/ir_ac_binary_parse.c b/src/ir_decoder/src/ir_ac_binary_parse.c index cf07677..747a8b8 100644 --- a/src/ir_decoder/src/ir_ac_binary_parse.c +++ b/src/ir_decoder/src/ir_ac_binary_parse.c @@ -114,7 +114,7 @@ INT8 binary_parse_data() UINT16 i = 0; for (i = 0; i < tag_count; i++) { - tags[i].pdata = p_ir_buffer->data + tags[i].offset + tag_head_offset; + tags[i].p_data = p_ir_buffer->data + tags[i].offset + tag_head_offset; } return IR_DECODE_SUCCEEDED; diff --git a/src/ir_decoder/src/ir_ac_build_frame.c b/src/ir_decoder/src/ir_ac_build_frame.c index 1cf2b75..f3f767d 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 t_ac_protocol *context; //return bit number per byte,default value is 8 @@ -21,19 +21,19 @@ UINT8 bits_per_byte(UINT8 index) UINT8 i = 0; UINT8 size = 0; - if (context->bitnum_cnt == 0) + if (context->bit_num_cnt == 0) return 8; //defaut value - if (context->bitnum_cnt >= MAX_BITNUM) + if (context->bit_num_cnt >= MAX_BITNUM) size = MAX_BITNUM; else - size = (UINT8) context->bitnum_cnt; + size = (UINT8) context->bit_num_cnt; for (i = 0; i < size; i++) { - if (context->bitnum[i].pos == index) - return (UINT8) context->bitnum[i].bits; - if (context->bitnum[i].pos > index) + if (context->bit_num[i].pos == index) + return (UINT8) context->bit_num[i].bits; + if (context->bit_num[i].pos > index) return 8; } return 8; @@ -67,7 +67,7 @@ UINT16 add_delaycode(UINT8 index) } } - if ((context->lastbit == 0) && (index == (ir_hex_len - 1))) + if ((context->last_bit == 0) && (index == (ir_hex_len - 1))) { context->time[context->code_cnt++] = context->one.low; //high } @@ -97,11 +97,11 @@ UINT16 create_ir_frame() context->code_cnt = 0; // boot code - for (i = 0; i < context->bootcode.len; i++) + for (i = 0; i < context->boot_code.len; i++) { - context->time[context->code_cnt++] = context->bootcode.data[i]; + context->time[context->code_cnt++] = context->boot_code.data[i]; } - //code_cnt += context->bootcode.len; + //code_cnt += context->boot_code.len; for (i = 0; i < ir_hex_len; i++) { diff --git a/src/ir_decoder/src/ir_ac_control.c b/src/ir_decoder/src/ir_ac_control.c index b84d882..2bd8219 100644 --- a/src/ir_decoder/src/ir_ac_control.c +++ b/src/ir_decoder/src/ir_ac_control.c @@ -30,7 +30,7 @@ static INT8 ir_context_init(); static INT8 ir_context_init() { - ir_memset(context, 0, sizeof(protocol)); + ir_memset(context, 0, sizeof(t_ac_protocol)); return IR_DECODE_SUCCEEDED; } @@ -59,14 +59,14 @@ INT8 ir_ac_lib_parse() binary_tags_info(); context->endian = 0; - context->lastbit = 0; + context->last_bit = 0; context->repeat_times = 1; 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; + context->n_mode[i].all_speed = FALSE; + context->n_mode[i].all_temp = FALSE; ir_memset(context->n_mode[i].speed, 0x00, AC_WS_MAX); context->n_mode[i].speed_cnt = 0; ir_memset(context->n_mode[i].temp, 0x00, AC_TEMP_MAX); @@ -105,8 +105,8 @@ INT8 ir_ac_lib_parse() { 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); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing1.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing1.comp_data) { return IR_DECODE_FAILED; @@ -125,8 +125,8 @@ INT8 ir_ac_lib_parse() { 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); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing2.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing2.comp_data) { return IR_DECODE_FAILED; @@ -286,7 +286,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - else if (tags[i].tag == TAG_AC_BITNUM) + else if (tags[i].tag == TAG_AC_BIT_NUM) { if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) { @@ -350,7 +350,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - if (tags[i].tag == TAG_AC_LASTBIT) + if (tags[i].tag == TAG_AC_LAST_BIT) { if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) { @@ -382,7 +382,7 @@ INT8 ir_ac_lib_parse() // 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)) + if (is_in(context->sc.solo_function_codes, i, context->sc.solo_func_count)) { context->solo_function_mark |= (1 << (i - 1)); } 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 d7c8c3a..0ea1c47 100644 --- a/src/ir_decoder/src/ir_ac_parse_forbidden_info.c +++ b/src/ir_decoder/src/ir_ac_parse_forbidden_info.c @@ -17,10 +17,10 @@ Revision log: #include "../include/ir_ac_parse_forbidden_info.h" -extern protocol *context; +extern t_ac_protocol *context; -INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_speed(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; char *p = pdata; @@ -44,7 +44,7 @@ INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_temp(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; @@ -68,7 +68,7 @@ INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_pos(char *buf, ac_n_mode index) +INT8 parse_nmode_pos(char *buf, t_ac_n_mode index) { UINT16 i = 0; char data[64] = {0}; @@ -77,11 +77,11 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) { if (buf[0] == 'S' || buf[0] == 's') { - context->n_mode[index].allspeed = 1; + context->n_mode[index].all_speed = 1; } else if (buf[0] == 'T' || buf[0] == 't') { - context->n_mode[index].alltemp = 1; + context->n_mode[index].all_temp = 1; } return IR_DECODE_SUCCEEDED; } @@ -106,14 +106,14 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) +INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index) { UINT16 i = 0; UINT16 preindex = 0; char buf[64] = {0}; - if (tag->pdata[0] == 'N' && tag->pdata[1] == 'A') + if (tag->p_data[0] == 'N' && tag->p_data[1] == 'A') { // ban this function directly context->n_mode[index].enable = 0; @@ -127,16 +127,16 @@ INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); return IR_DECODE_SUCCEEDED; 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 5a20932..b96bca1 100644 --- a/src/ir_decoder/src/ir_ac_parse_frame_info.c +++ b/src/ir_decoder/src/ir_ac_parse_frame_info.c @@ -28,7 +28,7 @@ INT8 parse_boot_code(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -41,13 +41,13 @@ INT8 parse_boot_code(struct tag_head *tag) { index++; } - ir_memcpy(buf, tag->pdata + pos, index - pos); + ir_memcpy(buf, tag->p_data + pos, index - pos); pos = (UINT16) (index + 1); index = pos; - context->bootcode.data[cnt++] = (UINT16) (atoi((char *) buf)); + context->boot_code.data[cnt++] = (UINT16) (atoi((char *) buf)); ir_memset(buf, 0, 16); } - context->bootcode.len = cnt; + context->boot_code.len = cnt; return IR_DECODE_SUCCEEDED; } @@ -62,7 +62,7 @@ INT8 parse_zero(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -74,8 +74,8 @@ INT8 parse_zero(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(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->zero.low = (UINT16) (atoi((char *) low)); context->zero.high = (UINT16) (atoi((char *) high)); @@ -93,7 +93,7 @@ INT8 parse_one(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -104,8 +104,8 @@ 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(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->one.low = (UINT16) (atoi((char *) low)); context->one.high = (UINT16) (atoi((char *) high)); @@ -183,16 +183,16 @@ INT8 parse_delay_code(struct tag_head *tag) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); @@ -217,7 +217,7 @@ INT8 parse_frame_len(struct tag_head *tag, UINT16 len) ir_memset(temp, 0x00, len + 1); - ir_memcpy(temp, tag->pdata, len); + ir_memcpy(temp, tag->p_data, len); temp[len] = '\0'; context->frame_length = (UINT16) (atoi((char *) temp)); @@ -234,7 +234,7 @@ INT8 parse_endian(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); + ir_memcpy(buf, tag->p_data, tag->len); context->endian = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -247,8 +247,8 @@ INT8 parse_lastbit(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); - context->lastbit = (UINT8) (atoi((char *) buf)); + ir_memcpy(buf, tag->p_data, tag->len); + context->last_bit = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -260,7 +260,7 @@ INT8 parse_repeat_times(struct tag_head *tag) return IR_DECODE_FAILED; } - ir_memcpy(asc_code, tag->pdata, tag->len); + ir_memcpy(asc_code, tag->p_data, tag->len); context->repeat_times = (UINT16) (atoi((char *) asc_code)); @@ -287,9 +287,9 @@ 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_cnt++; + context->bit_num[context->bit_num_cnt].pos = (UINT16) (atoi((char *) start)); + context->bit_num[context->bit_num_cnt].bits = (UINT16) (atoi((char *) data)); + context->bit_num_cnt++; return IR_DECODE_SUCCEEDED; } @@ -307,23 +307,23 @@ INT8 parse_bit_num(struct tag_head *tag) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); - for (i = 0; i < context->bitnum_cnt; i++) + for (i = 0; i < context->bit_num_cnt; i++) { - if (context->bitnum[i].pos == -1) - context->bitnum[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos + if (context->bit_num[i].pos == -1) + context->bit_num[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 39b03b7..70137bd 100644 --- a/src/ir_decoder/src/ir_ac_parse_parameter.c +++ b/src/ir_decoder/src/ir_ac_parse_parameter.c @@ -17,7 +17,7 @@ Revision log: #include "../include/ir_ac_parse_parameter.h" -INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -43,7 +43,7 @@ INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -69,7 +69,7 @@ INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type) +INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -93,7 +93,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to AC data structure //*comp_len = hex_len; @@ -136,7 +136,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_SUCCEEDED; } -INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code) +INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code) { UINT16 byteLen = 0; @@ -146,12 +146,12 @@ INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code) } byteLen = tag->len >> 1; - string_to_hex(tag->pdata, default_code, byteLen); + string_to_hex(tag->p_data, default_code); return IR_DECODE_SUCCEEDED; } -INT8 parse_power_1(struct tag_head *tag, power_1 *power1) +INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -176,7 +176,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to power1 data structure power1->len = (UINT8) hex_len; @@ -201,7 +201,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) +INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1) { UINT16 hex_len = 0; UINT16 i = 0; @@ -222,7 +222,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -276,7 +276,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) +INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -296,7 +296,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode1->len = (UINT8) hex_len; @@ -320,7 +320,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) +INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -340,7 +340,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed1->len = (UINT8) hex_len; @@ -364,7 +364,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) +INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -384,12 +384,12 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing1 data structure swing1->count = swing_count; swing1->len = (UINT8) hex_len; - swing1->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing1->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing1->comp_data) { ir_free(hex_data); @@ -415,7 +415,7 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -434,7 +434,7 @@ INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT1 return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -452,7 +452,7 @@ INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { /* * note: @@ -478,14 +478,14 @@ INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *check return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum_malloc(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 cnt = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { cnt++; } @@ -493,18 +493,18 @@ 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->checksum_data = (t_tag_checksum_data *) ir_malloc(sizeof(t_tag_checksum_data) * checksum->count); if (NULL == checksum->checksum_data) { return IR_DECODE_FAILED; } - ir_memset(checksum->checksum_data, 0x00, sizeof(tag_checksum_data) * checksum->count); + ir_memset(checksum->checksum_data, 0x00, sizeof(t_tag_checksum_data) * checksum->count); return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) +INT8 parse_checksum_data(UINT8 *buf, t_tag_checksum_data *checksum, UINT8 length) { UINT8 *hex_data = NULL; UINT16 hex_len = 0; @@ -574,7 +574,7 @@ INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 num = 0; @@ -597,9 +597,9 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -610,7 +610,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) } } - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -620,7 +620,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -687,7 +687,7 @@ INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) +INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -712,7 +712,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function1->len = (UINT8) hex_len; @@ -743,7 +743,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) +INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2) { UINT16 hex_len = 0; UINT16 i = 0; @@ -769,7 +769,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -823,7 +823,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) +INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -848,7 +848,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode2->len = (UINT8) hex_len; @@ -872,7 +872,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) +INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -897,7 +897,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed2->len = (UINT8) hex_len; @@ -921,7 +921,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) +INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -946,12 +946,12 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing2 data structure swing2->count = swing_count; swing2->len = (UINT8) hex_len; - swing2->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing2->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing2->comp_data) { ir_free(hex_data); @@ -977,7 +977,7 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -1045,7 +1045,7 @@ INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) +INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -1070,7 +1070,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function2->len = (UINT8) hex_len; @@ -1101,7 +1101,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_info(struct tag_head *tag, swing_info *si) +INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si) { if (NULL == tag) { @@ -1117,13 +1117,13 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) */ if (1 == tag->len) { - if ('0' == tag->pdata[0]) + if ('0' == tag->p_data[0]) { // to identify if there is only 1 status in TAG 26 OR 33 si->type = SWING_TYPE_NOT_SPECIFIED; si->mode_count = 0; } - else if ('1' == tag->pdata[0]) + else if ('1' == tag->p_data[0]) { si->type = SWING_TYPE_SWING_ONLY; si->mode_count = 1; @@ -1145,7 +1145,7 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) return IR_DECODE_SUCCEEDED; } -INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) +INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc) { UINT16 hex_len = 0; UINT8 *hex_data = NULL; @@ -1175,7 +1175,7 @@ INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) { return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure sc->len = (UINT8) hex_len; diff --git a/src/ir_decoder/src/ir_decode.c b/src/ir_decoder/src/ir_decode.c index cfc7b5b..f2b8cdd 100644 --- a/src/ir_decoder/src/ir_decode.c +++ b/src/ir_decoder/src/ir_decode.c @@ -35,7 +35,7 @@ UINT8 *binary_content = NULL; UINT8 ir_binary_type = IR_TYPE_STATUS; UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY; -protocol *context = (protocol *) byteArray; +t_ac_protocol *context = (t_ac_protocol *) byteArray; lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = { @@ -51,7 +51,7 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = // 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, +static UINT16 ir_ac_lib_control(t_remote_ac_status 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); @@ -159,7 +159,7 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar } -UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction) +UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction) { if (IR_TYPE_COMMANDS == ir_binary_type) { @@ -257,7 +257,7 @@ static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length) return IR_DECODE_SUCCEEDED; } -static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction) { UINT16 time_length = 0; @@ -281,7 +281,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, ir_memcpy(ir_hex_code, context->default_code.data, context->default_code.len); #if defined USE_APPLY_TABLE - if(ac_status.acPower != AC_POWER_OFF) + if(ac_status.ac_power != AC_POWER_OFF) { for (i = AC_APPLY_POWER; i < AC_APPLY_MAX; i++) { @@ -289,7 +289,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, } } #else - if (ac_status.acPower == AC_POWER_OFF) + if (ac_status.ac_power == AC_POWER_OFF) { // otherwise, power should always be applied apply_power(ac_status, function_code); @@ -297,7 +297,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, 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.ac_mode].enable) { if (is_solo_function(function_code)) { @@ -400,7 +400,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].alltemp) + if (1 == context->n_mode[ac_mode].all_temp) { *temp_min = *temp_max = -1; return IR_DECODE_SUCCEEDED; @@ -410,7 +410,7 @@ 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) || + if (is_in(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)) { @@ -463,7 +463,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].allspeed) + if (1 == context->n_mode[ac_mode].all_speed) { *supported_wind_speed = 0; return IR_DECODE_SUCCEEDED; @@ -473,7 +473,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) for (i = 0; i < AC_WS_MAX; i++) { - if (isin(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || + if (is_in(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || (context->speed1.len != 0 && 0 == context->speed1.comp_data[i].seg_len) || (context->speed2.len != 0 && 0 == context->speed2.comp_data[i].seg_len)) { diff --git a/src/ir_decoder/src/ir_test_main.c b/src/ir_decoder/src/ir_test_main.c index 10db3de..d2603d1 100644 --- a/src/ir_decoder/src/ir_test_main.c +++ b/src/ir_decoder/src/ir_test_main.c @@ -15,7 +15,7 @@ Revision log: #include "../include/ir_decode.h" // global variable definition -remote_ac_status_t ac_status; +t_remote_ac_status ac_status; UINT16 user_data[USER_DATA_SIZE]; @@ -40,14 +40,14 @@ INT8 decode_as_ac(char *file_name) BOOL need_control; // init air conditioner status - ac_status.acDisplay = 0; - ac_status.acSleep = 0; - ac_status.acTimer = 0; - ac_status.acPower = AC_POWER_OFF; - ac_status.acMode = AC_MODE_COOL; - ac_status.acTemp = AC_TEMP_20; - ac_status.acWindDir = AC_SWING_ON; - ac_status.acWindSpeed = AC_WS_AUTO; + ac_status.ac_display = 0; + ac_status.ac_sleep = 0; + ac_status.ac_timer = 0; + ac_status.ac_power = AC_POWER_OFF; + ac_status.ac_mode = AC_MODE_COOL; + ac_status.ac_temp = AC_TEMP_20; + ac_status.ac_wind_dir = AC_SWING_ON; + ac_status.ac_wind_speed = AC_WS_AUTO; if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_AC, 0, file_name)) { @@ -65,42 +65,42 @@ INT8 decode_as_ac(char *file_name) case 'w': case 'W': // temperature plus - ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1)); + ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.ac_temp + 1)); function_code = AC_FUNCTION_TEMPERATURE_UP; break; case 's': case 'S': // temperature minus - ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1)); + ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.ac_temp - 1)); function_code = AC_FUNCTION_TEMPERATURE_DOWN; break; case 'a': case 'A': // wind speed loop - ++ac_status.acWindSpeed; - ac_status.acWindSpeed = ac_status.acWindSpeed % AC_WS_MAX; + ++ac_status.ac_wind_speed; + ac_status.ac_wind_speed = ac_status.ac_wind_speed % AC_WS_MAX; function_code = AC_FUNCTION_WIND_SPEED; break; case 'd': case 'D': // wind swing loop - ac_status.acWindDir = ((ac_status.acWindDir == 0) ? AC_SWING_OFF : AC_SWING_ON); + ac_status.ac_wind_dir = ((ac_status.ac_wind_dir == 0) ? AC_SWING_OFF : AC_SWING_ON); function_code = AC_FUNCTION_WIND_SWING; break; case 'q': case 'Q': - ++ac_status.acMode; - ac_status.acMode = ac_status.acMode % AC_MODE_MAX; + ++ac_status.ac_mode; + ac_status.ac_mode = ac_status.ac_mode % AC_MODE_MAX; function_code = AC_FUNCTION_MODE; break; case '1': // turn on - ac_status.acPower = AC_POWER_ON; + ac_status.ac_power = AC_POWER_ON; function_code = AC_FUNCTION_POWER; break; case '2': // turn off - ac_status.acPower = AC_POWER_OFF; + ac_status.ac_power = AC_POWER_OFF; // FUNCTION MAX refers to power off // function_code = AC_FUNCTION_POWER; break; @@ -113,25 +113,25 @@ INT8 decode_as_ac(char *file_name) break; case '4': - if (IR_DECODE_SUCCEEDED == get_supported_swing(ac_status.acMode, &supported_swing)) + if (IR_DECODE_SUCCEEDED == get_supported_swing(ac_status.ac_mode, &supported_swing)) { - ir_printf("\nsupported swing in %d = %02X\n", ac_status.acMode, supported_swing); + ir_printf("\nsupported swing in %d = %02X\n", ac_status.ac_mode, supported_swing); } need_control = FALSE; break; case '5': - if (IR_DECODE_SUCCEEDED == get_supported_wind_speed(ac_status.acMode, &supported_speed)) + if (IR_DECODE_SUCCEEDED == get_supported_wind_speed(ac_status.ac_mode, &supported_speed)) { - ir_printf("\nsupported wind speed in %d = %02X\n", ac_status.acMode, supported_speed); + ir_printf("\nsupported wind speed in %d = %02X\n", ac_status.ac_mode, supported_speed); } need_control = FALSE; break; case '6': - if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.acMode, &min_temperature, &max_temperature)) + if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.ac_mode, &min_temperature, &max_temperature)) { ir_printf("\nsupported temperature range in mode %d = %d, %d\n", - ac_status.acMode, min_temperature, max_temperature); + ac_status.ac_mode, min_temperature, max_temperature); } need_control = FALSE; break; @@ -152,11 +152,11 @@ INT8 decode_as_ac(char *file_name) 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, - ac_status.acMode, - ac_status.acTemp, - ac_status.acWindSpeed, - ac_status.acWindDir + ac_status.ac_power, + ac_status.ac_mode, + ac_status.ac_temp, + ac_status.ac_wind_speed, + ac_status.ac_wind_dir ); ir_decode(function_code, user_data, &ac_status, TRUE); diff --git a/src/ir_decoder/src/ir_tv_control.c b/src/ir_decoder/src/ir_tv_control.c index e4b04ba..f2dbde2 100644 --- a/src/ir_decoder/src/ir_tv_control.c +++ b/src/ir_decoder/src/ir_tv_control.c @@ -13,8 +13,6 @@ Revision log: #include "../include/ir_defs.h" #include "../include/ir_decode.h" -#include "../include/ir_tv_control.h" - struct buffer { @@ -26,12 +24,11 @@ struct buffer static struct buffer *pbuffer = &ir_file; -//static UINT8 *prot_name = NULL; static UINT8 *prot_cycles_num = NULL; -static ir_cycles_t *prot_cycles_data[IRDA_MAX]; +static t_ir_cycles *prot_cycles_data[IRDA_MAX]; static UINT8 prot_items_cnt = 0; -static ir_data_t *prot_items_data = NULL; -static ir_data_tv_t *remote_p; +static t_ir_data *prot_items_data = NULL; +static t_ir_data_tv *remote_p; static UINT8 *remote_pdata = NULL; static UINT16 time_index = 0; @@ -45,13 +42,13 @@ static BOOL get_ir_protocol(UINT8 encode_type); static BOOL get_ir_keymap(void); -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time); +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time); -static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time); +static void process_decode_number(UINT8 keycode, t_ir_data *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); +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time); INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length) @@ -109,8 +106,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) pbuffer->offset = 0; - /* protocol name */ - // prot_name = pbuffer->data + pbuffer->offset; + /* t_ac_protocol name */ pbuffer->offset += name_size; /* cycles number */ @@ -145,7 +141,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) { if (0 != prot_cycles_num[i]) { - prot_cycles_data[i] = (ir_cycles_t *) (&prot_cycles[sizeof(ir_cycles_t) * cycles_sum]); + prot_cycles_data[i] = (t_ir_cycles *) (&prot_cycles[sizeof(t_ir_cycles) * cycles_sum]); } else { @@ -153,15 +149,15 @@ static BOOL get_ir_protocol(UINT8 encode_type) } cycles_sum += prot_cycles_num[i]; } - pbuffer->offset += sizeof(ir_cycles_t) * cycles_sum; + pbuffer->offset += sizeof(t_ir_cycles) * cycles_sum; /* items count */ prot_items_cnt = pbuffer->data[pbuffer->offset]; pbuffer->offset += sizeof(UINT8); /* items data */ - prot_items_data = (ir_data_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += prot_items_cnt * sizeof(ir_data_t); + prot_items_data = (t_ir_data *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += prot_items_cnt * sizeof(t_ir_data); ir_toggle_bit = FALSE; @@ -170,8 +166,8 @@ static BOOL get_ir_protocol(UINT8 encode_type) static BOOL get_ir_keymap(void) { - remote_p = (ir_data_tv_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += sizeof(ir_data_tv_t); + remote_p = (t_ir_data_tv *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += sizeof(t_ir_data_tv); if (strncmp(remote_p->magic, "irda", 4) == 0) { @@ -182,11 +178,11 @@ static BOOL get_ir_keymap(void) return FALSE; } -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time) { UINT8 i = 0; UINT8 cycles_num = 0; - ir_cycles_t *pcycles = NULL; + t_ir_cycles *pcycles = NULL; UINT8 key_code = 0; if (NULL == data || NULL == ir_time) @@ -301,10 +297,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) { break; } - else - { - pcycles++; - } + pcycles++; } } else @@ -331,7 +324,7 @@ 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) +static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time) { UINT8 i = 0; UINT8 value = 0; @@ -415,7 +408,7 @@ static void convert_to_ir_time(UINT8 value, UINT16 *ir_time) } } -static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time) +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time) { if (NULL == pcycles_num || NULL == ir_time) { diff --git a/src/ir_decoder/src/ir_utils.c b/src/ir_decoder/src/ir_utils.c index bbe78c6..e1a972a 100644 --- a/src/ir_decoder/src/ir_utils.c +++ b/src/ir_decoder/src/ir_utils.c @@ -23,7 +23,7 @@ UINT8 char_to_hex(char chr) return value; } -UINT8 chars_to_hex(UINT8 *p) +UINT8 chars_to_hex(const UINT8 *p) { return (char_to_hex(*p) << 4) + char_to_hex(*(p + 1)); } @@ -40,7 +40,7 @@ void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len) } } -void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len) +void string_to_hex(UINT8 *p, t_ac_hex *pac_hex) { UINT8 i = 0; @@ -53,38 +53,7 @@ void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len) } } -char hex_half_byte_to_single_char(UINT8 length, UINT8 half_byte) -{ - if (1 != length || half_byte >= 16) - { - return '0'; - } - if (half_byte >= 10 && half_byte < 16) - { - return (char) (half_byte - 10 + 0x41); - } - else - { - return (char) (half_byte + 0x30); - } -} - -void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src) -{ - UINT8 hi_num = 0; - UINT8 lo_num = 0; - if (NULL == dest || 2 != length) - { - return; - } - 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); -} - -BOOL isin(UINT8 array[], UINT8 value, UINT8 len) +BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len) { UINT16 i = 0; for (i = 0; i < len; i++)