| 35 | |
| 36 | |
| 37 | void AnalyzerLoop(){ |
| 38 | |
| 39 | memset(value, 0, sizeof(value)); |
| 40 | |
| 41 | int n = 50; |
| 42 | while (n--) { |
| 43 | pixels.setPixelColor(0, pixels.Color(2, 0, 2)); |
| 44 | pixels.show(); |
| 45 | int i = N; |
| 46 | while (i--) { |
| 47 | radio.setChannel(i); |
| 48 | radio.startListening(); |
| 49 | delayMicroseconds(128); |
| 50 | radio.stopListening(); |
| 51 | if(radio.testCarrier()) { |
| 52 | ++value[i]; |
| 53 | |
| 54 | pixels.setPixelColor(0, pixels.Color(0, 2, 2)); |
| 55 | pixels.show(); |
| 56 | |
| 57 | }; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | display.clearDisplay(); |
| 62 | int barWidth = SCREEN_WIDTH / N; |
| 63 | int x = xOffset; |
| 64 | for (int i = 0; i < N; ++i) { |
| 65 | int v = 31 - value[i] * 3 + yOffset; // Adjusted the y value |
| 66 | if(v < 0) { |
| 67 | v = 0; |
| 68 | } |
| 69 | display.drawFastVLine(x, v - 10, 32 - v, WHITE); |
| 70 | x += barWidth; |
| 71 | } |
| 72 | display.setTextSize(1); |
| 73 | display.setTextColor(WHITE); |
| 74 | display.setCursor(0, SCREEN_HEIGHT - 8); |
| 75 | display.println("1..10...50...80...128"); // Print the range values |
| 76 | display.display(); |
| 77 | |
| 78 | delay(50); |
| 79 | } |