Exemplo n.º 1
0
    def __init__(self, diameter, start_x, start_y, debug=False):
        # Store local variables in our object to access later in other functions
        self.diameter = diameter
        self.x = start_x
        self.y = start_y
        self.start_x = start_x
        self.start_y = start_y

        # Create a circle object for the screen
        self.circle = Circle(self.x,
                             self.y,
                             self.diameter,
                             fill=0x00FF00,
                             outline=0xFF00FF)

        # default to moving right
        self.going_right = True

        # Need screen height and width to check for collision with top/bottom and both side edges
        self.SCREEN_HEIGHT = 128
        self.SCREEN_WIDTH = 160

        # Badger object for easy button handling
        self.badger = PyBadger()
Exemplo n.º 2
0
from adafruit_pybadger import PyBadger

pybadger = PyBadger()

pybadger.show_badge(name_string="Blinka",
                    hello_scale=2,
                    my_name_is_scale=2,
                    name_scale=3)

while True:
    pybadger.auto_dim_display(delay=10)
    if pybadger.button.a:
        pybadger.show_business_card(image_name="Blinka.bmp",
                                    name_string="Blinka",
                                    name_scale=2,
                                    email_string_one="blinka@",
                                    email_string_two="adafruit.com")
    elif pybadger.button.b:
        pybadger.show_qr_code(data="https://circuitpython.org")
    elif pybadger.button.start:
        pybadger.show_badge(name_string="Blinka",
                            hello_scale=2,
                            my_name_is_scale=2,
                            name_scale=3)
Exemplo n.º 3
0
from adafruit_pybadger import PyBadger

pybadger = PyBadger()

pybadger.auto_dim_display(delay=10, movement_threshold=20)

first_display = True

while True:
    if pybadger.button.a:
        pybadger.show_business_card(image_name="supercon.bmp",
                                    name_string="gmackie",
                                    name_scale=1,
                                    email_string_one="*****@*****.**",
                                    email_string_two="https://gmac.io/")
    elif pybadger.button.b:
        pybadger.show_qr_code(data="https://wobscale.website")
    elif pybadger.button.start or first_display:
        pybadger.show_badge(name_string="gmackie",
                            hello_scale=2,
                            my_name_is_scale=2,
                            name_scale=2)
        first_display = False
Exemplo n.º 4
0
# try to use credentials from secrets.py file else raise an exception
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

# configuration for esp32 airlift featherwing, works with PyBadge
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets)
pybadger = PyBadger()
pybadger.pixels.fill(0)

# Setup a feed hierarchy for subscribing to changes
subscribe_feed = secrets['aio_username'] + '/feeds/#'


