Shop Learn
Visual Studio Code editor for P1 & P2 (spin & pasm) - Page 3 — Parallax Forums

Visual Studio Code editor for P1 & P2 (spin & pasm)

13»

Comments

  • Thanks, that does put things nicely in one place. I might get around to doing that. Now that I have my files set up it's pretty easy as is, though. Plus I can use them directly from the command line.

    I see now my squiggly lines have moved randomly from the __asm call, which still works, to a couple of #include statements, which also still work, so the whole squiggly thing is kind of .... squiggly .... Maybe I'll ditch them altogether and just let the compiler yell at me later:-)

    When I get a new folder of flexprop files from Eric's download I have a workflow for the Mac to make the binaries usable past the system Gatekeeper. I need three of the .mac files. I wrote a Python program to binary copy them to replacements, then I use Chmod 777 at the command prompt to make them executable and I'm back in business. I keep all my other files in a projects folder inside his folders so that's easy to move over. The whole thing takes about a minute.
  • Cluso99Cluso99 Posts: 17,474
    edited 2021-01-14 22:54
    To install Stephen’s (iron sheep) spin2 highlighter is extremely simple. I wrote a post here a while back simplifying the process - it’s dated 2020-11-11.
    I’m not sure how this works on a Mac.
  • Thanks, but I won't get around to that for a while. I looked into spin a little but I don't think it's for me, so I've moved back to C and I'm liking my setup with FlexC and VSCode, so I'll be there unless I find a reason not to be. Maybe I'm in the wrong place here now. I've been focused on getting a programming environment set up, not on learning a new language. I appreciate the help and what I've learned from you guys. We all have different preferences and needs for our tools.
  • dgatelydgately Posts: 1,423
    jlastofka wrote: »
    I wrote a Python program to binary copy them to replacements, then I use Chmod 777 at the command prompt to make them executable and I'm back in business.

    The custom in the Unix/Linux world is to use chmod 751 to allow execute... chmod 777 is not so safe, if you plan to distribute the file.

  • Thanks. Always good to learn the better ways. I'll go learn a bit about the difference. This is a very helpful group.
  • Thank you @"Stephen Moraco" @Cluso99 for bringing me up to speed on Visual Studio Code today for Spin2/PASM. I'm just about configured, pending the compiler command-line part.

    The planned improvements will make this a very fluid, productive workspace for P2 developers!

    Ken Gracey

  • @jlastofka said:
    The spin extension I have from the Marketplace is by Entomy. I don't see any others. The one you mentioned involves getting from github and installing I guess. I didn't want to get into that level of learning yet. I'm finding enough to learn just patching together miscellaneous stuff to get software going for my P2 board.

    You probably noticed by now that the spin2/pasm2 have many more instructions/constant names. You may want to add the IronSheep spin2 support in addition to using the Entomy spin1 support (for now.)

    I've made it much easier to install as there is now a releases page at the git hub repository and the top-level page now describes the single line command needed to install it.

    The IronSheep spin2 support will be showing up in the Marketplace shortly, as well.

    Thank you for your posts on building and downloading. I'm playing with your solutions and others.

    I'll be updating the README with suggested forms for configuring this compile/download feature set as well.

    Regards,
    Stephen

  • Cluso99Cluso99 Posts: 17,474
    edited 2021-02-17 23:47

    Ken,
    I leave VSC open with the spin2 program, making sure to save it if I make changes.

    To compile/download I can use PropTool & PST or pnut
    Just open other windows for these.
    Then make sure you re-open the file (in PropTool or pnut) if you edit/save it again in VSC (this is a trap) before you compile. If there is an error, fix it in VSC and re-save, and re-open it in PropTool/pnut.

    To compile/download with FlexProp
    On W10, I open the windows Command Prompt (I created a shortcut on the taskbar but it lives in Start | Windows System | Command Prompt).
    I setup a batch file r.bat to change the directory to the folder where my code resides. You can instead do CD/folder-path/

    I also have a batch file ff.bat for compiling which I can now run from the command prompt
    It uses Eric's FlexSpin and LoadP2 which I rename to the current version as F508.exe and L508.exe and resides in my base P2 folder "_RetroBlade2"
    Shortly I will update to v 510 and I will just edit my ff.bat file to use F510 and L510. As you can see, I hate typing so I have short batch filenames.

    Here is a dump from my Command Prompt screen. You will note I "type"d out the batch files for you so you can cut/paste and save.

    Microsoft Windows [Version 10.0.19041.804]
    (c) 2020 Microsoft Corporation. All rights reserved.
    
    C:\Users\Ray>type r.bat
    CD/P2/_RetroBlade2/
    C:\Users\Ray>r
    
    C:\Users\Ray>CD/P2/_RetroBlade2/
    
    C:\P2\_RetroBlade2>cd porthandler/demo-060
    
    C:\P2\_RetroBlade2\PortHandler\demo-060>type ff.bat
    del %1.binary
    C:\P2\_RetroBlade2\f508 %1.spin2 -2 -l
    C:\P2\_RetroBlade2\l508 %1.binary -b2000000 -t -SINGLE
    C:\P2\_RetroBlade2\PortHandler\demo-060>ff demo_fullduplexserial
    
    C:\P2\_RetroBlade2\PortHandler\demo-060>del demo_fullduplexserial.binary
    
    C:\P2\_RetroBlade2\PortHandler\demo-060>C:\P2\_RetroBlade2\f508 demo_fullduplexserial.spin2 -2 -l
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.0.8 Compiled on: Jan 24 2021
    demo_fullduplexserial.spin2
    |-rr_format_IO.spin2
    |-rr_ser_drv_multiport16.spin2
    demo_fullduplexserial.p2asm
    Done.
    Program size is 9296 bytes
    
    C:\P2\_RetroBlade2\PortHandler\demo-060>C:\P2\_RetroBlade2\l508 demo_fullduplexserial.binary -b2000000 -t -SINGLE
    ( Entering terminal mode.  Press Ctrl-] to exit. )
    waiting...
    ------------------------------------------------
    Multiport Serial driver and format/handlers v062
      Serial driver started in cog 1
    
    Port-ser-config     1F68
    01F68: 80 1F 00 00  00 00 00 00  BF FE 00 00  00 00 00 00  '................'
    
    Port-control        1F70
    01F70: BF FE 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    
    Port-params         1F80
    01F80: 80 20 00 00  80 20 00 00  80 20 00 00  C0 20 00 00  '. ... ... ... ..'
    01F90: DB 20 00 00  E9 20 00 00  C0 20 00 00  00 21 00 00  '. ... ... ...!..'
    01FA0: 00 21 00 00  00 21 00 00  00 21 00 00  40 21 00 00  '.!...!...!..@!..'
    01FB0: 40 21 00 00  40 21 00 00  40 21 00 00  80 21 00 00  '@!..@!..@!...!..'
    01FC0: 80 21 00 00  80 21 00 00  80 21 00 00  C0 21 00 00  '.!...!...!...!..'
    01FD0: C0 21 00 00  C0 21 00 00  C0 21 00 00  00 22 00 00  '.!...!...!..."..'
    01FE0: 00 22 00 00  00 22 00 00  00 22 00 00  40 22 00 00  '."..."..."..@"..'
    01FF0: 40 22 00 00  40 22 00 00  40 22 00 00  80 22 00 00  '@"..@"..@"..."..'
    02000: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02010: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02020: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02030: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02040: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02050: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02060: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    02070: 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  '................'
    
    Type some characters and see them being echoed... (<esc> to terminate)
    
    

    If you have any questions, just ask.

  • @Cluso99 said:
    Ken,
    I leave VSC open with the spin2 program, making sure to save it if I make changes.

    To compile/download I can use PropTool & PST or pnut
    Just open other windows for these.
    Then make sure you re-open the file if you edit it in VSC this is a trap before you compile. If there is an error, fix it in VSC and re-save, and re-open it in PropTool/pnut.

    You know you can use PNut to compile n' load from the command line? The Spin2 google doc has the details.

    You can also set up VSCode to run commands as a task, which can be configured to automatically save all modified files beforehand

  • Cluso99Cluso99 Posts: 17,474

    @Wuerfel_21 said:

    @Cluso99 said:
    Ken,
    I leave VSC open with the spin2 program, making sure to save it if I make changes.

    To compile/download I can use PropTool & PST or pnut
    Just open other windows for these.
    Then make sure you re-open the file if you edit it in VSC this is a trap before you compile. If there is an error, fix it in VSC and re-save, and re-open it in PropTool/pnut.

    You know you can use PNut to compile n' load from the command line? The Spin2 google doc has the details.

    You can also set up VSCode to run commands as a task, which can be configured to automatically save all modified files beforehand

    Yes, and yes.

    I have a dislike for command lines. I think it's the *nix way which is plain wrong these days. But sometimes they are a necessary evil. I find it easier to leave pnut open and then just re-open and compile - Ctl-O gets me directly to the open screen and then I have to enter.

    re VSC I just need an easy way to add this as I never seem to have enough time to experiment with everything new. When we have an easy to install method that is agreed then I'll add it in.

    I made the mistake of installing PlatformIO on VSC. I regretted it immediately as for ages it kept prompting for something?? Took me ages to get rid of the popups.

  • @Cluso99 said:

    @Wuerfel_21 said:

    @Cluso99 said:
    Ken,
    I leave VSC open with the spin2 program, making sure to save it if I make changes.

    To compile/download I can use PropTool & PST or pnut
    Just open other windows for these.
    Then make sure you re-open the file if you edit it in VSC this is a trap before you compile. If there is an error, fix it in VSC and re-save, and re-open it in PropTool/pnut.

    You know you can use PNut to compile n' load from the command line? The Spin2 google doc has the details.

    You can also set up VSCode to run commands as a task, which can be configured to automatically save all modified files beforehand

    Yes, and yes.

    I have a dislike for command lines. I think it's the *nix way which is plain wrong these days. But sometimes they are a necessary evil. I find it easier to leave pnut open and then just re-open and compile - Ctl-O gets me directly to the open screen and then I have to enter.

    Ideally all programs would expose a structured API that could be used for automation, but that isn't really a thing. Windows has OLE, but nobody uses it :(. So command line it is for automation.

  • TubularTubular Posts: 4,292

    At one stage OLE was very common in Automation. Then OPC (="OLE for process control") came along as the preferred method. A lot of stuff used OPC

    But yes command line has always been a useful way to get things done. Its possible to load the MicroPython (~500kB) image into the P2 and have it run, from the DOS command line at 115200 baud, using the Prop_Hex Base64 loading protocol. I wanted to prove that it could be done without any special tools whatsoever, just "Mode" to set up the baudrate, followed by "copy upython.bin com3" to initiate the copy. Its important to complete within a minute, so the P2 doesn't go to sleep.

  • ersmithersmith Posts: 4,750

    If you want to use FlexProp but with an external editor, that's relatively easy: just check the "Auto Reload Files if changed externally" box in the "Edit > Editor Options" menu. FlexProp checks before doing any compile and run step to see if there were changes to the files involved, so if you edit them in another program that shouldn't be a problem.

  • I have just started using VS code and now have everything automated so I don't have to use FlexProp at all.

    I have constructed a task for the two things it needs to do. I also use a custom loader program and that works good as well.

    Things are little simpler for me since all my code is in C and not SPIN so the formatting is already built in.

    These are the two task I created to build and run the code.

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Run Propeller Program",
                "type": "shell",
                "command": "d:/flexprop/bin/p2loader.exe com10 '${fileDirname}\\${fileBasenameNoExtension}.binary'",
                "problemMatcher": []
            },
            {
                "type": "cppbuild",
                "label": "Build Propeller Program",
                "command": "d:/flexprop/bin/flexspin.exe",
                "args": [
                    "-2",
                    "-l",
                    "-D_BAUD=230400",
                    "-O1",
                    "-I",
                    "D:/flexprop/include",
                    "-I",
                    "D:/Custom",
                    "${file}"
                ],
                "options": {
                    "cwd": "${workspaceFolder}"
                },
                "problemMatcher": [
                    "$msCompile"
                ],
                "group": "build",
                "detail": "compiler: flexspin.exe"
            }
        ]
    }
    

    Mike

  • Ken GraceyKen Gracey Posts: 7,184
    edited 2021-02-18 15:37

    @iseries said:
    Mike

    Mike, I'm at the stage where I have Stephen's extensions configured but haven't gone to this next step. How does this code get applied and used? Part of the program, or does it sit in a vscode directory?

    Should I be using the example from @Cluso99 above?

    Thanks,

    Ken Gracey

  • I have always set up my own folder structure for developing code.

    I can easily jump from FlexProp to VS code as they are both looking at the same folder structure.

    The nice thing is that VS Code wants to open a folder up and show what's in it. From there I can pick the program and work on it.
    FlexProp is the same in that once you pick a folder it remembers that location.

    image

    Mike

  • NEWS: Spin2 for vscode is now available from the MarketPlace!

    Please uninstall the extension you have already installed (See Uninstall an extension)

    Then search for the Spin2 extension in the MarketPlace (See Browse for Extensions) and install it.
    From this point forward you'll be notified when new versions of our extension become available.

    Since this is now available, I'll no longer be posting .vsix files here in this thread. We can all now use the MarketPlace delivered Spin2 extension.

    UP Next:
    I'm working on a 1st draft of Semantic highlighting support. Hopefully I'll have a new release later next week.

    Regards,
    Stephen

  • Cluso99Cluso99 Posts: 17,474

    Excellent news Stephen.
    I have a fresh VSC on my laptop so I'll give it a try now :)

  • Cluso99Cluso99 Posts: 17,474
    edited 2021-02-21 06:51

    The marketplace install is a breeze, so many thanks for this Stephen :smiley:

    It's a fresh VSC install yesterday (never previously installed on this laptop since SSD reformat and W10 install).

    Things I noticed...

    • I am using a different color scheme (the VSC default or python default) with a black background and pale green for comments.
    • So I selected my color scheme (from the spin2 install). Didn't like it anymore and probably should go :(
    • Switched to IronSheep color scheme. Sorry, not much better (bright red and bright green) :(
    • This also changed the screen formatting from tabs to boxes ie a flat screen style. (revered below)
    • The color scheme has overwritten my default color scheme and replaces the python colors too, so it's global

    So, I tried a new color scheme (which obviously replaces the previous selected onte)

    • File|Preferences|Color Theme
    • Select Dark (Visual Studio) or Dark (default dark)
    • Now I have my colors back and the tabs (ie flat screen style back off)

    I don't know if it's possible to have a different color scheme depending on the file type open??
    Otherwise, either of the Dark color schemes works quite ok with spin as well as python.

    Thanks again Stephen.

    Just need a button to compile and download using the terminal window of VSC and I'll be in heaven. It's easy enough to drop out to command window and run a bat file to do this but it would be better if we can do this within VSC. BTW would be nice for two buttons, one for flexspin and one for pnut (or a new command line PropTool).Then we'd have a choice of either compiler at our fingertips.

  • Ken GraceyKen Gracey Posts: 7,184
    edited 2021-02-22 03:35

    Here ye, here ye!

    Manual extension removed, installed the new one from the Marketplace! I'm almost ready to join @Cluso99 in heaven when that compile/download button is added to VSC. Stephen is actually ahead of his own schedule he shared with me last week. @Cluso99, since I'm a bit booked early this week with educational projects, I'm gonna lay my bets on the Iron Sheep because I think that "play" button is likely to appear soon enough. So, you may not need to walk me through the command line stuff. Once Stephen has this part done, my system updates itself!

    I invite you to join me in the support of Stephen Moraco!

    Like many others, Stephen is making important contributions to the Propeller 2 community and while he's intrinsically motivated, it always helps to show that appreciation and support his coffee/home automation fund. Stephen shows us the importance of learning new things, working constructively as a team, and having a methodical engineering process. Make your deposit right here each month https://www.patreon.com/IronSheep. Parallax will join as a Herdman, so we can shepherd him in the P2 community direction without a sheepish, lamb-like intent! **

    Ken Gracey

  • This will be a very important P2 Quick Byte once that compile/download button appears.

    Ken Gracey

  • Cluso99Cluso99 Posts: 17,474

    Anxiously awaiting that button :smiley:

    The marketplace install was a breeze!!!

    Thanks again Stephen :smiley:

  • NEWS: Updated the P2 VSCodeExtensions repository README - the top level page and added new pages:

    1. Configuring Tasks follow along with me as I document configuring VSCode to compile and download to our P2 boards. I'm writing what I've learned and you can copy/paste the examples into your environment and be running as I am. After I get each solution running I'll update this page so it's immediately avail. for use.

    2. VSCode Extensions we find useful in our own P2 development

    In our zoom call today (25 Feb) you saw me running the latest version of Flexspin/Loadp2 on the Mac under VSCode using cmd-shift-B to build(compile for P2) and cmd-shift-D to download to the P2 board. The Mac working solution is already posted to this new page.

    My next additions to this same page will be the Flexspin/Loadp2 examples for Windows and then from Raspberry Pi. I'll move to PNut examples on Windows after that. The solutions will all be the same but will have examples specific to each platform for you to copy-n-paste.

    However, since this is mostly step-and-repeat I'm going to move for a couple of days to the Up Next item and then return to this.

    UP Next:
    I'm working on the 1st draft of Semantic highlighting support. Hopefully, I'll have a new Spin2 release early next week.

    Regards,
    Stephen

  • NEWS

    VSCode's use of FlexProp tools now has working examples for both macOS and Windows. See: Configuring Tasks

    I've also adjusted the pattern to prevent the download of non-top-level files to our P2s. DownloadP2 now depends on a new task, compileTopP2, instead of the original default build task compileP2.

    Work continues on the 1st draft of Semantic highlighting support.

    Regards,
    Stephen

  • In my opinion, tasks.json should be OS and install location independent. So I'd change it to explain how to add the tools to PATH. No need for silly absolute paths.

  • Cluso99Cluso99 Posts: 17,474

    @Wuerfel_21 said:
    In my opinion, tasks.json should be OS and install location independent. So I'd change it to explain how to add the tools to PATH. No need for silly absolute paths.

    Depends.
    I have a number of python installations and because of the PATH statement I cannot get one of the versions to install an addon because another python version intercepts the addon install :(

  • @Cluso99 said:

    @Wuerfel_21 said:
    In my opinion, tasks.json should be OS and install location independent. So I'd change it to explain how to add the tools to PATH. No need for silly absolute paths.

    Depends.
    I have a number of python installations and because of the PATH statement I cannot get one of the versions to install an addon because another python version intercepts the addon install :(

    Yea that sometimes happens. Should be fine for flexspin and friends though, can just rename old versions

  • Stephen MoracoStephen Moraco Posts: 120
    edited 2021-03-07 07:40

    NEWS

    I've just released v0.3.0 of our Spin2 vscode extension. This provides fixes to some highlighting issues (e.g., numbers within symbol names are no longer marked as numbers.)
    This also has the 1st draft of our new Semantic Highlighting and the theme "Spin2 IronSheep" has been updated to highlight based on the new semantic information. Note: while your favorite themes should work and custom theme for Spin will be able to work better as there are some language elements that do not have support in traditional language. I'll be writing more about this as I make more progress.

    See the ChangeLog from within vscode or at github.

    I'll be posting new details about what exactly is called out in the highlighting soon.

    Longer-term I'll be looking for help from someone with a great color-theory background so we can make a couple of really great-looking light and dark themes for spin2. Have a background like this and want to help? Please contact me. It's not a big effort, just very detailed. A knowledge of spin2 and an understanding of elements of computer languages would help.

    I'll be releasing new versions once or twice a week as I continue to get known issues fixed and the pasm support added.

    Regards,
    Stephen

  • Cluso99Cluso99 Posts: 17,474
    edited 2021-03-07 09:27

    @"Stephen Moraco" said:
    NEWS

    I've just released v0.3.0 of our Spin2 vscode extension. This provides fixes to some highlighting issues (e.g., numbers within symbol names are no longer marked as numbers.)
    This also has the 1st draft of our new Semantic Highlighting and the theme "Spin2 IronSheep" has been updated to highlight based on the new semantic information. Note: while your favorite themes should work and custom theme for Spin will be able to work better as there are some language elements that do not have support in traditional language. I'll be writing more about this as I make more progress.

    See the ChangeLog from within vscode or at github.

    I'll be posting new details about what exactly is called out in the highlighting soon.

    Longer-term I'll be looking for help from someone with a great color-theory background so we can make a couple of really great-looking light and dark themes for spin2. Have a background like this and want to help? Please contact me. It's not a big effort, just very detailed. A knowledge of spin2 and an understanding of elements of computer languages would help.

    I'll be releasing new versions once or twice a week as I continue to get known issues fixed and the pasm support added.

    Regards,
    Stephen

    Excellent news Stephen.
    I find the python colors nice and eye pleasing using the VSC default dark theme.

    Count me out when it comes to colors. My wife tells me I have a terrible color sense :(

Sign In or Register to comment.