# Simple test of primitive drawing with ILI9341 TFT display.
# This is made to work with ESP8266 MicroPython and the TFT FeatherWing, but
# adjust the SPI and display initialization at the start to change boards.
# Author: Tony DiCola
# License: MIT License (https://opensource.org/licenses/MIT)
import time
import gfx
import ili9341
import machine

# Setup hardware SPI at 32mhz on ESP8266 MicroPython.
spi = machine.SPI(1, baudrate=32000000)

# Setup ILI9341 display using TFT FeatherWing pinout for CS & DC pins.
display = ili9341.ILI9341(spi, cs=machine.Pin(0), dc=machine.Pin(15))


# 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
예제 #2
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")
예제 #3
0
        self.last_audio.play()

    def stop(self):
        if self.last_audio:
            self.last_audio.stop()

    def mute(self, value=True):
        self.mute_pin.value = not value


dc = digitalio.DigitalInOut(board.D10)
cs = digitalio.DigitalInOut(board.D9)
cs.switch_to_output(value=True)
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

display = ili9341.ILI9341(spi, dc, cs, 0)

backlight = pulseio.PWMOut(board.D11)
backlight.duty_cycle = 2**14

# buttons = gamepad.GamePad(
#     digitalio.DigitalInOut(board.X),
#     digitalio.DigitalInOut(board.DOWN),
#     digitalio.DigitalInOut(board.LEFT),
#     digitalio.DigitalInOut(board.RIGHT),
#     digitalio.DigitalInOut(board.UP),
#     digitalio.DigitalInOut(board.O),
# )

buttons = gamepad.GamePad(digitalio.DigitalInOut(board.D8), spi)
예제 #4
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:
예제 #5
0
import ili9341
from machine import Pin, SPI
spi = SPI(1, baudrate=40000000, polarity=0, phase=0)
display = ili9341.ILI9341(spi,
                          cs=Pin(15),
                          dc=Pin(16),
                          rst=None,
                          width=320,
                          height=240)
import ili9341_fb
fb = ili9341_fb.Ili9341Framebuffer(display)
import ps2
ps2.init(clock=5, data=0)
from fbconsole import FBConsole
console = FBConsole(fb)
import os
os.dupterm(console)


def cls():
    console.cls()


def on():
    console.on()


def off():
    console.off()
예제 #6
0
 def __init__(self, config):
     spi = SPI(1, baudrate=32000000)
     self.display = ili9341.ILI9341(spi, cs=Pin(15), dc=Pin(2), rst=Pin(16))
     self.config = config
     self.rgbt = rgb_text.rgbtext(self.display)
예제 #7
0
from machine import Pin
from widgets import TextArea
from widgets import Graph

# use VSPI (ID=2) at 80mhz
spi = machine.SPI(
    2,
    baudrate=32000000,
    mosi=Pin(23, Pin.OUT),  # mosi = 23
    miso=Pin(25, Pin.IN),  # miso = 25
    sck=Pin(19, Pin.OUT))  # sclk = 19

display = ili9341.ILI9341(
    spi,
    cs=Pin(22, Pin.OUT),  # cs   = 22
    dc=Pin(21, Pin.OUT),  # dc   = 21
    rst=Pin(18, Pin.OUT),  # rst  = 18
    width=240,
    height=320)

# turn on the backlight
bl = Pin(5, Pin.OUT)
bl.value(0)


def graph():
    random.seed(time.ticks_cpu() * time.ticks_us())
    graph = Graph(display, 30, 24, x=10, y=50, bg=0, fg=colors.RGB_YELLOW)
    graph.point(10)
    for i in range(50):
        v = random.randint(0, 10)
예제 #8
0
import ntptime

import gc

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)
# MADCTL values
MADCTL_MY = 0X80
MADCTL_MX = 0X40
MADCTL_MV = 0X20
MADCTL_ML = 0X10
MADCTL_RGB = 0X00
MADCTL_BGR = 0X08
MADCTL_MH = 0X04

cs = digitalio.DigitalInOut(board.D2)
dc = digitalio.DigitalInOut(board.D7)

spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# Setup ILI9341 display using TFT FeatherWing pinout for CS & DC pins.
display = ili9341.ILI9341(spi, cs=cs, dc=dc)

display.newWidth(240)
display.newHeight(320)

gfx = GFX.GFX(240,
              320,
              pixel=display.pixel,
              font_name=ariali12pt7b,
              dispobj=display,
              newWidth=display.newWidth,
              newHeight=display.newHeight)


def testText():
    gfx.setFill(BLACK)