merged AC/TV public API into one
This commit is contained in:
@@ -25,168 +25,134 @@ extern "C"
|
|||||||
#define IR_DECODE_FAILED (-1)
|
#define IR_DECODE_FAILED (-1)
|
||||||
#define IR_DECODE_SUCCEEDED (0)
|
#define IR_DECODE_SUCCEEDED (0)
|
||||||
|
|
||||||
|
#define IR_CATEGORY_AC 1
|
||||||
|
#define IR_CATEGORY_TV 2
|
||||||
|
|
||||||
/* exported functions */
|
#define IR_TYPE_STATUS 0
|
||||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
#define IR_TYPE_COMMANDS 1
|
||||||
/*
|
|
||||||
* function ir_ac_file_open
|
#define SUB_CATEGORY_QUATERNARY 0
|
||||||
|
#define SUB_CATEGORY_HEXADECIMAL 1
|
||||||
|
|
||||||
|
// exported functions
|
||||||
|
/**
|
||||||
|
* function ir_file_open
|
||||||
*
|
*
|
||||||
* parameters: file name of remote binary
|
* description: open IR binary code from file
|
||||||
|
*
|
||||||
|
* parameters: category (in) - category ID get from indexing API
|
||||||
|
* sub_category (in) - subcategory ID get from indexing API
|
||||||
|
* file_name (in) - file name of IR binary
|
||||||
|
*
|
||||||
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
*/
|
||||||
extern INT8 ir_ac_file_open(const char *file_name);
|
extern INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function ir_ac_lib_open
|
* function ir_binary_open
|
||||||
*
|
*
|
||||||
* parameters: binary (in) binary content
|
* description: open IR binary code from buffer
|
||||||
* binary_length (in) length of binary content
|
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* parameters: category (in) - category ID get from indexing API
|
||||||
|
* sub_category (in) - subcategory ID get from indexing API
|
||||||
|
* binary (in) - pointer to binary buffer
|
||||||
|
* binary_length (in) - binary buffer size
|
||||||
|
*
|
||||||
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length);
|
extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function ir_ac_lib_parse
|
* function ir_decode
|
||||||
*
|
*
|
||||||
* parameters:
|
* description: decode IR binary into INT16 array which indicates the IR levels
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* parameters: key_code (in) - the code of pressed key
|
||||||
|
* user_data (out) - output decoded data in INT16 array format
|
||||||
|
* ac_status(in) - pointer to AC status (optional)
|
||||||
|
* change_wind_direction (in) - if control changes wind direction for AC (for AC only)
|
||||||
|
*
|
||||||
|
* returns: length of decoded data (0 indicates decode failure)
|
||||||
*/
|
*/
|
||||||
extern INT8 ir_ac_lib_parse();
|
extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function ir_ac_lib_control
|
* function ir_close
|
||||||
*
|
*
|
||||||
* parameters: ac_status (in) indicates the current status of air conditioner to be controlled
|
* description: close IR binary code
|
||||||
* user_data (out) wave code array to be transmitted
|
|
||||||
* function_code (in) indicates the AC function to be updated
|
|
||||||
* change_wind_direction (in) indicates if the wind direction need to be changed
|
|
||||||
*
|
*
|
||||||
* return: length of wave code array
|
* parameters: N/A
|
||||||
|
*
|
||||||
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
extern INT8 ir_close();
|
||||||
BOOL change_wind_direction);
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function ir_ac_lib_close
|
* function get_temperature_range
|
||||||
*
|
*
|
||||||
* parameters:
|
* description: get the supported temperature range [min, max] for the opened AC IR binary
|
||||||
*
|
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
|
||||||
extern INT8 ir_ac_lib_close();
|
|
||||||
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
|
||||||
/*
|
|
||||||
* function ir_tv_file_open
|
|
||||||
*
|
|
||||||
* parameters: file name of remote binary
|
|
||||||
*
|
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
|
||||||
extern INT8 ir_tv_file_open(const char *file_name);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* function ir_tv_lib_open
|
|
||||||
*
|
|
||||||
* parameters: binary (in) binary content
|
|
||||||
* binary_length (in) length of binary content
|
|
||||||
*
|
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
|
||||||
extern INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* function ir_tv_lib_parse
|
|
||||||
*
|
|
||||||
* parameters:
|
|
||||||
*
|
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
|
||||||
extern INT8 ir_tv_lib_parse(UINT8 ir_hex_encode);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* function ir_tv_lib_control
|
|
||||||
*
|
|
||||||
* parameters: key_code (in) indicates the number of pressed key
|
|
||||||
* user_data (out) wave code array to be transmitted
|
|
||||||
*
|
|
||||||
* return: length of wave code array
|
|
||||||
*/
|
|
||||||
extern UINT16 ir_tv_lib_control(UINT8 key_code, UINT16 *user_data);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* function ir_tv_lib_close
|
|
||||||
*
|
|
||||||
* parameters:
|
|
||||||
*
|
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
|
||||||
*/
|
|
||||||
extern INT8 ir_tv_lib_close();
|
|
||||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
|
|
||||||
/*
|
|
||||||
* function get_temperature_range
|
|
||||||
*
|
*
|
||||||
* parameters: ac_mode (in) specify in which AC mode the application need to get temperature info
|
* parameters: ac_mode (in) specify in which AC mode the application need to get temperature info
|
||||||
* temp_min (out) the min temperature supported in a specified AC mode
|
* temp_min (out) the min temperature supported in a specified AC mode
|
||||||
* temp_max (out) the max temperature supported in a specified AC mode
|
* temp_max (out) the max temperature supported in a specified AC mode
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max);
|
extern INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function get_supported_mode
|
* function get_supported_mode
|
||||||
|
*
|
||||||
|
* description: get supported mode for the opened AC IR binary
|
||||||
*
|
*
|
||||||
* parameters: supported_mode (out) mode supported by the remote in lower 5 bits
|
* parameters: supported_mode (out) mode supported by the remote in lower 5 bits
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 get_supported_mode(UINT8 *supported_mode);
|
extern INT8 get_supported_mode(UINT8 *supported_mode);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function get_supported_wind_speed
|
* function get_supported_wind_speed
|
||||||
|
*
|
||||||
|
* description: get supported wind speed levels for the opened AC IR binary in certain mode
|
||||||
*
|
*
|
||||||
* parameters: ac_mode (in) specify in which AC mode the application need to get wind speed info
|
* parameters: ac_mode (in) specify in which AC mode the application need to get wind speed info
|
||||||
* supported_wind_speed (out) wind speed supported by the remote in lower 4 bits
|
* supported_wind_speed (out) wind speed supported by the remote in lower 4 bits
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed);
|
extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function get_supported_swing
|
* function get_supported_swing
|
||||||
|
*
|
||||||
|
* description: get supported swing functions for the opened AC IR binary in certain mode
|
||||||
*
|
*
|
||||||
* parameters: ac_mode (in) specify in which AC mode the application need to get swing info
|
* parameters: ac_mode (in) specify in which AC mode the application need to get swing info
|
||||||
* supported_swing (out) swing supported by the remote in lower 2 bits
|
* supported_swing (out) swing supported by the remote in lower 2 bits
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing);
|
extern INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function get_supported_wind_direction
|
* function get_supported_wind_direction
|
||||||
|
*
|
||||||
|
* description: get supported wind directions for the opened AC IR binary in certain mode
|
||||||
*
|
*
|
||||||
* parameters: supported_wind_direction (out) swing supported by the remote in lower 2 bits
|
* parameters: supported_wind_direction (out) swing supported by the remote in lower 2 bits
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction);
|
extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction);
|
||||||
|
|
||||||
|
|
||||||
// private extern function
|
// private extern function
|
||||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||||
|
|
||||||
extern void ir_lib_free_inner_buffer();
|
extern void ir_lib_free_inner_buffer();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////// Utils End /////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ Revision log:
|
|||||||
#include "../include/ir_utils.h"
|
#include "../include/ir_utils.h"
|
||||||
#include "../include/ir_ac_build_frame.h"
|
#include "../include/ir_ac_build_frame.h"
|
||||||
#include "../include/ir_ac_apply.h"
|
#include "../include/ir_ac_apply.h"
|
||||||
#include "../include/ir_ac_control.h"
|
|
||||||
#include "../include/ir_tv_control.h"
|
|
||||||
|
|
||||||
struct ir_bin_buffer binary_file;
|
struct ir_bin_buffer binary_file;
|
||||||
struct ir_bin_buffer *p_ir_buffer = &binary_file;
|
struct ir_bin_buffer *p_ir_buffer = &binary_file;
|
||||||
@@ -34,29 +32,166 @@ UINT8 byteArray[PROTOCOL_SIZE] = {0};
|
|||||||
size_t binary_length = 0;
|
size_t binary_length = 0;
|
||||||
UINT8 *binary_content = NULL;
|
UINT8 *binary_content = NULL;
|
||||||
|
|
||||||
|
UINT8 ir_binary_type = IR_TYPE_STATUS;
|
||||||
|
UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
||||||
|
|
||||||
protocol *context = (protocol *) byteArray;
|
protocol *context = (protocol *) byteArray;
|
||||||
|
|
||||||
lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
|
lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
|
||||||
|
{
|
||||||
|
apply_power,
|
||||||
|
apply_mode,
|
||||||
|
apply_temperature,
|
||||||
|
apply_temperature,
|
||||||
|
apply_wind_speed,
|
||||||
|
apply_swing,
|
||||||
|
apply_swing
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
BOOL change_wind_direction);
|
||||||
|
static INT8 ir_ac_lib_close();
|
||||||
|
static INT8 ir_tv_file_open(const char *file_name);
|
||||||
|
static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length);
|
||||||
|
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode);
|
||||||
|
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data);
|
||||||
|
static INT8 ir_tv_lib_close();
|
||||||
|
|
||||||
|
|
||||||
|
// pubic function definitions
|
||||||
|
|
||||||
|
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
|
||||||
|
{
|
||||||
|
INT8 ret = IR_DECODE_SUCCEEDED;
|
||||||
|
if (category == IR_CATEGORY_AC)
|
||||||
|
{
|
||||||
|
ir_binary_type = IR_TYPE_STATUS;
|
||||||
|
ret = ir_ac_file_open(file_name);
|
||||||
|
if (IR_DECODE_SUCCEEDED == ret)
|
||||||
{
|
{
|
||||||
apply_power,
|
return ir_ac_lib_parse();
|
||||||
apply_mode,
|
}
|
||||||
apply_temperature,
|
else
|
||||||
apply_temperature,
|
{
|
||||||
apply_wind_speed,
|
return ret;
|
||||||
apply_swing,
|
}
|
||||||
apply_swing
|
}
|
||||||
};
|
else
|
||||||
|
{
|
||||||
|
ir_binary_type = IR_TYPE_COMMANDS;
|
||||||
|
if (1 == sub_category)
|
||||||
|
{
|
||||||
|
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
||||||
|
}
|
||||||
|
else if (2 == sub_category)
|
||||||
|
{
|
||||||
|
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return IR_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ir_tv_file_open(file_name);
|
||||||
|
if (IR_DECODE_SUCCEEDED == ret)
|
||||||
|
{
|
||||||
|
return ir_tv_lib_parse(ir_hexadecimal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
|
||||||
|
{
|
||||||
|
INT8 ret = IR_DECODE_SUCCEEDED;
|
||||||
|
if (category == IR_TYPE_STATUS)
|
||||||
|
{
|
||||||
|
ir_binary_type = IR_TYPE_STATUS;
|
||||||
|
ret = ir_ac_lib_open(binary, binary_length);
|
||||||
|
if (IR_DECODE_SUCCEEDED == ret)
|
||||||
|
{
|
||||||
|
return ir_ac_lib_parse();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ir_binary_type = IR_TYPE_COMMANDS;
|
||||||
|
if (1 == sub_category)
|
||||||
|
{
|
||||||
|
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
||||||
|
}
|
||||||
|
else if (2 == sub_category)
|
||||||
|
{
|
||||||
|
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return IR_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ir_tv_lib_open(binary, binary_length);
|
||||||
|
if (IR_DECODE_SUCCEEDED == ret)
|
||||||
|
{
|
||||||
|
return ir_tv_lib_parse(ir_hexadecimal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction)
|
||||||
|
{
|
||||||
|
if (IR_TYPE_COMMANDS == ir_binary_type)
|
||||||
|
{
|
||||||
|
return ir_tv_lib_control(key_code, user_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NULL == ac_status)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ir_ac_lib_control(*ac_status, user_data, key_code, change_wind_direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT8 ir_close()
|
||||||
|
{
|
||||||
|
if (IR_TYPE_COMMANDS == ir_binary_type)
|
||||||
|
{
|
||||||
|
return ir_tv_lib_close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ir_ac_lib_close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||||
|
|
||||||
void ir_lib_free_inner_buffer();
|
void ir_lib_free_inner_buffer();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
// static function definitions
|
||||||
INT8 ir_ac_file_open(const char *file_name)
|
|
||||||
|
//////// AC Begin ////////
|
||||||
|
static INT8 ir_ac_file_open(const char *file_name)
|
||||||
{
|
{
|
||||||
#if !defined NO_FS
|
#if !defined NO_FS
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
@@ -106,7 +241,7 @@ INT8 ir_ac_file_open(const char *file_name)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
// it is recommended that the parameter binary pointing to
|
// it is recommended that the parameter binary pointing to
|
||||||
// a global memory block in embedded platform environment
|
// a global memory block in embedded platform environment
|
||||||
@@ -116,7 +251,7 @@ INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
||||||
BOOL change_wind_direction)
|
BOOL change_wind_direction)
|
||||||
{
|
{
|
||||||
UINT16 time_length = 0;
|
UINT16 time_length = 0;
|
||||||
@@ -228,7 +363,7 @@ UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8
|
|||||||
return time_length;
|
return time_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 ir_ac_lib_close()
|
static INT8 ir_ac_lib_close()
|
||||||
{
|
{
|
||||||
// free context
|
// free context
|
||||||
if (NULL != tags)
|
if (NULL != tags)
|
||||||
@@ -383,10 +518,10 @@ INT8 get_supported_wind_direction(UINT8 *supported_wind_direction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
|
//////// AC End ////////
|
||||||
|
|
||||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
//////// TV Begin ////////
|
||||||
INT8 ir_tv_file_open(const char *file_name)
|
static INT8 ir_tv_file_open(const char *file_name)
|
||||||
{
|
{
|
||||||
#if !defined NO_FS
|
#if !defined NO_FS
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
@@ -437,12 +572,12 @@ INT8 ir_tv_file_open(const char *file_name)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
return tv_lib_open(binary, binary_length);
|
return tv_lib_open(binary, binary_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
|
static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
|
||||||
{
|
{
|
||||||
if (FALSE == tv_lib_parse(ir_hex_encode))
|
if (FALSE == tv_lib_parse(ir_hex_encode))
|
||||||
{
|
{
|
||||||
@@ -452,7 +587,7 @@ INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
|
static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
|
||||||
{
|
{
|
||||||
#if defined BOARD_PC
|
#if defined BOARD_PC
|
||||||
UINT16 print_index = 0;
|
UINT16 print_index = 0;
|
||||||
@@ -463,30 +598,27 @@ UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
|
|||||||
|
|
||||||
#if defined BOARD_PC
|
#if defined BOARD_PC
|
||||||
// have some debug
|
// have some debug
|
||||||
ir_printf("=============================\n");
|
ir_printf("length of IR code = %d\n", ir_code_length);
|
||||||
ir_printf("length of IRDA code = %d\n", ir_code_length);
|
|
||||||
for (print_index = 0; print_index < ir_code_length; print_index++)
|
for (print_index = 0; print_index < ir_code_length; print_index++)
|
||||||
{
|
{
|
||||||
ir_printf("%d ", l_user_data[print_index]);
|
ir_printf("%d ", l_user_data[print_index]);
|
||||||
}
|
}
|
||||||
ir_printf("\n=============================\n\n");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ir_code_length;
|
return ir_code_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 ir_tv_lib_close()
|
static INT8 ir_tv_lib_close()
|
||||||
{
|
{
|
||||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||||
ir_lib_free_inner_buffer();
|
ir_lib_free_inner_buffer();
|
||||||
#endif
|
#endif
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
//////// TV End ////////
|
||||||
|
|
||||||
|
|
||||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||||
|
|
||||||
void ir_lib_free_inner_buffer()
|
void ir_lib_free_inner_buffer()
|
||||||
{
|
{
|
||||||
if (NULL != binary_content)
|
if (NULL != binary_content)
|
||||||
@@ -495,5 +627,4 @@ void ir_lib_free_inner_buffer()
|
|||||||
binary_content = NULL;
|
binary_content = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -49,18 +49,12 @@ INT8 decode_as_ac(char *file_name)
|
|||||||
ac_status.acWindDir = AC_SWING_ON;
|
ac_status.acWindDir = AC_SWING_ON;
|
||||||
ac_status.acWindSpeed = AC_WS_AUTO;
|
ac_status.acWindSpeed = AC_WS_AUTO;
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_ac_file_open(file_name))
|
if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_AC, 0, file_name))
|
||||||
{
|
{
|
||||||
ir_ac_lib_close();
|
ir_close();
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_ac_lib_parse())
|
|
||||||
{
|
|
||||||
ir_printf("\nac lib parse failed\n");
|
|
||||||
ir_ac_lib_close();
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
in_char = getchar();
|
in_char = getchar();
|
||||||
@@ -71,12 +65,12 @@ INT8 decode_as_ac(char *file_name)
|
|||||||
case 'w':
|
case 'w':
|
||||||
case 'W':
|
case 'W':
|
||||||
// temperature plus
|
// temperature plus
|
||||||
ac_status.acTemp = (UINT8) ((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1));
|
ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1));
|
||||||
function_code = AC_FUNCTION_TEMPERATURE_UP;
|
function_code = AC_FUNCTION_TEMPERATURE_UP;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
case 'S':
|
||||||
ac_status.acTemp = (UINT8) ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1));
|
ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1));
|
||||||
function_code = AC_FUNCTION_TEMPERATURE_DOWN;
|
function_code = AC_FUNCTION_TEMPERATURE_DOWN;
|
||||||
// temperature minus
|
// temperature minus
|
||||||
break;
|
break;
|
||||||
@@ -89,7 +83,7 @@ INT8 decode_as_ac(char *file_name)
|
|||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
ac_status.acWindDir = (UINT8) ((ac_status.acWindDir == 0) ? 1 : 0);
|
ac_status.acWindDir = ((ac_status.acWindDir == 0) ? AC_SWING_OFF : AC_SWING_ON);
|
||||||
function_code = AC_FUNCTION_WIND_SWING;
|
function_code = AC_FUNCTION_WIND_SWING;
|
||||||
// wind swing loop
|
// wind swing loop
|
||||||
break;
|
break;
|
||||||
@@ -165,11 +159,11 @@ INT8 decode_as_ac(char *file_name)
|
|||||||
ac_status.acWindDir
|
ac_status.acWindDir
|
||||||
);
|
);
|
||||||
|
|
||||||
ir_ac_lib_control(ac_status, user_data, function_code, TRUE);
|
ir_decode(function_code, user_data, &ac_status, TRUE);
|
||||||
}
|
}
|
||||||
} while ('0' != in_char);
|
} while ('0' != in_char);
|
||||||
|
|
||||||
ir_ac_lib_close();
|
ir_close();
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
@@ -180,31 +174,28 @@ INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
|
|||||||
int in_char = 0;
|
int in_char = 0;
|
||||||
int key_code = 0;
|
int key_code = 0;
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_tv_file_open(file_name))
|
if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_TV, ir_hex_encode, file_name))
|
||||||
{
|
{
|
||||||
|
ir_close();
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_tv_lib_parse(ir_hex_encode))
|
|
||||||
{
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
in_char = getchar();
|
in_char = getchar();
|
||||||
if (in_char >= '0' && in_char <= '9')
|
if (in_char >= '0' && in_char <= '9')
|
||||||
{
|
{
|
||||||
key_code = in_char - '0';
|
key_code = in_char - '0';
|
||||||
ir_tv_lib_control((UINT8) key_code, user_data);
|
ir_decode((UINT8)key_code, user_data, NULL, 0);
|
||||||
}
|
}
|
||||||
else if (in_char >= 'a' && in_char <= 'f')
|
else if (in_char >= 'a' && in_char <= 'f')
|
||||||
{
|
{
|
||||||
key_code = 10 + (in_char - 'a');
|
key_code = 10 + (in_char - 'a');
|
||||||
ir_tv_lib_control((UINT8) key_code, user_data);
|
ir_decode((UINT8) key_code, user_data, NULL, 0);
|
||||||
}
|
}
|
||||||
else if (in_char == 'q')
|
else if (in_char == 'q')
|
||||||
{
|
{
|
||||||
ir_tv_lib_close();
|
ir_close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user