summaryrefslogtreecommitdiff
path: root/src/radio-controller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/radio-controller.cpp')
-rw-r--r--src/radio-controller.cpp30
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);
}