# Define callback methods which are called when events occur
def connected(client, userdata, flags, rc):
    # successfully to the broker.
    print('Connected to MQTT Broker! Listening for topic changes on %s' %
          subscribe_feed)
    client.subscribe(subscribe_feed)
    # basic badge render on successful connect of broker
    pybadger.show_badge(name_string="<Your_Name>",
                        hello_scale=2,
Exemplo n.º 5
0
  Connect the EDGE badge to the computer.
  The badge will appear as a USB drive. 
  Change the name of this file # to code.py.
  Copy code.py to the badge. 
  The file should automatically run!
"""

from adafruit_pybadger import PyBadger
import array
import math
import time
import audiobusio
import displayio
import board

pybadger = PyBadger()
pybadger.auto_dim_display(delay=30)

first_display = True
run_slow = False

mic = audiobusio.PDMIn(board.TX, board.D12, sample_rate=16000, bit_depth=16)

samples1 = array.array('H', [0] * 150)

display = board.DISPLAY

# To synchronize the display update to the waveform update,
# turn off automatic display refresh.
# Use explicit refresh function calls to update the display.
# The display refresh feature requires CircuitPython v5.0.0 or later.
Exemplo n.º 6
0
from adafruit_pybadger import PyBadger
display_name = "Your Name Here"
pybadger = PyBadger()

pybadger.show_badge(name_string=display_name,
                    hello_scale=2,
                    my_name_is_scale=2,
                    name_scale=2)

while True:
    pybadger.auto_dim_display(
        delay=10)  # Remove or comment out this line if you have the PyBadge LC
    try:
        if pybadger.button.a:
            pybadger.show_business_card(image_name="ccds_logo_160x160.bmp")
        elif pybadger.button.b:
            pybadger.show_qr_code(data="https://www.ccds.io/")
        elif pybadger.button.start:
            pybadger.show_badge(name_string=display_name,
                                hello_scale=2,
                                my_name_is_scale=2,
                                name_scale=2)
    except Exception as ex:
        print(ex)
Exemplo n.º 7
0
from adafruit_pybadger import PyBadger

pybadger = PyBadger()

while True:
    pybadger.show_badge(hello_scale=2, my_name_is_scale=2, name_scale=3)
    pybadger.auto_dim_display()

    if pybadger.button.a:
        pybadger.show_business_card(image_name="Blinka.bmp")
    elif pybadger.button.b:
        print("b B")
    elif pybadger.button.start:
        print("b start")
    elif pybadger.button.select:
        pybadger.show_qr_code()
Exemplo n.º 8
0
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
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

# Establish panel instance and check for joystick
panel = PyBadger(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

# 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")

# Display spash graphics and play startup tones
with open("/thermal_cam_splash.bmp", "rb") as bitmap_file:
Exemplo n.º 9
0
from adafruit_pybadger import PyBadger

pybadger = PyBadger()

pybadger.auto_dim_display(delay=30)

first_display = True

while True:
    if pybadger.button.a:
        pybadger.show_business_card(image_name="qrcode.bmp",
                                    name_string="Changeme in code.py",
                                    name_scale=1,
                                    email_string_one="*****@*****.**",
                                    email_string_two="https://hackaday.io/")
    elif pybadger.button.b:
        pybadger.show_qr_code(data="https://hackaday.io/superconference/")
    elif pybadger.button.start or first_display:
        pybadger.show_badge(name_string="SuperCon",
                            hello_scale=2,
                            my_name_is_scale=2,
                            name_scale=2)
        first_display = False
    from pypanel_device import catalog
except:
    raise RuntimeError("pypanel_device.py file error")

for device in catalog.keys():
    try:
        exec(catalog[device]['import'])
        exec(catalog[device]['instance'])
        exec(catalog[device]['test'])
        stemma.append((device, catalog[device]['name'], catalog[device]['desc']))
    except:
        pass

# establish PyBadger instance
from adafruit_pybadger import PyBadger
panel = PyBadger(pixels_brightness=0.01)

# look for PyGamer's joystick
if hasattr(board, "JOYSTICK_X"):
    panel.has_joystick = True
else: panel.has_joystick = False

# establish terminalio text display instance
import terminalio
from adafruit_display_text import label
display = board.DISPLAY

# establish displayio instance
import displayio
display = board.DISPLAY
Exemplo n.º 11
0
import board
import busio
from digitalio import DigitalInOut
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_requests as requests
from adafruit_pybadger import PyBadger
import neopixel
import json
from secrets import secretsAWS, secretsPhone
import time

OFF = (0, 0, 0)
BLUE = (32, 32, 255)
pybadger = PyBadger()
pixels = pybadger.pixels
pixels.brightness = 0.005
pixels.fill(OFF)
pixels.show()

# Store number of service globally
services_count = 79

# Setup WiFi
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi,
                                       esp32_cs,
Exemplo n.º 12
0
        "entity": True,
        "before_move": allow_push
    },
    "heart": {
        "sprite_index": 2,
        "can_walk": True,
        "entity": True,
    },
    "player": {
        "sprite_index": 0,
        "entity": True,
    }
}

# Badger object for easy button handling
badger = PyBadger()

# display object variable
display = board.DISPLAY

# Load the sprite sheet (bitmap)
sprite_sheet, palette = adafruit_imageload.load("/castle_sprite_sheet.bmp",
                                                bitmap=displayio.Bitmap,
                                                palette=displayio.Palette)

# make bright pink be transparent so entities can be drawn on top of map tiles
palette.make_transparent(5)

# Create the castle TileGrid
castle = displayio.TileGrid(sprite_sheet,
                            pixel_shader=palette,
Exemplo n.º 13
0
# Lanyard Neopixel Setup
pixel_pin = board.D2
num_pixels = 50
ORDER = neopixel.GRB
pixels = neopixel.NeoPixel(pixel_pin,
                           num_pixels,
                           brightness=0.2,
                           auto_write=False,
                           pixel_order=ORDER)
pixels.fill((0, 0, 0))
pixels.show()

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets)
pybadger = PyBadger()
#pybadger.show_badge(name_string="AYAN", hello_scale=2, my_name_is_scale=2, name_scale=3)
pybadger.pixels.fill(0)

# Setup a feed hierarchy for subscribing to changes
subscribe_feed = secrets['aio_username'] + '/feeds/#'


# Define callback methods which are called when events occur
def connected(client, userdata, flags, rc):
    # successfully to the broker.
    print('Connected to MQTT Broker! Listening for topic changes on %s' %
          subscribe_feed)
    client.subscribe(subscribe_feed)
    # basic badge render
    pybadger.show_badge(name_string="Ayan",
Exemplo n.º 14
0
from adafruit_pybadger import PyBadger

badge = PyBadger()


def show_badge():
    badge.show_badge(
        hello_font="Aller-14.bdf",
        hello_scale=1,
        my_name_is_font='Aller-14.bdf',
        my_name_is_scale=1,
        name_string="Mikey",
        name_scale=1,
        name_font="Warehouse-40.bdf",
    )


show_badge()

while True:
    badge.auto_dim_display(delay=30)
    if badge.button.a:
        badge.show_business_card(
            image_name="m_libby.bmp",
            name_string="Michael C. Libby",
            name_scale=1,
            name_font="Aller-14.bdf",
            email_string_one="m@",
            email_string_two="mlibby.com",
        )
    elif badge.button.b:
Exemplo n.º 15
0
from adafruit_pybadger import PyBadger

pybadger = PyBadger()

pybadger.show_badge(name_string="Jason", hello_scale=1, hello_font="fonts/Noto-18.bdf",my_name_is_scale=2, name_scale=3)

while True:
    pybadger.auto_dim_display(delay=10)
    if pybadger.button.a:
        pybadger.show_business_card(image_name="pics/face.bmp", name_scale=2)
    elif pybadger.button.b:
        pybadger.show_business_card(image_name="pics/vcard.bmp", name_scale=2)
    elif pybadger.button.start:
        pybadger.show_badge(name_string="Jason", hello_scale=1, hello_font="fonts/Noto-18.bdf",my_name_is_scale=2, name_scale=3)
    elif pybadger.button.up:
        pybadger.show_qr_code(data="https://www.choptanktransport.com")