diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_apply.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_apply.h index 42537bd..af68831 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_apply.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_apply.h @@ -12,7 +12,9 @@ Revision log: #ifndef _IR_APPLY_H_ #define _IR_APPLY_H_ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedMacroInspection" +#endif #ifdef __cplusplus extern "C" diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_build_frame.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_build_frame.h index 1b55b11..f77274d 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_build_frame.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_build_frame.h @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_utils.c +Filename: ir_ac_build_frame.h Revised: Date: 2016-10-26 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_control.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_control.h index 655f9db..60d8722 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_control.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_control.h @@ -11,7 +11,9 @@ Revision log: #ifndef _IR_DECODER_IR_AC_CONTROL_H #define _IR_DECODER_IR_AC_CONTROL_H +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" +#endif #ifdef __cplusplus extern "C" diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_forbidden_info.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_forbidden_info.h index a134ff9..ce86c1e 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_forbidden_info.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_forbidden_info.h @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_parse_forbidden_info.h +Filename: ir_ac_parse_forbidden_info.h Revised: Date: 2016-10-05 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_frame_info.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_frame_info.h index 3016ea2..3ca3667 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_frame_info.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_frame_info.h @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_parse_frame_parameter.h +Filename: ir_ac_parse_frame_info.h Revised: Date: 2016-10-11 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_parameter.h b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_parameter.h index c991e46..78680e8 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_parameter.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_ac_parse_parameter.h @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_parse_ac_parameter.h +Filename: ir_ac_parse_parameter.h Revised: Date: 2016-10-12 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_decode.h b/android-example/decodesdk/ir_decoder/src/include/ir_decode.h index 5ba789f..6d7ebeb 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_decode.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_decode.h @@ -12,8 +12,10 @@ Revision log: #ifndef _IR_DECODE_H_ #define _IR_DECODE_H_ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" #pragma ide diagnostic ignored "OCUnusedMacroInspection" +#endif #ifdef __cplusplus extern "C" @@ -219,10 +221,11 @@ typedef enum typedef enum { - SUB_CATEGORY_QUATERNARY = 0, - SUB_CATEGORY_HEXADECIMAL = 1, - SUB_CATEGORY_NEXT = 2, - SUB_CATEGORY_MAX = 7, + SUB_CATEGORY_BINARY = 0, // deprecated + SUB_CATEGORY_QUATERNARY = 1, + SUB_CATEGORY_HEXADECIMAL = 2, + SUB_CATEGORY_NEXT = 3, + SUB_CATEGORY_MAX = 4, } t_remote_sub_category; /** diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_defs.h b/android-example/decodesdk/ir_decoder/src/include/ir_defs.h index e8e3f85..be31f58 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_defs.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_defs.h @@ -12,8 +12,10 @@ Revision log: #ifndef _IR_DEFS_H #define _IR_DEFS_H +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" #pragma ide diagnostic ignored "OCUnusedMacroInspection" +#endif #ifdef __cplusplus extern "C" diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_tv_control.h b/android-example/decodesdk/ir_decoder/src/include/ir_tv_control.h index 6149556..94f04ae 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_tv_control.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_tv_control.h @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_lib.h +Filename: ir_tv_control.h Revised: Date: 2016-02-23 Revision: Revision: 1.0 @@ -12,8 +12,10 @@ Revision log: #ifndef _IR_TV_CONTROL_H_ #define _IR_TV_CONTROL_H_ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedMacroInspection" #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" +#endif #ifdef __cplusplus extern "C" diff --git a/android-example/decodesdk/ir_decoder/src/include/ir_utils.h b/android-example/decodesdk/ir_decoder/src/include/ir_utils.h index 299b76d..842ac16 100644 --- a/android-example/decodesdk/ir_decoder/src/include/ir_utils.h +++ b/android-example/decodesdk/ir_decoder/src/include/ir_utils.h @@ -12,7 +12,9 @@ Revision log: #ifndef _IR_UTILS_H_ #define _IR_UTILS_H_ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" +#endif #ifdef __cplusplus extern "C" diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_apply.c b/android-example/decodesdk/ir_decoder/src/ir_ac_apply.c index 8ab1da3..1dc8881 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_apply.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_apply.c @@ -8,8 +8,10 @@ Description: This file provides methods for AC IR applying functionalities Revision log: * 2016-10-12: created by strawmanbobi **************************************************************************************/ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "bugprone-branch-clone" #pragma ide diagnostic ignored "hicpp-signed-bitwise" +#endif #include "include/ir_utils.h" #include "include/ir_ac_apply.h" diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_binary_parse.c b/android-example/decodesdk/ir_decoder/src/ir_ac_binary_parse.c index c2ff2eb..de1f016 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_binary_parse.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_binary_parse.c @@ -33,11 +33,11 @@ const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] = INT8 binary_parse_offset() { int i = 0; -#if defined BOARD_ESP8266 +#if defined(ESP8266) || defined(ESP32) UINT8 *phead = (UINT8 *)&p_ir_buffer->data[1]; #else UINT16 *phead = (UINT16 *)&p_ir_buffer->data[1]; -#endif // BOARD_ESP8266 +#endif // ESPRESSIF tag_count = p_ir_buffer->data[0]; if (TAG_COUNT_FOR_PROTOCOL != tag_count) @@ -63,7 +63,7 @@ INT8 binary_parse_offset() #if defined BOARD_STM8 && defined COMPILER_IAR UINT16 offset = *(phead + i); tags[i].offset = (offset >> 8) | (offset << 8); -#elif defined BOARD_ESP8266 +#elif defined(ESP8266) || defined(ESP32) UINT16 tmp_a = *(phead + i * 2); UINT16 tmp_b = *(phead + i * 2 + 1); tags[i].offset = tmp_b << 8 | tmp_a; diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_build_frame.c b/android-example/decodesdk/ir_decoder/src/ir_ac_build_frame.c index a34c11b..366e08c 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_build_frame.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_build_frame.c @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_irframe.c +Filename: ir_ac_build_frame.c Revised: Date: 2016-10-01 Revision: Revision: 1.0 @@ -9,8 +9,10 @@ Revision log: * 2016-10-01: created by strawmanbobi **************************************************************************************/ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "hicpp-signed-bitwise" #pragma ide diagnostic ignored "readability-redundant-declaration" +#endif #include "include/ir_ac_build_frame.h" #include "include/ir_decode.h" diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_control.c b/android-example/decodesdk/ir_decoder/src/ir_ac_control.c index 36ce198..e6ee7b7 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_control.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_control.c @@ -550,10 +550,11 @@ INT8 free_ac_context() return IR_DECODE_SUCCEEDED; } -#pragma clang diagnostic push +#if defined (BOARD_PC) #pragma ide diagnostic ignored "hicpp-signed-bitwise" +#endif + BOOL is_solo_function(UINT8 function_code) { return (((context->solo_function_mark >> (function_code - 1)) & 0x01) == 0x01) ? TRUE : FALSE; -} -#pragma clang diagnostic pop +} \ No newline at end of file diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_forbidden_info.c b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_forbidden_info.c index 2339c7a..5121932 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_forbidden_info.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_forbidden_info.c @@ -9,7 +9,9 @@ Revision log: * 2016-10-05: created by strawmanbobi **************************************************************************************/ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "readability-redundant-declaration" +#endif #include #include diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_frame_info.c b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_frame_info.c index 336530d..d103815 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_frame_info.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_frame_info.c @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_parse_frame_parameter.c +Filename: ir_ac_parse_frame_info.c Revised: Date: 2016-10-11 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_parameter.c b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_parameter.c index ee4e4e9..d8d2a03 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_ac_parse_parameter.c +++ b/android-example/decodesdk/ir_decoder/src/ir_ac_parse_parameter.c @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_parse_ac_parameter.c +Filename: ir_ac_parse_parameter.c Revised: Date: 2016-10-12 Revision: Revision: 1.0 diff --git a/android-example/decodesdk/ir_decoder/src/ir_decode.c b/android-example/decodesdk/ir_decoder/src/ir_decode.c index 26c864c..1994d5f 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_decode.c +++ b/android-example/decodesdk/ir_decoder/src/ir_decode.c @@ -31,8 +31,10 @@ struct tag_head tags[TAG_COUNT_FOR_PROTOCOL]; #endif static UINT8 byte_array[PROTOCOL_SIZE] = { 0 }; +#if !defined NO_FS static size_t binary_length = 0; static UINT8 *binary_content = NULL; +#endif static t_remote_category remote_category = REMOTE_CATEGORY_NONE; static UINT8 ir_binary_type = IR_TYPE_STATUS; @@ -137,13 +139,13 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi else { ir_binary_type = IR_TYPE_COMMANDS; - if (1 == sub_category) + if (SUB_CATEGORY_QUATERNARY == sub_category) { - ir_hexadecimal = SUB_CATEGORY_QUATERNARY; + ir_hexadecimal = 0; } - else if (2 == sub_category) + else if (SUB_CATEGORY_HEXADECIMAL == sub_category) { - ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL; + ir_hexadecimal = 1; } else { @@ -178,7 +180,7 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar ir_printf("wrong remote category\n"); return IR_DECODE_FAILED; } - remote_category = category; + remote_category = (t_remote_category) category; if (sub_category < SUB_CATEGORY_QUATERNARY || sub_category >= SUB_CATEGORY_NEXT) @@ -203,13 +205,13 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar else { ir_binary_type = IR_TYPE_COMMANDS; - if (1 == sub_category) + if (SUB_CATEGORY_QUATERNARY == sub_category) { - ir_hexadecimal = SUB_CATEGORY_QUATERNARY; + ir_hexadecimal = 0; } - else if (2 == sub_category) + else if (SUB_CATEGORY_HEXADECIMAL == sub_category) { - ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL; + ir_hexadecimal = 1; } else { @@ -468,19 +470,6 @@ static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16* user_data, UIN time_length = create_ir_frame(); -#if (defined BOARD_PC) -#if (defined BOARD_PC_JNI) - ir_printf("code count = %d\n", context->code_cnt); -#else - int i = 0; - for (i = 0; i < context->code_cnt; i++) - { - ir_printf("%d,", context->time[i]); - } -#endif - ir_printf("\n"); -#endif - return time_length; } @@ -724,15 +713,6 @@ static UINT16 ir_tv_control(UINT8 key, UINT16 *l_user_data) memset(l_user_data, 0x00, USER_DATA_SIZE); ir_code_length = tv_binary_decode(key, l_user_data); -#if defined BOARD_PC - // have some debug - ir_printf("length of IR code = %d\n", ir_code_length); - for (print_index = 0; print_index < ir_code_length; print_index++) - { - ir_printf("%d ", l_user_data[print_index]); - } -#endif - return ir_code_length; } @@ -760,7 +740,7 @@ UINT16 ir_decode_combo(const UINT8 category, const UINT8 sub_category, return IR_DECODE_FAILED; } - remote_category = category; + remote_category = (t_remote_category) category; if (key_code < 0 || key_code >= KEY_CODE_MAX[remote_category]) { diff --git a/android-example/decodesdk/ir_decoder/src/ir_decode_test.c b/android-example/decodesdk/ir_decoder/src/ir_decode_test.c index 5ae2a1b..f3d3a85 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_decode_test.c +++ b/android-example/decodesdk/ir_decoder/src/ir_decode_test.c @@ -1,9 +1,9 @@ /************************************************************************************** -Filename: ir_main.c +Filename: ir_decode_test.c Revised: Date: 2016-11-05 Revision: Revision: 1.0 -Description: This file provides main entry for irda decoder +Description: This file provides main entry for irda decoder test Revision log: * 2016-11-05: created by strawmanbobi @@ -12,7 +12,6 @@ Revision log: #pragma ide diagnostic ignored "OCUnusedMacroInspection" #include -#include #include #include #include @@ -60,9 +59,10 @@ static INT8 decode_as_ac(char *file_name) { BOOL op_match = TRUE; BOOL change_wind_dir = FALSE; - UINT8 function_code = AC_FUNCTION_MAX; int key_code = 0; int first_time = 1; + int length = 0; + int index = 0; // get status UINT8 supported_mode = 0x00; @@ -72,13 +72,13 @@ static INT8 decode_as_ac(char *file_name) UINT8 supported_swing = 0x00; UINT8 supported_wind_direction = 0x00; - BOOL need_control; + BOOL need_control = TRUE; // init air conditioner status 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_power = AC_POWER_ON; ac_status.ac_mode = AC_MODE_COOL; ac_status.ac_temp = AC_TEMP_20; ac_status.ac_wind_dir = AC_SWING_ON; @@ -162,8 +162,9 @@ static INT8 decode_as_ac(char *file_name) { switch (key_code) { + // notice: only if ac_power is turned on will user_data change when input a different key_code case 0: - ac_status.ac_power = ((ac_status.ac_wind_dir == AC_POWER_ON) ? AC_POWER_OFF : AC_POWER_ON); + ac_status.ac_power = ((ac_status.ac_power == AC_POWER_ON) ? AC_POWER_OFF : AC_POWER_ON); need_control = TRUE; break; @@ -210,15 +211,20 @@ static INT8 decode_as_ac(char *file_name) if (TRUE == op_match && TRUE == need_control) { - printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d with function code = %d\n", + printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d with key_code = %d\n", ac_status.ac_power, ac_status.ac_mode, ac_status.ac_temp, ac_status.ac_wind_speed, ac_status.ac_wind_dir, - function_code); - - ir_decode(function_code, user_data, &ac_status, change_wind_dir); + key_code); + length = ir_decode(key_code, user_data, &ac_status, change_wind_dir); + printf("\n === Binary decoded : %d\n", length); + for (index = 0; index < length; index++) + { + printf("%d, ", user_data[index]); + } + printf("\n"); } } } while (TRUE); @@ -233,6 +239,8 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode) // keyboard input int key_code = 0; int first_time = 1; + int length = 0; + int index = 0; // here remote category TV represents for command typed IR code if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_TV, ir_hex_encode, file_name)) @@ -258,7 +266,13 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode) { break; } - ir_decode(key_code, user_data, NULL, 0); + length = ir_decode(key_code, user_data, NULL, 0); + printf("\n === Binary decoded : %d\n", length); + for (index = 0; index < length; index++) + { + printf("%d, ", user_data[index]); + } + printf("===\n"); } while (TRUE); @@ -280,7 +294,7 @@ int main(int argc, char *argv[]) if (4 != argc) { - print_usage(basename(argv[0])); + print_usage((argv[0])); return -1; } diff --git a/android-example/decodesdk/ir_decoder/src/ir_tv_control.c b/android-example/decodesdk/ir_decoder/src/ir_tv_control.c index c7cc98f..53a3e80 100644 --- a/android-example/decodesdk/ir_decoder/src/ir_tv_control.c +++ b/android-example/decodesdk/ir_decoder/src/ir_tv_control.c @@ -1,5 +1,5 @@ /************************************************************************************** -Filename: ir_lib.c +Filename: ir_tv_control.c Revised: Date: 2016-10-21 Revision: Revision: 1.0 @@ -9,7 +9,9 @@ Revision log: * 2016-10-21: created by strawmanbobi **************************************************************************************/ +#if defined (BOARD_PC) #pragma ide diagnostic ignored "hicpp-signed-bitwise" +#endif #include @@ -118,7 +120,8 @@ static BOOL get_ir_protocol(UINT8 encode_type) if (encode_type == 0) { - cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */ + cycles_num_size = 8; + /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */ if (prot_cycles_num[IRDA_TWO] == 0 && prot_cycles_num[IRDA_THREE] == 0) { ir_decode_flag = IRDA_DECODE_1_BIT;