Last active
May 25, 2018 19:29
-
-
Save jhoughjr/790cc7bd39f1d8f5b10c10730cdbdd00 to your computer and use it in GitHub Desktop.
This file contains 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 settings | |
streams.serial() | |
print("Serial stream initialized") | |
print("Loading config...") | |
def flash_test(): | |
s = settings.load() | |
print(s) | |
flash_test() |
This file contains 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
Serial stream initialized | |
Loading config... | |
loading json... | |
reading flash file |
This file contains 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 json | |
import flash | |
import streams | |
def write(s): | |
print("writing flash file") | |
ff = flash.FlashFileStream(0x00310000,512) | |
ff.seek(0,streams.SEEK_SET) | |
# save length and json to flash | |
ff.write(len(s)) | |
ff.write(s) | |
ff.flush() | |
ff.seek(0,streams.SEEK_SET) | |
def read(): | |
ff = flash.FlashFileStream(0x00310000,512) | |
print("reading flash file") | |
n = ff.read_int() | |
print("length: " + str(int)) | |
ss = "" | |
for i in range(n+4): | |
s = ff[i] | |
ss += chr(s) | |
return ss | |
def load(): | |
print("loading json...") | |
r = read() | |
print("read " + r) | |
x = json.loads(r) | |
print("loaded " + x) | |
return x | |
def store(j): | |
print("dumping json...") | |
js = json.dumps(j) | |
print("writting string " + js) | |
write(js) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment