# cPy - testing Fram MB85RS64 emulator and FS
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-01-28  initial release

import  os;                 os.system('clear')
from	ve_fram_emu	import	MB85RS64	as	Fram
from	ve_fram_fs	import	FramFs

# ======================= main =========================
    
def main():
    fram = Fram(spi=None, cs=None)
    fs   = FramFs(fram)
    fs.erase()
    # fs.write('A1', 'hello')
    # fs.write('A2', '12345')
    # fs.write('A3', 'Hello world')
    # fs.write('A4', '0123456789')
    # print(fs.read('A1'))
    # print(fs.read('A2'))
    # print(fs.read('A3'))
    # print(fs.read('A4'))
#     fs.dump(0x0000, 0x0040);	print()
#     fs.dump(0x0400, 0x0440);	print()
    # fs.printLs();    			print()
    # print(fs.ls())
    # fs.delete('A2')
    # fs.printLs();    			print()
    # print(fs.ls())
    # fs.defragment()
    # fs.printLs();    			print()
    # print(fs.ls())
    # fs.dump()
    # fs.dump(0x0000, 0x0040);	print()
    # fs.dump(0x0400, 0x0440);	print()
#     fs.printLs();				print()
#     print(fs.ls());				print()
    
#     print(fs.read('A1'))
#     print(fs.read('A3'))
#     print(fs.read('A4'))

    file1 = 'line1\nline2\nline3'
    fs.write('file1.txt', file1)
    print(fs.read('file1.txt'))

    file2 = '''
line 10
line 20
line 33'''
    fs.write('file2.txt', file2)
    print(fs.read('file2.txt'))

    d = dict(key1=123, key2='hello', key3=3.14, key4=[1,2,3,4,5])
    fs.write('A5', d)
    print(fs.read('A5'))
    # fram.save()    


main()

# ======================== End ==========================
