MCPcopy Create free account
hub / github.com/FastLED/FastLED / loop

Function loop

examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.h:97–131  ·  view source on GitHub ↗

Run repetitively

Source from the content-addressed store, hash-verified

95
96// Run repetitively
97void loop() {
98 unsigned int x, y, freqBin;
99 float level;
100
101 if (fft.available()) {
102 // freqBin counts which FFT frequency data has been used,
103 // starting at low frequency
104 freqBin = 0;
105
106 for (x=0; x < matrix_width; x++) {
107 // get the volume for each horizontal pixel position
108 level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1);
109
110 // uncomment to see the spectrum in Arduino's Serial Monitor
111 // Serial.print(level);
112 // Serial.print(" ");
113
114 for (y=0; y < matrix_height; y++) {
115 // for each vertical pixel, check if above the threshold
116 // and turn the LED on or off
117 if (level >= thresholdVertical[y]) {
118 leds[xy(x,y)] = CRGB(myColor);
119 } else {
120 leds[xy(x,y)] = CRGB::Black;
121 }
122 }
123 // increment the frequency bin count, so we display
124 // low to higher frequency from left to right
125 freqBin = freqBin + frequencyBinsHorizontal[x];
126 }
127 // after all pixels set, show them all at the same instant
128 FastLED.show();
129 // Serial.println();
130 }
131}
132
133
134// Run once from setup, the compute the vertical levels

Callers

nothing calls this directly

Calls 5

xyFunction · 0.85
CRGBClass · 0.50
availableMethod · 0.45
readMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected