Ejemplo n.º 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 
Ejemplo n.º 2
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
Ejemplo n.º 3
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))
Ejemplo n.º 4
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))
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):