-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppcheck.txt
More file actions
41 lines (34 loc) · 884 Bytes
/
cppcheck.txt
File metadata and controls
41 lines (34 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// To check patterns generated to write to AVR port registers
#include <iostream>
#include <bitset>
const int TXLength = 12;
const int c = 343; // speed of sound in m/s
const int pitch = 0.01; // distance between TXR nodes in m
int phases[TXLength];
void genChannelBits(int arr[], int bitShift){
for (int i = 0; i<TXLength; i++) {
if (i%6 <= 2){
arr[(bitShift + i)%TXLength] = 1;
}
}
}
void genCompositeSignal(int arr[], int bitDelay){
for(int txr=0; txr<8; txr++){
int tmp[TXLength];
for(int i=0; i<TXLength;i++){
tmp[i] = 0;
}
genChannelBits(tmp, (txr*bitDelay)%6);
for(int i=0; i<TXLength; i++){
arr[i] += tmp[i]<<txr;
}
}
}
int main() {
// Write C++ code here
genCompositeSignal(phases, 1);
for(int i=0; i<TXLength; i++){
std::cout << std::bitset<8>(phases[i]) << "\n";
}
return 0;
}