File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
src/cpp/hu.bme.mit.inf.modes3.components.soc Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 22#include " s88.h"
33
44// #define DEBUG
5- #define WINDOW_SIZE 50
5+ #define WINDOW_SIZE 21
66
77uint32_t buffer[WINDOW_SIZE];
88
@@ -38,8 +38,8 @@ void loop() {
3838 uint8_t byte = (occ >> shift) & 0xFF ;
3939 Serial.print (byte);
4040 Serial.print (' ' );
41+ Serial.println ();
4142 }
42- Serial.println ();
4343#endif
4444
4545 // Shifting the previous buffer values
@@ -49,9 +49,29 @@ void loop() {
4949 // Reading the occupancy vector into the buffer
5050 buffer[WINDOW_SIZE-1 ] = occ;
5151
52+ // majority decision for each section
5253 uint32_t max = 0 ;
53- for (uint8_t i = 0 ; i < WINDOW_SIZE; ++i) {
54- max = (max < buffer[i]) ? buffer[i] : max;
54+ for (uint32_t sectionId = 0 ; sectionId < 32 ; ++sectionId){
55+ uint32_t ones = 0 ;
56+ uint32_t zeroes = 0 ;
57+ for (uint32_t window = 0 ; window < WINDOW_SIZE; ++window){
58+ uint32_t bit = buffer[window] & (static_cast <uint32_t >(1 ) << sectionId);
59+ if (bit){
60+ ones += 1 ;
61+ } else {
62+ zeroes += 1 ;
63+ }
64+ }
65+ #ifdef DEBUG
66+ Serial.print (sectionId);
67+ Serial.print (" " );
68+ Serial.print (ones);
69+ Serial.print (" " );
70+ Serial.println (zeroes);
71+ #endif
72+ if (ones > zeroes){
73+ max |= (static_cast <uint32_t >(1 ) << sectionId);
74+ }
5575 }
5676
5777 // Sending header first
@@ -68,4 +88,5 @@ void loop() {
6888#ifdef DEBUG
6989 Serial.println ();
7090#endif
91+ delay (10 );
7192}
You can’t perform that action at this time.
0 commit comments