fastspin Basic RTC
Rsadeika
Posts: 3,837
in Propeller 1
I thought I would try to do some User I/O, I am using an RTC(DS1302) for this program.
First off I get the error shown below with the program as listed. Next thing I noticed is a lack of a facility for doing "CRLF". I was trying to use "13" and "10", but I did not get very far. I also noticed when using input$(), there is no way to have it work with CR as the end of the input request. The way it is now, if you have a varying size on the input string, it forces you to create multiple 'if … end if' lines of code with the input$() having to match your string input. More to come after I figure out how fix the below lines of code.
For the program below I want to be able to manually(user I/O) set the date and time, if it needs to be updated.
So far when I use any Optimization setting, for this program, it seems to be working as expected.
Ray
First off I get the error shown below with the program as listed. Next thing I noticed is a lack of a facility for doing "CRLF". I was trying to use "13" and "10", but I did not get very far. I also noticed when using input$(), there is no way to have it work with CR as the end of the input request. The way it is now, if you have a varying size on the input string, it forces you to create multiple 'if … end if' lines of code with the input$() having to match your string input. More to come after I figure out how fix the below lines of code.
For the program below I want to be able to manually(user I/O) set the date and time, if it needs to be updated.
So far when I use any Optimization setting, for this program, it seems to be working as expected.
Ray
|-DS1302_full.spin
|-FullDuplexSerial.spin
G:/fastspin/programs/test5/test5.bas(31) error: syntax error, unexpected end of line
child process exited abnormally
rem test5.bas ' ' April 23, 2019 ' dim rtc as class using "DS1302_full.spin" dim ser as class using "FullDuplexSerial.spin" dim day1 as byte dim month1 as byte dim year1 as byte dim dow1 as byte dim minutes as byte dim hour as byte dim seconds as byte dim dow dim inBuff as string rtc.init(10,11,9) waitcnt(getcnt() + 10_000_000) ' User I/O do print "> "; inBuff = input$(10) if inBuff = "dtime" then datetime() else if inBuff = "settime" dummy() else if inBuff = "setdate" dummy() else print "Do not understand!" end if ' pausems 3000 loop ' Subroutines and Funtions sub datetime rtc.readDate(@day1, @month1, @year1, @dow1) rtc.readTime(@hour,@minutes,@seconds) print month1;"/";day1;"/";"20";year1;" ";hour;":";minutes;":";seconds end sub sub dummy print "Empty" end sub
Comments
Are you talking about input or output? For output you can just do "print" with nothing else; that will output an end of line. For input, you can use CHR$ or ASC to try to match a character with a specific ASCII value.
Use just plain "input", like:
No Optimization - 13336 bytes
Default Optimization - 9136 bytes
Full Optimization - 8932 bytes
I would like to add in the CM2302 code, but using the Full Optimization option would probably trash the program, I think. I might have to try it just to see what happens.
Ray
The program below I added the CM2302 code.
No Optimization - 22636 bytes
Default Optimization - 15116 bytes Note: The values produced for the temperature are incorrect.
Full Optimization - 14436 bytes Note: The values produced for the temperature are incorrect.
As for including "FullDuplexSerial.spin", I really wanted to see how that was handled , in terms of program size. I will probably try pairing this up with a Raspberry Pi, using the COM, for remote access. The COM will be running in its own CPU, not sure how much program memory will be necessary for this.
Ray
Eric
I wonder, in this case, would some kind of modification of the Spin code would resolve the Optimization problem. But it sounds like it would be creating a whole new set of problems for other Spin objects that you would try to use with fastspin Basic, modifying Spin code objects to run with fastspin Basic.
Ray
dht22.StartDHTnn(2,22,@temp,@humid,@status)
The 2 is for the pin number, and the 22 is for the model number. I tried to do something like: The compiler came back with an error message. I also tried: The compiler did not like that either. Is there a way to have those two items up in the declarations. Or maybe because I am doing this with a user I/O, have some thing that the user types in the pin number and the model number.
Ray
What error messages did you get? Both of those approaches sound like they should work.
Since it seems to be float related, some dummy sensor values should be enough to give a simple fail-test case ?
Something weird is going on, this morning I tried the: and this morning it worked as expected. Is the Win 10 Pro messing around with the spin2gui program?
As for the DHTnn_Object.spin, to bad we don't have the C version for the dht22, which is in the simpletools lib, for comparison.
As for debugging, to find the optimization problem, I am not sure as to what I can do.
Ray
LOL, drat you Ray, now I have to clean the coffee spray off my laptop and work bench. If true that would be a new bug, even for Windows.
I hope that optimizer problem gets resolved, so I can move on with the program. At the moment if I add another Spin object, like the SD code, that will take me over the top, in the memory area.
Today, while I was trying out some different debugging things, like using the 'Full optimization' option I was getting: That almost sounds like a problem with the LMM, but I am not a developer, so I could be way off target.
Ray
Ray
Ray