MCPcopy Create free account
hub / github.com/cifertech/nRFBox / scanChannels

Function scanChannels

nRFBox_V2/scanner.cpp:74–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void scanChannels(void) {
75 disable();
76
77 memset(channel, 0, sizeof(channel));
78
79 const int samplesPerChannel = 50; // Number of samples per channel to average
80
81 for (int i = 0; i < CHANNELS; i++) {
82 setRegister(_NRF24_RF_CH, (128 * i) / CHANNELS);
83
84 for (int j = 0; j < samplesPerChannel; j++) {
85 setRX();
86 delayMicroseconds(100);
87 disable();
88 channel[i] += getRegister(_NRF24_RPD); // Add the RPD value (1 or 0)
89 }
90
91 // Average the accumulated values for this channel
92 channel[i] = (channel[i] * 100) / samplesPerChannel; // Convert to percentage
93 }
94}
95
96
97void outputChannels(void) {

Callers 1

scannerLoopFunction · 0.70

Calls 4

disableFunction · 0.70
setRegisterFunction · 0.70
setRXFunction · 0.70
getRegisterFunction · 0.70

Tested by

no test coverage detected