2 from PIL
import Image
, ImageDraw
3 from enviroplus
.noise
import Noise
5 print("""noise-amps-at-freqs.py - Measure amplitude from specific frequency bins
7 This example retrieves the median amplitude from 3 user-specified frequency ranges and plots them in Blue, Green and Red on the Enviro+ display.
9 As you play a continuous rising tone on your phone, you should notice peaks that correspond to the frequency entering each range.
19 cs
=ST7735
.BG_SPI_CS_FRONT
,
26 img
= Image
.new('RGB', (disp
.width
, disp
.height
), color
=(0, 0, 0))
27 draw
= ImageDraw
.Draw(img
)
31 amps
= noise
.get_amplitudes_at_frequency_ranges([
36 amps
= [n
* 32 for n
in amps
]
38 draw
.rectangle((0, 0, disp
.width
, disp
.height
), (0, 0, 0))
39 img
.paste(img2
, (1, 0))
40 draw
.line((0, 0, 0, amps
[0]), fill
=(0, 0, 255))
41 draw
.line((0, 0, 0, amps
[1]), fill
=(0, 255, 0))
42 draw
.line((0, 0, 0, amps
[2]), fill
=(255, 0, 0))