Exemple #1
0
  def __init__(self, i2c, w=128, h=128, addr=_ADDR_SSD1327,
               auto_refresh=True, rotation_deg=90):
    # Initialize
    self.i2c_device = i2c
    self._i2c_addr = addr
    self._height = h
    self._width = w
    self._border = 8
    self._fontscale = 1
    self._tCol = _MAX_COLORS -1
    self._bCol = 0
    self._tyPos = 0
    self._font = terminalio.FONT
    dxy = self._font.get_bounding_box()
    self._tdx = dxy[0]
    self._tdy = dxy[1]
    self._power = True

    # Generate actual display object
    displayio.release_displays()
    self._displayBus = displayio.I2CDisplay(i2c.bus, device_address=addr)
    self._display = SSD1327(self._displayBus, width=w, height=h,
                            auto_refresh=auto_refresh, rotation=rotation_deg)
    # Generate graphic tools
    self._bmp = displayio.Bitmap(w, h, _MAX_COLORS)
    self._pal = displayio.Palette(_MAX_COLORS)
    self._pal[0] = 0x000000
    self._pal[1] = 0x555555
    self._pal[2] = 0xAAAAAA
    self._pal[3] = 0xFFFFFF
    self._tgrid = displayio.TileGrid(self._bmp, pixel_shader=self._pal)
    self._group = displayio.Group(max_size=_MAX_GROUPS)
    self._group.append(self._tgrid)
    self.show()
    self.isReady = True
Exemple #2
0
def init(i2c):
    global display, is_initialized, splash

    displayio.release_displays()

    display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
    WIDTH = 128
    HEIGHT = 32
    display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)
    splash = displayio.Group(max_size=10)
    display.show(splash)
    color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
    color_palette = displayio.Palette(1)
    color_palette[0] = 0x000000 # White
    bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)

    splash.append(bg_sprite)
    text = " "
    text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF, x=0, y=3)
    splash.append(text_area)
    text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF, x=0, y=13)
    splash.append(text_area)
    text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF, x=0, y=23)
    splash.append(text_area)
    is_initialized = True
 def __init__(self,
              SDA,
              SCL,
              toDisplay="ACTIVE LAYER",
              oWidth=128,
              oHeight=32,
              tileWidth=128,
              tileHeight=32,
              gridWidth=1,
              gridHeight=1):
     releaseDisp()
     self._toDisplay = toDisplay
     self._display = SSD1306(displayio.I2CDisplay(I2C(SDA, SCL),
                                                  device_address=0x3C),
                             width=oWidth,
                             height=oHeight)
     self._tileHeight = tileHeight
     self._tileWidth = tileWidth
     self._gridWidth = gridWidth
     self._gridHeight = gridHeight
     self._prevLayers = 0
Exemple #4
0
    def _init_stuff(self):

        # decouple display
        self.state_display_timeout = 1.0
        self.state_display_start = 0
        displayio.release_displays()
        i2c = board.I2C()

        display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)
        self.display = adafruit_displayio_ssd1306.SSD1306(
            display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT)

        self.min_press_str = "min: %d" % self.min_pressure
        self.high_press_str = "hi: %d" % self.high_pressure

        self.pressure_sensor = adafruit_lps35hw.LPS35HW(i2c)
        self.pressure_sensor.zero_pressure()
        self.pressure_sensor.data_rate = adafruit_lps35hw.DataRate.RATE_75_HZ

        self.pressure_sensor.filter_enabled = True
        self.pressure_sensor.filter_config = True
Exemple #5
0
    def SetupDisplay():
        # So we can communicate with our OLED via I2C
        i2c = busio.I2C(scl=board.GP3, sda=board.GP2)
        #while not i2c.try_lock():
        #    pass
        #print("i2c address is = ",i2c.scan())

        # How displayio talks to physical screen
        display_bus = displayio.I2CDisplay(
            i2c, device_address=60)  # was 0x3A, reset=oled_reset)

        # display represents the physical screen
        display = adafruit_displayio_ssd1306.SSD1306(display_bus,
                                                     width=WIDTH,
                                                     height=HEIGHT,
                                                     auto_refresh=False)

        # Group is a list of TileGrids that display would render on physical screen
        group = displayio.Group(max_size=1)

        display.show(group)

        return (display, group)
Exemple #6
0
# pylint: disable=redefined-outer-name
def lookup(layer, key_number):
    while layer >= 0:
        key = keymaps[layer][key_number]
        if key is not None:
            return key
        layer -= 1
    return None


displayio.release_displays()
# oled_reset = board.D9

# Use for I2C
i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)

# SH1107 is vertically oriented 64x128
WIDTH = 128
HEIGHT = 64

display = adafruit_displayio_sh1107.SH1107(display_bus,
                                           width=WIDTH,
                                           height=HEIGHT,
                                           rotation=180)
display.auto_refresh = False

