In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Bond wrote:
[3][/3]
[3]Hi Guys[/3]
[3][/3]
[3]I'm becoming quite impressed with SXB2.0 as I use it more. I am also aware that there are features that give us users vastly more power to customise our code. Maybe by sharing our ideas, we can get even more out. [/3]
[3] [/3]
[3]Imagine just enabling large chunks of SXB code with just a single keystroke...[/3]
[3]What about having single simple commands for motors, RTclocks, buffered UARTs and LCDs...[/3]
[3]Imagine writing the bulk of your code in minutes then being able to concentrate on the exciting new stuff...[/3]
[3] [/3]
[3]Dream on, dream on![/3]
[3] [/3]
[3]Well, various of the more experienced SX geeks have been moving in this direction. Bean included some compiling directives in SXB2.0 and Peter Verkaik posted an interesting program to exploit these features. I am not sure that we have got our heads round the incredible power of some of the new features on SXB2.0. Unfortunately, a lot of the stuff I've seen so far has been too complex for me to use. I want a simple programming template, a vast array of new commands and features and some automatic optimisation of the code. (Don't tell me, I should be programming the Propeller!). [/3]
[3] [/3]
[3]What about using the LOAD and INC commands with conditional compiling (like PVK did) but hide it under the hood and keep the template clean? What about borrowing the multi-file approach used in "C" to simplify the process?[/3]
[3] [/3]
[3]I have attached an example of how I think the template and files may look. [/3]
[3] [/3]
[3]1. The idea is to keep the MAIN program template as simple clean and uncluttered as possible. Re-useable and robust code is stored as a component and automatically loaded - only when needed (you don't need to copy and paste code each time you need common code)[/3]
[3]2. Each project has the main program, three Header files and a folder called "Components" that stores the files of reusable code[/3]
[3]3. All application specific code (code used by the current project only) is placed in this "Main Program" template. Code that is often re-used in other different programs is added as a component (file). This template will LOAD the code when it is activated in "Software_Comp.sxb" file. [/3]
[3]4. Once you've built the hardware, comment out or delete the code that is not used in the "Software_Comp.sxb" file. This will automatically optimise the subroutines and reduce the program size. You then update the files "Device_XXX.sxb" and "IO_Setup.sxb" files to suite your current project.[/3]
[3]5. You only have to disable a component in the "Software_Comp.sxb" to remove the code. You don't have to remove any of the LOAD instructions from this or any other file. [/3]
[3]6. When adding a re-useable component, you need to add it to this template, create the suitable "Components\XXX_XXX.sxb" file and add it to some or all of the following. "Software_Comp.sxb "CONs&VARs.SXB", "Components\DeclareSubs.sxb "Components\Start-Up_LCD.sxb". Try where practical to write the re-useable code as a SUB, FUNC or TASK [/3]
[3] [/3]
[3]Enables reusable software - "Software_Comp.sxb"[/3]
[3]Device (MCU) directives - "Device_XXXX.sxb"[/3]
[3]I/O assignment - "IO_Setup.sxb"[/3]
[3]CONs & VARs for components - "CONs&VARs.SXB"[/3]
[3]Declaring subs used - "DeclareSubs.sxb"[/3]
[3]Interrupt Code - "Interrupts.sxb" - see my comments below[/3]
[3]Individual interrupt code - "Components\Interupt_XXXXX.sxb"[/3]
[3]Startup code - "Components\Start-Up_XXXX.sxb"[/3]
[3]SUBs, FUNCs AND TASKs - "Components\Subs_XXXXX.sxb"[/3]
[3]DATA, WDATA AND CDATA - "Components\Data_XXXXX.sxb"[/3]
[3]Explanatory text - "Components\Text_XXXXX.sxb"[/3]
[3] [/3]
[3]Known bugs - If you have one disabled subroutine that calls another disabled subroutine, you get the UNKNOWN COMMAND ... error when you compile, even though both are disabled. for example, open the Software_Comp.sxb file and disable both Components\Subs_Delay.sxb and Components\Subs_LCD.sxb then compile the main program... OOPS[/3]
[3][/3]
[3]Sorry about the long post and kind regards from the dark continent[/3]
[3]John Bond[/3]
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=352776
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)