예제 #1
0
def initialize_display():
    # ILI9341 display
    spi = SPI(1, baudrate=32000000, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
    display = Display(spi,
                      dc=Pin(26),
                      cs=Pin(5),
                      rst=Pin(25),
                      rotation=270,
                      width=320,
                      height=240)
    display.clear()
    return display
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    x, y = 0, 0
    angle = 0.0
    #  Loop all angles from 0 to 2 * PI radians
    while angle < PI2:
        # Calculate x, y from a vector with known length and angle
        x = int(CENTER_X * sin(angle) + HALF_WIDTH)
        y = int(CENTER_Y * cos(angle) + HALF_HEIGHT)
        color = color565(*hsv_to_rgb(angle / PI2, 1, 1))
        display.draw_line(x, y, CENTER_X, CENTER_Y, color)
        angle += ANGLE_STEP_SIZE

    sleep(5)

    for r in range(CENTER_X, 0, -1):
        color = color565(*hsv_to_rgb(r / HALF_WIDTH, 1, 1))
        display.fill_circle(CENTER_X, CENTER_Y, r, color)

    sleep(9)
    display.cleanup()
def test():
    """CircuitPython Text, Shape & Sprite"""
    if implementation.name != 'circuitpython':
        print()
        print('This demo is for CircuitPython only!')
        exit()
    try:
        # Configuratoin for CS and DC pins:
        cs_pin = DigitalInOut(board.P0_15)
        dc_pin = DigitalInOut(board.P0_17)
        rst_pin = DigitalInOut(board.P0_20)

        # Setup SPI bus using hardware SPI:
        spi = SPI(clock=board.P0_24, MOSI=board.P0_22)

        # Create the ILI9341 display:
        display = Display(spi, dc=dc_pin, cs=cs_pin, rst=rst_pin)
        display.clear()

        # Load Fixed Font
        fixed = XglcdFont('fonts/FixedFont5x8.c', 5, 8, letter_count=96)

        # Title
        WIDTH = 128
        text = 'CircuitPython Demo'
        # Measure text and center
        length = fixed.measure_text(text)
        x = int((WIDTH / 2) - (length / 2))
        display.draw_text(x, 6, text, fixed, color565(255, 255, 0))

        # Draw title outline
        display.draw_rectangle(0, 0, 127, 20, color565(0, 255, 0))

        # Load sprite
        logo = BouncingSprite('images/blinka45x48.raw', 45, 48, 239, 319, 1,
                              display)

        while True:
            timer = monotonic()
            logo.update_pos()
            logo.draw()
            # Attempt to set framerate to 30 FPS
            timer_dif = .033333333 - (monotonic() - timer)
            if timer_dif > 0:
                sleep(timer_dif)

    except KeyboardInterrupt:
        display.cleanup()
예제 #4
0
    def setup_screen(self):
        self.screen_power = Pin(m5stack.TFT_LED_PIN, Pin.OUT)
        self.screen_power.value(1)
        spi = SPI(
            2,
            baudrate=40000000,
            miso=Pin(m5stack.TFT_MISO_PIN),
            mosi=Pin(m5stack.TFT_MOSI_PIN),
            sck=Pin(m5stack.TFT_CLK_PIN))    
        #display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))
        self.display = Display(
            spi,
            cs=Pin(m5stack.TFT_CS_PIN),
            dc=Pin(m5stack.TFT_DC_PIN),
            rst=Pin(m5stack.TFT_RST_PIN), width=320, height=240, rotation=0)
        self.display.clear()    

        self.header_font = XglcdFont('/screen/m5stack/fonts/Unispace12x24.c', 12, 24)
        self.large_label_font = XglcdFont('/screen/m5stack/fonts/IBMPlexMono12x24.c', 12, 24)
        self.small_label_font = XglcdFont('/screen/m5stack/fonts/ArcadePix9x11.c', 9, 11)
        self.display.draw_text(0, 0, 'Loading...', self.large_label_font, color565(0, 0, 0), background=color565(255, 255, 255))
예제 #5
0
def test():
    """Bouncing box."""
    try:
        # Baud rate of 40000000 seems about the max
        spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
        display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))
        display.clear()

        colors = [
            color565(255, 0, 0),
            color565(0, 255, 0),
            color565(0, 0, 255),
            color565(255, 255, 0),
            color565(0, 255, 255),
            color565(255, 0, 255)
        ]
        sizes = [12, 11, 10, 9, 8, 7]
        boxes = [Box(239, 319, sizes[i], display, colors[i]) for i in range(6)]

        while True:
            timer = ticks_us()
            for b in boxes:
                b.update_pos()
                b.draw()
            # Attempt to set framerate to 30 FPS
            timer_dif = 33333 - ticks_diff(ticks_us(), timer)
            if timer_dif > 0:
                sleep_us(timer_dif)

    except KeyboardInterrupt:
        display.cleanup()
