Shop OBEX P1 Docs P2 Docs Learn Events
Multi-Language programming with fastspin/flexgui — Parallax Forums

Multi-Language programming with fastspin/flexgui

ersmithersmith Posts: 5,909
edited 2020-06-28 12:13 in Propeller 2
On Wednesday I plan to give a presentation on multi-language programming with fastspin/flexgui (thanks Ken for setting this up!).

Topics I'd like to cover are:

- an overview of fastspin/flexgui
- Spin programming and how to use C from Spin/Spin2
- PASM programming and how to wrap pure PASM in C or BASIC files
- fastspin C programming and calling Spin2 objects from C (the sample program for this is a mandelbrot demo in C)
- fastspin BASIC programming and calling C and Spin2 objects from BASIC (the sample program here is a BASIC turtle graphics program)

I'm open to suggestions for other topics too, of course!

All of the source code for the demos is included in the flexgui 4.2.3 zip file, downloadable from:

https://github.com/totalspectrum/flexgui/releases/download/v4.2.3/flexgui.zip

I'll be using flexgui 4.2.3, and if you'd like to follow along and try out the examples at home then I suggest downloading this version of flexgui.

To whet your appetite I've attached screenshots of the mandelbrot and turtle demos. The turtle.bmp file was actually created on the P2 and saved to the PC's disk via the file server built in to flexgui (actually loadp2) that lets P2 applications read/write files on the PC.

Edit: fixed the URL to point to flexgui rather than fastspin, sorry about that!

