예제 #1
0
def test_open_image(filename):
    """ Test the open_image helper """
    # open_image() returns a ClipReader objet
    clip = open_image(filename)
    clip.show()

    clip.clip(2, 2, 20, 16)  # x,y, w, h
    for y in range(clip.height):
        print("--- Clip Line %i ---------" % y)
        for x in range(clip.width):
            print("(%i,%i) : %s" % (x, y, clip.read_pix()))  #x,y, color
    clip.close()
예제 #2
0
#    spi = SPI(-1, baudrate=4000000, polarity=1, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
# Hardware SPI on Pyboard
spi = SPI(2)  # MOSI=Y8, MISO=Y7, SCK=Y6, SS=Y5
spi.init(baudrate=2000000, phase=0, polarity=0)  # low @ 2 MHz
# We must manage the SS signal ourself
ss = Pin(Pin.board.Y5, Pin.OUT)

# Just 6 LED-8x8RGB organized in 2 row of 3 columns each
# so 24x16 pixel display
modled = ModLedRGB(spi, ss, width=3, height=2)

# ClipReader opening the 24x91 pixels bitmap
modled.clear()
modled.show()

clip = open_image("olimex.bmp")
print("size: X*Y = %i * %i " % (clip.reader.width, clip.reader.height))
for y_scroll in range(91 - 16):  # Nbr of pixels to scrool
    #print( '=== Clipping @ y = %i ==========================' % y_scroll )
    clip.clip(0, y_scroll, 24, 16)
    #clip.show( )
    #clip.clip( 0, y_scroll, 23, 16 ) # will reseek the cursor at the right position

    # Copy from clipped image TO FrameBuffer
    for line in range(clip.height):  #  16 pixels height
        for row in range(clip.width):  # 23 pixels width
            # Read a pixel color (r,g,b) --> transfert to 3 bit color --> draw pixel on frameBuffer
            c = clip.read_pix()
            modled.pixel(row, line, colorTo3Bit(c))
    modled.show()
예제 #3
0
# PYBStick: S19=mosi, S23=sck, S26=/ss
cs = Pin( 'S26', Pin.OUT, value=0 )
spi = SPI( 1 )
spi.init( polarity=0, phase=1 )

# Pico: GP7=mosi, GP6=sck, GP5=/ss
#cs = Pin( 5, Pin.OUT, value=0 )
#spi = SPI( 0 )
#spi.init( polarity=0, phase=1 )

# PYBOARD: Y8=mosi, Y6=sck, Y5=/ss
#cs = Pin( 'Y5', Pin.OUT, value=0 )
#spi = SPI( 2 )
#spi.init( polarity=0, phase=1 )

lcd = SPI_LCD12864( spi=spi, cs=cs )
# texte à X=10, Y=25, couleur=1 (trait)
#lcd.text( "MicroPython !", 10, 25, 1 )
#lcd.update()

def color_transform( rgb ):
	# transform the clipreader (rgb) color to the target FrameBuffer color (2 colors)
	return 0 if rgb==(0,0,0) else 1

reader = open_image( 'mpy.pbm' )
reader.clip(0,0,lcd.width,lcd.height)
# Copy the clipped aread TO a target FrameBuffer (lcd) at is starting
# position 0,0 for the given clipping width,height .
reader.copy_to(lcd, 0,0, color_transform )
lcd.update()