예제 #6
0
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    c = 0
    for x in range(0, 240, 20):
        for y in range(0, 320, 20):
            color = color565(*hsv_to_rgb(c / 192, 1, 1))
            display.fill_circle(x + 9, y + 9, 9, color)
            c += 1
    sleep(9)
    display.cleanup()
예제 #7
0
    def __init__(self, spi1, spi2, dc=4, cs1=16, rst=17, cs2=5, rotation=270):
        """Initialize PwnLookup."""
        # Set up display
        self.display = Display(spi1,
                               dc=Pin(dc),
                               cs=Pin(cs1),
                               rst=Pin(rst),
                               width=320,
                               height=240,
                               rotation=rotation)

        # Load font
        self.unispace = XglcdFont('fonts/Unispace12x24.c', 12, 24)

        # Set up Keyboard
        self.keyboard = TouchKeyboard(self.display, self.unispace)

        # Set up touchscreen
        self.xpt = Touch(spi2,
                         cs=Pin(cs2),
                         int_pin=Pin(0),
                         int_handler=self.touchscreen_press)
        self.wlan = WLAN(STA_IF)
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    # Build color list from all upper case constants (lazy approach)
    colors = [
        getattr(modules[__name__], name) for name in dir(modules[__name__])
        if name.isupper() and name is not 'SPI'
    ]

    colors.sort()
    c = 0
    for x in range(0, 240, 48):
        for y in range(0, 320, 64):
            display.fill_rectangle(x, y, 47, 63, colors[c])
            c += 1
    sleep(9)
    display.cleanup()
예제 #9
0
def test():
    """Bouncing sprite."""
    try:
        # Baud rate of 40000000 seems about the max
        spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
        display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))
        display.clear()

        # Load sprite
        logo = BouncingSprite('images/Python41x49.raw',
                              41, 49, 240, 320, 1, display)

        while True:
            timer = ticks_us()
            logo.update_pos()
            logo.draw()
            # Attempt to set framerate to 30 FPS
            timer_dif = 33333 - ticks_diff(ticks_us(), timer)
            if timer_dif > 0:
                sleep_us(timer_dif)

    except KeyboardInterrupt:
        display.cleanup()
