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
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
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
import gpu, framebuf | |
gpu.fb_init(240, 135, screen_w=1920, screen_h=1080) | |
fb = framebuf.FrameBuffer(gpu.fb_data(), 240, 135, framebuf.RGB565) | |
fb.fill_rect(0,0,240,135,0) | |
minX = -2.0 | |
maxX = 1.0 | |
width = 240 | |
height = 135 | |
aspectRatio = 1.0 |
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, utime | |
log = [] | |
def add_log(t): | |
global log | |
log.append((utime.ticks_us() & 0xffffffff) + 1000 - t.compare_register()) | |
times = 1000 | |
tim = machine.Timer(3) | |
tim.init(period=1000,mode=tim.PERIODIC,callback=lambda t:add_log(t)) |
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 Pin,Timer | |
led = Pin(47) | |
led.init(led.OUT) | |
def led_toggle(t): | |
global led | |
led.value(1 - led.value()) | |
tim = Timer(3) | |
tim.init(period=500000,mode=tim.PERIODIC,callback=lambda t:led_toggle(t)) |
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
typedef enum _timer_mode_t { | |
ONE_SHOT = 0, | |
PERIODIC = 1, | |
} timer_mode_t; | |
typedef struct _machine_timer_obj_t { | |
mp_obj_base_t base; | |
uint32_t id; | |
uint32_t period; | |
timer_mode_t mode; |
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 | |
counter = 0 | |
def inc_ctr(t): | |
global counter | |
counter += 1 | |
print(t) | |
t = machine.Timer(0) | |
t.init(period=1000000,mode=t.PERIODIC,callback=lambda t:inc_ctr(t)) |