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_SUCCEEDED (0)
|
||||
|
||||
#define IR_CATEGORY_AC 1
|
||||
#define IR_CATEGORY_TV 2
|
||||
|
||||
/* exported functions */
|
||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
||||
/*
|
||||
* function ir_ac_file_open
|
||||
#define IR_TYPE_STATUS 0
|
||||
#define IR_TYPE_COMMANDS 1
|
||||
|
||||
#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
|
||||
* binary_length (in) length of binary content
|
||||
* description: open IR binary code from buffer
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* description: close IR binary code
|
||||
*
|
||||
* 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,
|
||||
BOOL change_wind_direction);
|
||||
extern INT8 ir_close();
|
||||
|
||||
/*
|
||||
* function ir_ac_lib_close
|
||||
/**
|
||||
* function get_temperature_range
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* 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
|
||||
* description: get the supported temperature range [min, max] for the opened AC IR binary
|
||||
*
|
||||
* 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_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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
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
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
* returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction);
|
||||
|
||||
|
||||
// private extern function
|
||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||
|
||||
extern void ir_lib_free_inner_buffer();
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////// Utils End /////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,6 @@ Revision log:
|
||||
#include "../include/ir_utils.h"
|
||||
#include "../include/ir_ac_build_frame.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 *p_ir_buffer = &binary_file;
|
||||
@@ -34,29 +32,166 @@ UINT8 byteArray[PROTOCOL_SIZE] = {0};
|
||||
size_t binary_length = 0;
|
||||
UINT8 *binary_content = NULL;
|
||||
|
||||
UINT8 ir_binary_type = IR_TYPE_STATUS;
|
||||
UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
||||
|
||||
protocol *context = (protocol *) byteArray;
|
||||
|
||||
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,
|
||||
apply_mode,
|
||||
apply_temperature,
|
||||
apply_temperature,
|
||||
apply_wind_speed,
|
||||
apply_swing,
|
||||
apply_swing
|
||||
};
|
||||
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_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)
|
||||
|
||||
void ir_lib_free_inner_buffer();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
||||
INT8 ir_ac_file_open(const char *file_name)
|
||||
// static function definitions
|
||||
|
||||
//////// AC Begin ////////
|
||||
static INT8 ir_ac_file_open(const char *file_name)
|
||||
{
|
||||
#if !defined NO_FS
|
||||
size_t ret = 0;
|
||||
@@ -106,7 +241,7 @@ INT8 ir_ac_file_open(const char *file_name)
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
INT8 ir_ac_lib_close()
|
||||
static INT8 ir_ac_lib_close()
|
||||
{
|
||||
// free context
|
||||
if (NULL != tags)
|
||||
@@ -383,10 +518,10 @@ INT8 get_supported_wind_direction(UINT8 *supported_wind_direction)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
|
||||
//////// AC End ////////
|
||||
|
||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
||||
INT8 ir_tv_file_open(const char *file_name)
|
||||
//////// TV Begin ////////
|
||||
static INT8 ir_tv_file_open(const char *file_name)
|
||||
{
|
||||
#if !defined NO_FS
|
||||
size_t ret = 0;
|
||||
@@ -437,12 +572,12 @@ INT8 ir_tv_file_open(const char *file_name)
|
||||
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);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
@@ -452,7 +587,7 @@ INT8 ir_tv_lib_parse(UINT8 ir_hex_encode)
|
||||
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
|
||||
UINT16 print_index = 0;
|
||||
@@ -463,30 +598,27 @@ UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
|
||||
|
||||
#if defined BOARD_PC
|
||||
// have some debug
|
||||
ir_printf("=============================\n");
|
||||
ir_printf("length of IRDA code = %d\n", ir_code_length);
|
||||
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]);
|
||||
}
|
||||
ir_printf("\n=============================\n\n");
|
||||
#endif
|
||||
|
||||
return ir_code_length;
|
||||
}
|
||||
|
||||
INT8 ir_tv_lib_close()
|
||||
static INT8 ir_tv_lib_close()
|
||||
{
|
||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||
ir_lib_free_inner_buffer();
|
||||
#endif
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
||||
//////// TV End ////////
|
||||
|
||||
|
||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||
|
||||
void ir_lib_free_inner_buffer()
|
||||
{
|
||||
if (NULL != binary_content)
|
||||
@@ -495,5 +627,4 @@ void ir_lib_free_inner_buffer()
|
||||
binary_content = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -49,18 +49,12 @@ INT8 decode_as_ac(char *file_name)
|
||||
ac_status.acWindDir = AC_SWING_ON;
|
||||
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;
|
||||
}
|
||||
|
||||
if (IR_DECODE_FAILED == ir_ac_lib_parse())
|
||||
{
|
||||
ir_printf("\nac lib parse failed\n");
|
||||
ir_ac_lib_close();
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
do
|
||||
{
|
||||
in_char = getchar();
|
||||
@@ -71,12 +65,12 @@ INT8 decode_as_ac(char *file_name)
|
||||
case 'w':
|
||||
case 'W':
|
||||
// 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;
|
||||
break;
|
||||
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;
|
||||
// temperature minus
|
||||
break;
|
||||
@@ -89,7 +83,7 @@ INT8 decode_as_ac(char *file_name)
|
||||
break;
|
||||
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;
|
||||
// wind swing loop
|
||||
break;
|
||||
@@ -165,11 +159,11 @@ INT8 decode_as_ac(char *file_name)
|
||||
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);
|
||||
|
||||
ir_ac_lib_close();
|
||||
ir_close();
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
@@ -180,31 +174,28 @@ INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
|
||||
int in_char = 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;
|
||||
}
|
||||
|
||||
if (IR_DECODE_FAILED == ir_tv_lib_parse(ir_hex_encode))
|
||||
{
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
do
|
||||
{
|
||||
in_char = getchar();
|
||||
if (in_char >= '0' && in_char <= '9')
|
||||
{
|
||||
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')
|
||||
{
|
||||
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')
|
||||
{
|
||||
ir_tv_lib_close();
|
||||
ir_close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user