Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: a complete programming system for P2 (and P1) - Page 11 — Parallax Forums

FlexProp: a complete programming system for P2 (and P1)

18911131455

Comments

  • ersmith wrote: »
    which is probably not what you intended. As Jon mentioned, you more likely wanted
        long[@X][i] := i
    
    Yes, that's how I should be filling the array, in Spin2 Thx!

  • RaymanRayman Posts: 14,737
    edited 2020-12-19 18:37
    Trying to compile some Gameduino code and get an error on this:
    class xy {
    public:
      int x, y;
      void set(int _x, int _y);
      void rmove(int distance, int angle);
      int angleto(class xy &other);
      void draw(byte offset = 0);
      void rotate(int angle);
      int onscreen(void);
      class xy operator<<=(int d);
      class xy operator+=(class xy &other);
      class xy operator-=(class xy &other);
      long operator*(class xy &other);
      class xy operator*=(int);
      int nearer_than(int distance, xy &other);
    };
    

    Doesn't like the operator stuff. I imagine that is not implemented, right?
    Hopefully, I can rewrite that as a function like:
    void LeftShiftEquals(int d)
    void PlusEquals(class xy &other)
    

    Update: Seems to be compiling as long as add the prefix "class" to all references to "xy"
  • RaymanRayman Posts: 14,737
    I'm getting an error on this:
    static void cFFFFFF(byte v);
    
    says:
    1>Version 5.0.1 Compiled on: Nov 28 2020
    1>helloworld.cc
    1>GD2.h:721: error: syntax error, unexpected static
    
    I see "static" being using in c.md, so not sure what's going on...
  • RaymanRayman Posts: 14,737
    edited 2020-12-19 22:09
    It looks like functional typecasting does not work... Is that a C++ feature?
    This gives an error:
       double x = 10.3;
        int y;
        y = int(x);
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-12-19 21:26
    Eric,
    I am inputting a line (string) from the command line (w10) terminal and I need my routine to cater for <bs> to edit the line before acceptance/enter. However, the <bs> character is just displaying a character (sort of a house like character) for the <bs> character.

    Is there another character or sequence I can use to either move the cursor left or perform a backspace?


    Solved. The <bs> is returned as a $7F from the terminal instead of $08. $08 performs a backspace, so the sequence $08,$20,$08 performs a destructive backspace.

    So here is my solution
      Print.fstr0(string("SD:>"))                                   ' prompt
      addr := @commandLine
      repeat
          ch := Print.rx()                                          ' waits for an input char
          if (ch == $08 or ch == $7F)                               ' <bs> ? (doesn't work in command line terminal!)
            ch := $08                                               ' force <bs>
            addr--
            if addr < @commandLine                                  ' <bs> and empty buffer?
              addr := @commandLine                                  ' y: so back to start of buffer
            else
              Print.tx(ch)                                          ' <bs>
              Print.tx(" ")                                         ' <space>
              Print.tx(ch)                                          ' <bs>
          else
            byte[addr++] := ch                                      ' store char
            Print.tx(ch)                                            ' echo
      while ch <> _cx._carriageReturnCharacter
      Print.tx(_cx._lineFeedCharacter)                              ' <lf>
      byte[addr] := 0                                               ' store terminating 0
    
  • Rayman wrote: »
    Doesn't like the operator stuff. I imagine that is not implemented, right?
    Correct, that is a C++ feature that flexcc does not implement yet.
    Rayman wrote: »
    I'm getting an error on this:
    static void cFFFFFF(byte v);
    
    says:
    1>Version 5.0.1 Compiled on: Nov 28 2020
    1>helloworld.cc
    1>GD2.h:721: error: syntax error, unexpected static
    
    I see "static" being using in c.md, so not sure what's going on...

    Look on the previous line, that's probably where the error is. flexcc certainly does understand "static", but if it's confused by earlier errors then it might not expect the static where it actually sees it.

    Ah, it might be that this declaration is inside a class? If so, flexcc doesn't support static member functions yet ("static" means something quite different in a class).

  • Rayman wrote: »
    It looks like functional typecasting does work... Is that a C++ feature?
    This gives an error:
       double x = 10.3;
        int y;
        y = int(x);
    

    Probably won't work. You'll have to use C style like:
      y = (int)x;
    
  • FlexProp 5.0.3 is available now from the usual places (links are in my signature and in the first post in this thread). There are some Changelog files listing the changes; mainly these are bug fixes, except that:

    - loadp2 now accepts a -RTS flag to use RTS for reset instead of DTR
    - FlexBasic has a new reserved word, 'private', which isn't used yet but will eventually allow for private methods in classes
  • RaymanRayman Posts: 14,737
    Question about the "class" construct using "typedef struct"...
    Should it be able to access global variables?

    I have x, y, and vxf defined globally, but I get an "unknown symbol" error on this unless they are present in the structure:
    typedef struct PolyStruct {
        int x0, y0, x1, y1;
        int x[8], y[8];
        byte n;
    
        int w;  //RJA added these locally as FlexSpin does not recognize global variables in this "class"
        int h;
        byte vxf;   // Vertex Format
    
        void restart() {
            n = 0;
            x0 = (1 << vxf) * w;
            x1 = 0;
            y0 = (1 << vxf) * h;
            y1 = 0;
        }
    
  • RaymanRayman Posts: 14,737
    Visual Studio flags this as an error, saying "Unnamed prototype parameters not allowed when body is present". But, it seems to work anyway. Should it?
    void ray(int &x, int &y, int r, int i)
    {
      uint16_t th = 0x8000 + 65536UL * i / 7;
      polar(x, y, r, th);
      x += 16 * 240;
      y += 16 * 136;
    }
    
  • Rayman wrote: »
    Question about the "class" construct using "typedef struct"...
    Should it be able to access global variables?
    It "should" in the sense that that's the way it really ought to work. But right now it won't, because in FlexProp the structures are like independent Spin objects and so can't reference global variables. I hope to fix this, but don't have a timeline for it.
    Rayman wrote: »
    Visual Studio flags this as an error, saying "Unnamed prototype parameters not allowed when body is present". But, it seems to work anyway. Should it?
    void ray(int &x, int &y, int r, int i)
    {
      uint16_t th = 0x8000 + 65536UL * i / 7;
      polar(x, y, r, th);
      x += 16 * 240;
      y += 16 * 136;
    }
    

    It looks OK to me -- I don't see any unnamed prototype parameters in that snippet. Is there another definition elsewhere in the class?
  • RaymanRayman Posts: 14,737
    edited 2020-12-24 02:10
    Thanks. That "unnamed prototype" thing is strange. Visual Studio gets hung up on &x and &y.
    Think it works though...
  • Where is the function _pinstart defined.

    Do I use _pinr(x) to read a pin?

    Mike

  • Found an optimization bug.
    int main()
    {
        int i;
        int mask;
        int x;
        
        mask = 0x07 << 24;
        
        x = 0;
        while (1)
        {
            __asm volatile {
                modz 0 wz
                setpat mask, mask
                waitpat
                mov i, ina
                modz 1 wz
                setpat mask, mask
                waitpat
            }
            
            i = i >> 24;
            i = i & 0x07; 
            if ((i & 2) == 0) <-- this doesn't work over optimized
            	x++;
            if ((i & 4) == 0)
            	x--;
            if ((i & 1) == 0)
            	x = 0;
            printf("Count: %d %x\n", x, i & 1);
        }
        
        
        while (1)
        {
            _waitms(1000);
    	}
    }
    

    Mike
  • iseries wrote: »
    Where is the function _pinstart defined.
    It's built-in, and defined in sys/p2_code.spin.
    Do I use _pinr(x) to read a pin?
    Yes, for a regular pin. For smartpins use _rdpin.
  • iseries wrote: »
    Found an optimization bug.
    Wow, that's a really bad one -- the peephole optimizer has a serious flaw in its AND/TEST optimization. I'm surprised it hasn't shown up earlier. It's fixed now in github.
    Thanks for the bug report!

  • I've released version 5.0.4, which has a number of compiler bug fixes (including a fix for the optimizer bug @iseries mentioned above). It's available at both my patreon page and at github (see my signature or the first post in this thread).
  • Cluso99Cluso99 Posts: 18,069
    Thanks Eric :)
  • dgately wrote: »
    Wuerfel_21 wrote: »
    Again, IDK about the GUI, but for the flexspin compiler you just
    git clone https://github.com/totalspectrum/spin2cpp.git
    
    All the source is available in the github flexprop repository...
    https://github.com/totalspectrum/flexprop
    As ersmith stated, you can easily build the whole project (i.e. GUI, all the binaries for compiling & loading) on WIN10, Linux, macOS...

    I suggest (on Linux or macOS) something like:
    $ mkdir source
    $ cd source
    $ git clone --recursive https://github.com/totalspectrum/flexprop.git
    $ cd flexprop
    $ make clean     # only if you had previously run make
    $ make install
    
    Note: '--recursive' allows git to include all of the projects sub-modules (PropLoader, loadp2, & spin2cpp).
    If successful, you'll find a new flexprop directory in your home directory, where you'll find the flexprop.tcl GUI, tools & sample code:
    $ cd ~/flexprop
    $ ls
    License.txt  bin          doc          include      src
    README.md    board        flexprop.tcl samples
    $ ls bin
    fastspin        flexcc          flexspin        loadp2          mac_terminal.sh proploader
    

    Use flexprop.tcl if you like or the tools in the bin directory from the Linux/macOS command line. It's "all there".

    Note: flexprop may have some requirements for successful building... If make install does not work, you can probably get help here in the forum...


    dgately

    Wuerfel, Dgately,

    Thanks! this got it working for me (With a couple of side trips, easily solved with a search in the Ubuntu forum...)

    I presume that cloning flexprop got me the latest, greatest, right? What would I do when new versions are released? would it be best to follow this process, or just unzip the new zip file over it?

    Thanks again!
  • You can just do all that again. In theory you should also be able to just "git pull" the latest changes, but IDK how to do it properly when submodules are involved...
  • dgatelydgately Posts: 1,630
    edited 2020-12-30 17:12
    R Baggett wrote: »
    I presume that cloning flexprop got me the latest, greatest, right? What would I do when new versions are released? would it be best to follow this process, or just unzip the new zip file over it?
    On my system (my disclaimer), with the loadp2 & spin2cpp sub-modules, a "git pull" within the flexprop directory, has NOT given me a full update. Not sure if this is something to do with my own macOS system, but here's a sure fire way to get updates and build flexprop on macOS & Linux systems:
    $ cd flexprop/spin2cpp
    $ git pull
    ...  <== resultant git stuff
    $ make clean
    ...
    $ make
    ...  <== resultant build stuff, hopefully successful
    $ cd ../loadp2
    $ git pull
    $ make clean
    $ make
    ...  <== reluctant build stuff, hopefully successful
    $ cd ../    <== back to flexprop directory
    $ git pull
    $ make clean
    ...
    $ make install
    ...  <== hopefully successful
    $ cd ~/flexprop   <== should now be ready to execute ./flexprop.tcl
    
    When I previously just exec'd git pull at flexprop's top directory, spin2cpp & loadp2 did not get updated. Maybe there's a missing option (like: "--recursive") that is needed for git pull... I'm not aware of one.


    dgately

  • ersmithersmith Posts: 6,068
    edited 2020-12-31 00:22
    I think that performing
    cd source/flexprop
    git pull
    git submodule update
    make clean
    make install
    
    should update both the main flexprop and also all submodules (spin2cpp, loadp2, etc.), and then rebuild everything. I have found that the "make clean" seems to be necessary, some dependency isn't quite correct.
  • If I just type 'make' I get this. I seem to have to do 'make install'. Is that normal?
    dbetz@Davids-Mac-mini-2 flexprop % make
    
    Usage:
      make install
      make zip SIGN=signscript
    
  • David Betz wrote: »
    If I just type 'make' I get this. I seem to have to do 'make install'. Is that normal?
    dbetz@Davids-Mac-mini-2 flexprop % make
    
    Usage:
      make install
      make zip SIGN=signscript
    

    Oops, sorry, yes it should have been "make install" rather than just "make". I'll fix the original post.
  • FlexProp version 5.0.5 is available now. Changes are detailed in docs/Changelog*.txt. The GUI has tooltips that pop up when you hover over the file name tabs to show the full file name (they're a little bit finicky, so you may have to leave the tab and go back into it a few times to get them to work). The compiler has a few minor bug fixes, including adding some missing EVENT_* symbols for Spin2 and a better procedure for loading objects with no explicit file extension.

    The binary has been up on my patreon page for a few days, but is now available to the public. It's also on github: https://github.com/totalspectrum/flexprop/releases.
  • I think I found a bug?

    In simpleIDE the function getStr(Buffer, 200) does not echo characters.

    Your code aliased to safe_gets(text_t, Buffer, 200) does echo characters and I would get double if echo was turned on.

    I think the code on this line should be changed from:
    int ch = text ? text->rxChar(text) : _rx();
    To:
    int ch = text ? text->rxChar(text) : _rxraw();

    Mike
  • Thanks, Mike! That's fixed in github now.
  • For Spin2 in PropellerTool and PNut, getms() is defined, while in flexprop _getms() is defined, which makes it difficult to compile code "as is" between the 2 different compilers/IDEs. Should flexprop provide an alias getms() to _getms()?

    We found this during one of JonnyMac's P2 presentations, using example code he had written with PropellerTool 2.4.1.

    dgately
  • dgately wrote: »
    For Spin2 in PropellerTool and PNut, getms() is defined, while in flexprop _getms() is defined, which makes it difficult to compile code "as is" between the 2 different compilers/IDEs. Should flexprop provide an alias getms() to _getms()?
    I didn't realize that Chip had added getms. It's fixed in github now. Thanks!
  • I've released FlexProp version 5.0.6 on my Patreon page. A public release will follow later this week.

    Compiler changes:
    - Added cog_* functions from libsimpletools
    - Added get_directions() and get_outputs() functions from simpletools
    - Added getms() in Spin2
    - Documented _pinstart() function for C
    - Fixed an off-by-one in the BASIC INSERT$ function.
    - Fixed errors in declarations of C modf() and frexp() functions.
    - Fixed read() on terminal to break on newline if applicable
    - Improved error messages for type mismatches.
    - Made libsimpletext text read use _rxraw() to avoid echo.
    

    GUI changes:
    - Added links to Parallax documentation under Help menu
    - Made help text for GUI wrap
    - Removed search hilight when search window is closed
    
Sign In or Register to comment.