Quazee137
 Guru
 Joined: 07/08/2016 Location: United StatesPosts: 600 |
| Posted: 07:32pm 04 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
What is the structure of the vartbl ?
I have been trying code snippets from TBS in 2014 on using FRAM. I can write/read/clear the chip with that code. The next part is using the VARTBL and this is as far as I have got.
showvar.bas
'The showvar code is gleamed from TassyJim short array code. Thanks again for helping me to some what understand things. 'I am still trying to figure out the rest of the table 'the init code is ripped from my quad tower controller test. 'What I am trying to do is copy the var functionality to FRAM's. 'my test chip is 8k by 8 and on the DS3231 RTC module and that is 4 times the flash space of the 170 'later I will try the larger FRAM 128K by 8. Thats a lota storage for the 28 pin Mite. Still reading pdf
'OPTION COLOURCODE ON 'OPTION DISPLAY 24,132 easier to see it all
Option base 1 Option EXPLICIT
Dim test(2,2,2,2,2,2,2) length 2 'data arrays Dim fn=100,r$(fn) length 1, f$(fn) length 1, d$(fn) length 4, s$(fn) length 4 Dim day$(fn) length 2 'runtime display vars Dim rn$(4) length 9,dd$(4) length 4, ds$(4) length 4, df$(4) length 1 Dim c,count(4),fsc 'touch Dim tx,ty,itx,ity,itx2,ity2,icx,icy,row,srow,col,penup=1,pendown=0 ' mis keyboard vars "testing wip they cant decide which one to use" Dim key$(45)=("1","2","3","4","5","6","7","8","9","0",".","q","w","e","r","t","y","u","i","o","p","*","a","s","d","f","g","h ","j","k","l",":","/","z","x","c","v","b","n","m","#","-","^","^"," ") length 1 Dim ar$(36)=("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21"," 22","23","00","05","10","15","20","25","30","35","40","45","50","55") Dim week$(35)=("Sun","Mon","Tue","Wed","Thr","Fri","Sat"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28") length 3 Dim dy,mdow$(7) =("SUN","MON","TUE","WED","THR","FRI","SAT") length 3 'relay hardware pins and vars Dim rstat(4) = (1,1,1,1) 'rstat stat 1=off 0=on Dim relay(4) = (10,9,7,6) 'relay pins Dim ry 'preset relays to off For ry=1 To 4 ' Pin(relay(ry)) = 1 ' SetPin relay(ry),dout,oc Next ry ' Flow switches Dim FW12 = 4, FW34 = 5, P26 = 26 'flow switch status 1 = off 0 = on ' SetPin FW12, din ' SetPin FW34, din ' SetPin p26, ain
'just throw some values in them tx=0:ty=8 itx=15:ity=16 itx2=63:ity2=64 icx=127:icy=128 row=5:srow=8:col=6
I2CScanner ' get a sub var test in here to show the locals here don't show
showvar ' but the ones here do End
Sub clr Print Chr$(27)+"[f" : Print Chr$(27)+"[2J" End Sub
Sub locate x,y Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f"; End Sub
'==================== Sub I2CScanner Local found, i, temp found=0 Print "I2C-Scanner from Adr. 8-119":Print:Print For i = &h08 To &h77 ' gueltige I2C-Adressen von 8-119 I2C open 100, 1000 ' i2c enable 100kHz, 1000ms timeout I2C read i, 0, 1, temp ' Print i;">"; MM.I2C " "; If MM.I2C = 0 Then Print:Print:Print "Found I2C-Address at "; i; " ("dec2hex$(i)+")" found=1 EndIf I2C close ' i2c disable Next i If found = 0 Then Print:Print:Print "NO I2C-Address found!" End Sub
Function dec2hex$(number) ' used by I2C-Scanner dec2hex$ = "&H"+ Hex$(number) End Function
Sub showvar Local g,n,p,ascii$,last=137
For g=0 To 63 'look through upto 64 variables ascii$="" For n = 0 To 31 p=Peek(VARTBL,n+g*64) If p=0 Then Exit For 'build variable name (end at chr$(0)) Select Case Chr$(p) Case "A" To "Z","0" To "9" ascii$=ascii$+Chr$(p) End Select Next n Print Str$(g,2);" ";ascii$;" ",
Print Hex$(Peek(VARTBL,32+g*64),2);" "; ' type 1 is number 2 is string not sure what anything else is Print Hex$(Peek(VARTBL,33+g*64),2);" "; ' level sub / func ???? Print Hex$(Peek(VARTBL,35+g*64),2);Hex$(Peek(VARTBL,34+g*64),2);" "; ' looks like 8 levels of dimensions Print Hex$(Peek(VARTBL,37+g*64),2);Hex$(Peek(VARTBL,36+g*64),2);" "; ' seems I can only use the 7 them ?? Print Hex$(Peek(VARTBL,39+g*64),2);Hex$(Peek(VARTBL,38+g*64),2);" "; Print Hex$(Peek(VARTBL,41+g*64),2);Hex$(Peek(VARTBL,40+g*64),2);" "; Print Hex$(Peek(VARTBL,43+g*64),2);Hex$(Peek(VARTBL,42+g*64),2);" "; Print Hex$(Peek(VARTBL,45+g*64),2);Hex$(Peek(VARTBL,44+g*64),2);" "; Print Hex$(Peek(VARTBL,47+g*64),2);Hex$(Peek(VARTBL,46+g*64),2);" "; Print Hex$(Peek(VARTBL,49+g*64),2);Hex$(Peek(VARTBL,48+g*64),2);" ";
Print Hex$(Peek(VARTBL,50+g*64),2);" "; ' size ??
For n=51 To 55 Print Hex$(Peek(VARTBL,n+g*64),2);" "; Next n Print " "; Print Hex$(Peek(VARTBL,59+g*64),2);Hex$(Peek(VARTBL,58+g*64),2); Print Hex$(Peek(VARTBL,57+g*64),2);Hex$(Peek(VARTBL,56+g*64),2);" ";' little e address and/or ???? For n=60 To 63 Print Hex$(Peek(VARTBL,n+g*64),2);" "; Next n Print If ascii$="LAST" Then Exit For Next g
Print "test ";Hex$(Peek(VARADDR test())) Print "fn ";Hex$(Peek(VARADDR fn)) Print "r$ ";Hex$(Peek(VARADDR r$())) Print "rstat ";Hex$(Peek(VARADDR rstat())) Print "relay ";Hex$(Peek(VARADDR relay())) Print "last ";Hex$(Peek(VARADDR last)) End Sub
The 170 is a great worker and with a large pool for r/w nonvolatile memory many things like having lib's stacked up in it and pulling in whats functions are needed at the time. Can extend the language with added customized functions.
No need to add new functions to the main MMBasic code. Have scratch pad ram area and move lib's in as needed. Then we can as a community create a very large library base of functions.
I will post my attempts as I get more information. As it is always good to have many eyes and minds go over ones code and thinking process.
Thanks to all that have added code here at TBS It really helps to see the back and forth of many and their ideas of how a piece code works.
Quazee
|