コード例 #1
0
seesaw = Seesaw(i2c_bus, addr=0x36)

seesaw_product = (seesaw.get_version() >> 16) & 0xFFFF
print("Found product {}".format(seesaw_product))
if seesaw_product != 4991:
    print("Wrong firmware loaded?  Expected 4991")

button = DigitalIO(seesaw, 24)

encoder = IncrementalEncoder(seesaw)
LAST_POSITION = 0

# Set up display
bus = board.SPI()
chip_select_pin = board.IO12
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, chip_select_pin, 400,
                                                  240)

display = framebufferio.FramebufferDisplay(framebuffer)

splash = displayio.Group()
display.show(splash)

# Set up PWM LEDs
WARM_PIN = board.IO5
COOL_PIN = board.IO6

FADE_SLEEP = 0.01  # Number of milliseconds to delay between changes.
# Increase to slow down, decrease to speed up.

# Define PWM outputs:
warm = pwmio.PWMOut(WARM_PIN)
コード例 #2
0
import math

from digitalio import DigitalInOut, Direction, Pull

import busio

# Release the existing display, if any
displayio.release_displays()

bus = busio.SPI(board.P0_12, board.P0_04)
chip_select_pin = board.P0_08
# Select JUST ONE of the following lines:
# For the 400x240 display (can only be operated at 2MHz)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus,
                                                  chip_select_pin,
                                                  400,
                                                  240,
                                                  baudrate=2000000)
# For the 144x168 display (can be operated at up to 8MHz)
#framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, chip_select_pin, width=144, height=168, baudrate=8000000)

display_on_in = DigitalInOut(board.P0_30)
display_on_in.direction = Direction.OUTPUT
display_on_in.value = True

display = framebufferio.FramebufferDisplay(framebuffer)

from adafruit_display_text.label import Label
from terminalio import FONT

# rotary encoder
コード例 #3
0
import displayio
import framebufferio
import microcontroller
import sharpdisplay
import supervisor
import terminalio

try:
    import usb_hid
except ImportError:
    usb_hid = None

# Initialize the display, cleaning up after a display from the previous
# run if necessary
displayio.release_displays()
framebuffer = sharpdisplay.SharpMemoryFramebuffer(board.SPI(), board.RX, 400,
                                                  240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh=False)


def extraprec(add=8, num=0, den=1):
    def inner(fn):
        def wrapper(*args, **kw):
            with localcontext() as ctx:
                ctx.prec = ctx.prec + add + (ctx.prec * num + den - 1) // den
                result = fn(*args, **kw)
            return +result

        return wrapper

    return inner
コード例 #4
0
# A function to choose "k" different items from the "population" list
# We'll use it to select the names to display
def sample(population, k):
    population = population[:]
    for _ in range(k):
        j = random.randint(0, len(population) - 1)
        yield population[j]
        population[j] = population[-1]
        population.pop()


# Initialize the display, cleaning up after a display from the previous run
# if necessary
displayio.release_displays()
bus = board.SPI()
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.D6, 400, 240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh=True)

# Load our font
font = bitmap_font.load_font("/GothamBlack-54.bdf")

# Create a Group for the BLM text
blm_group = displayio.Group(max_size=10)
display.show(blm_group)

# Create a 3 line set of text for BLM
blm_font = [None, None, None]
for line in range(3):
    label = adafruit_display_text.label.Label(font,
                                              color=0xFFFFFF,
                                              max_glyphs=16)
コード例 #5
0
PIN_CLK = board.GP18
PIN_RX = board.GP16  # unused
PIN_TX = board.GP19
PIN_CS = board.GP17
bus = busio.SPI(clock=PIN_CLK, MOSI=PIN_TX)  #, MISO=PIN_RX)

# --- display configuration   --------------------------------------------

WIDTH = 400
HEIGHT = 240

# --- main program   -----------------------------------------------------

# For the 400x240 display (can only be operated at 2MHz)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, PIN_CS, WIDTH, HEIGHT)
display = framebufferio.FramebufferDisplay(framebuffer)

# Make the display context
main_group = displayio.Group()

# Make a background color fill
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0,
                               y=0)
main_group.append(bg_sprite)