Ejemplo n.º 1
0
    def touchscreen_press(self, x, y):
        """Process touchscreen press events."""
        if self.keyboard.handle_keypress(x, y, debug=False) is True:
            self.keyboard.locked = True
            pwd = self.keyboard.kb_text

            self.keyboard.show_message("Searching...", color565(0, 0, 255))
            try:
                hits = self.lookup(pwd)

                if hits:
                    # Password found
                    msg = "PASSWORD HITS: {0}".format(hits)
                    self.keyboard.show_message(msg, color565(255, 0, 0))
                else:
                    # Password not found
                    msg = "PASSWORD NOT FOUND"
                    self.keyboard.show_message(msg, color565(0, 255, 0))
            except Exception as e:
                if hasattr(e, 'message'):
                    self.keyboard.show_message(e.message[:22],
                                               color565(255, 255, 255))
                else:
                    self.keyboard.show_message(
                        str(e)[:22], color565(255, 255, 255))

            self.keyboard.waiting = True
            self.keyboard.locked = False
Ejemplo n.º 2
0
    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 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()
Ejemplo n.º 4
0
 def write_display(self):
     self.display.fill(ili9341.color565(255, 255, 255))
     self.display.fill_rectangle(2, 2, 236, 105,
                                 ili9341.color565(255, 0, 0))
     self.display.fill_rectangle(2, 109, 236, 105,
                                 ili9341.color565(0, 0, 255))
     self.display.fill_rectangle(2, 216, 236, 102,
                                 ili9341.color565(0, 0, 0))
Ejemplo n.º 5
0
 def hot_indication(self, on):
     if not on:
         self.display.fill_rectangle(2, 216, 236, 102,
                                     ili9341.color565(0, 255, 0))
         self.display.fill_rectangle(6, 220, 228, 94,
                                     ili9341.color565(0, 0, 0))
         self.write_level()
     else:
         self.display.fill_rectangle(2, 216, 236, 102,
                                     ili9341.color565(0, 0, 0))
         self.write_level()
Ejemplo n.º 6
0
 def write_data(self):
     txt = str(round(self.config['p']['hot'], 3))
     x = int(self.display.width / 2 - self.rgbt.len_pix(txt) / 2)
     self.display.fill_rectangle(2, 40, 236, 30,
                                 ili9341.color565(255, 0, 0))
     self.rgbt.text(txt, x, 40, background=ili9341.color565(255, 0, 0))
     txt = str(round(self.config['p']['cold'], 3))
     x = int(self.display.width / 2 - self.rgbt.len_pix(txt) / 2)
     self.display.fill_rectangle(2, 147, 236, 30,
                                 ili9341.color565(0, 0, 255))
     self.rgbt.text(txt, x, 147, background=ili9341.color565(0, 0, 255))
     self.write_level()
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()
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()
Ejemplo n.º 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))

    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()
Ejemplo n.º 11
0
 def __init__(self):
     #font_path = "/ArcadePix9x11.c"
     font_path = "/Unispace12x24.c"
     spi = machine.SPI(1,
                       baudrate=1000000,
                       miso=machine.Pin(19),
                       mosi=machine.Pin(23),
                       sck=machine.Pin(18))
     self.__display = ili9341.Display(spi,
                                      cs=machine.Pin(15),
                                      dc=machine.Pin(2),
                                      rst=machine.Pin(4),
                                      width=320,
                                      height=240,
                                      rotation=270)
     self.__color_white = ili9341.color565(255, 255, 255)
     self.__font_obj = XglcdFont(
         font_path, 12, 24
     )  #def __init__(self, path, width, height, start_letter=32, letter_count=96):
Ejemplo n.º 12
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))
Ejemplo n.º 13
0
#py-base 01studio
import ili9341
from machine import Pin, SPI

from xpt2046 import XPT2046
from time import sleep

##blk是背光引脚,可以默认悬空不接,其他引脚接上即可

#6个引脚
spi = SPI(miso=Pin(12), mosi=Pin(13, Pin.OUT), sck=Pin(14, Pin.OUT))  #240*320
#or add : scroll = True ->scroll 320*240
display = ili9341.ILI9341(spi, cs=Pin(15), dc=Pin(21), rst=Pin(33))
display.fill(ili9341.color565(0xff, 0x11, 0x22))
display.pixel(120, 160, 0)
##########################

#触摸 +2个引脚
#Y1-PEN-0
#Y2-CS2-2
pen = Pin(0, Pin.OUT)
pen.off()
cs2 = Pin(2, Pin.OUT)
cs2.off()

# spi = SPI(1, baudrate=1000000)
xpt = XPT2046(spi)  #上述描述=spi1的接线定义,但是为软串口,也可以替换为硬串口,都能用

while True:
    p = xpt.get_touch(raw=True)
    if p is not None:
Ejemplo n.º 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))

    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()
