fixed IR decode win32 example
This commit is contained in:
@@ -29,14 +29,14 @@ void input_number(int *val)
|
|||||||
char n[50]={0};
|
char n[50]={0};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
*val = 0;
|
*val = 0;
|
||||||
scanf_s("%3s", n);
|
scanf_s("%3s", n, (unsigned)_countof(n));
|
||||||
getchar();
|
getchar();
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(n[i] < '0'||n[i] > '9')
|
if(n[i] < '0'||n[i] > '9')
|
||||||
{
|
{
|
||||||
printf("\nInvalid number format, please re-input : ");
|
printf("\nInvalid number format, please re-input : ");
|
||||||
scanf_s("%3s", n);
|
scanf_s("%3s", n, (unsigned)_countof(n));
|
||||||
i=0;
|
i=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -54,7 +54,7 @@ void input_number(int *val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT8 decode_as_ac(char *file_name)
|
static INT8 decode_as_ac(char *file_name, int sub_cate)
|
||||||
{
|
{
|
||||||
BOOL op_match = TRUE;
|
BOOL op_match = TRUE;
|
||||||
UINT8 function_code = AC_FUNCTION_MAX;
|
UINT8 function_code = AC_FUNCTION_MAX;
|
||||||
@@ -84,8 +84,9 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
ac_status.ac_wind_speed = AC_WS_AUTO;
|
ac_status.ac_wind_speed = AC_WS_AUTO;
|
||||||
ac_status.change_wind_direction = FALSE;
|
ac_status.change_wind_direction = FALSE;
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_AC, 0, file_name))
|
if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_AC, sub_cate, file_name))
|
||||||
{
|
{
|
||||||
|
printf("Failed to open file: %s\n", file_name);
|
||||||
ir_close();
|
ir_close();
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
@@ -107,6 +108,8 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
op_match = TRUE;
|
op_match = TRUE;
|
||||||
need_control = FALSE;
|
need_control = FALSE;
|
||||||
|
|
||||||
|
printf("input key code = %d\n", key_code);
|
||||||
|
|
||||||
if (99 == key_code)
|
if (99 == key_code)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -165,7 +168,7 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
switch (key_code)
|
switch (key_code)
|
||||||
{
|
{
|
||||||
case 0:
|
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;
|
need_control = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -309,7 +312,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
case '0':
|
case '0':
|
||||||
printf("Decode %s as status-typed binary\n", argv[2]);
|
printf("Decode %s as status-typed binary\n", argv[2]);
|
||||||
decode_as_ac(argv[2]);
|
decode_as_ac(argv[2], ir_hex_encode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1':
|
case '1':
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>D:\Project\irext\examples\win32-example\ir_decoder\src\include;$(IncludePath)</IncludePath>
|
<IncludePath>D:\Project\irext\examples\win32-example\ir_decoder\src\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
@@ -103,12 +103,13 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BOARD_PC;DEBUG;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ static INT8 ir_ac_file_open(const char *file_name)
|
|||||||
|
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
|
ir_printf("ir_ac_binary_open fread failed\n");
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
ir_free(binary_content);
|
ir_free(binary_content);
|
||||||
binary_length = 0;
|
binary_length = 0;
|
||||||
@@ -345,6 +346,7 @@ static INT8 ir_ac_file_open(const char *file_name)
|
|||||||
|
|
||||||
if (IR_DECODE_FAILED == ir_ac_binary_open(binary_content, (UINT16) binary_length))
|
if (IR_DECODE_FAILED == ir_ac_binary_open(binary_content, (UINT16) binary_length))
|
||||||
{
|
{
|
||||||
|
ir_printf("ir_ac_binary_open failed\n");
|
||||||
ir_free(binary_content);
|
ir_free(binary_content);
|
||||||
binary_length = 0;
|
binary_length = 0;
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
|
|||||||
Reference in New Issue
Block a user