Datasheet
You'll need to manually install two additional libraries
from the bundle:
adafruit_display_text
simpleio.mpy
Before continuing, make sure your board's lib folder has
the adafruit_mlx90640.mpy, adafruit_bus_device,
adafruit_display_text and simpleio.mpy files and
folders copied over.
CircuitPython PyBadge/PyGamer Thermal Camera
Save the following code to your PyBadge or PyGamer as code.py.
import time
import board
import busio
import adafruit_mlx90640
import displayio
import terminalio
from adafruit_display_text.label import Label
from simpleio import map_range
number_of_colors = 64 # Number of color in the gradian
last_color = number_of_colors-1 # Last color in palette
palette = displayio.Palette(number_of_colors) # Palette with all our colors
## Heatmap code inspired from: http://www.andrewnoske.com/wiki/Code_-_heatmaps_and_color_gradients
color_A = [[0, 0, 0], [0, 0, 255], [0, 255, 255], [0, 255, 0], [255, 255, 0], \
[255, 0, 0], [255, 255, 255]]
color_B = [[0, 0, 255], [0, 255, 255] , [0, 255, 0], [255, 255, 0], [255, 0, 0]]
color_C = [[0, 0, 0], [255, 255, 255]]
color_D = [[0, 0, 255], [255, 0, 0]]
color = color_B
NUM_COLORS = len (color)
def MakeHeatMapColor():
© Adafruit Industries https://learn.adafruit.com/adafruit-mlx90640-ir-thermal-camera Page 24 of 30










