Пример #1
0
    def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin,
                 rst_pin, busy_pin):
        super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin,
                         rst_pin, busy_pin)
        stride = width
        if stride % 8 != 0:
            stride += 8 - stride % 8

        self._buffer1_size = int(stride * height / 8)
        self._buffer2_size = self._buffer1_size

        if sramcs_pin:
            self._buffer1 = self.sram.get_view(0)
            self._buffer2 = self.sram.get_view(self._buffer1_size)
        else:
            self._buffer1 = bytearray(self._buffer1_size)
            self._buffer2 = bytearray(self._buffer2_size)
        # since we have *two* framebuffers - one for red and one for black
        # we dont subclass but manage manually
        self._framebuf1 = adafruit_framebuf.FrameBuffer(
            self._buffer1,
            width,
            height,
            stride=stride,
            buf_format=adafruit_framebuf.MHMSB,
        )
        self._framebuf2 = adafruit_framebuf.FrameBuffer(
            self._buffer2,
            width,
            height,
            stride=stride,
            buf_format=adafruit_framebuf.MHMSB,
        )
        self.set_black_buffer(0, True)
        self.set_color_buffer(0, True)
    def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin,
                 rst_pin, busy_pin):
        super(Adafruit_SSD1675,
              self).__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin,
                             rst_pin, busy_pin)
        if width % 8 != 0:
            width += (8 - width % 8)

        self._buffer1_size = int(width * height / 8)
        self._buffer2_size = self._buffer1_size

        if sramcs_pin:
            self._buffer1 = self.sram.get_view(0)
            self._buffer2 = self.sram.get_view(self._buffer1_size)
        else:
            self._buffer1 = bytearray(self._buffer1_size)
            self._buffer2 = bytearray(self._buffer2_size)
        # since we have *two* framebuffers - one for red and one for black
        # we dont subclass but manage manually
        self._framebuf1 = adafruit_framebuf.FrameBuffer(
            self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB)
        self._framebuf2 = adafruit_framebuf.FrameBuffer(
            self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB)
        self.set_black_buffer(0, True)
        self.set_color_buffer(0, True)
Пример #3
0
    def __init__(
        self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
    ):
        super().__init__(
            width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
        )

        if width % 8 != 0:
            width += 8 - width % 8

        self._buffer1_size = int(width * height / 8)
        self._buffer2_size = self._buffer1_size

        if sramcs_pin:
            self._buffer1 = self.sram.get_view(0)
            self._buffer2 = self.sram.get_view(self._buffer1_size)
        else:
            self._buffer1 = bytearray(self._buffer1_size)
            self._buffer2 = bytearray(self._buffer2_size)

        self._framebuf1 = adafruit_framebuf.FrameBuffer(
            self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
        )
        self._framebuf2 = adafruit_framebuf.FrameBuffer(
            self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
        )
        self.set_black_buffer(0, True)
        self.set_color_buffer(1, False)
Пример #4
0
def show_text(text, display):
    # Create a framebuffer for our display
    buf = bytearray(32)  # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes)
    fb = adafruit_framebuf.FrameBuffer(buf,
        display.width, display.height, adafruit_framebuf.MVLSB)

    frame = 0 # start with frame 0
    for i in range(len(text) * 12):
        fb.fill(0)
        fb.text(text, -i + display.width, 0, color=1)

        # to improve the display flicker we can use two frames
        # fill the next frame with scrolling text, then
        # show it.
        display.frame(frame, show=False)
        # turn all LEDs off
        display.fill(0)
        for x in range(display.width):
            # using the FrameBuffer text result
            bite = buf[x]
            for y in range(display.height):
                bit = 1 << y & bite
                # if bit > 0 then set the pixel brightness
                if bit:
                    display.pixel(x, y, 50)

        # now that the frame is filled, show it.
        display.frame(frame, show=True)
        frame = 0 if frame else 1
    display.fill(0)
    sleep(1)
Пример #5
0
    def text(self, text_to_show):
        # Create a framebuffer for our display
        buffer_array = bytearray(32)  # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes)
        frame_buffer = adafruit_framebuf.FrameBuffer(
            buffer_array, self.matrix.width, self.matrix.height, adafruit_framebuf.MVLSB
        )

        frame = 0  # start with frame 0

        for i in range(len(text_to_show) * 9):
            frame_buffer.fill(0)
            frame_buffer.text(text_to_show, -i + self.matrix.width, 0, color=1, font_name='fonts/font5x8.bin')

            # to improve the display flicker we can use two frame
            # fill the next frame with scrolling text, then show it.
            self.matrix.frame(frame, show=False)

            # turn all LEDs off
            self.matrix.fill(0)

            # Loop through the matrix and set pixels according to the text
            for x in range(self.matrix.width):
                bite = buffer_array[x]
                for y in range(self.matrix.height):
                    bit = 1 << y & bite
                    # if bit > 0 then set the pixel brightness
                    if bit:
                        self.matrix.pixel(x, y, 50)

            # now that the frame is filled, show it.
            self.matrix.frame(frame, show=True)
            frame = 0 if frame else 1
