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
class RAMBlockDev: | |
def __init__(self, block_size, num_blocks): | |
self.block_size = block_size | |
self.data = bytearray(block_size * num_blocks) | |
def readblocks(self, block_num, buf): | |
for i in range(len(buf)): | |
buf[i] = self.data[block_num * self.block_size + i] | |
def writeblocks(self, block_num, buf): |
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 time | |
def performanceTest(): | |
millis = time.ticks_ms | |
endTime = millis() + 10000 | |
count = 0 | |
while millis() < endTime: | |
count += 1 | |
print("Count: ", count) |
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
class RAMBlockDev: | |
def __init__(self, block_size, num_blocks): | |
self.block_size = block_size | |
self.data = bytearray(block_size * num_blocks) | |
def readblocks(self, block_num, buf): | |
for i in range(len(buf)): | |
buf[i] = self.data[block_num * self.block_size + i] | |
def writeblocks(self, block_num, buf): |
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
if (sd_init() == SD_OK) { | |
unsigned char buf[1024]; | |
if (sd_readblock(0, buf, 1)) { | |
for (int i = 0; i < 512; i++) { | |
if (i % 16 == 0) { | |
printf("%04x:", i); | |
} | |
printf("%02x ", buf[i]); | |
if ((i + 1) % 16 == 0) { | |
printf("\n\r"); |
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
sd = SD() | |
os.mount(sd, '/sd') | |
os.chdir('sd') | |
import gpu, framebuf | |
gpu.fb_init(320, 240, screen_w=1920, screen_h=1080) | |
fb = framebuf.FrameBuffer(gpu.fb_data(), 320, 240, framebuf.RGB565) | |
fb.fill_rect(0, 0, 320, 240, 0) | |
f = open('test1.raw', 'rb') |
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 write_data(self, buf): | |
self.temp[0] = self.addr << 1 | |
self.temp[1] = 0x40 # Co=0, D/C#=1 | |
self.i2c.start() | |
self.i2c.write(self.temp) | |
self.i2c.write(buf) | |
self.i2c.stop() |
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 write_data(self, buf): | |
self.i2c.writeto(self.addr, bytearray([0x40]), False) | |
self.i2c.writeto(self.addr, buf) |
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 decimal2num(b): | |
return ((b & 0xf) + 10 * (b >> 4)) | |
def num2decimal(d): | |
return (d % 10) | (d // 10) << 4 | |
def hour_value(b): | |
result = decimal2num(b & 0x1f) | |
if (b & 0x20): | |
result += 12 |
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 Timer,I2C | |
i2c = I2C(1) | |
i2c.init() | |
d = SSD1306_I2C(128,64,i2c) | |
c = DS3231(i2c) | |
c.write([2018, 5, 30, 23, 30, 45, 3]) | |
day = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] |
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 | |
sd = machine.SD() | |
import os | |
os.mount(sd, '/sd') | |
os.chdir('sd') |