Skip to content

Instantly share code, notes, and snippets.

View boochow's full-sized avatar
🏠
Working from home

boochow

🏠
Working from home
View GitHub Profile
from fbconsole import FBConsole
scr = FBConsole(fb, TFT.BLACK, TFT.WHITE)
import os
os.dupterm(scr)
tft.setvscroll(1, 1)
from ST7735fb import TFTfb
from petme128 import petme128
fb = TFTfb(tft, petme128)
from ST7735 import TFT
from machine import SPI,Pin
spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
tft=TFT(spi,16,17,18)
tft.initb2()
tft.rgb(True)
from ST7735 import TFT
from machine import SPI,Pin
import time
spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
tft=TFT(spi,16,17,18)
tft.initb2()
tft.rgb(True)
tft.setvscroll(17, 17)
tft.fill(TFT.BLACK)
tft.fillrect((0, 0), (128, 16), TFT.PURPLE)
import framebuf
import uio
class FBConsole(uio.IOBase):
def __init__(self, fb, bgcolor=0, fgcolor=-1, width=-1, height=-1, readobj=None):
self.readobj = readobj
self.fb = fb
if width > 0:
self.width=width
else:
import machine
import struct
import utime
I2C_2 = machine.I2C(2)
LSM6DSL_ADDR = 106
LSM6DSL_REG_CTRL1_XL = 0x10
LSM6DSL_REG_CTRL2_G = 0x11
>>> ht = HTS221(2)
>>> ht.get()
[73.21584, 36.9939]
>>> ht.getTemp()
36.9939
>>> ht.getHumi()
73.26691
>>>
>>> i2c = pyb.I2C(2, pyb.I2C.MASTER)
>>> i2c.scan()
[30, 41, 45, 86, 93, 95, 106]
>>>
>>> import pyb
>>> tim = pyb.Timer(1)
>>> tim.init(freq=10)
>>> tim.callback(lambda t:pyb.LED(1).toggle())
>>> tim.deinit()
>>>
import pyb, time
while(True):
pyb.LED(1).on()
time.sleep_ms(200)
pyb.LED(1).off()
time.sleep_ms(300)