Пример #6
0
    def setScreen(self):
        initScreen = self.initials["screen"]
        self.screenWidth = self.initials["width"]
        self.screenHeight = self.initials["height"]

        initScreen = bytearray(round(self.screenWidth * self.screenHeight / 8))
        self.screenBuffer = adafruit_framebuf.FrameBuffer(
            initScreen, self.screenWidth, self.screenHeight, buf_format=adafruit_framebuf.MVLSB
        )
 def __init__(self, pin, width, height, color):
     self.width = width
     self.height = height
     self.color = color
     pin = "board." + pin
     #this is a bad way to define the pin, but it works until a better way comes along
     #we are turing off the auto write to have smoother animation without the visible filling of pixles
     self.pixels = neopixel.NeoPixel(eval(pin),
                                     self.width * self.height,
                                     auto_write=False)
     self.buffer = bytearray(round(self.width * self.height / 8))
     self.fb = adafruit_framebuf.FrameBuffer(
         self.buffer,
         self.width,
         self.height,
         buf_format=adafruit_framebuf.MVLSB)
Пример #8
0
    def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin,
                 rst_pin, busy_pin):
        super(Adafruit_IL0373_BW,
              self).__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin,
                             rst_pin, busy_pin)

        self._buffer_size = int(width * height / 8)

        if sramcs_pin:
            self._buffer1 = self.sram.get_view(0)
        else:
            self._buffer1 = bytearray((width * height) // 8)
        # since we have *two* framebuffers - one for red and one for black
        # we dont subclass but manage manually
        self._framebuf1 = adafruit_framebuf.FrameBuffer(
            self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB)
        self.set_black_buffer(0, True)
Пример #9
0
    def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin,
                 rst_pin, busy_pin):
        super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin,
                         rst_pin, busy_pin)

        if height % 8 != 0:
            height += 8 - height % 8
            self._height = height

        self._buffer1_size = int(width * height / 8)

        if sramcs_pin:
            self._buffer1 = self.sram.get_view(0)
        else:
            self._buffer1 = bytearray((width * height) // 8)
        self._framebuf1 = adafruit_framebuf.FrameBuffer(
            self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB)
        self.set_black_buffer(0, True)
        self.set_color_buffer(0, True)
Пример #10
0
import adafruit_framebuf  # sudo pip3 install adafruit-circuitpython-framebuf
import math

BUSPIRATE_PORT = '/dev/ttyUSB0'  # customize this! Find it in device manager.

# DISPLAY PARAMETERS
# Visible width: 106
# Visible height: 8x8

# Framebuffer
WIDTH = 106
HEIGHT = 64

buffer = bytearray(round(WIDTH * HEIGHT / 8))
fb = adafruit_framebuf.FrameBuffer(buffer,
                                   WIDTH,
                                   HEIGHT,
                                   buf_format=adafruit_framebuf.MVLSB)


def send(ser, cmd, storeResult=False):
    """send the command and listen to the response."""
    ser.write(str(cmd + '\n').encode('ascii'))  # send our command

    for line in ser.readlines():  # while there's a response
        print(line.decode('utf-8').strip())  # show it


def lcd_init():
    txtdat = ""
    txtdat += "[0x78,0x00,0x01,0x10]"
    txtdat += "[0x78,0x00,0x01,0x0e,0x12]"
# initial display using Feather CharlieWing LED 15 x 7
# display = adafruit_is31fl3731.CharlieWing(i2c)
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
# display = adafruit_is31fl3731.Matrix(i2c)
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
display = adafruit_is31fl3731.CharlieBonnet(i2c)
# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

text_to_show = "Adafruit!!"

# Create a framebuffer for our display
buf = bytearray(32)  # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes)
fb = adafruit_framebuf.FrameBuffer(
    buf, display.width, display.height, adafruit_framebuf.MVLSB
)


frame = 0  # start with frame 0
while True:
    for i in range(len(text_to_show) * 9):
        fb.fill(0)
        fb.text(text_to_show, -i + display.width, 0, color=1)

        # to improve the display flicker we can use two frame
        # fill the next frame with scrolling text, then
        # show it.
        display.frame(frame, show=False)
        # turn all LEDs off
        display.fill(0)
Пример #12
0
# Create the matrix class.
# This creates a 16x8 matrix:
matrix = matrix.Matrix16x8(i2c)

# Low brightness so it's easier to look at
matrix.brightness = 0

# Clear the matrix.
matrix.fill(0)

text_to_show = "Hello Blinka"

# Create a framebuffer for our display
buf = bytearray(16)  # 1 bytes tall x 16 wide = 16 bytes
fb = adafruit_framebuf.FrameBuffer(buf, 16, 8, adafruit_framebuf.MVLSB)

while True:
    for i in range(len(text_to_show) * 8):
        fb.fill(0)
        fb.text(text_to_show, -i + 16, 0, color=1)
        # turn all LEDs off
        matrix.fill(0)
        for x in range(16):
            # using the FrameBuffer text result
            bite = buf[x]
            for y in range(8):
                bit = 1 << y & bite
                # if bit > 0 then set the pixel brightness
                if bit:
                    matrix[16 - x, y + 1] = 1
Пример #13
0
def initFrameBuffer(buffer):
    fb = framebuf.FrameBuffer(buffer, EPD_WIDTH, EPD_HEIGHT, framebuf.MHMSB)
    return fb
Пример #14
0
          phase=0,
          sck=sck,
          miso=miso,
          mosi=mosi)