Comments

  • RaymanRayman Posts: 13,850
    Sounds good. I’d put cross-platform in there somewhere too...
  • During the overview phase, point out the folder structure. There are documentation and example files explaining the languages, that people seem to miss.

    Maybe explain what a markdown .md file is, and what a open the them. Same with the PDF versions.

    Also demonstrate the ifdef usage, as that is one majorly huge reason to use your compiler suite.
  • Please also cover "what FlexGUI can't do" too. Agreed with Ray - does it run on Mac and Linux?

    Make it clear that people can follow along if they download the tool and have a P2 Evaluation Board. I'll point that out in the e-mail this week.

    Ken Gracey

  • I appreciate the time because 2.00PM and 8.00AM PDT (Raymond) corresponds to 23.00 and 17.00 CEST time.
    The webinars at 8.00PM PDT (others) are really hard to follow here in Europe because of 5.00(AM) CEST.
  • dMajo wrote: »
    I appreciate the time because 2.00PM and 8.00AM PDT (Raymond) corresponds to 23.00 and 17.00 CEST time.
    The webinars at 8.00PM PDT (others) are really hard to follow here in Europe because of 5.00(AM) CEST.

    Good to know. We're mixing up the times as you can see. This way, at least 2/3rd of the main Propeller 2 users can participate. Between Australia, the United States and Europe somebody will usually be sleeping.

    I'm still getting a feeling for the number of European community members.

    Ken Gracey
  • I am interested on tricks (if there is no a native solution) on how to mix more different projects (from development point of view) on the same P2.

    Project 1 main application on more cogs using mainly PASM and Spin

    Project 2,3,4,.... using any kind of language to build some tools (apps) that can reference (call code) functions/variables from Project 1 and that make binaries that can be loaded during runtime.

    Physically the main project is resident using +/- 6 cogs and having big data buffers in hub.
    The other Projects/binary blobs get loaded and executed in the remaining cogs, when needed, and share the basic code (call it kernel or system API if you want) and data already in the hub. A way to include a sort of data/object definition/structures from Project1 one into Project2 (to referentiate/point/execute/read/write them) without having allocated the object/data space physically in the binary file.
    I think perhaps a parameter should be defined to instruct the compiler for which memory area (address) it have to build the binary or the code must be relocatable.

    I hope my English is good enough to express my intentions.
  • Perhaps you could include a demo using P1?

    I have downloaded FlexGui this morning after using other controllers for some years and I am very much impressed!

    Actually I think, the "Parallax Aircraft" could use this tool as a very powerful booster!

    Some benchmarks, as this is a real compiler?
    Some hints how to deal with the bigger code size?

  • Actually I think, the "Parallax Aircraft" could use this tool as a very powerful booster!

    The difficult part for us to determine is the expectations from customers if this powerful booster was installed. Once it looks and feels like something offered by Parallax, we start taking the calls, writing the code, and using two of our most qualified team to take care of issues. This amounts to a hands-off experience with no direct feedback or accountability for the developer. Customers will ask for code enhancements, improvements, and bug fixes -- but it's not a codebase we work with nor do we control the designer. While I'm sure Eric would do his absolute best, we still wouldn't have an internal ability to back him up, to replicate his work if needed.

    There are many popular Python editors, and same for Arduino. I think the best approach is to ensure the FlexGUI becomes the most popular P2 tool not made by Parallax, and doing our part to ensure Eric experiences some financial success along the way.

    It may be that the most useful collaboration is what's taking shape right now. Give it some time and know that we're watching it closely. We all succeed together.

    Ken Gracey
  • Thanks for the suggestions, everyone!
    Perhaps you could include a demo using P1?

    That's probably a topic for another day, since I think this series of talks is mainly about programming the P2. I will mention P1 compatibility in the slides though, thanks.
    Some benchmarks, as this is a real compiler?

    Good point. Here are the dhrystone-2.1 results that I have to compare P2 C compilers:
    riscvp2 (gcc 8.2.0, -O3):     47846 dhrystones/sec
    fastspin 4.2.3 -O2:           21070 dhrystones/sec
    p2gcc (default -Os):          19426 dhrystones/sec
    catalina 4.1 -O3:             11030 dhrystones/sec
    
    Some hints how to deal with the bigger code size?

    On the P2 this isn't nearly as much of an issue.
  • dMajo wrote: »
    I am interested on tricks (if there is no a native solution) on how to mix more different projects (from development point of view) on the same P2.

    Project 1 main application on more cogs using mainly PASM and Spin

    Project 2,3,4,.... using any kind of language to build some tools (apps) that can reference (call code) functions/variables from Project 1 and that make binaries that can be loaded during runtime.

    Physically the main project is resident using +/- 6 cogs and having big data buffers in hub.
    The other Projects/binary blobs get loaded and executed in the remaining cogs, when needed, and share the basic code (call it kernel or system API if you want) and data already in the hub.

    I think I understand what you want to do (your English is great, btw!). fastspin does have a -H option to specify a different starting address, and a -E option to skip startup code. But it doesn't have a linker or any way to export symbols. So the sub-projects and main project would have to share variables and code by using fixed locations in HUB memory. That's not very convenient, and maybe some day we can find a way to improve this.

    I've attached a simple demo "operating system" in which COG 0 loads a program to run in COG 1.
  • Ken Gracey wrote: »

    Actually I think, the "Parallax Aircraft" could use this tool as a very powerful booster!

    I think the best approach is to ensure the FlexGUI becomes the most popular P2 tool not made by Parallax, and doing our part to ensure Eric experiences some financial success along the way.

    It may be that the most useful collaboration is what's taking shape right now. Give it some time and know that we're watching it closely. We all succeed together.

    Ken Gracey

    In the meantime I would encourage forum member to contribute to Eric's Patron or PayPal links in his signature. I know he has 16 Patron contributors, (I am one), I don't know about PayPal. Keep Eric happy and don't let it go the way of "Brad's Spin Tool".
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2020-06-28 15:25
    Publison wrote: »

    In the meantime I would encourage forum member to contribute to Eric's Patron or PayPal links in his signature.

    Exactly, Jim. I'll be doing the same, and will share this link during his presentation. Engineers are often not natural at marketing their talents and I view this role as a responsibility of our community. We want him to spend his time on FlexGUI, too.

    Ken Gracey
  • Please be a Patreon to Eric.
    I never used Patreon befor, but he really deserves it
Sign In or Register to comment.