Commit | Line | Data |
---|---|---|
aa747a41 PH |
1 | import ST7735 |
2 | from PIL import Image, ImageDraw | |
3 | from enviroplus.noise import Noise | |
4 | ||
18c9ae73 | 5 | print("""noise-profile.py - Get a simple noise profile. |
aa747a41 | 6 | |
18c9ae73 PH |
7 | This example grabs a basic 3-bin noise profile of low, medium and high frequency noise, plotting the noise characteristics as coloured bars. |
8 | ||
9 | Press Ctrl+C to exit! | |
10 | ||
11 | """) | |
aa747a41 PH |
12 | |
13 | noise = Noise() | |
14 | ||
15 | disp = ST7735.ST7735( | |
16 | port=0, | |
17 | cs=ST7735.BG_SPI_CS_FRONT, | |
18 | dc=9, | |
19 | backlight=12, | |
20 | rotation=90) | |
21 | ||
22 | disp.begin() | |
23 | ||
24 | img = Image.new('RGB', (disp.width, disp.height), color=(0, 0, 0)) | |
25 | draw = ImageDraw.Draw(img) | |
26 | ||
27 | ||
28 | while True: | |
504b0f7f | 29 | low, mid, high, amp = noise.get_noise_profile() |
aa747a41 PH |
30 | low *= 128 |
31 | mid *= 128 | |
32 | high *= 128 | |
33 | amp *= 64 | |
34 | ||
35 | img2 = img.copy() | |
36 | draw.rectangle((0, 0, disp.width, disp.height), (0, 0, 0)) | |
37 | img.paste(img2, (1, 0)) | |
38 | draw.line((0, 0, 0, amp), fill=(int(low), int(mid), int(high))) | |
39 | ||
40 | disp.display(img) |