예제 #1
0
        tft.rect(115,h,3,6,tft.rgbcolor(255,255,0))
        tft.rect(118,h+2,2,6,tft.rgbcolor(255,255,0))
        tft.rect(120,h,3,6,tft.rgbcolor(255,255,0))
        h-=10


# game parameter initialize
end=False
Bx0=60;Bx1=60;By=150
Cx=-10;Cy=-10
Rx0=60;Rx1=0;Ry=0
Mx=-10;My=170
dx=3
life=5

tft.clear(tft.rgbcolor(0, 0, 0))
tft.line(112, 0, 112, 160,tft.rgbcolor(255,255,255))
plotYelloHeart(life)

while True:
    
    key=getKey(adc.read())
    # normal condition    
    if end == False:
        # move My tank
        if key=="l" and Bx1>0  :Bx1-=3
        if key=="r" and Bx1<100 :Bx1+=3
        plotBluTank(Bx0,Bx1,By)
        Bx0=Bx1
        
        # fire Cyan bullet 
예제 #2
0
# MicroPython ST7735 TFT display driver example usage

from machine import Pin, SPI
from tft import TFT_GREEN

# DC       - RS/DC data/command flag
# CS       - Chip Select, enable communication
# RST/RES  - Reset
dc = Pin('GP3', Pin.OUT, Pin.PULL_DOWN)
cs = Pin('GP7', Pin.OUT, Pin.PULL_DOWN)
rst = Pin('GP4', Pin.OUT, Pin.PULL_DOWN)

# SPI Bus (CLK/MOSI/MISO)
# check your port docs to see which Pins you can use
spi = SPI(0, mode=SPI.MASTER, baudrate=8000000, polarity=1, phase=0)

# TFT object, this is ST7735R green tab version
tft = TFT_GREEN(128, 160, spi, dc, cs, rst)

# init TFT
tft.init()

# start using the driver
tft.clear(tft.rgbcolor(255, 0, 0))
예제 #3
0
#Network
sta = network.WLAN(network.STA_IF)
ap = network.WLAN(network.AP_IF)
sta.active(True)
sta.connect("YOUR_SSID_HERE", "YOUR_PASSWORD_HERE")
while not sta.isconnected():
    pass
print(sta.ifconfig())
ap.active(False)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
addr = socket.getaddrinfo("0.0.0.0", 23)[0][-1]
s.bind(addr)
s.listen(1)

tft.clear(tft.rgbcolor(0, 0, 0))  #b, g, r
tft.text(0, 0, "Test", font.terminalfont, tft.rgbcolor(255, 255, 255), 2)
r, a = s.accept()
tft.text(0, 0, "Test", font.terminalfont, tft.rgbcolor(0, 0, 0), 2)
old = " "
while True:
    d = r.recv(1024).decode("utf-8")
    if d[0:8] == "rotation":
        ro = int(d[9:12])
        tft.changeRotate(ro)
        continue
    print(d)
    tft.text(0, 0, old, font.terminalfont, tft.rgbcolor(0, 0, 0), 2)
    tft.text(0, 0, d, font.terminalfont, tft.rgbcolor(255, 255, 255), 2)
    old = d
예제 #4
0
from machine import Pin, SPI, reset
from tft import TFT_GREEN
# DC       - RS/DC data/command flag
# CS       - Chip Select, enable communication
# RST/RES  - Reset
dc = Pin(5, Pin.OUT)
cs = Pin(2, Pin.OUT)
rst = Pin(15, Pin.OUT)

# SPI Bus (CLK/MOSI/MISO)
# check your port docs to see which Pins you can use
spi = SPI(1,
          baudrate=60000000,
          polarity=1,
          phase=0,
          sck=Pin(14),
          mosi=Pin(13),
          miso=Pin(12))

# TFT object, this is ST7735R green tab version
tft = TFT_GREEN(128, 160, spi, dc, cs, rst)
tft.init()
while Thread[0]:
    # start using the driver
    tft.clear(tft.rgbcolor(0, 0, 0))
    print(111)
    tft.pixel(0, 0, tft.rgbcolor(0, 155, 255))
