formalized code

This commit is contained in:
2017-10-13 15:24:37 +08:00
parent 01156d8521
commit 40d1a7053c
20 changed files with 347 additions and 392 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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);

View File

@@ -22,15 +22,11 @@ extern "C"
#include <stdio.h>
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
}