# Optionally create faster horizontal and vertical line drawing functions using
# the display's native filled rectangle function (which updates chunks of memory
# instead of pixel by pixel).
def fast_hline(x, y, width, color):
    display.fill_rectangle(x, y, width, 1, color)


def fast_vline(x, y, height, color):
    display.fill_rectangle(x, y, 1, height, color)


# Initialize the GFX library, giving it the display pixel function as its pixel
# drawing primitive command.  The hline and vline parameters specify optional
# optimized horizontal and vertical line drawing functions.  You can remove these
# to see how much slower the filled shape functions perform!
graphics = gfx.GFX(240, 320, display.pixel, hline=fast_hline, vline=fast_vline)

# Now loop forever drawing random lines.
display.fill(0)
while True:
    x0 = randrange(0, 240)
    y0 = randrange(0, 320)
    x1 = randrange(0, 240)
    y1 = randrange(0, 320)
    r = randrange(0, 255)
    g = randrange(0, 255)
    b = randrange(0, 255)
    graphics.line(x0, y0, x1, y1, ili9341.color565(r, g, b))
    time.sleep(0.01)
Ejemplo n.º 16
0
# On définit la taille de la zone : ici la totalité de l'écran
width = 240
height = 320

# On modifie les réglages de l'écran pour faire miroir
display._write(0x36, b'\x08')

t0 = ticks_ms()

display._write(0x2a, ustruct.pack(">HH", 0, width - 1))
display._write(0x2b, ustruct.pack(">HH", 0, height - 1))
display._write(0x2c)

filename = 'imageV.bmp'
BMP_file = open(filename, 'rb')

try:
    BMP_file.seek(54)  #On passe les 54 premiers octets
    for row in range(height):  # For each row
        for pixel in range(width):  # For each pixel in one row
            unpacked_data = ustruct.unpack(
                'BBB', BMP_file.read(3))  #Read RGB value of pixel
            r = unpacked_data[2]
            g = unpacked_data[1]
            b = unpacked_data[0]
            display._data(ustruct.pack(">H", ili9341.color565(r, g, b)))
    print(ticks_ms() - t0, "ms pour afficher une image")
finally:
    BMP_file.close()
Ejemplo n.º 17
0
    def get_field(self):
        # CONSTS
        square_num = 0
        err_margin = 0.15
        color = ili9341.color565(255, 255, 255)
        dict_of_values = {
            4.63: 1,
            3.67: 2,
            3: 3,
            2.47: 4,
            2: 5,
            1.56: 6,
            1.19: 7,
            0.87: 8,
            0.63: 9,
            5: 10
        }
        # CONSTS END

        # FONT
        font_path = "/Unispace12x24.c"
        unispace = XglcdFont(
            font_path, 12, 24
        )  #def __init__(self, path, width, height, start_letter=32, letter_count=96):
        # FONT END

        self.__display.draw_text(100, 100, "Wprowadz pole", unispace, color)

        # GET VOLTAGE FROM ONE OF THE MODULES
        while True:

            time.sleep_ms(10)

            voltage_val_1 = self.__module_1.read() * 5 / 4095
            voltage_val_2 = self.__module_2.read() * 5 / 4095
            print("Voltage_val_1: ", voltage_val_1, "Voltage_val_2: ",
                  voltage_val_2)

            if voltage_val_1 >= 0.1:
                voltage = voltage_val_1
                print("Voltage 1:  ", voltage)
                base = 0
                break
            if voltage_val_2 >= 0.1:
                voltage = voltage_val_2
                print("Voltage 1:  ", voltage)
                base = 10
                break

        # PICK SQUARE NUM ACCORDING TO VOLTAGE
        for key in dict_of_values:

            if abs(key - voltage) <= err_margin:
                square_num = dict_of_values[key]

        self.__display.draw_text(100, 100, "Pole odczytane", unispace, color)
        sleep(2)
        numer_pola = str(base + square_num)
        self.__display.draw_text(130, 130, numer_pola, unispace, color)
        sleep(3)

        return base + square_num
Ejemplo n.º 18
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()
Ejemplo n.º 19
0
 def clear_dashboard(self):
     '''
     Clear the dashboard area
     '''
     self.display.fill_rectangle(70, 80, 200, 100, color565(0,0,0))
Ejemplo n.º 20
0
 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))
Ejemplo n.º 21
0
 def write_level(self):
     txt = 'l=' + str(round(self.config['p']['l'], 1))
     x = int(self.display.width / 2 - self.rgbt.len_pix(txt) / 2)
     self.display.fill_rectangle(10, 260, 224, 30,
                                 ili9341.color565(0, 0, 0))
     self.rgbt.text(txt, x, 260)
Ejemplo n.º 22
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()
Ejemplo n.º 23
0
 def clear_reg(self):
     self.display.fill_rectangle(90, 50, 15, 8, ili9341.color565(255, 0, 0))
     self.display.fill_rectangle(90, 155, 15, 8,
                                 ili9341.color565(0, 0, 255))
