reformatted encoding algorithm

This commit is contained in:
strawmanbobi
2016-11-13 13:52:57 +08:00
parent c169499e3a
commit fb7c06afa6
40 changed files with 663 additions and 483 deletions

View File

@@ -83,7 +83,7 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
void free_pirda(void);
#endif
///////////////////////////////////////////////// Air Conditioner Begin /////////////////////////////////////////////////
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
INT8 binary_parse_offset()
{
@@ -509,7 +509,9 @@ INT8 irda_ac_lib_parse()
{
IR_PRINTF("\nparse mode 2\n");
context->mode2.len = tags[i].len >> 1;
if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->mode2.comp_data, AC_MODE_MAX, AC_PARAMETER_TYPE_1))
if (IR_DECODE_FAILED ==
parse_common_ac_parameter(&tags[i],
context->mode2.comp_data, AC_MODE_MAX, AC_PARAMETER_TYPE_1))
{
return IR_DECODE_FAILED;
}
@@ -518,7 +520,9 @@ INT8 irda_ac_lib_parse()
{
IR_PRINTF("\nparse speed 2\n");
context->speed2.len = tags[i].len >> 1;
if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], context->speed2.comp_data, AC_WS_MAX, AC_PARAMETER_TYPE_1))
if (IR_DECODE_FAILED ==
parse_common_ac_parameter(&tags[i],
context->speed2.comp_data, AC_WS_MAX, AC_PARAMETER_TYPE_1))
{
return IR_DECODE_FAILED;
}
@@ -864,11 +868,13 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code)
{
if(IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp))
{
if(function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
if(function_code == AC_FUNCTION_TEMPERATURE_UP
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
{
return IR_DECODE_FAILED;
}
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
{
return IR_DECODE_FAILED;
}
@@ -877,11 +883,13 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code)
else
{
// if this level is in black list, do not send IR wave if user want to apply this function
if(function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
if(function_code == AC_FUNCTION_TEMPERATURE_UP
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
{
return IR_DECODE_FAILED;
}
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
{
return IR_DECODE_FAILED;
}
@@ -890,11 +898,13 @@ INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code)
else
{
// if this level is in black list, do not send IR wave if user want to apply this function
if(function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
if(function_code == AC_FUNCTION_TEMPERATURE_UP
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/)
{
return IR_DECODE_FAILED;
}
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
else if(function_code == AC_FUNCTION_TEMPERATURE_DOWN
/*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_DOWN)*/)
{
return IR_DECODE_FAILED;
}
@@ -1165,7 +1175,7 @@ INT8 get_supported_wind_direction(UINT8* supported_wind_direction)
}
}
///////////////////////////////////////////////// Air Conditioner End /////////////////////////////////////////////////
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length)

View File

@@ -172,7 +172,8 @@ INT8 decode_as_ac(const char* file_name)
case '6':
if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.acMode, &min_temperature, &max_temperature))
{
IR_PRINTF("\nsupported temperature range in mode %d = %d, %d\n", ac_status.acMode, min_temperature, max_temperature);
IR_PRINTF("\nsupported temperature range in mode %d = %d, %d\n",
ac_status.acMode, min_temperature, max_temperature);
}
need_control = FALSE;
break;

View File

@@ -361,15 +361,18 @@ static void print_irda_time(irda_data_t *data, UINT8 keyindex, UINT16 *irda_time
if (irda_decode_flag == IRDA_DECODE_1_BIT)
{
process_decode_number(keycode, data, 1, irda_time); // '0','1'
// for binary formatted code
process_decode_number(keycode, data, 1, irda_time);
}
else if (irda_decode_flag == IRDA_DECODE_2_BITS)
{
process_decode_number(keycode, data, 2, irda_time); // '0','1','2','3'
// for quanternary formatted code
process_decode_number(keycode, data, 2, irda_time);
}
else if (irda_decode_flag == IRDA_DECODE_4_BITS)
{
process_decode_number(keycode, data, 4, irda_time); // '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
// for hexadecimal formatted code
process_decode_number(keycode, data, 4, irda_time);
}
}
}

View File

@@ -8,13 +8,9 @@ Description: This file provides generic utils for IRDA algorithms
Revision log:
* 2016-10-01: created by strawmanbobi
**************************************************************************************************/
#include <stdlib.h>
#include "include/irda_utils.h"
/*
*0123456789abcdef/0123456789ABCDEF
*/
UINT8 char_to_hex(char chr)
{
UINT8 value = 0;