Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Kharisov <ah@bright-box.com>2021-05-18 13:51:00 +0300
committerGitHub <noreply@github.com>2021-05-18 13:51:00 +0300
commit3114a2d4b8fc3ec13e5542377d65ac2c922bc7c3 (patch)
tree4246eba9cc9f44615fb6b6feb03e1619b15739a9 /applications/irda_monitor
parentba0419276e26ba6bf32688e0bf0af4b3c544dd1a (diff)
[FL-1156, FL-1249] Add IRDA encoder/decoder library (#451)
* Add cscope db generation * Add api-hal-irda, TIM2: HAL->LL * Add libirda: pwm decoding * Universal state machine * Add irda decoder library * Move IRDA capture to standalone tool * Add encoder/decoder samsung32, NEC, fix bugs * Port current App to new Irda lib * Fix clang format for test data * Port IRDA api-hal to f6 Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/irda_monitor')
-rw-r--r--applications/irda_monitor/irda_monitor.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/applications/irda_monitor/irda_monitor.c b/applications/irda_monitor/irda_monitor.c
new file mode 100644
index 00000000..dd6c9328
--- /dev/null
+++ b/applications/irda_monitor/irda_monitor.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <furi.h>
+#include <api-hal-irda.h>
+#include <api-hal.h>
+
+#define IRDA_TIMINGS_SIZE 2000
+
+typedef struct {
+ uint32_t timing_cnt;
+ struct {
+ uint8_t level;
+ uint32_t duration;
+ } timing[IRDA_TIMINGS_SIZE];
+} IrdaDelaysArray;
+
+static void irda_rx_callback(void* ctx, bool level, uint32_t duration) {
+ IrdaDelaysArray* delays = ctx;
+
+ if(delays->timing_cnt < IRDA_TIMINGS_SIZE) {
+ if(delays->timing_cnt > 1)
+ furi_check(level != delays->timing[delays->timing_cnt - 1].level);
+ delays->timing[delays->timing_cnt].level = level;
+ delays->timing[delays->timing_cnt].duration = duration;
+ delays->timing_cnt++; // Read-Modify-Write in ISR only: no need to add synchronization
+ }
+}
+
+int32_t irda_monitor_app(void* p) {
+ (void)p;
+ static uint32_t counter = 0;
+
+ IrdaDelaysArray* delays = furi_alloc(sizeof(IrdaDelaysArray));
+
+ api_hal_irda_rx_irq_init();
+ api_hal_irda_rx_irq_set_callback(irda_rx_callback, delays);
+
+ while(1) {
+ delay(20);
+
+ if(counter != delays->timing_cnt) {
+ api_hal_light_set(LightRed, 0x00);
+ api_hal_light_set(LightGreen, 0x00);
+ api_hal_light_set(LightBlue, 0xFF);
+ delay(20);
+ api_hal_light_set(LightRed, 0x00);
+ api_hal_light_set(LightGreen, 0x00);
+ api_hal_light_set(LightBlue, 0x00);
+ counter = delays->timing_cnt;
+ }
+
+ if(delays->timing_cnt >= IRDA_TIMINGS_SIZE) {
+ api_hal_irda_rx_irq_deinit();
+ printf("== IRDA MONITOR FOUND (%d) records) ==\r\n", IRDA_TIMINGS_SIZE);
+ printf("{");
+ for(int i = 0; i < IRDA_TIMINGS_SIZE; ++i) {
+ printf(
+ "%s%lu, ",
+ (delays->timing[i].duration > 15000) ? "\r\n" : "",
+ delays->timing[i].duration);
+ }
+ printf("\r\n};\r\n");
+ break;
+ }
+ }
+
+ free(delays);
+
+ return 0;
+}