23 Star 47 Fork 2

Gitee 极速下载/micropython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/micropython/micropython/
克隆/下载
pyb.py 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
# pyboard testing functions for CPython
import time
def delay(n):
# time.sleep(float(n) / 1000)
pass
rand_seed = 1
def rng():
global rand_seed
# for these choice of numbers, see P L'Ecuyer, "Tables of linear congruential generators of different sizes and good lattice structure"
rand_seed = (rand_seed * 653276) % 8388593
return rand_seed
# LCD testing object for PC
# uses double buffering
class LCD:
def __init__(self, port):
self.width = 128
self.height = 32
self.buf1 = [[0 for x in range(self.width)] for y in range(self.height)]
self.buf2 = [[0 for x in range(self.width)] for y in range(self.height)]
def light(self, value):
pass
def fill(self, value):
for y in range(self.height):
for x in range(self.width):
self.buf1[y][x] = self.buf2[y][x] = value
def show(self):
print("") # blank line to separate frames
for y in range(self.height):
for x in range(self.width):
self.buf1[y][x] = self.buf2[y][x]
for y in range(self.height):
row = "".join(["*" if self.buf1[y][x] else " " for x in range(self.width)])
print(row)
def get(self, x, y):
if 0 <= x < self.width and 0 <= y < self.height:
return self.buf1[y][x]
else:
return 0
def pixel(self, x, y, value):
if 0 <= x < self.width and 0 <= y < self.height:
self.buf2[y][x] = value
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/micropython.git
git@gitee.com:mirrors/micropython.git
mirrors
micropython
micropython
master

搜索帮助