def fast_vline(x, y, height, color):
    display.fill_rectangle(x, y, 1, height, color)


# Initialize the GFX library, giving it the display pixel function as its pixel
# drawing primitive command.  The hline and vline parameters specify optional
# optimized horizontal and vertical line drawing functions.  You can remove these
# to see how much slower the filled shape functions perform!
graphics = gfx.GFX(240, 320, display.pixel, hline=fast_hline, vline=fast_vline)

# Now loop forever drawing different primitives.
while True:
    # Clear screen and draw a red line.
    display.fill(0)
    graphics.line(0, 0, 239, 319, ili9341.color565(255, 0, 0))
    time.sleep(2)
    # Clear screen and draw a green rectangle.
    display.fill(0)
    graphics.rect(0, 0, 120, 160, ili9341.color565(0, 255, 0))
    time.sleep(2)
    # Clear screen and draw a filled green rectangle.
    display.fill(0)
    graphics.fill_rect(0, 0, 120, 160, ili9341.color565(0, 255, 0))
    time.sleep(2)
    # Clear screen and draw a blue circle.
    display.fill(0)
    graphics.circle(120, 160, 60, ili9341.color565(0, 0, 255))
    time.sleep(2)
    # Clear screen and draw a filled blue circle.
    display.fill(0)
Ejemplo n.º 25
0
LOG_OUT = False
LOG_FILE = 'debug.log'
CASE_LOG = 'cases.log'
DUMMY_DATA = '20200929,25335'

# URL = "https://covid19-japan-web-api.now.sh/api/v1/total"
URL = "https://covid19-japan-web-api.now.sh/api/v1/prefectures"

######################### Display Config #######################
import ili9341
spi = SPI(miso=Pin(19), mosi=Pin(23, Pin.OUT), sck=Pin(18, Pin.OUT))
display = ili9341.ILI9341(spi, cs=Pin(14), dc=Pin(27), rst=Pin(33))
Pin(32, Pin.OUT).on()   # back light pin

COLOR565_INACTIVE = ili9341.color565(0xF0, 0xF0, 0xF0)
COLOR565_ACTIVE = ili9341.color565(0x40, 0x40, 0x40)

TEXT_X = 160
TEXT_Y = 120

######################### Update behaviour #######################
TIMESTAMP_OFFSET = 3 # 3: hour, 4: min
SLEEP_LENGTH_sec = 1
is_time_set = False

######################### Button Config #######################
btnA = Pin(39, Pin.IN, Pin.PULL_UP)
btnB = Pin(38, Pin.IN, Pin.PULL_UP)
btnC = Pin(37, Pin.IN, Pin.PULL_UP)
Ejemplo n.º 26
0
import ili9341  # Import de la bibliothèque ili9341
from time import *  # Nécessaire pour mesurer les temps d'affichage
from machine import Pin, SPI  # Bibliothèque de gestion des entrées sorties

# Initialise la liaison SPI à une fréquence de 24Mhz avec 3 pins matériels dédiés PybStick26
spi = SPI(baudrate=24000000,
          miso=Pin("S21"),
          mosi=Pin("S19", Pin.OUT),
          sck=Pin("S23", Pin.OUT))
# Objet display basé sur la classe ILI9341 et initialisé avec le SPI et les deux derniers pins de notre montage
display = ili9341.ILI9341(spi, cs=Pin("S11"), dc=Pin("S5"), rst=Pin("S3"))

t0 = ticks_ms()
display.fill(ili9341.color565(0x00, 0x00, 0xff))
print(ticks_ms() - t0, "ms pour afficher une page bleue")
Ejemplo n.º 27
0
# MIT License; Copyright (c) 2017 Jeffrey N. Magee

from hwspi.hwspi import VSPI

from ili9341 import ILI9341, color565
from ili9341.fonts import tt14
from ili9341.fonts import glcdfont
from ili9341.fonts import tt14
from ili9341.fonts import tt24
from ili9341.fonts import tt32

fonts = [glcdfont, tt14, tt24, tt32]

text = 'Now is the time for all good men to come to the aid of the party.'

display = ILI9341(busid=VSPI, cs=22, dc=21, baudrate=60000000)

display.erase()
#display.set_pos(0, 0)
#for ff in fonts:
#    display.set_font(ff)
#    display.print(text)

display.fill_rectangle(0, 300, 240, 320, color=color565(200, 200, 200))
display.set_color(color565(0, 0, 0), color565(200, 200, 200))
display.set_font(tt14)
x_extra = display._font.get_width(' ')
x_tc1 = display.chars('TC1', 10, 302) + x_extra
x_tc2 = display.chars('TC2', 90, 302) + x_extra
x_tc3 = display.chars('TC3', 170, 302) + x_extra