예제 #10
0
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    print('Loading fonts...')
    print('Loading arcadepix')
    arcadepix = XglcdFont('fonts/ArcadePix9x11.c', 9, 11)
    print('Loading bally')
    bally = XglcdFont('fonts/Bally7x9.c', 7, 9)
    print('Loading broadway')
    broadway = XglcdFont('fonts/Broadway17x15.c', 17, 15)
    print('Loading espresso_dolce')
    espresso_dolce = XglcdFont('fonts/EspressoDolce18x24.c', 18, 24)
    print('Loading fixed_font')
    fixed_font = XglcdFont('fonts/FixedFont5x8.c', 5, 8)
    print('Loading neato')
    neato = XglcdFont('fonts/Neato5x7.c', 5, 7, letter_count=223)
    print('Loading robotron')
    robotron = XglcdFont('fonts/Robotron13x21.c', 13, 21)
    print('Loading unispace')
    unispace = XglcdFont('fonts/Unispace12x24.c', 12, 24)
    print('Loading wendy')
    wendy = XglcdFont('fonts/Wendy7x8.c', 7, 8)
    print('Fonts loaded.')

    display.draw_text(0, 0, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0))
    display.draw_text(0, 22, 'Bally 7x9', bally, color565(0, 255, 0))
    display.draw_text(0, 43, 'Broadway 17x15', broadway, color565(0, 0, 255))
    display.draw_text(0, 66, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(0, 255, 255))
    display.draw_text(0, 104, 'Fixed Font 5x8', fixed_font,
                      color565(255, 0, 255))
    display.draw_text(0, 125, 'Neato 5x7', neato, color565(255, 255, 0))
    display.draw_text(0, 155, 'ROBOTRON 13X21', robotron,
                      color565(255, 255, 255))
    display.draw_text(0, 190, 'Unispace 12x24', unispace,
                      color565(255, 128, 0))
    display.draw_text(0, 220, 'Wendy 7x8', wendy, color565(255, 0, 128))

    sleep(9)
    display.clear()

    display.draw_text(0, 255, 'Arcade Pix 9x11', arcadepix,
                      color565(255, 0, 0),
                      landscape=True)
    display.draw_text(22, 255, 'Bally 7x9', bally, color565(0, 255, 0),
                      landscape=True)
    display.draw_text(43, 255, 'Broadway 17x15', broadway, color565(0, 0, 255),
                      landscape=True)
    display.draw_text(66, 255, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(0, 255, 255), landscape=True)
    display.draw_text(104, 255, 'Fixed Font 5x8', fixed_font,
                      color565(255, 0, 255), landscape=True)
    display.draw_text(125, 255, 'Neato 5x7', neato, color565(255, 255, 0),
                      landscape=True)
    display.draw_text(155, 255, 'ROBOTRON 13X21', robotron,
                      color565(255, 255, 255),
                      landscape=True)
    display.draw_text(190, 255, 'Unispace 12x24', unispace,
                      color565(255, 128, 0),
                      landscape=True)
    display.draw_text(220, 255, 'Wendy 7x8', wendy, color565(255, 0, 128),
                      landscape=True)

    sleep(9)
    display.clear()

    display.draw_text(0, 0, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0),
                      background=color565(0, 255, 255))
    display.draw_text(0, 22, 'Bally 7x9', bally, color565(0, 255, 0),
                      background=color565(0, 0, 128))
    display.draw_text(0, 43, 'Broadway', broadway, color565(0, 0, 255),
                      background=color565(255, 255, 0))
    display.draw_text(0, 66, 'Espresso', espresso_dolce,
                      color565(0, 255, 255), background=color565(255, 0, 0))
    display.draw_text(0, 104, 'Fixed Font 5x8', fixed_font,
                      color565(255, 0, 255), background=color565(0, 128, 0))
    display.draw_text(0, 125, 'Neato 5x7', neato, color565(255, 255, 0),
                      background=color565(0, 0, 255))
    display.draw_text(0, 155, 'ROBOTRON 13X21', robotron,
                      color565(255, 255, 255),
                      background=color565(128, 128, 128))
    display.draw_text(0, 190, 'Unispace', unispace, color565(255, 128, 0),
                      background=color565(0, 128, 255))
    display.draw_text(0, 220, 'Wendy 7x8', wendy, color565(255, 0, 128),
                      background=color565(255, 255, 255))

    sleep(9)
    display.cleanup()
예제 #11
0
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    display.draw_image('images/RaspberryPiWB128x128.raw', 0, 0, 128, 128)
    sleep(2)

    display.draw_image('images/MicroPython128x128.raw', 0, 129, 128, 128)
    sleep(2)

    display.draw_image('images/Tabby128x128.raw', 112, 0, 128, 128)
    sleep(2)

    display.draw_image('images/Tortie128x128.raw', 112, 129, 128, 128)

    sleep(9)

    display.cleanup()
