Shop OBEX P1 Docs P2 Docs Learn Events
Open Propeller Project #5: BlocklyProp - Page 2 — Parallax Forums

Open Propeller Project #5: BlocklyProp

2456789

Comments

  • Michel LMichel L Posts: 141
    edited 2014-04-21 15:10
    msrobots wrote: »
    Hm - how to exit the server?

    Tried ctrl-c. no avail.

    On my computer I get a cmd-screen. To stop, I do a ctrl-c and then confirm (Because my OS is in Dutch I need to confirm with "J" but I guess its "Y" on other systems) and then press 'enter'.

    If you could give this a try and if it works, could you please send me a screenshot so I can make a kind of manual.

    Thanks
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-21 16:00
    Michel L
    I've been playing with this whenever you add new blocks, and it's getting good!

    The main thing I'd like to see next is some basic math. I'd like to be able to at least increment and decrement variables, but if you just add in an "operator" block that would be similar to the logic block that does the comparisons except it would have +, -, *, /.

    Then, the thing that would make it truly a "Prop" version would be to have a block in the methods section that does a cognew/coginit as a form of method call, and a block that is cogstop.

    After that, a way to declare local variables (they are always longs). You could use the existing declare block, and when it's inside of a method block it forces the long type and just puts it on the PUB line instead of making a global.
  • msrobotsmsrobots Posts: 3,709
    edited 2014-04-21 16:20
    Michel L wrote: »
    On my computer I get a cmd-screen. To stop, I do a ctrl-c and then confirm (Because my OS is in Dutch I need to confirm with "J" but I guess its "Y" on other systems) and then press 'enter'.

    If you could give this a try and if it works, could you please send me a screenshot so I can make a kind of manual.

    Thanks

    My bad. was using javaw.exe instead of java.exe.

    On a standard installation of java, java is not in the path, as it is for you as developer. so I needed to change the bat file to
    "C:\Program Files (x86)\Java\jre7\bin\java.exe" -jar propeller-web-loader-1.0-SNAPSHOT.jar

    now everything fine. CTRL-C works as expected. I deleted my post as soon as I found out, but - to late. You already answered...

    I also can run your Blocky snapshot local now. Great. It was just me not knowing about how to handle java. wasn't even installed on my computer.

    I do like the way to deploy this embedded webserver as host. Unzip, adjust path to java if needed and run in the browser. Quite painless.

    Thanks again.

    Enjoy!

    Mike
  • Michel LMichel L Posts: 141
    edited 2014-04-22 01:23
    Roy Eltham wrote: »
    Michel L
    I've been playing with this whenever you add new blocks, and it's getting good!

    Nice, thanks
    Roy Eltham wrote: »
    The main thing I'd like to see next is some basic math. I'd like to be able to at least increment and decrement variables, but if you just add in an "operator" block that would be similar to the logic block that does the comparisons except it would have +, -, *, /.

    This is next on my list, I should be able to do that this evening (West European Time zone)
    Roy Eltham wrote: »
    Then, the thing that would make it truly a "Prop" version would be to have a block in the methods section that does a cognew/coginit as a form of method call, and a block that is cogstop.

    I'll move this up in the priority list. I myself thought to first do calls to objects. The terminal object for example
    Roy Eltham wrote: »
    After that, a way to declare local variables (they are always longs). You could use the existing declare block, and when it's inside of a method block it forces the long type and just puts it on the PUB line instead of making a global.

    I'll see what I can do, this will be one of the hardest things to do in Blockly I'm afraid. I've had to hack the system already to be able to have different variable types as well as making sure method parameter variables are not declared at the top.

    Thanks for the input

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-04-22 01:35
    msrobots wrote: »
    My bad. was using javaw.exe instead of java.exe.

    On a standard installation of java, java is not in the path, as it is for you as developer. so I needed to change the bat file to
    "C:\Program Files (x86)\Java\jre7\bin\java.exe" -jar propeller-web-loader-1.0-SNAPSHOT.jar

    now everything fine. CTRL-C works as expected. I deleted my post as soon as I found out, but - to late. You already answered...

    I also can run your Blocky snapshot local now. Great. It was just me not knowing about how to handle java. wasn't even installed on my computer.

    I do like the way to deploy this embedded webserver as host. Unzip, adjust path to java if needed and run in the browser. Quite painless.

    Thanks again.

    Enjoy!

    Mike

    Mike,

    I'll see if I can add some logic in the bat file that locates java.exe. Then you can just unzip it and run it.
    I also noticed that the name of the jar file was wrong and in the latest version that is corrected.

    I could also try to not show the cmd window and instead show a little window with some buttons: "Close" and "Open in browser" That might be a little bit more user friendly. After all, its intended for novice users.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-22 01:38
    Michel L,
    I was going to mention declaring objects (OBJ section), and then calling into the objects, but I figured that would be pretty hard since it's very foreign to Blockly.

    I didn't think local variable declaration would be so hard. It's ok to leave for later, since you can use globals most of the time (just not in recursion).
  • Heater.Heater. Posts: 21,230
    edited 2014-04-22 02:14
    Hurray!

    This works on my Debian 64 bit machine:

    java -jar propeller-web-loader-1.0-SNAPSHOT.jar

    Had to add execute permissions to the openspin executable.

    It at least tries to run it. I have no Propellers connected to test with though...
  • Michel LMichel L Posts: 141
    edited 2014-04-22 08:55
    I just had a look at the Blockly wiki, because the next stuff will be more complex and might requiring me to read their manual.

    I found a page about their Language Design Philosophy: https://code.google.com/p/blockly/wiki/Language

    The most important one for BlocklyProp is:
    Global Variables:

    Novice programmers also have difficulties understanding scope. As a result, all variables in Blockly follows the lead of App Inventor by making all variables global. The only down-side of global variables is that recursion is trickier (one has to push and pop variables onto a list), but that's a programming technique that's beyond the scope of Blockly's target users.

    So, if I really want local variables I will have to set that up myself, any opinions?
  • Michel LMichel L Posts: 141
    edited 2014-04-22 12:36
    I added numeric operators:
    • pre-increment/decrement
    • limit max/min
    • square root
    • absolute
    • negate
    • +, -, *, /

    Anything else?

    http://blocklyprop.creatingfuture.eu/
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-22 13:06
    If it's not hard to do, then the shift operators are handy.

    Also, negate should probably just say negate instead of using the -. It's odd with how the block works, and makes it look like subtraction. Maybe if the assignment blocks has the = on them?
  • Heater.Heater. Posts: 21,230
    edited 2014-04-22 13:09
    Ouch! I imagine that Blockly has no concept of "objects",

    In Spin, variables can be "global" to all methods within an object. But they are totally unavailable to other objects.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-22 13:17
    Heater,
    Do you think it's required that an object and a program using the object be in the same "workspace"? I say workspace there meaning the area where you place and arrange blocks that ends up being converted into a single output spin file.
    I could see having tabs to allow having multiple workspaces each converting to their own spin files. Then objects work out fine, even with the only global variable limitation, because each workspace would have it's globals and they wouldn't cross over.
  • Michel LMichel L Posts: 141
    edited 2014-04-22 13:24
    Heater. wrote: »
    Ouch! I imagine that Blockly has no concept of "objects",

    In Spin, variables can be "global" to all methods within an object. But they are totally unavailable to other objects.

    Indeed, there are no objects in Blockly. It's intended to be always 1 file.
    I intend to provide functionality like serial connections through blocks that will define the OBJ part for you.

    Unless you make a graphical programming system very complex it will always limit your possibilities. It's not a replacement for code written directly in spin.
    Just as they say on the Blockly site: it's an introduction to a language. Therefor the code generated by Blockly needs to be as clean and readable as possible. So you can just switch to the spin tab and view your code.

    I have no intention to put in the complete language but hope to come to a point where you can write an application that can interact with the terminal, process entered text, read some sensors and make something move (servo).
    If I then can integrate some kind of learning system that slowly introduces new blocks I think this could be a nice addition to the existing IDE's. (Something like: https://blockly-demo.appspot.com/static/apps/maze/index.html
  • Michel LMichel L Posts: 141
    edited 2014-04-22 13:28
    Roy Eltham wrote: »
    If it's not hard to do, then the shift operators are handy.

    There on the list, maybe tomorrow.
    Roy Eltham wrote: »
    Also, negate should probably just say negate instead of using the -.

    I have changed it in the code. Will be changed in the next build.
    Roy Eltham wrote: »
    It's odd with how the block works, and makes it look like subtraction. Maybe if the assignment blocks has the = on them?

    I don't really understand what you mean (English is not my first language, just so you now). Could you please elaborate?
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-22 13:38
    This is what I meant:
    negateblock.jpg

    That converts to this spin code: x := -y

    However, it looks like it is: x - y

    The x block on the left is an assignment block. If it had the '=' character as part of the block (next to the x), then it might be more clear what's going on.
    130 x 63 - 6K
  • Michel LMichel L Posts: 141
    edited 2014-04-22 13:41
    Roy Eltham wrote: »
    This is what I meant:
    negateblock.jpg

    That converts to this spin code: x := -y

    However, it looks like it is: x - y

    The x block on the left is an assignment block. If it had the '=' character as part of the block (next to the x), then it might be more clear what's going on.

    Ok, no problem, I'll change that tomorrow.
  • Heater.Heater. Posts: 21,230
    edited 2014-04-22 13:55
    OK, I do see that Blockly has it's limitations. And intentionally.

    Starts me wondering though. There are similar systems that generate JavaScript as an output. Do they understand first class functions, closures, and so on? Perhaps not.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-22 14:32
    Michel L,
    Have you seen this: https://blockly-demo.appspot.com/static/apps/blockfactory/index.html
    Maybe you are already using it to help you make blocks? Seems neat to be able to make blocks for blockly with blockly. Of course, it only makes a stub for the language generate part, you have to fill that in,
  • Heater.Heater. Posts: 21,230
    edited 2014-04-22 14:47
    Oh Jees Roy, mind bending.

    Or not...if Blockly is sufficiently expressive then the entire system can be made in Bockly.

    In the same way C++ compilers are written in C.

    Sounds like hard work though.
  • Michel LMichel L Posts: 141
    edited 2014-04-23 13:03
    I've put a new version online.

    I've included Roy Eltham's suggestions and added bitwise operations. (Shift, rotate, and, or, not)

    Next?
  • JonnyMacJonnyMac Posts: 9,159
    edited 2014-04-23 13:18
    The pin control blocks work only with constants. Should the be blocks that allow a variable pin #?
  • Michel LMichel L Posts: 141
    edited 2014-04-23 13:24
    JonnyMac wrote: »
    The pin control blocks work only with constants. Should the be blocks that allow a variable pin #?

    I'll add that Added

    I'm still looking for the best way of setting pins, what I have now is copied from the Arduino version but with the Propeller we can set multiple pins at once (and read out). And I don't know yet how to make blocks that allow this in an easy to do/understand way.
  • JonnyMacJonnyMac Posts: 9,159
    edited 2014-04-23 14:06
    It took a minute, but I figured out how to define parameters for a method. Should there be another group revealed by the [+] that allows one to define local variables for a method?

    I'm still looking for the best way of setting pins, what I have now is copied from the Arduino version but with the Propeller we can set multiple pins at once (and read out). And I don't know yet how to make blocks that allow this in an easy to do/understand way.

    That the Arduino was first doesn't mean its implementation is the best. DigitalWrite, for example, is the Arduino equivalent of PBASIC HIGH -- which doesn't exist in the Propeller (unless one creates a method).

    Perhaps you have a block the says something like DIRA := {] to {] Value []. You could do the same with OUTA. Each would have an option for constant and variable values (as you're doing in other areas).

    To read a group of pins maybe it's: := INA {] to {]

    Would be nice for single pins if only the first constant/variable slot has to be used.

    These are just ideas. Again, kudos for your efforts.
  • Michel LMichel L Posts: 141
    edited 2014-04-23 14:17
    JonnyMac wrote: »
    It took a minute, but I figured out how to define parameters for a method. Should there be another group revealed by the [+] that allows one to define local variables for a method?

    That would indeed be the best method, sadly just defining them there is not enough. I have to manage them and they should actually only be available within the method scope. (That's currently already a problem)
    Blockly doesn't have the concept of local variables. They decided that was outside the scope as they focus on novice users.

    I've had to do a hack and hide the variable declaration from the VAR block for parameter variables.
  • Michel LMichel L Posts: 141
    edited 2014-04-23 15:38
    I just added another block, now the fun can start: cognew

    Just specify the stackspace (attention, currently you can enter any text here, and it is not validated to be numeric) and the method call (I can't block you from putting in other code, so it's easy to create invalid code)
  • Ken GraceyKen Gracey Posts: 7,395
    edited 2014-04-23 20:54
    This is fantastic, and a great replacement for the Open Propeller Project about Scratch.

    Parallax has much interest in this effort - we are currently revising our S2 robot and it'll need Scratch or Blockly.

    Can we get behind this effort and make it Open Propeller Project #5: Blockly and draw more attention to the work?

    Ken Gracey
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-24 00:02
    Ken, between Michel's effort and the other efforts to allow programming the chip with the generated spin results, I think this is a great thing to use for S2 (and eventually S3).
    There could even be a set of blocks made that are tailored to the S2's components.

    Also, If you look at the Maze tutorial link Michel shared a few posts back, imagine a tutorial like that but reworked with S2 art and added blocks for making sounds and blinking the leds. Each tutorial step could have a button to download the same program into an actual S2 and have it perform the same steps. Maybe even have some large size poster sheets with the tutorial mazes on it for them to place the S2 on when running the tutorial code. It would be so cool!
  • Michel LMichel L Posts: 141
    edited 2014-04-24 00:31
    Ken, that would be great. I've been re-reading the open propeller project page and also watched some videos about S2 and I think we could make a great product.

    The software could have different modes depending on the experience level of the user. From high level blocks specific for the S2/3 to the set of blocks I'm currently creating.
    A tutorial like Roy suggested would also be nice to learn the blocks gradually. (I also suggested putting a learning system in earlier, but that was for the current set of blocks)

    One question though:
    I've currently put in the apache2 licence because this is the Blockly licence and as such I can't make it (at least not completely) MIT licensed. Is this a problem? I don't have experience with licences, so if this has to change i'll need some advice.

    Another thing I thought of is a way to compile and load programs into the propeller. What if we create a version that is hosted at Parallax, and users download a small native (cross platform) application that opens a socket to the server and identifies itself.
    When loading the application, the server would compile the application and send it to the selected client.
    This would eliminate the requirement for a server on the users computer while supporting all browsers (I'm thinking about the IE plugin). And, at least I think, would be easier to use.

    To conclude:
    Just let me know if I need to do anything to make it into an Open Propeller project. And how you guys at Parallax would like this application to evolve.

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-04-24 12:30
    I just added a new block: servo.

    I had to add a lib directory to the compiler call as well as setup the system for the OBJ code-block. Now higher level blocks are possible.

    Requests?
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-04-24 13:21
    I think a "PING)))" block would be the next obvious choice. :)
Sign In or Register to comment.