updated win32 example

This commit is contained in:
strawmanbobi
2025-10-20 16:23:33 +08:00
parent 28377e4a69
commit f17592e00e
28 changed files with 273 additions and 217 deletions

View File

@@ -290,7 +290,7 @@ __pycache__/
*.odx.cs
*.xsd.cs
DecodeTestWin/DecodeTestWin.vcxproj.filters
DecodeTestWin/DecodeTestWin.vcxproj
DecodeTestWin.vcxproj.filters
DecodeTestWin.vcxproj
# End of https://www.gitignore.io/api/visualstudio
# End of https://www.gitignore.io/api/visualstudio

View File

@@ -1,178 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{F4139B9B-37FF-436C-BE1E-B552940BA753}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>IRextWin32Example</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BOARD_PC;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DecodeTestWin.cpp" />
<ClCompile Include="ir_decoder\src\ir_ac_apply.c" />
<ClCompile Include="ir_decoder\src\ir_ac_binary_parse.c" />
<ClCompile Include="ir_decoder\src\ir_ac_build_frame.c" />
<ClCompile Include="ir_decoder\src\ir_ac_control.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_forbidden_info.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_frame_info.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_parameter.c" />
<ClCompile Include="ir_decoder\src\ir_decode.c" />
<ClCompile Include="ir_decoder\src\ir_tv_control.c" />
<ClCompile Include="ir_decoder\src\ir_utils.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ir_decoder\src\include\ir_ac_apply.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_binary_parse.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_build_frame.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_control.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_forbidden_info.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_frame_info.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_parameter.h" />
<ClInclude Include="ir_decoder\src\include\ir_decode.h" />
<ClInclude Include="ir_decoder\src\include\ir_defs.h" />
<ClInclude Include="ir_decoder\src\include\ir_tv_control.h" />
<ClInclude Include="ir_decoder\src\include\ir_utils.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{F4139B9B-37FF-436C-BE1E-B552940BA753}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>IRextWin32Example</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BOARD_PC;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="DecodeTestWin.cpp" />
<ClCompile Include="ir_decoder\src\ir_ac_apply.c" />
<ClCompile Include="ir_decoder\src\ir_ac_binary_parse.c" />
<ClCompile Include="ir_decoder\src\ir_ac_build_frame.c" />
<ClCompile Include="ir_decoder\src\ir_ac_control.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_forbidden_info.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_frame_info.c" />
<ClCompile Include="ir_decoder\src\ir_ac_parse_parameter.c" />
<ClCompile Include="ir_decoder\src\ir_decode.c" />
<ClCompile Include="ir_decoder\src\ir_tv_control.c" />
<ClCompile Include="ir_decoder\src\ir_utils.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ir_decoder\src\include\ir_ac_apply.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_binary_parse.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_build_frame.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_control.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_forbidden_info.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_frame_info.h" />
<ClInclude Include="ir_decoder\src\include\ir_ac_parse_parameter.h" />
<ClInclude Include="ir_decoder\src\include\ir_decode.h" />
<ClInclude Include="ir_decoder\src\include\ir_defs.h" />
<ClInclude Include="ir_decoder\src\include\ir_tv_control.h" />
<ClInclude Include="ir_decoder\src\include\ir_utils.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -126,30 +126,30 @@ typedef enum
AC_APPLY_MAX
} t_ac_apply;
typedef struct _ac_hex
typedef struct ac_hex
{
UINT8 len;
UINT8 *data;
} t_ac_hex;
typedef struct _ac_level
typedef struct ac_level
{
UINT16 low;
UINT16 high;
} t_ac_level;
typedef struct _ac_bootcode
typedef struct ac_bootcode
{
UINT16 len;
UINT16 data[16];
} t_ac_bootcode;
} t_ac_boot_code;
typedef struct _ac_delaycode
typedef struct ac_delay_code
{
INT16 pos;
UINT16 time[8];
UINT16 time_cnt;
} t_ac_delaycode;
} t_ac_delay_code;
/*
* the array of tag_100X application data
@@ -157,26 +157,26 @@ typedef struct _ac_delaycode
* byte_pos : the position of update byte
* byte_value : the value to be updated to position
*/
typedef struct _tag_comp_type_1
typedef struct tag_comp_type_1
{
UINT8 seg_len;
UINT8 *segment;
} t_tag_comp;
typedef struct _tag_swing_info
typedef struct tag_swing_info
{
swing_type type;
UINT8 mode_count;
UINT8 dir_index;
} t_swing_info;
typedef struct _tag_power_1
typedef struct tag_power_1
{
UINT8 len;
t_tag_comp comp_data[AC_POWER_MAX];
} t_power_1;
typedef struct _tag_temp_1
typedef struct tag_temp_1
{
UINT8 len;
UINT8 type;
@@ -236,7 +236,7 @@ typedef struct tag_horiswing_1
} hori_swing_1;
#endif
typedef struct _tag_checksum_data
typedef struct tag_checksum_data
{
UINT8 len;
UINT8 type;
@@ -273,7 +273,7 @@ typedef struct tag_solo_code
UINT8 solo_function_codes[AC_FUNCTION_MAX - 1];
} t_solo_code;
typedef struct _ac_bitnum
typedef struct ac_bitnum
{
INT16 pos;
UINT16 bits;
@@ -302,7 +302,7 @@ typedef enum
CHECKSUM_TYPE_MAX,
} t_checksum_type;
typedef struct _ac_n_mode_info
typedef struct ac_n_mode_info
{
UINT8 enable;
UINT8 all_speed;
@@ -320,8 +320,8 @@ typedef struct ac_protocol
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_ac_boot_code boot_code;
t_ac_delay_code dc[MAX_DELAYCODE_NUM];
t_power_1 power1;
t_temp_1 temp1;
t_mode_1 mode1;

View File

@@ -12,6 +12,8 @@ Revision log:
#ifndef _IR_DEFS_H
#define _IR_DEFS_H
#define IR_DECODE_LIB_VER "1.5.0"
#if defined (BOARD_PC)
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
@@ -65,7 +67,7 @@ void noprint(const char *fmt, ...);
#define ir_memset(A, B, C) memset(A, B, C)
#define ir_strlen(A) strlen(A)
#if ((defined BOARD_PC) || (defined BOARD_PC_JNI)) && (defined DEBUG)
#define ir_printf printf
#define ir_printf(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
#else
#define ir_printf noprint
#endif

View File

@@ -22,7 +22,7 @@ Revision log:
struct ir_bin_buffer binary_file;
struct ir_bin_buffer *p_ir_buffer = &binary_file;
static const char* version = "0.2.5";
static const char* version = IR_DECODE_LIB_VER;
#if defined USE_DYNAMIC_TAG
struct tag_head *tags;
@@ -82,6 +82,7 @@ static INT8 ir_ac_binary_open(UINT8 *binary, UINT16 bin_length);
static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16* user_data, UINT8 key_code,
BOOL change_wind_direction);
static INT8 ir_ac_binary_close();
static BOOL validate_ac_status(t_remote_ac_status* ac_status, BOOL change_wind_dir);
#if !defined NO_FS
static INT8 ir_tv_file_open(const char *file_name);
@@ -218,7 +219,19 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar
return IR_DECODE_FAILED;
}
ret = ir_tv_binary_open(binary, bin_length);
#if (defined(BOARD_PC) || defined (BOARD_PC_DLL) || defined (BOARD_ANDROID))
binary_content = (UINT8 *) ir_malloc(bin_length);
if (NULL == binary_content)
{
ir_printf("failed to malloc memory for binary\n");
return IR_DECODE_FAILED;
}
memcpy(binary_content, binary, bin_length);
#else
binary_content = binary;
#endif
ret = ir_tv_binary_open(binary_content, bin_length);
if (IR_DECODE_SUCCEEDED == ret)
{
return ir_tv_binary_parse(ir_hexadecimal);
@@ -259,6 +272,10 @@ UINT16 ir_decode(UINT8 key_code, UINT16* user_data,
ac_status->ac_temp, ac_status->ac_wind_dir,
ac_status->ac_wind_speed,
key_code, change_wind_direction);
// ac status validation
if (FALSE == validate_ac_status(ac_status, change_wind_direction)) {
return 0;
}
return ir_ac_control(*ac_status, user_data, key_code, change_wind_direction);
}
}
@@ -489,6 +506,35 @@ static INT8 ir_ac_binary_close()
return IR_DECODE_SUCCEEDED;
}
static BOOL validate_ac_status(t_remote_ac_status* ac_status, BOOL change_wind_dir)
{
if (AC_POWER_OFF != ac_status->ac_power && AC_POWER_ON != ac_status->ac_power)
{
return FALSE;
}
if (ac_status->ac_mode < AC_MODE_COOL || ac_status->ac_mode >= AC_MODE_MAX)
{
return FALSE;
}
if (ac_status->ac_temp < AC_TEMP_16 || ac_status->ac_temp >= AC_TEMP_MAX)
{
return FALSE;
}
if (ac_status->ac_wind_speed < AC_WS_AUTO || ac_status->ac_wind_speed >= AC_WS_MAX)
{
return FALSE;
}
if (ac_status->ac_wind_dir < AC_SWING_ON || ac_status->ac_wind_dir >= AC_SWING_MAX)
{
return FALSE;
}
if (0 != change_wind_dir && 1 != change_wind_dir)
{
return FALSE;
}
return TRUE;
}
// utils
INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max)
{
@@ -652,7 +698,7 @@ static INT8 ir_tv_file_open(const char *file_name)
if (stream == NULL)
{
ir_printf("\nfile open failed\n");
ir_printf("file open failed\n");
return IR_DECODE_FAILED;
}
@@ -662,7 +708,7 @@ static INT8 ir_tv_file_open(const char *file_name)
binary_content = (UINT8 *) ir_malloc(binary_length);
if (NULL == binary_content)
{
ir_printf("\nfailed to alloc memory for binary\n");
ir_printf("failed to malloc memory for binary\n");
fclose(stream);
return IR_DECODE_FAILED;
}
@@ -681,6 +727,7 @@ static INT8 ir_tv_file_open(const char *file_name)
if (IR_DECODE_FAILED == ir_tv_binary_open(binary_content, (UINT16) binary_length))
{
ir_printf("failed to parse command type binary\n");
ir_free(binary_content);
binary_length = 0;
return IR_DECODE_FAILED;

View File

@@ -30,15 +30,21 @@ void input_number(int *val)
char n[50]={0};
int i = 0;
*val = 0;
scanf("%s", n);
if (0 != scanf("%s", n))
{
return;
}
getchar();
while(1)
{
if(n[i] < '0'||n[i] > '9')
{
printf("\nInvalid number format, please re-input : ");
scanf("%s", n);
i=0;
printf("invalid number format, please re-input : ");
if (0 != scanf("%s", n))
{
break;
}
i = 0;
}
else
{
@@ -94,13 +100,13 @@ static INT8 decode_as_ac(char *file_name)
{
if (1 == first_time)
{
printf("Please input valid key code "
"(Key code could be referenced from https://irext.net/doc#keymap) : \n");
printf("please input valid key code "
"(key code could be referenced from https://irext.net/doc#keymap) : \n");
first_time = 0;
}
else
{
printf("Please input valid key code : \n");
printf("please input valid key code : \n");
}
input_number(&key_code);
@@ -219,7 +225,7 @@ static INT8 decode_as_ac(char *file_name)
ac_status.ac_wind_dir,
key_code);
length = ir_decode(key_code, user_data, &ac_status, change_wind_dir);
printf("\n === Binary decoded : %d\n", length);
printf("\n === binary decoded : %d\n", length);
for (index = 0; index < length; index++)
{
printf("%d, ", user_data[index]);
@@ -245,6 +251,7 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
// here remote category TV represents for command typed IR code
if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_TV, ir_hex_encode, file_name))
{
printf("failed to open file : %s\n", file_name);
ir_close();
return IR_DECODE_FAILED;
}
@@ -253,13 +260,13 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
{
if (1 == first_time)
{
printf("Please input valid key code "
printf("please input valid key code "
"(Key code could be referenced from https://irext.net/doc#keymap) : \n");
first_time = 0;
}
else
{
printf("Please input valid key code : \n");
printf("please input valid key code : \n");
}
input_number(&key_code);
if (99 == key_code)
@@ -267,7 +274,7 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
break;
}
length = ir_decode(key_code, user_data, NULL, 0);
printf("\n === Binary decoded : %d\n", length);
printf("\n === binary decoded : %d\n", length);
for (index = 0; index < length; index++)
{
printf("%d, ", user_data[index]);
@@ -281,10 +288,10 @@ static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)
}
static void print_usage(const char *progn) {
printf("Usage: %s [function] [file] [subcate]\n"
"[function] : 0 - decode for AC; 1 - decode for TV\n"
printf("usage: %s [function] [file] [subcate]\n"
"[function] : 0 - decode for AC; 1 - decode for others\n"
"[file] : the remote control binary file\n"
"[subcate] : the sub_cate value from remote_index", progn);
"[sub_cate] : the sub_cate value from remote_index", progn);
}
int main(int argc, char *argv[])
@@ -304,17 +311,17 @@ int main(int argc, char *argv[])
switch (function)
{
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]);
break;
case '1':
printf("Decode %s as command-typed binary in sub_cate %d\n", argv[2], ir_hex_encode);
printf("decode %s as command-typed binary in sub_cate %d\n", argv[2], ir_hex_encode);
decode_as_tv(argv[2], ir_hex_encode);
break;
default:
printf("Decode functionality not supported : %c\n", function);
printf("decode functionality not supported : %c\n", function);
break;
}
}