예제 #12
0
def test():
    """Scrolling Marquee."""
    try:
        # Implementation dependant pin and SPI configuration
        if implementation.name == 'circuitpython':
            import board
            from busio import SPI
            from digitalio import DigitalInOut
            cs_pin = DigitalInOut(board.P0_15)
            dc_pin = DigitalInOut(board.P0_17)
            rst_pin = DigitalInOut(board.P0_20)
            spi = SPI(clock=board.P0_24, MOSI=board.P0_22)
        else:
            from machine import Pin, SPI
            cs_pin = Pin(16)
            dc_pin = Pin(4)
            rst_pin = Pin(17)
            # Baud rate of 40000000 seems about the max
            spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))

        # Create the ILI9341 display:
        display = Display(spi, dc=dc_pin, cs=cs_pin, rst=rst_pin)
        display.clear()

        # Draw non-moving circles
        display.fill_rectangle(0, 0, 239, 99, color565(27, 72, 156))
        display.fill_rectangle(0, 168, 239, 151, color565(220, 27, 72))

        # Load Marquee image
        display.draw_image('images/Rototron128x26.raw', 56, 120, 128, 26)

        # Set up scrolling
        display.set_scroll(top=152, bottom=100)

        spectrum = list(range(152, 221)) + list(reversed(range(152, 220)))
        while True:
            for y in spectrum:
                display.scroll(y)
                sleep(.1)

    except KeyboardInterrupt:
        display.cleanup()
