This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from fbconsole import FBConsole | |
from rpi import RPiScreen | |
scr = FBConsole(RPiScreen(480,270)) | |
os.dupterm(scr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gpu | |
import framebuf | |
class RPiScreen(framebuf.FrameBuffer): | |
def __init__(self, width, height): | |
self.width = width | |
self.height = height | |
gpu.fb_init(width,height,screen_w=1920,screen_h=1080) | |
super().__init__(gpu.fb_data(),width,height,framebuf.RGB565) | |
self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def uint32(x): | |
if x & 0x8000000: | |
x = x - 0xffffffff - 1 | |
return x | |
def byte2pwm(b): | |
bits = "{:08b}".format(b) | |
data = 0 | |
for c in bits: | |
data = (data << 4) | (0b1000 if c == '0' else 0b1110) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from machine import Clock, PWM, Pin | |
import time | |
Clock(Clock.PWM, enable=False, source=Clock.OSC, divi=6, divf=0, mash=0) | |
Clock(Clock.PWM, enable=True) | |
# set PWM to serializer mode, inverted (1 = L, 0 = H), FIFO enabled | |
p0 = PWM(Pin(18), mode=PWM.MODE_SERIALIZER, active=0, tick_hz=3200000, duty_ticks=0, period=32, ms=PWM.MS_ENABLE, polarity=1, use_fifo=1, fifo_repeat=0) | |
p1 = PWM(1, active=0, period=32, use_fifo=1) # both two PWMs must be fifo enabled (chip bug?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pyb | |
>>> pyb.LED(1).on() | |
>>> pyb.LED(1).off() | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyb, time | |
while(True): | |
pyb.LED(1).on() | |
time.sleep_ms(200) | |
pyb.LED(1).off() | |
time.sleep_ms(300) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pyb | |
>>> tim = pyb.Timer(1) | |
>>> tim.init(freq=10) | |
>>> tim.callback(lambda t:pyb.LED(1).toggle()) | |
>>> tim.deinit() | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> i2c = pyb.I2C(2, pyb.I2C.MASTER) | |
>>> i2c.scan() | |
[30, 41, 45, 86, 93, 95, 106] | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> ht = HTS221(2) | |
>>> ht.get() | |
[73.21584, 36.9939] | |
>>> ht.getTemp() | |
36.9939 | |
>>> ht.getHumi() | |
73.26691 | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import struct | |
import utime | |
I2C_2 = machine.I2C(2) | |
LSM6DSL_ADDR = 106 | |
LSM6DSL_REG_CTRL1_XL = 0x10 | |
LSM6DSL_REG_CTRL2_G = 0x11 |