Possible to load a spin1 object in a spin2 top level object?
Getting started with the Prop2. I used the Prop1 extensively maybe 10 years ago, but this is a re-learn for me. Have read through the relevant documentation so far (I think), but I don't see any comments about how to load a spin1 object in a spin2 object (or at least a comment saying its not possible).
I'm trying to hook up a Parallax Ping Sonar to the Prop2, and I can only find a Prop1 Object for it in the Object Exchange. When I try to load it, I get "cannot find object ping.spin2" error.
If this is not possible, is there any "porting" guides that I can reference? I tried copying the Prop1 version of the Ping object as a Spin2 file, but it looks like there is an error regarding waitpne
Thanks!
Comments
The simple answer is no -- unless your object uses very simple Spin and every method has parameters. In Spin2, methods w/o parameters must have empty parenthesis, and all return values must be declared. I've attached my Spin2 object for the P2 to get you started.
It's always going to be a game of catch-up comparing the P2 to the P1. In the P1, Spin was fixed and embedded in the silicon. This is not the case with Spin2; the interpreter is downloaded with the compiled program -- what these means is that Chip can (and does) add features to Spin2. There are plenty of us who've ported lots of P1 code to the P2, so ask questions. It won't take long for you to get the hang of the P2 and enjoy the great new features.
This is an old thread but the little python utility I wrote might help
-- https://forums.parallax.com/discussion/174523/from-spin1-to-spin2#latest
This is the latest I found on my computer
There's also FlexProp, which does let you compile Spin1 for P2 (and mix & match Spin1 and Spin2). However, it cannot translate assembly language from P1 ASM to P2 ASM, so you'll still need to do some porting.
Awesome answers, thanks so much!
@JonnyMac Digging through your ping driver code a bit. Trying to make sure I understand what's going on.
I believe the code:
is designed to take advantage of the SmartPin modes available on the Propeller 2? But technically similiar logic could be done like in the Propeller 1 object:
Is this just a design choice to use the SmartPin mode, or is there performance improvements because of your method?
If this is better to post in a different thread let me know.
You're misreading the P2 code and your P1 code won't work -- you're mixing P2 things into it. This is the P1 equivalent of what my P2 code is doing -- without the ability to return as soon as the pulse is done.
Note that I write code that goes into products that my employer sells, so I have greater restraints than the Parallax demo code has. For example, I'm not using waitpeq or waitpne. Why? Because a broken wire or sensor could cause the code to hang forever; there is no escaping waitpxx without a state change.
You should limit your threads to a single topic.