예제 #13
0
class Hardware(BaseHardware):
    
    def __init__(self, config) :

        pin_a = Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None)
        pin_b = Pin(BUTTON_B_PIN, mode=Pin.IN, pull=None)
        pin_c = Pin(BUTTON_C_PIN, mode=Pin.IN, pull=None)
        
        self.buttonA = Button(pin=pin_a)
        self.buttonB = Button(pin=pin_b)
        self.buttonC = Button(pin=pin_c)
        self.buttonA.press_func(self.button_A_callback, (pin_a,))  # Note how function and args are passed
        self.buttonB.press_func(self.button_B_callback, (pin_b,))  # Note how function and args are passed
        self.buttonC.press_func(self.button_C_callback, (pin_c,))  # Note how function and args are passed
 
        # display
        self.display = None
        self.screen_power = None
        self.header_font = None
        self.large_label_font = None
        self.small_label_font = None

        self.setup_screen()

        # screen saver
        # 0 - disable
        # x - screen saver activation in second
        self.screensaver = 0
        self.currentcount  = 0
        if "screensaver" in config:
            self.screensaver = int(config["screensaver"])
            self.currentcount = int(config["screensaver"])
        
        self.screen_timeout_lock = Lock()
        
        # wifi
        super().__init__(config)
    
    def get_ble_handle(self):
        return self.ble_handle
    
    def set_callback(self, button, cb):
        if button == BUTTON_A_PIN:
            self.buttonA = Button(pin=Pin(BUTTON_A_PIN, mode=Pin.IN, pull=None),  
                callback=cb, trigger=Pin.IRQ_FALLING)

    def button_A_callback(self, pin):
        print("Button (%s) changed to: %r" % (pin, pin.value()))
        if pin.value() == 0 :
            
            #device = self.device_req_handler["studyrmfan"]
            # handle the request
            topic = self.tranport_handler.topicprefix + 'cmnd/studyrmfan/press'
            self.tranport_handler.publish(topic, 'on')
            # rest the screen saver
            self.tranport_handler.loop.create_task(self.reset_screen_saver())         
            
    def button_B_callback(self, pin):
        print("Button (%s) changed to: %r" % (pin, pin.value()))
        if pin.value() == 0 :
            
            # handle the request
            topic = self.tranport_handler.topicprefix + 'cmnd/studyrmtemp/getstatus'
            self.tranport_handler.publish(topic, 'on')
            # rest the screen saver
            self.tranport_handler.loop.create_task(self.reset_screen_saver())            

    def button_C_callback(self, pin):
        print("Button (%s) changed to: %r" % (pin, pin.value()))
        if pin.value() == 0 :
            
            #device = self.device_req_handler["waterheater"]
            # handle the request
            topic = self.tranport_handler.topicprefix + 'cmnd/waterheater/press'
            self.tranport_handler.publish(topic, 'on')
            # rest the screen saver
            self.tranport_handler.loop.create_task(self.reset_screen_saver())      
    def clear_dashboard(self):
        '''
        Clear the dashboard area
        '''
        self.display.fill_rectangle(70, 80, 200, 100, color565(0,0,0))

    def setup_screen(self):
        self.screen_power = Pin(m5stack.TFT_LED_PIN, Pin.OUT)
        self.screen_power.value(1)
        spi = SPI(
            2,
            baudrate=40000000,
            miso=Pin(m5stack.TFT_MISO_PIN),
            mosi=Pin(m5stack.TFT_MOSI_PIN),
            sck=Pin(m5stack.TFT_CLK_PIN))    
        #display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))
        self.display = Display(
            spi,
            cs=Pin(m5stack.TFT_CS_PIN),
            dc=Pin(m5stack.TFT_DC_PIN),
            rst=Pin(m5stack.TFT_RST_PIN), width=320, height=240, rotation=0)
        self.display.clear()    

        self.header_font = XglcdFont('/screen/m5stack/fonts/Unispace12x24.c', 12, 24)
        self.large_label_font = XglcdFont('/screen/m5stack/fonts/IBMPlexMono12x24.c', 12, 24)
        self.small_label_font = XglcdFont('/screen/m5stack/fonts/ArcadePix9x11.c', 9, 11)
        self.display.draw_text(0, 0, 'Loading...', self.large_label_font, color565(0, 0, 0), background=color565(255, 255, 255))

    def show_setupcomplete(self):
        self.home_page()
        self.display.draw_text(70, 80, 'Waiting For', self.large_label_font, color565(255, 255, 255), background=color565(0, 0, 0))
        self.display.draw_text(70, 100, 'Messages', self.large_label_font, color565(255, 255, 255), background=color565(0, 0, 0))

        #activate the screen saver
        self.tranport_handler.loop.create_task(self.screen_saver_countdown())

    def home_page(self):
        self.display.clear()
        self.display.draw_image('/images/blecanvas.raw',0,0,320,240)
        #self.display.draw_text(45, 203, 'Fan', self.large_label_font, color565(0, 0, 0), background=color565(255, 255, 255))
        #self.display.draw_text(135, 203, 'Temp', self.large_label_font, color565(0, 0, 0), background=color565(255, 255, 255))
        #self.display.draw_text(225, 203, 'Heater', self.large_label_font, color565(0, 0, 0), background=color565(255, 255, 255))
        self.screen_power.value(1)

        

    def display_result(self, text):
        print("Display Result")
        self.clear_dashboard()
        self.display.draw_text(70, 80, text["line1"], self.large_label_font, color565(255, 255, 255))
        self.display.draw_text(70, 100, text["line2"], self.large_label_font, color565(255, 255, 255))
        self.display.draw_text(70, 120, text["line3"], self.large_label_font, color565(255, 255, 255))
    
    def screen_off(self):
        self.screen_power.value(0)
    
    def screen_on(self):
        self.screen_power.value(1)
    
    async def reset_screen_saver(self):
        '''
        Reset the screen Saver timeout to
        
        '''
        await self.screen_timeout_lock.acquire()
        self.currentcount = self.screensaver
        self.screen_timeout_lock.release()
        self.screen_on()

    
    async def screen_saver_countdown(self):
        while True:
            await self.screen_timeout_lock.acquire()
            if self.currentcount > 0: 
                self.currentcount -= 1 
            if self.currentcount == 0 :
                self.screen_off()
            self.screen_timeout_lock.release()
            await asyncio.sleep(1)
    
       
    
        
