updated win32 example
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
This repository contails various of example which show you how to port IRext decode algorithm to different OS and platforms
|
This repository contails various of example which show you how to port IRext decode algorithm to different OS and platforms
|
||||||
|
|
||||||
|
Version 1.2.7
|
||||||
|
|
||||||
- Android example
|
- Android example
|
||||||
- CC26XX ARM-Cortex M3 example
|
- CC26XX ARM-Cortex M3 example
|
||||||
- Java web example with JNI
|
- Java web example with JNI
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_utils.c
|
Filename: ir_ac_build_frame.h
|
||||||
Revised: Date: 2016-10-26
|
Revised: Date: 2016-10-26
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_parse_forbidden_info.h
|
Filename: ir_ac_parse_forbidden_info.h
|
||||||
Revised: Date: 2016-10-05
|
Revised: Date: 2016-10-05
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_parse_frame_parameter.h
|
Filename: ir_ac_parse_frame_info.h
|
||||||
Revised: Date: 2016-10-11
|
Revised: Date: 2016-10-11
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_parse_ac_parameter.h
|
Filename: ir_ac_parse_parameter.h
|
||||||
Revised: Date: 2016-10-12
|
Revised: Date: 2016-10-12
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -221,10 +221,11 @@ typedef enum
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SUB_CATEGORY_QUATERNARY = 0,
|
SUB_CATEGORY_BINARY = 0, // deprecated
|
||||||
SUB_CATEGORY_HEXADECIMAL = 1,
|
SUB_CATEGORY_QUATERNARY = 1,
|
||||||
SUB_CATEGORY_NEXT = 2,
|
SUB_CATEGORY_HEXADECIMAL = 2,
|
||||||
SUB_CATEGORY_MAX = 7,
|
SUB_CATEGORY_NEXT = 3,
|
||||||
|
SUB_CATEGORY_MAX = 4,
|
||||||
} t_remote_sub_category;
|
} t_remote_sub_category;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_lib.h
|
Filename: ir_tv_control.h
|
||||||
Revised: Date: 2016-02-23
|
Revised: Date: 2016-02-23
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] =
|
|||||||
INT8 binary_parse_offset()
|
INT8 binary_parse_offset()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#if defined BOARD_ESP8266
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
UINT8 *phead = (UINT8 *)&p_ir_buffer->data[1];
|
UINT8 *phead = (UINT8 *)&p_ir_buffer->data[1];
|
||||||
#else
|
#else
|
||||||
UINT16 *phead = (UINT16 *)&p_ir_buffer->data[1];
|
UINT16 *phead = (UINT16 *)&p_ir_buffer->data[1];
|
||||||
#endif // BOARD_ESP8266
|
#endif // ESPRESSIF
|
||||||
|
|
||||||
tag_count = p_ir_buffer->data[0];
|
tag_count = p_ir_buffer->data[0];
|
||||||
if (TAG_COUNT_FOR_PROTOCOL != tag_count)
|
if (TAG_COUNT_FOR_PROTOCOL != tag_count)
|
||||||
@@ -63,7 +63,7 @@ INT8 binary_parse_offset()
|
|||||||
#if defined BOARD_STM8 && defined COMPILER_IAR
|
#if defined BOARD_STM8 && defined COMPILER_IAR
|
||||||
UINT16 offset = *(phead + i);
|
UINT16 offset = *(phead + i);
|
||||||
tags[i].offset = (offset >> 8) | (offset << 8);
|
tags[i].offset = (offset >> 8) | (offset << 8);
|
||||||
#elif defined BOARD_ESP8266
|
#elif defined(ESP8266) || defined(ESP32)
|
||||||
UINT16 tmp_a = *(phead + i * 2);
|
UINT16 tmp_a = *(phead + i * 2);
|
||||||
UINT16 tmp_b = *(phead + i * 2 + 1);
|
UINT16 tmp_b = *(phead + i * 2 + 1);
|
||||||
tags[i].offset = tmp_b << 8 | tmp_a;
|
tags[i].offset = tmp_b << 8 | tmp_a;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_irframe.c
|
Filename: ir_ac_build_frame.c
|
||||||
Revised: Date: 2016-10-01
|
Revised: Date: 2016-10-01
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_parse_frame_parameter.c
|
Filename: ir_ac_parse_frame_info.c
|
||||||
Revised: Date: 2016-10-11
|
Revised: Date: 2016-10-11
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_parse_ac_parameter.c
|
Filename: ir_ac_parse_parameter.c
|
||||||
Revised: Date: 2016-10-12
|
Revised: Date: 2016-10-12
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -139,13 +139,13 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ir_binary_type = IR_TYPE_COMMANDS;
|
ir_binary_type = IR_TYPE_COMMANDS;
|
||||||
if (1 == sub_category)
|
if (SUB_CATEGORY_QUATERNARY == sub_category)
|
||||||
{
|
{
|
||||||
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
ir_hexadecimal = 0;
|
||||||
}
|
}
|
||||||
else if (2 == sub_category)
|
else if (SUB_CATEGORY_HEXADECIMAL == sub_category)
|
||||||
{
|
{
|
||||||
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
|
ir_hexadecimal = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -205,13 +205,13 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ir_binary_type = IR_TYPE_COMMANDS;
|
ir_binary_type = IR_TYPE_COMMANDS;
|
||||||
if (1 == sub_category)
|
if (SUB_CATEGORY_QUATERNARY == sub_category)
|
||||||
{
|
{
|
||||||
ir_hexadecimal = SUB_CATEGORY_QUATERNARY;
|
ir_hexadecimal = 0;
|
||||||
}
|
}
|
||||||
else if (2 == sub_category)
|
else if (SUB_CATEGORY_HEXADECIMAL == sub_category)
|
||||||
{
|
{
|
||||||
ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL;
|
ir_hexadecimal = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_main.c
|
Filename: ir_decode_test.c
|
||||||
Revised: Date: 2016-11-05
|
Revised: Date: 2016-11-05
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
Description: This file provides main entry for irda decoder
|
Description: This file provides main entry for irda decoder test
|
||||||
|
|
||||||
Revision log:
|
Revision log:
|
||||||
* 2016-11-05: created by strawmanbobi
|
* 2016-11-05: created by strawmanbobi
|
||||||
@@ -12,7 +12,6 @@ Revision log:
|
|||||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <libgen.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -60,7 +59,6 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
{
|
{
|
||||||
BOOL op_match = TRUE;
|
BOOL op_match = TRUE;
|
||||||
BOOL change_wind_dir = FALSE;
|
BOOL change_wind_dir = FALSE;
|
||||||
UINT8 function_code = AC_FUNCTION_MAX;
|
|
||||||
int key_code = 0;
|
int key_code = 0;
|
||||||
int first_time = 1;
|
int first_time = 1;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
@@ -74,13 +72,13 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
UINT8 supported_swing = 0x00;
|
UINT8 supported_swing = 0x00;
|
||||||
UINT8 supported_wind_direction = 0x00;
|
UINT8 supported_wind_direction = 0x00;
|
||||||
|
|
||||||
BOOL need_control;
|
BOOL need_control = TRUE;
|
||||||
|
|
||||||
// init air conditioner status
|
// init air conditioner status
|
||||||
ac_status.ac_display = 0;
|
ac_status.ac_display = 0;
|
||||||
ac_status.ac_sleep = 0;
|
ac_status.ac_sleep = 0;
|
||||||
ac_status.ac_timer = 0;
|
ac_status.ac_timer = 0;
|
||||||
ac_status.ac_power = AC_POWER_OFF;
|
ac_status.ac_power = AC_POWER_ON;
|
||||||
ac_status.ac_mode = AC_MODE_COOL;
|
ac_status.ac_mode = AC_MODE_COOL;
|
||||||
ac_status.ac_temp = AC_TEMP_20;
|
ac_status.ac_temp = AC_TEMP_20;
|
||||||
ac_status.ac_wind_dir = AC_SWING_ON;
|
ac_status.ac_wind_dir = AC_SWING_ON;
|
||||||
@@ -164,8 +162,9 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
{
|
{
|
||||||
switch (key_code)
|
switch (key_code)
|
||||||
{
|
{
|
||||||
|
// notice: only if ac_power is turned on will user_data change when input a different 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;
|
||||||
|
|
||||||
@@ -212,21 +211,20 @@ static INT8 decode_as_ac(char *file_name)
|
|||||||
|
|
||||||
if (TRUE == op_match && TRUE == need_control)
|
if (TRUE == op_match && TRUE == need_control)
|
||||||
{
|
{
|
||||||
printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d with function code = %d\n",
|
printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d with key_code = %d\n",
|
||||||
ac_status.ac_power,
|
ac_status.ac_power,
|
||||||
ac_status.ac_mode,
|
ac_status.ac_mode,
|
||||||
ac_status.ac_temp,
|
ac_status.ac_temp,
|
||||||
ac_status.ac_wind_speed,
|
ac_status.ac_wind_speed,
|
||||||
ac_status.ac_wind_dir,
|
ac_status.ac_wind_dir,
|
||||||
function_code);
|
key_code);
|
||||||
|
length = ir_decode(key_code, user_data, &ac_status, change_wind_dir);
|
||||||
length = ir_decode(function_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++)
|
for (index = 0; index < length; index++)
|
||||||
{
|
{
|
||||||
printf("%d, ", user_data[index]);
|
printf("%d, ", user_data[index]);
|
||||||
}
|
}
|
||||||
printf("===\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
@@ -296,7 +294,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (4 != argc)
|
if (4 != argc)
|
||||||
{
|
{
|
||||||
print_usage(basename(argv[0]));
|
print_usage((argv[0]));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +317,4 @@ int main(int argc, char *argv[])
|
|||||||
printf("Decode functionality not supported : %c\n", function);
|
printf("Decode functionality not supported : %c\n", function);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
Filename: ir_lib.c
|
Filename: ir_tv_control.c
|
||||||
Revised: Date: 2016-10-21
|
Revised: Date: 2016-10-21
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
@@ -120,7 +120,8 @@ static BOOL get_ir_protocol(UINT8 encode_type)
|
|||||||
|
|
||||||
if (encode_type == 0)
|
if (encode_type == 0)
|
||||||
{
|
{
|
||||||
cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
cycles_num_size = 8;
|
||||||
|
/* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
||||||
if (prot_cycles_num[IRDA_TWO] == 0 && prot_cycles_num[IRDA_THREE] == 0)
|
if (prot_cycles_num[IRDA_TWO] == 0 && prot_cycles_num[IRDA_THREE] == 0)
|
||||||
{
|
{
|
||||||
ir_decode_flag = IRDA_DECODE_1_BIT;
|
ir_decode_flag = IRDA_DECODE_1_BIT;
|
||||||
|
|||||||
Reference in New Issue
Block a user