gc.collect() import font import network, socket # DC - RS/DC data/command flag # CS - Chip Select, enable communication # RST/RES - Reset dc = Pin(4, Pin.OUT) cs = Pin(2, Pin.OUT) rst = Pin(5, Pin.OUT) # SPI Bus (CLK/MOSI/MISO) # check your port docs to see which Pins you can use spi = SPI(1, baudrate=8000000, polarity=1, phase=0) # TFT object, this is ST7735R green tab version tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=90) # init TFT tft.init() #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)
from tft import TFT_GREEN import time from urandom import * # setting TFT pings and init -------------- # DC - RS/DC data/command flag # CS - Chip Select, enable communication # RST/RES - Reset dc = Pin(5, Pin.OUT) cs = Pin(15, Pin.OUT) rst = Pin(0, Pin.OUT) # SPI Bus (CLK/MOSI/MISO) # check your port docs to see which Pins you can use spi = SPI(1, baudrate=8000000, polarity=1, phase=0) # TFT object, this is ST7735R green tab version tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=180) tft.init() # low level random generator -------------- def randrange(start, stop=None): if stop is None: stop = start start = 0 upper = stop - start bits = 0 pwr2 = 1 while upper > pwr2: pwr2 <<= 1 bits += 1
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))
# 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))
from tft import TFT_GREEN import time from urandom import * # setting TFT pings and init -------------- # DC - RS/DC data/command flag # CS - Chip Select, enable communication # RST/RES - Reset dc = Pin(5, Pin.OUT) cs = Pin(15, Pin.OUT) rst = Pin(0, Pin.OUT) # SPI Bus (CLK/MOSI/MISO) # check your port docs to see which Pins you can use spi = SPI(1, baudrate=8000000, polarity=1, phase=0) # TFT object, this is ST7735R green tab version tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=180) tft.init() # low level random generator -------------- def randrange(start, stop=None): if stop is None: stop = start start = 0 upper = stop - start bits = 0 pwr2 = 1 while upper > pwr2: pwr2 <<= 1 bits += 1 while True:
from tft import TFT_GREEN import time from urandom import * # setting TFT pings and init -------------- # DC - RS/DC data/command flag # CS - Chip Select, enable communication # RST/RES - Reset dc = Pin(5, Pin.OUT) cs = Pin(15, Pin.OUT) rst = Pin(0, Pin.OUT) # SPI Bus (CLK/MOSI/MISO) # check your port docs to see which Pins you can use spi = SPI(1, baudrate=8000000, polarity=1, phase=0) # TFT object, this is ST7735R green tab version tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=180) tft.init() buzzer = PWM(Pin(12, Pin.OUT), duty=500) def toot(): buzzer.duty(500) buzzer.freq(1000) time.sleep(.01) buzzer.duty(0) def ding(): buzzer.duty(500) buzzer.freq(500)
from machine import Pin, SPI, PWM from tft import TFT_GREEN _dc = Pin(4, Pin.OUT) _cs = Pin(15, Pin.OUT) _rst = Pin(2, Pin.OUT) _spi = SPI(1, baudrate=16000000, polarity=0, phase=0) TFT = TFT_GREEN(128, 160, _spi, _dc, _cs, _rst, rotate=90) display_led_pwm = PWM(Pin(5), freq=1000) from base import Buttons primary_button = Pin(16, Pin.IN | Pin.PULL_UP) buttons_watcher = Buttons([primary_button]) from base import ICTime ic_time = ICTime() from base import AlarmManager alarm_manager = AlarmManager() from base import Audio _audio_pin = Pin(12, Pin.OUT)
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):