diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-06-06 09:11:22 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-06-06 09:11:22 +0200 |
commit | 1729acd9b72369af45ee5ed45a8d29642f3df367 (patch) | |
tree | 652f3f679b27287c9be6d3ea0676188f87fa5f33 /src | |
parent | 4ee01dab6105e346b731a13321a3e6a5d111d3e4 (diff) | |
download | radio-controller-1729acd9b72369af45ee5ed45a8d29642f3df367.tar.gz radio-controller-1729acd9b72369af45ee5ed45a8d29642f3df367.tar.bz2 radio-controller-1729acd9b72369af45ee5ed45a8d29642f3df367.tar.xz radio-controller-1729acd9b72369af45ee5ed45a8d29642f3df367.zip |
wip
o Dropping Samsung-specific code, will be replaces by a small script.
o Starting on some unit test code.
Diffstat (limited to 'src')
-rw-r--r-- | src/radio-controller.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/radio-controller.cpp b/src/radio-controller.cpp index 11da06f..a2f20d6 100644 --- a/src/radio-controller.cpp +++ b/src/radio-controller.cpp @@ -1,5 +1,4 @@ #include "decoder.h" -//#include "samsung_decoder.h" #include "script_decoder.h" #include <usbd_cdc_if.h> @@ -199,8 +198,6 @@ void main_post_init() static uint32_t tick_next = 0; -radio_controller::end end; - /* static const radio_controller::start samsung_start{9000, 4500}; static const radio_controller::data samsung_data{2250, 560, 1125, 560}; @@ -212,9 +209,13 @@ static const instruction *const samsung_instructions[] = { }; */ +static const radio_controller::nop nop{}; + // NEC? static const radio_controller::start nec_start{13500, 9000}; static const radio_controller::data nec_data{2250, 560, 1125, 560}; +static const radio_controller::set_field nec_manufacturer_code{1, 0, 16}; +static const radio_controller::set_field nec_code{2, 16, 8}; static const instruction *const nec_instructions[] = { &nec_start, @@ -226,7 +227,13 @@ static const instruction *const nec_instructions[] = { &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, &nec_data, - &end, + &nec_manufacturer_code, + &nec_code, + &nop, + &nop, + &nop, + &nop, + &nop, }; void main_loop() @@ -293,7 +300,7 @@ void main_loop() script_decoder sd{nec_instructions, SizeOfArray(nec_instructions)}; auto it = ir_buffer.iterator(); - auto result = sd.decode(&it); + auto result = sd.decode(it); if (result.state == radio_controller::decoding_state::FAIL) { printf("FAIL\n"); @@ -305,8 +312,15 @@ void main_loop() } } else if (result.state == radio_controller::decoding_state::OK) { - printf("OK: size=%d, value: 0x%08" PRIx32 "%08" PRIx32 "\n", result.data.size(), - result.data.u32(1), result.data.u32(0)); + printf("OK: size=%d, value: 0x%08" PRIx32 "%08" PRIx32 "\n" + "field1=%d, 0x%08" PRIx32 "\n" + "field2=%d, 0x%08" PRIx32 "\n" + "field3=%d, 0x%08" PRIx32 "\n", + result.data.size(), result.data.u32(1), result.data.u32(0), + result.field1, result.field1, + result.field2, result.field2, + result.field3, result.field3); + // uint32_t manufacturer = result.data.extract_bits(0, 12); // uint32_t command = result.data.extract_bits(12, 8); // printf("Samsung: Manufacturer=%" PRIu32 ", 0x%" PRIx32 ", command=%" PRIu32 ", 0x%" PRIx32 "\n", @@ -319,6 +333,7 @@ void main_loop() HAL_NVIC_EnableIRQ(TIM2_IRQn); } + /* if (ir_level_buffer.is_full()) { ir_buffer_lock.lock(); @@ -335,6 +350,7 @@ void main_loop() ir_buffer_lock.unlock(); HAL_NVIC_EnableIRQ(TIM2_IRQn); } + */ __HAL_IWDG_RELOAD_COUNTER(&hiwdg); } |