e = epaper4in2.EPD(spi, cs, dc, rst, busy)
e.init()

w = 400
h = 300
x = 0
y = 0

# use a frame buffer
# 400 * 300 / 8 = 15000 - thats a lot of pixels
import adafruit_framebuf as framebuf

buf = bytearray(w * h // 8)
fb = framebuf.FrameBuffer(buf, w, h, buf_format=framebuf.MHMSB)
fb.rotation = 3
print('Frame buffer things')
fb.fill(True)
fb.text('Hello World', 30, 0, False)
fb.pixel(30, 10, True)
fb.line(30, 70, 40, 80, False)
fb.rect(30, 90, 10, 10, False)
fb.fill_rect(30, 110, 10, 10, False)
for row in range(0, 36):
    fb.text(str(row), 0, row * 8, False)
fb.text('Line 36', 0, 288, False)
e.display_frame(buf)
Пример #15
0
#     0x3C, 0x40, 0x30, 0x40, 0x3C,
#     0x44, 0x28, 0x10, 0x28, 0x44,
#     0x4C, 0x90, 0x90, 0x90, 0x7C,
#     0x44, 0x64, 0x54, 0x4C, 0x44,
#     0x00, 0x08, 0x36, 0x41, 0x00,
#     0x00, 0x00, 0x77, 0x00, 0x00,
#     0x00, 0x41, 0x36, 0x08, 0x00,
#     0x02, 0x01, 0x02, 0x04, 0x02,
#     0x3C, 0x26, 0x23, 0x26, 0x3C]

# Display data
width = None
height = None
pages = None
buffer = bytearray(128 // 8 * 64)
framebuffer = framebuf.FrameBuffer(memoryview(buffer), 128, 64)


def isConnected():
    if i2c != None:
        # Check I2C devices
        devices = i2c.scan()  # returns list of slave addresses
        for d in devices:
            if d == SSD1306_I2C_ADDRESS: return True
        return False
    else:
        # No check for SPI
        return True


def command1(c):
Пример #16
0
    epd = EPD_2in9()
    #epd.Clear(0xff)
    epd.init()
    #
    #     epd.fill(0xff)
    #     epd.text("Wright Rocket", 5, 10, 0x00)
    #     epd.text("Pico_ePaper-2.9", 5, 40, 0x00)
    #     epd.text("Raspberry Pico", 5, 70, 0x00)
    #     epd.display(epd.buffer)
    #     epd.delay_ms(2000)
    #     epd.set_rotate(90)

    # epd.set_pixel(epd.buffer, 0, 0, 0xff)
    buffer = bytearray(round(EPD_WIDTH * EPD_HEIGHT / 8))
    fb = framebuf.FrameBuffer(buffer, EPD_WIDTH, EPD_HEIGHT, framebuf.MHMSB)
    fb.fill(WHITE)

    #
    #     epd.set_frame_memory(hello_world_dark, 0, 0, EPD_WIDTH, EPD_HEIGHT)
    #     print('hw_dark')
    #     epd.delay_ms(2000)
    #     epd.set_frame_memory(hello_world_light, 0, 0, EPD_WIDTH, EPD_HEIGHT)
    #     print('hw_light')
    #epd.display(epd.buffer)
    fb.rotation = 1  # 90 DEGREES
    TOP_MARGIN = 32
    LEFT_MARGIN = 10
    RADIUS = 5
    fb.text('WrightRocket', 75, 8, BLACK, size=2)
    fb.vline(round(EPD_HEIGHT / 2 - LEFT_MARGIN / 2), TOP_MARGIN,