Quazee137
 Guru
 Joined: 07/08/2016 Location: United StatesPosts: 600 |
| Posted: 10:30pm 03 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Here's and update to where Im at with this the basic idea
VARF "s","v1 w x$ y() z$()" Print or test vs VARF "r" restore if "r","w z$()" then selective restore Print "varf status ";vs VARF "c" if vs then Print "error ";vs -------------------------------
Sub VARF op$,myvar$ 'test op$ for s,r,c 'extract var names from myvar$ ? I think only global vars are safe 'find in vartable 's=copy to FRAM vname,vsize,vdata 'r=copy from FRAM vdata 'c=clear FRAM '0 no error 'if any errors save in vs End Sub
learning the vartable
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
Can any one help with the vartable structure.
Thanks Quazee
|
Quazee137
 Guru
 Joined: 07/08/2016 Location: United StatesPosts: 600 |
| Posted: 03:16am 06 Jul 2018 |
Copy link to clipboard |
 Print this post |
|
OK here is the first part of my adventure with the FRAM
Getting the variable names passed to function
Print "1st part testing of varf concept " Print " This part extracts the variable names to be use in the 2nd part." Print " This is raw not cleaned up, just working concept" Print " Code segments are from code by TassyJim, twofingers, Centrex" Print " And many others on TBS. Thanks to every one!" Print
Dim x As integer 'Im cheating here. As type is in the vartable already so no need to use ' or parse it here. But! may be better for code documentation if it is. ' could just strip them out before hand.
x= VARFS("a1,b,c,d4,e5,cats,z33,apples,b3,j,tbs,k")
Print x ' V x=VARFS("a1,b,c,d4,e5,c-ats,z33,apples,b3,j,tbs,k") Print x ' V x=VARFS("a1,b,c,d4,e5,cats,z33,{apples,b3,j,tbs,k")
Print x ' V x= VARFS("a1,b,c?,d4,e5,cats,z33,apples,b3,j,tbs,k")
Print x ' V x=VARFS("a1,b,c,d4,e5,cats,z33,apples,b3,9j,tbs,k")
Print x ' V V x=VARFS("a1,b,c,d4,e5,cats,z33,apples,b,j,tbs,k")
Print x
Print varfs("A,big,THANKS,to,all,at,the,back,shed")
Print "-----------------------------------------"
Function VARFS(a$) Local INTEGER z,n,m,e
a$=UCase$(a$) ' the names in vartable are UPPER CASED e=0 For z=1 To Len(a$) If Mid$(a$,z,1)="," Then z=z+1 If Mid$(a$,z,1)< "0" Then e=1 If Mid$(a$,z,1)> "Z" Then e=2 If Mid$(a$,z,1)> "9" And Mid$(a$,z,1)<"A" Then e=3 Next z
If e<>0 Then VARFS=e Exit Function End If
On ERROR SKIP 1' if SP$ doesn't exist, next line will cause an error Erase SP$ z=1:n=0 Do 'count instances of delimiter for DIM SP$() z=Instr(z,a$,",") If z=0 Then Exit Do End If n=n+1:z=z+1 Loop
m=n+1:n=1 Dim SP$(m)
Do z=Instr(1,a$,",") If z=0 Then SP$(m)=a$:Exit Do SP$(n)=Left$(a$,z-1):a$=Mid$(a$,z+1)
e=Instr(1,"0123456789",Left$(sp$(n),1)) ' can't start with number
If e<>0 Then VARFS=4 Exit Function End If n=n+1 Loop
For z=1 To m ' all var names are exclusve. For n=1 To m If z=n Then Exit For If sp$(n)=sp$(z) Then e=5 Next n Next z
If e<>0 Then VARFS=e Exit Function End If
'testing to show sp$() For z=1 To m Print sp$(z);" "; Next z Print
End Function
Working on a fram hex editor for testing and playing with the vartable dump test.
I have 8K,32K and 64K byte chips on RTC modules the 128K is on the way.
|