font = bitmap_font.load_font("/digit-16px.pcf")
text_area = label.Label(font, text=" ", line_spacing=0.95)
text_area.y = 8
display.show(text_area)
Exemple #7
0
from adafruit_midi.note_on import NoteOn
from adafruit_midi.pitch_bend import PitchBend

displayio.release_displays()

oled_reset = board.D1

# I2C setup for display

# STEMMA I2C setup pre-CP 7.2
i2c = busio.I2C(board.SCL1, board.SDA1)

#  STEMMA I2C setup for CP 7.2+
#  i2c = board.STEMMA_I2C()

display_bus = displayio.I2CDisplay(i2c, device_address=0x3D, reset=oled_reset)

#  midi setup
print(usb_midi.ports)
midi = adafruit_midi.MIDI(
    midi_in=usb_midi.ports[0], in_channel=0, midi_out=usb_midi.ports[1], out_channel=0
)

msg = midi.receive()

#  display width and height setup
WIDTH = 128
HEIGHT = 64
BORDER = 5

#  display setup
    password=secrets["aio_key"],
)

# Initialize an Adafruit IO MQTT Client
io = IO_MQTT(mqtt_client)

# Connect the callback methods defined above to Adafruit IO
io.on_connect = connected
io.on_subscribe = subscribe
io.on_message = message

# Connect to Adafruit IO
print("Connecting to Adafruit IO...")
io.connect()

display_bus = displayio.I2CDisplay(board.I2C(), device_address=0x3C)

WIDTH = 128
HEIGHT = 32
BORDER = 2

display = adafruit_displayio_ssd1306.SSD1306(display_bus,
                                             width=WIDTH,
                                             height=HEIGHT)

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

digital_label = label.Label(terminalio.FONT,
                            text="Battery Percent: ",
                            color=0xFFFFFF,
Exemple #9
0
    def __init__(self, bitmap):  #imported bitmap

        displayio.release_displays()
        oled_reset = board.D9

        #defines display; change device address/width/height if needed
        i2c = board.I2C()
        display_bus = displayio.I2CDisplay(i2c,
                                           device_address=0x3D,
                                           reset=oled_reset)
        self.display = adafruit_displayio_ssd1306.SSD1306(display_bus,
                                                          width=128,
                                                          height=64)

        #imports sprite sheet, this should contain all sprites, you'll parse them later
        self.sprite_sheet, palette = adafruit_imageload.load(
            bitmap, bitmap=displayio.Bitmap, palette=displayio.Palette)

        #making individual tilemaps from main sprite sheet
        self.words = displayio.TileGrid(
            self.sprite_sheet,
            pixel_shader=palette,
            width=35,
            height=1,
            tile_width=1,
            tile_height=5
        )  #width and height are of the tilegrid: tile_width and tile_height are the number of pixels of the bitmap
        self.background = displayio.TileGrid(self.sprite_sheet,
                                             pixel_shader=palette,
                                             width=8,
                                             height=4,
                                             tile_width=16,
                                             tile_height=16)
        self.sprite = displayio.TileGrid(self.sprite_sheet,
                                         pixel_shader=palette,
                                         width=1,
                                         height=1,
                                         tile_width=3,
                                         tile_height=3)
        self.highscore = displayio.TileGrid(self.sprite_sheet,
                                            pixel_shader=palette,
                                            width=60,
                                            height=1,
                                            tile_width=1,
                                            tile_height=5)

        #sub groups
        self.words_group = displayio.Group(
            scale=3
        )  #creates subgroups; the scale value, suprisingly, changes the scale of the tilegrid
        self.words_group.x = 11  #position of subgroup in relation to main group
        self.words_group.y = 24

        self.background_group = displayio.Group(scale=1)
        self.background_group.x = 0
        self.background_group.y = 0

        self.sprite_group = displayio.Group(scale=1)

        self.highscore_group = displayio.Group(scale=2)
        self.highscore_group.x = 4
        self.highscore_group.y = 27

        #main group
        self.group = displayio.Group()  #creates main group
Exemple #10
0
    @property
    def tile_grid(self):
        return self._tile_grid


### CircuitPython will use an initalised display for a persistent console
### so release this if this has happened and re-initialise
displayio.release_displays()

### If screen is dead or not present
### ValueError: Unable to find I2C Display at 3c
### RuntimeError: No pull up found on SDA or SCL; check your wiring
try:
    i2c = busio.I2C(SSD1306_SCL_PIN, SSD1306_SDA_PIN, frequency=400 * 1000)
    display_bus = displayio.I2CDisplay(i2c, device_address=SSD1306_ADDR)
    display = adafruit_displayio_ssd1306.SSD1306(display_bus,
                                                 width=SSD1306_WIDTH,
                                                 height=SSD1306_HEIGHT)
except (ValueError, RuntimeError, OSError):
    display = None

if display:
    main_group = displayio.Group(max_size=7)
    display.show(main_group)

pixel = neopixel.NeoPixel(MPP_NEOPIXEL_PIN, 1)

d_print(1, "T-10")
time.sleep(10)