Skip to content

Instantly share code, notes, and snippets.

@jhoughjr
Last active May 25, 2018 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhoughjr/790cc7bd39f1d8f5b10c10730cdbdd00 to your computer and use it in GitHub Desktop.
Save jhoughjr/790cc7bd39f1d8f5b10c10730cdbdd00 to your computer and use it in GitHub Desktop.
import settings
streams.serial()
print("Serial stream initialized")
print("Loading config...")
def flash_test():
s = settings.load()
print(s)
flash_test()
Serial stream initialized
Loading config...
loading json...
reading flash file
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