Shop OBEX P1 Docs P2 Docs Learn Events
SPIN In Blockly? — Parallax Forums

SPIN In Blockly?

JwolfJwolf Posts: 74
edited 2018-10-31 07:48 in Learn with BlocklyProp
I have many completed projects in SPIN and often clip pieces of code for use in new projects... this saves a tremendous amount of time.
I would like to be able to do this with Blockly. Is there a way to insert spin code as a new block/function?
A great example is custom display routines for a WS2812 LED strip. I've created 80 amazing displays for led strips in SPIN, these display routines do not interact directly with the LED's, rather they create variables for position and color, which would take forever to recreate in blockly... Ideally I would like to define a new block which I could simply paste the spin code into.

Comments

  • I think this is a very valuable objective for Parallax to pursue -- a Spin/PASM block! ¿Como no?

    -Phil
  • Parallax won't be integrating Spin support into BlocklyProp anytime soon. We had to make a decision early on about which language to support (Spin or C), our educational goals with the tool, and the cost/benefit of these decisions.

    I realize many users here would like Spin support in BlocklyProp. You'll need to give us a pardon on the request. We can't do everything, all the time. Consider that adding Spin support is a 4,000 hour request by the time we've got it fully documented, working, and supported in tutorials.

    Ken Gracey
  • Does Blockly support C blocks? If so you could convert your Spin/PASM code to C with spin2cpp, then paste it in there.
  • SPIN has been the foundation of programming for the propeller... with the OBEX and amount of forum support available, the loss of that to introduce a visual method seems like a huge step backwards in my opinion. I cannot even get the parallax 4x20 LCD to work properly in blockly and I'm not getting any support to resolve the issue in forum. Without any way other than to abandon all completed work in SPIN code and restart with C to fix the errors with blockly, is a deal breaker to me.
    I was expecting more... much more :(
  • ersmith wrote: »
    Does Blockly support C blocks? If so you could convert your Spin/PASM code to C with spin2cpp, then paste it in there.

    Yes. There are two ways to go about doing this, I suppose.

    One way is to insert the converted spin2cpp code in a user-defined block in BlocklyProp, which allows you to put C code directly into your program.

    The more official route, which is better for long-term, is to make a GitHub request with your converted C code and ask us to create a block for it. Then, we'll integrate it with our library distribution, create a reference guide for using the blocks, and make it a permanent part of BlocklyProp. Only a few people have gone this route- likely because it's a fair amount of work to go from tire-kicking to driving the car.

    Ken Gracey
  • Is there a way to implement that blockly code into SPIN?
    for example, the MEMSIC 2125... I'd like to use variable assignments which retrieve XY Accel & XY Tilt, in SPIN loops.

    Such as this bit of code (obviously pin assignments will be completed later)
    http://blockly.parallax.com/blockly/projectlink?id=63808&key=bdfc2970-3743-443a-862b-88fea61ce700
  • The best I can recommend is to use the User defined code block. It's under the system menu in a few of the board types. From there, you should be able to add C code. As for putting inline SPIN into a C project, that I don't know how to do, or if it's possible.

    That being said, the BlocklyProp project itself is open source, so you can dive and and see how the blocks generate C code...it's not actually that complicated. You *could* create SPIN generators for each of the existing blocks if you wanted, and build a custom version of the offline app...

    Look for the offline app elsewhere here in the forums for all the code and a few instructions to get you going.
  • Can a program be created in Blockly, the code saved as a file, then a SPIN program call that file to a new cog or even just for one time use?
    Similar to how OBJ is used... I would like to create a program in blockly for the LSM9 IMU sensor, then load that into a new cog within a spin program so that I can constantly poll readings.
Sign In or Register to comment.