File tree Expand file tree Collapse file tree 4 files changed +45
-36
lines changed Expand file tree Collapse file tree 4 files changed +45
-36
lines changed Original file line number Diff line number Diff line change
1
+ #include "bit_ops.h"
2
+
3
+ // https://stackoverflow.com/questions/746171/efficient-algorithm-for-bit-reversal-from-msb-lsb-to-lsb-msb-in-c/746382#746382
4
+ int bit_reversal (uint32_t input ) {
5
+ int s = sizeof (input ) * 2 ;
6
+ int i , x , y , p ;
7
+ int rtn = 0 ;
8
+
9
+ for (i = 0 ; i < (s / 2 ); i ++ ) {
10
+ // extract bit on the left, from MSB
11
+ p = s - i - 1 ;
12
+ x = input & (1 << p );
13
+ x = x >> p ;
14
+
15
+ // extract bit on the right, from LSB
16
+ y = input & (1 << i );
17
+ y = y >> i ;
18
+
19
+ rtn = rtn | (x << i );
20
+ rtn = rtn | (y << p );
21
+ }
22
+ return rtn ;
23
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include <stdint.h>
4
+
5
+ int bit_reversal (uint32_t input );
Original file line number Diff line number Diff line change 1
- #include <furi.h>
2
- #include <furi_hal.h>
3
- #include <infrared.h>
4
- #include <infrared_worker.h>
5
- #include <furi_hal_infrared.h>
6
- #include <gui/gui.h>
7
-
8
- #define TAG "IR Decoder"
9
-
10
- typedef struct {
11
- InfraredMessage * decoded_signal ;
12
- FuriMutex * mutex ;
13
- ViewPort * view_port ;
14
- } IRDecoderState ;
15
-
16
- // https://stackoverflow.com/questions/746171/efficient-algorithm-for-bit-reversal-from-msb-lsb-to-lsb-msb-in-c/746382#746382
17
- static int bit_reversal (uint32_t input ) {
18
- int s = sizeof (input ) * 2 ;
19
- int i , x , y , p ;
20
- int rtn = 0 ;
21
-
22
- for (i = 0 ; i < (s / 2 ); i ++ ) {
23
- // extract bit on the left, from MSB
24
- p = s - i - 1 ;
25
- x = input & (1 << p );
26
- x = x >> p ;
27
-
28
- // extract bit on the right, from LSB
29
- y = input & (1 << i );
30
- y = y >> i ;
31
-
32
- rtn = rtn | (x << i );
33
- rtn = rtn | (y << p );
34
- }
35
- return rtn ;
36
- }
1
+ #include "ir_decoder.h"
37
2
38
3
static void render_callback (Canvas * canvas , void * ctx ) {
39
4
FURI_LOG_T (TAG , "Render callback" );
Original file line number Diff line number Diff line change
1
+ #include <furi.h>
2
+ #include <furi_hal.h>
3
+ #include <infrared.h>
4
+ #include <infrared_worker.h>
5
+ #include <furi_hal_infrared.h>
6
+ #include <gui/gui.h>
7
+
8
+ #include "helpers/bit_ops.h"
9
+
10
+ #define TAG "IR Decoder"
11
+
12
+ typedef struct {
13
+ InfraredMessage * decoded_signal ;
14
+ FuriMutex * mutex ;
15
+ ViewPort * view_port ;
16
+ } IRDecoderState ;
You can’t perform that action at this time.
0 commit comments