From 951025961b9c37b82511e68835a064d3c29b3e74 Mon Sep 17 00:00:00 2001 From: huangyidao2006 Date: Wed, 22 Jul 2020 17:18:55 +0800 Subject: [PATCH] corrected a few mistakes in ir_decode_test.c --- src/ir_decoder/src/ir_decode_test.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ir_decoder/src/ir_decode_test.c b/src/ir_decoder/src/ir_decode_test.c index 5ae2a1b..14b7b51 100644 --- a/src/ir_decoder/src/ir_decode_test.c +++ b/src/ir_decoder/src/ir_decode_test.c @@ -60,7 +60,6 @@ static INT8 decode_as_ac(char *file_name) { BOOL op_match = TRUE; BOOL change_wind_dir = FALSE; - UINT8 function_code = AC_FUNCTION_MAX; int key_code = 0; int first_time = 1; @@ -162,8 +161,9 @@ static INT8 decode_as_ac(char *file_name) { switch (key_code) { + // notice: only if ac_power is turned on will user_data change when input a different key_code 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; break; @@ -210,15 +210,20 @@ static INT8 decode_as_ac(char *file_name) 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_mode, ac_status.ac_temp, ac_status.ac_wind_speed, ac_status.ac_wind_dir, - function_code); + key_code); - ir_decode(function_code, user_data, &ac_status, change_wind_dir); + int len = ir_decode(key_code, user_data, &ac_status, change_wind_dir); + for (int i = 0; i < len; i++) { + printf("%d, ", user_data[i]); + } + + printf("\n"); } } } while (TRUE);