summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-06-04 17:39:52 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-06-04 17:39:52 +0200
commit094c977b8877d652f629260cc753aacc7000e328 (patch)
tree96443f22bf31e93fd76b3dcef8c6ce57bddc5139
parentd30e3fa68d7192da22c1569f56f564b92896170d (diff)
downloadradio-controller-094c977b8877d652f629260cc753aacc7000e328.tar.gz
radio-controller-094c977b8877d652f629260cc753aacc7000e328.tar.bz2
radio-controller-094c977b8877d652f629260cc753aacc7000e328.tar.xz
radio-controller-094c977b8877d652f629260cc753aacc7000e328.zip
o Daewoo -> Samsung.
-rw-r--r--CMakeLists.txt7
-rw-r--r--include/decoder.h6
-rw-r--r--include/samsung_decoder.h (renamed from include/daewoo_decoder.h)11
-rw-r--r--src/radio-controller.cpp7
4 files changed, 20 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 307f18d..52c9c42 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,12 @@ set(CMAKE_CXX_STANDARD 14)
include(thirdparty/mcucpp/cmake/mcucpp.cmake)
-add_executable(firmware src/radio-controller.cpp include/radio-controller.h include)
+add_executable(firmware src/radio-controller.cpp
+ include/decoder.h
+ include/misc.h
+ include/radio-controller.h
+ include/samsung_decoder.h
+ include)
target_compile_definitions(firmware PUBLIC MCUCMAKE_USING_STM32CUBE=1)
target_include_directories(firmware PUBLIC include)
target_link_libraries(firmware PUBLIC gcc)
diff --git a/include/decoder.h b/include/decoder.h
index 55e7d96..56ea647 100644
--- a/include/decoder.h
+++ b/include/decoder.h
@@ -1,5 +1,7 @@
#pragma once
+#include <cstdint>
+
namespace radio_controller {
struct sample {
@@ -26,7 +28,8 @@ class bit_string final {
int size_ = 0;
public:
- int size() const {
+ int size() const
+ {
return size_;
}
@@ -42,7 +45,6 @@ public:
}
}
- __noinline
void append(bool value)
{
if (size_ < 32) {
diff --git a/include/daewoo_decoder.h b/include/samsung_decoder.h
index b790a1a..52978ec 100644
--- a/include/daewoo_decoder.h
+++ b/include/samsung_decoder.h
@@ -1,10 +1,12 @@
#pragma
+#include <cstdint>
+#include <cstdio>
#include "decoder.h"
namespace radio_controller {
-class daewoo_decoder : public decoder {
+class samsung_decoder : public decoder {
inline
bool between(uint16_t smallest, uint16_t biggest, uint16_t value)
@@ -41,8 +43,8 @@ class daewoo_decoder : public decoder {
return check_pulse<1125, 560>(s);
}
- __noinline
- void dump_values(sample_iterator *it) {
+ void dump_values(sample_iterator *it)
+ {
while (it->next()) {
auto s = it->value();
auto pct = int(s.pulse_us / double(s.period_us) * 100);
@@ -53,10 +55,9 @@ class daewoo_decoder : public decoder {
public:
- __noinline
decoding_result decode(sample_iterator *it) override
{
- printf("Daewoo, size=%d\n", it->size());
+ printf("Samsung, size=%d\n", it->size());
dump_values(it);
it->reset();
diff --git a/src/radio-controller.cpp b/src/radio-controller.cpp
index 8d3149c..2c038ed 100644
--- a/src/radio-controller.cpp
+++ b/src/radio-controller.cpp
@@ -1,3 +1,6 @@
+#include "decoder.h"
+#include "samsung_decoder.h"
+
#include <usbd_cdc_if.h>
#include <cinttypes>
#include "radio-controller.h"
@@ -7,8 +10,6 @@
#include "mcu/stm32cube/debug.h"
#include "mcu/util.h"
#include "misc.h"
-#include "decoder.h"
-#include "daewoo_decoder.h"
using mcu::arm::mutex;
using namespace radio_controller;
@@ -233,7 +234,7 @@ void main_loop()
HAL_NVIC_DisableIRQ(TIM2_IRQn);
- daewoo_decoder d;
+ samsung_decoder d;
auto it = ir_buffer.iterator();
auto result = d.decode(&it);