Is there a way to simulate a #ifdef directive in PASM/SPIN?
cbmeeks
Posts: 634
in Propeller 1
One of the beauties of C/C++ compilers is the #ifdef directive.
What I would like to do is define certain longs like VSCL configs, etc. for different oscillator frequencies.
For example:
I *might* be able to simulate this behavior with Sublime Text using a custom build process. Perhaps dynamically generate a file and then load that into Propeller IDE.
I'm interested in knowing if anyone else has done something like this.
I'd rather not do a bunch of if/else statements in SPIN if I don't have to. It's not the end of the world but when you're counting bytes, everything matters. :-)
Thanks.
What I would like to do is define certain longs like VSCL configs, etc. for different oscillator frequencies.
For example:
#ifdef OSC6_25MHZ vscl_front_porch = 120 #endif #ifdef OSC5_00MHZ vscl_front_porch = 86 #endif
I *might* be able to simulate this behavior with Sublime Text using a custom build process. Perhaps dynamically generate a file and then load that into Propeller IDE.
I'm interested in knowing if anyone else has done something like this.
I'd rather not do a bunch of if/else statements in SPIN if I don't have to. It's not the end of the world but when you're counting bytes, everything matters. :-)
Thanks.
Comments
https://github.com/parallaxinc/OpenSpin/wiki/Preprocessor
Thanks for the tip!
By just switching that "Constants" object to reference another file, you can have access to a different bank of constants with identical names, but different values. It's not as flexible as #defines, but for Spin it's not bad, and it'll work in pasm or spin code.
J
Great idea. Thanks for sharing it.
If the driver is dynamic, then the computation can be used when changes are needed. For video, a good time to perform this is during the VBLANK, so that new parameters can take effect next frame.
Or it could be calculated in spin and stored in hub ram so the resolution could be updated on the fly.
So I just pre-compute the values and use it like:
I'm sorry, I misspoke. I actually use OpenSpin for compiling the source. But I use BST to upload to the propeller.
Is there a better way to upload/run from a batch file?
Thanks.
Thanks again.