| 72 | } |
| 73 | |
| 74 | void 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 | |
| 97 | void outputChannels(void) { |
no test coverage detected