forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from prplecake/ir_decoder
- Loading branch information
Showing
4 changed files
with
45 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "bit_ops.h" | ||
|
||
// https://stackoverflow.com/questions/746171/efficient-algorithm-for-bit-reversal-from-msb-lsb-to-lsb-msb-in-c/746382#746382 | ||
int bit_reversal(uint32_t input) { | ||
int s = sizeof(input) * 2; | ||
int i, x, y, p; | ||
int rtn = 0; | ||
|
||
for(i = 0; i < (s / 2); i++) { | ||
// extract bit on the left, from MSB | ||
p = s - i - 1; | ||
x = input & (1 << p); | ||
x = x >> p; | ||
|
||
// extract bit on the right, from LSB | ||
y = input & (1 << i); | ||
y = y >> i; | ||
|
||
rtn = rtn | (x << i); | ||
rtn = rtn | (y << p); | ||
} | ||
return rtn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
int bit_reversal(uint32_t input); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include <infrared.h> | ||
#include <infrared_worker.h> | ||
#include <furi_hal_infrared.h> | ||
#include <gui/gui.h> | ||
|
||
#include "helpers/bit_ops.h" | ||
|
||
#define TAG "IR Decoder" | ||
|
||
typedef struct { | ||
InfraredMessage* decoded_signal; | ||
FuriMutex* mutex; | ||
ViewPort* view_port; | ||
} IRDecoderState; |