#a=Hardware()
#a.show_setupcomplete
예제 #14
0
def test():
    """Test code."""
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
    display = Display(spi, dc=Pin(4), cs=Pin(16), rst=Pin(17))

    display.clear(color565(64, 0, 255))
    sleep(1)

    display.clear()

    display.draw_hline(10, 319, 229, color565(255, 0, 255))
    sleep(1)

    display.draw_vline(10, 0, 319, color565(0, 255, 255))
    sleep(1)

    display.fill_hrect(23, 50, 30, 75, color565(255, 255, 255))
    sleep(1)

    display.draw_hline(0, 0, 222, color565(255, 0, 0))
    sleep(1)

    display.draw_line(127, 0, 64, 127, color565(255, 255, 0))
    sleep(2)

    display.clear()

    coords = [[0, 63], [78, 80], [122, 92], [50, 50], [78, 15], [0, 63]]
    display.draw_lines(coords, color565(0, 255, 255))
    sleep(1)

    display.clear()
    display.fill_polygon(7, 120, 120, 100, color565(0, 255, 0))
    sleep(1)

    display.fill_rectangle(0, 0, 15, 227, color565(255, 0, 0))
    sleep(1)

    display.clear()

    display.fill_rectangle(0, 0, 163, 163, color565(128, 128, 255))
    sleep(1)

    display.draw_rectangle(0, 64, 163, 163, color565(255, 0, 255))
    sleep(1)

    display.fill_rectangle(64, 0, 163, 163, color565(128, 0, 255))
    sleep(1)

    display.draw_polygon(3, 120, 286, 30, color565(0, 64, 255), rotate=15)
    sleep(3)

    display.clear()

    display.fill_circle(132, 132, 70, color565(0, 255, 0))
    sleep(1)

    display.draw_circle(132, 96, 70, color565(0, 0, 255))
    sleep(1)

    display.fill_ellipse(96, 96, 30, 16, color565(255, 0, 0))
    sleep(1)

    display.draw_ellipse(96, 256, 16, 30, color565(255, 255, 0))

    sleep(5)
    display.cleanup()
예제 #15
0
def test():
    """Test code."""
    print('Loading Espresso Dolce font...')
    espresso_dolce = XglcdFont('fonts/EspressoDolce18x24.c', 18, 24)
    print('Font loaded.')
    # Baud rate of 40000000 seems about the max
    spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))

    display = Display(spi,
                      dc=Pin(4),
                      cs=Pin(16),
                      rst=Pin(17),
                      width=240,
                      height=320,
                      rotation=0)
    display.draw_text(0, 0, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(0, 255, 255))
    display.draw_text(0,
                      319,
                      'Espresso Dolce 18x24',
                      espresso_dolce,
                      color565(255, 255, 0),
                      landscape=True)
    sleep(5)

    display = Display(spi,
                      dc=Pin(4),
                      cs=Pin(16),
                      rst=Pin(17),
                      width=320,
                      height=240,
                      rotation=90)
    display.draw_text(0, 215, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(255, 0, 255))
    display.draw_text(295,
                      239,
                      'Espresso Dolce 18x24',
                      espresso_dolce,
                      color565(255, 255, 255),
                      landscape=True)
    sleep(5)

    display = Display(spi,
                      dc=Pin(4),
                      cs=Pin(16),
                      rst=Pin(17),
                      width=240,
                      height=320,
                      rotation=180)
    display.draw_text(0, 0, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(0, 0, 255))
    display.draw_text(0,
                      319,
                      'Espresso Dolce 18x24',
                      espresso_dolce,
                      color565(255, 0, 0),
                      landscape=True)
    sleep(5)

    display = Display(spi,
                      dc=Pin(4),
                      cs=Pin(16),
                      rst=Pin(17),
                      width=320,
                      height=240,
                      rotation=270)
    display.draw_text(0, 215, 'Espresso Dolce 18x24', espresso_dolce,
                      color565(225, 0, 128))
    display.draw_text(295,
                      239,
                      'Espresso Dolce 18x24',
                      espresso_dolce,
                      color565(0, 255, 0),
                      landscape=True)
    sleep(5)
    display.cleanup()