|
5 | 5 | import busio
|
6 | 6 | import board
|
7 | 7 |
|
8 |
| -import pygame |
9 | 8 | import numpy as np
|
| 9 | +import pygame |
10 | 10 | from scipy.interpolate import griddata
|
11 | 11 |
|
12 | 12 | from colour import Color
|
@@ -62,27 +62,27 @@ def constrain(val, min_val, max_val):
|
62 | 62 | return min(max_val, max(min_val, val))
|
63 | 63 |
|
64 | 64 | def map_value(x, in_min, in_max, out_min, out_max):
|
65 |
| - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min |
| 65 | + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min |
66 | 66 |
|
67 | 67 | #let the sensor initialize
|
68 | 68 | time.sleep(.1)
|
69 |
| - |
| 69 | + |
70 | 70 | while True:
|
71 | 71 |
|
72 | 72 | #read the pixels
|
73 | 73 | pixels = []
|
74 | 74 | for row in sensor.pixels:
|
75 | 75 | pixels = pixels + row
|
76 | 76 | pixels = [map_value(p, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1) for p in pixels]
|
77 |
| - |
| 77 | + |
78 | 78 | #perform interpolation
|
79 | 79 | bicubic = griddata(points, pixels, (grid_x, grid_y), method='cubic')
|
80 | 80 |
|
81 | 81 | #draw everything
|
82 | 82 | for ix, row in enumerate(bicubic):
|
83 | 83 | for jx, pixel in enumerate(row):
|
84 |
| - pygame.draw.rect(lcd, colors[constrain(int(pixel), 0, COLORDEPTH- 1)], |
85 |
| - (displayPixelHeight * ix, displayPixelWidth * jx, displayPixelHeight, displayPixelWidth)) |
86 |
| - |
87 |
| - pygame.display.update() |
| 84 | + pygame.draw.rect(lcd, colors[constrain(int(pixel), 0, COLORDEPTH- 1)], |
| 85 | + (displayPixelHeight * ix, displayPixelWidth * jx, |
| 86 | + displayPixelHeight, displayPixelWidth)) |
88 | 87 |
|
| 88 | + pygame.display.update() |
0 commit comments