When the PyGamer's power is turned on, the code.py module first imports all the required libraries. That includes the thermal_cam_converters.py helper file that we'll review later.
# Thermal_Cam_v32.py # 2020-01-29 v3.2 # (c) 2020 Jan Goolsbey for Adafruit Industries import time import board import displayio from simpleio import map_range from adafruit_display_text.label import Label from adafruit_bitmap_font import bitmap_font from adafruit_display_shapes.rect import Rect import adafruit_amg88xx from adafruit_pybadger import pybadger as panel from thermal_cam_converters import celsius_to_fahrenheit, fahrenheit_to_celsius # Load default alarm and min/max range values list from config file from thermal_cam_config import ALARM_F, MIN_RANGE_F, MAX_RANGE_F
Next, the code checks to see if the PyGamer's joystick is present and sets the panel.has_joystick
flag to True
. If not, then the host device is probably a PyBadge or EdgeBadge; this code will work for those devices, interpreting the D-Pad buttons like the joystick.
# Establish panel instance and check for joystick panel.pixels.brightness = 0.1 # Set NeoPixel brightness panel.pixels.fill(0) # Clear all NeoPixels if hasattr(board, "JOYSTICK_X"): panel.has_joystick = True # PyGamer else: panel.has_joystick = False # Must be PyBadge
The AMG8833 FeatherWing is instantiated on the I2C communications bus, then the OpenSans-9.bdf font file is loaded from the /fonts folder.
# Establish I2C interface for the AMG8833 Thermal Camera i2c = board.I2C() amg8833 = adafruit_amg88xx.AMG88XX(i2c)
# Load the text font from the fonts folder font = bitmap_font.load_font("/fonts/OpenSans-9.bdf")
Finally, the welcome graphics screen, thermal_cam_splash.bmp is displayed followed by a two-tone welcoming beep.
# Display splash graphics and play startup tones splash = displayio.Group() bitmap = displayio.OnDiskBitmap("/thermal_cam_splash.bmp") splash.append(displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader)) board.DISPLAY.root_group = splash time.sleep(0.1) # Allow the splash to display panel.play_tone(440, 0.1) # A4 panel.play_tone(880, 0.1) # A5
Page last edited March 08, 2024
Text editor powered by tinymce.