예제 #5
0
# MicroPython ST7735 TFT display driver example usage

from machine import Pin, SPI
from tft import TFT_GREEN

# DC       - RS/DC data/command flag
# CS       - Chip Select, enable communication
# RST/RES  - Reset
dc  = Pin('GP3', Pin.OUT, Pin.PULL_DOWN)
cs  = Pin('GP7', Pin.OUT, Pin.PULL_DOWN)
rst = Pin('GP4', Pin.OUT, Pin.PULL_DOWN)

# SPI Bus (CLK/MOSI/MISO)
# check your port docs to see which Pins you can use
spi = SPI(0, mode=SPI.MASTER, baudrate=8000000, polarity=1, phase=0)

# TFT object, this is ST7735R green tab version
tft = TFT_GREEN(128, 160, spi, dc, cs, rst)

# init TFT
tft.init()

# start using the driver
tft.clear(tft.rgbcolor(255, 0, 0))
예제 #6
0
#def plotYelloHeart(n):
#    h=150
#    tft.rect(113,0,15,160,tft.rgbcolor(0,0,0))
#    for i in range(n):
#        tft.rect(115,h,3,6,tft.rgbcolor(255,255,0))
#        tft.rect(118,h+2,2,6,tft.rgbcolor(255,255,0))
#        tft.rect(120,h,3,6,tft.rgbcolor(255,255,0))
#        h-=10

life=3


# game parameter initialize
end=False

tft.clear(tft.rgbcolor(0, 0, 0))
tft.line(112, 0, 112, 160,tft.rgbcolor(255,255,255))
#plotYelloHeart(life)

direction="d"
snake=[[1,1],[1,2],[1,3],[1,4],[1,5]]
dt=.4
plotSnake(snake)

food = [10,10]
plotTile(food[0],food[1],tft.rgbcolor(255,0,0))
    
while True:
    v=adc.read()
    key=getKey(v)
    print(key)
예제 #7
0
    for _ in range(n):
        tft.rect(115, h, 3, 6, tft.rgbcolor(255, 255, 0))
        tft.rect(118, h + 2, 2, 6, tft.rgbcolor(255, 255, 0))
        tft.rect(120, h, 3, 6, tft.rgbcolor(255, 255, 0))
        h -= 10


# game parameter initialize
end = False
x0 = 50
x1 = 50
bx = 10
by0 = 0
by1 = 0

tft.clear(tft.rgbcolor(0, 0, 0))
#tft.line(112, 0, 112, 160,tft.rgbcolor(255,255,255))
life = 0
#plotYelloHeart(life)
while True:
    key = getKey(adc.read())
    # normal condition
    if end == False:
        if key == "l" and x1 > 0:
            x1 -= 5
            toot()
        elif key == "r" and x1 < 120:
            x1 += 5
            toot()
        plotRedCar(x0, x1)
        x0 = x1
print("SCREEN BENCHMARK by https://github.com/rakovskij-stanislav\n"
      "It helps to look at perfomance differences)\n"
      "This test is suitable for each display (TFT, OLED, LED matrix)\n"
      "that has at least 64x64 pixels")

# 1 - YOUR MODULE PREPARATION SCENE
from tft import TFT_GREEN
from machine import Pin, SPI, reset
dc = Pin(5, Pin.OUT)
cs = Pin(4, Pin.OUT)
rst = Pin(15, Pin.OUT)
spi = SPI(1, baudrate=8000000, polarity=1, phase=0)
t = TFT_GREEN(128, 128, spi, dc, cs, rst)
t.init()
t.clear(t.rgbcolor(255, 255, 255))
## 1 - END

# 2 - SET UNIVERSAL PARAMETERS FOR BENCHMARK
# You should remake this defs for your screen class


def line(x1, y1, x2, y2, r, g, b):
    # draw the line
    t.line(x1, y1, x2, y2, t.rgbcolor(r, g, b))


def fill_screen(r=255, g=255, b=255):
    t.clear(t.rgbcolor(r, g, b))


def invert(state):