Shop OBEX P1 Docs P2 Docs Learn Events
FlexGUI 4.3.1: Program your P2 in Spin, BASIC, or C - Page 4 — Parallax Forums

FlexGUI 4.3.1: Program your P2 in Spin, BASIC, or C

1246

Comments

  • Cluso99Cluso99 Posts: 18,069
    If you are just using the C FAT32 system, how much hub code does this require?
  • Cluso99 wrote: »
    If you are just using the C FAT32 system, how much hub code does this require?

    It's pretty big, I left all the options in the code "on" so it compiles the formatting, directory, read/write, and all FAT options. A test program using FAT is about 20K bigger than one using the host file system.

  • Cluso99Cluso99 Posts: 18,069
    Thanks Eric.

    Then I'll continue (when I next get time) to complete Kye's FAT32 spin code conversion to spin2.
    It's done but not tested with the PASM2 SD Driver I've done.
  • @ersmith This new SD file system is big fun! :) Note that we are restricted to DOS-style 8.3 filenames. So "hello.txt" works fine, but "hellothere.txt" fails. This isn't remotely a show-stopper, but it had me scratching my head for a bit so I figured I'd post it.
  • Huh, I thought the long filename support was enabled. Enabling it takes up another 10K of space though, so I think I'll leave it off by default. In the next release you'll be able to manually turn it on by editing the filesys/fatfs/ffconf.h file.
  • Cluso99Cluso99 Posts: 18,069
    ersmith wrote: »
    Cluso99 wrote: »
    If you are just using the C FAT32 system, how much hub code does this require?

    It's pretty big, I left all the options in the code "on" so it compiles the formatting, directory, read/write, and all FAT options. A test program using FAT is about 20K bigger than one using the host file system.

    Seems I may have this wrong, missing the whole size including the host file system.

    How big is the total p2 code please?
  • Cluso99 wrote: »
    ersmith wrote: »
    Cluso99 wrote: »
    If you are just using the C FAT32 system, how much hub code does this require?

    It's pretty big, I left all the options in the code "on" so it compiles the formatting, directory, read/write, and all FAT options. A test program using FAT is about 20K bigger than one using the host file system.

    Seems I may have this wrong, missing the whole size including the host file system.

    How big is the total p2 code please?

    @Cluso99 Take this with a grain of salt, but when I implement fopen(), fclose(), fread(), fwrite(), fputc(), fgetc(), fputs() and fgets() it compiles to about 40K, and this includes a BASIC "wrapper" bringing those functions more conveniently forward for non-C/Spin2 folks. That number also includes calls to sdmmc_is_present() and disk_initialize() (both of which may or may not actually work, as it is still very early in the learning curve for me). YMMV.


  • Cluso99Cluso99 Posts: 18,069
    edited 2020-05-02 03:34
    So it's worth continuing the SPIN2/PASM2 conversion. It's almost working but I haven't had any time recently.
    SD FAT32 Driver in SPIN2        4.8 KB
    Spin2 Interpreter               4   KB
    Variables                       0.7 KB
    SD Driver in PASM2              1.5 KB
    SD Buffer (included in Vars?)   0.5 KB
                                   -------
    Total memory footprint         11.5 KB
    
  • I've released the FlexGUI 4.1.8 binary in the usual places. The compiler improvements are mainly bug fixes, although I did add the CALL and REG builtins from Spin2 for improved compatibility with Chip's compiler.

    On the GUI side there's a new editor option to enable syntax highlighting. It's off by default, because it's still an experimental feature and probably not very satisfactory. Only Spin and C syntax highlighting is supported for now, I hope to add BASIC soon.

    The binaries are avilable from the links in my signature. As usual, both Windows and Mac OS X executables are included in the flexgui.zip file.
  • Hi Eric,

    I just tested 4.1.8. The "save session on exit" and syntax highlighting is great! The editor is starting to become user friendly! Highlighting is not perfect, yet. For example it also highlights keywords in comments like "if" and "for". And at the moment it doesn't recognize assembler. But a good step forward.
  • I don't think Eric is seeking criticism of the syntax highlighting just yet.
  • AribaAriba Posts: 2,689
    Wow, syntaxhighlighting !
    I did not think this will happen. I find it already good enough to always let it switched on.

    I see, the locktry() now works as in Spin2 - thank's

    Andy
  • Time to change the title to 4.1.8? :)
  • Publison wrote: »
    Time to change the title to 4.1.8? :)

    Yes, thanks @Publison.
  • Cluso99Cluso99 Posts: 18,069
    Hey Eric,

    Compiling my Monitor & SD Driver code using spin2 and pasm with fastspin v4.1.8 and it runs :)
    Thanks heaps for your compiler :sunglasses::sunglasses::sunglasses::sunglasses::sunglasses: (5 stars)
  • Cluso99Cluso99 Posts: 18,069
    Eric,
    Believe I've found a bug.
    REG[$120] := REG[$101]
    This puts $101 into reg $120, not the contents of reg $101. The left side works fine.

    This also fails in the same way
    REG[mon.x] := REG[sd.cmdout]
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-05-05 09:15
    Eric,
    A little more info... (seems to be wrongly setting the immediate bit in the instruction)

    Tried this with same result - it loads $101 as immediate
    asm
    ' mov mon.x, sd.cmdpar
    mov $120, $101-0
    endasm

    which gave
    00660 01 D3 04 F6 | mov local01, #257 + 0

    and this seems to not work (possibly same problem)
    if REG[sd.status] == $a5

    BTW Do you have any workaround ideas? There's two things I'm trying to do
    1. move register to register
    2. compare register to constant
  • @Cluso99: thanks for the bug report. I think I've fixed the REG problem in github, and it'll be in the next release.
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-05-06 00:09
    Eric,
    Just reporting some differences in pnut to fastspin.
        STAT := initialiseSD(sd.BUF)                        ' initialise SD Card
    .....
    PRI initialiseSD(addr) 
    .....
        return($00)
    
    pnut reports a missing return parameter while fastspin is ok with this.
    The fix
        STAT := initialiseSD(sd.BUF)                        ' initialise SD Card
    .....
    PRI initialiseSD(addr) : status
    .....
        return($00)
    
    And this - checkStatus is a subroutine
        return(checkStatus)
    
    pnut requires this
        return(checkStatus())
    
  • fastspin accepts both Spin1 and Spin2, so things like the parentheses after functions with no arguments, or explicit return variable declarations, are optional in fastspin's version of both languages. Personally I think some of the breaking changes from Spin1 to Spin2 were a bad idea. Not necessarily from an aesthetic point of view: for example "checkStatus()" is more obviously a function call than "checkStatus". But there was no particular need for the change, and making it harder to port Spin1 code was, IMHO, a mistake. I plan to keep accepting the old Spin1 version of these things alongside the new Spin2 versions. You'll also find other things (like accepting "sd#BUF" as well as sd.BUF) along these lines.
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-05-06 13:01
    Eric,
    Good to know, and yes I’m not an advocate of the changes either. But it is what it is.

    FYI I can compile and run my monitor and sd driver unchanged with both fastspin and pnut now.

    Your listing is great! It’s enabling me to see what’s compiled if it doesn’t work as expected. I’m also finding my serial monitor great for debugging too now that I can see what’s happening and not flying blind. Great to just drop into the monitor and examine all cog/LUT/hub and then return back into my program, or just print a section on the fly.

    Also I find the inbuilt terminal great too. Saves having to quickly enable pst after downloading :)
    Slight annoyance when inputting at the command prompt is the backspace deletes the whole word. Takes a bit of getting used to as I correct a typo. I know it’s a feature.

    You’ve done a magnificent job so many thanks :)
  • RaymanRayman Posts: 14,537
    edited 2020-05-08 13:09
    Is the fastspin download page gone?
    Google used to bring it up for me... Can't find it today...

    Never mind... Found it with Spin2Cpp...
  • I just now downloaded and installed FlexGUI 4.1.8 It installed perfectly and everything works! i know it must have taken you a lot of time & effort to put this together. I appreciate the excellent documentation as well.
    I might have missed it but the pin-out for the VGA sample programs was hard to find: You might want to add a chart in the VGA remarks section. FYI - I found different VGA drivers have different pin-outs.
    The breakout board I made was: (starting with the base pin)
    Hsync = P0 = 13, VGA pin
    Blue = P1 = 3
    Green = P2 = 2
    Red = P3 = 1
    Vsync = P4 = 14
    Gnd = Gnd= 5
    Second item - Almost there, but how difficult is it to add ADC and DAC functions to the application code - or are there enough commands to do this in my program code?
  • @PropGuy2 : Thanks, I can't believe I forgot to mention in the README that the hardware is assumed to have the same pin-out as the P2-ES Audio/Video breakout board. I missed updating this in the 4.1.9 release but I'll try to get it in to the next one.

    ADC and DAC are done with smart pins on the P2, and low-level smart pin access is supported in all of the languages. If a high level API becomes standard perhaps I can add that as a built in.
  • I've posted FlexGUI 4.1.9 on github; Patreon seems to be messed up for me at the moment but I hope to put a version there soon as well. This version has BASIC syntax highlighting in the GUI, and a whole bunch of bug fixes in the compiler.

    The compiler also has "OPEN FOR INPUT/OUTPUT" in BASIC now, and a "mount" function in C and BASIC to allow multiple file systems to be accessed at the same time. The file system code is still under heavy development so these may still need some work, caveat emptor.
  • RaymanRayman Posts: 14,537
    @ersmith I actually prefer function calls to have parenthesis. Following old Spin1 code is difficult when you can’t tell what is what ...
  • Rayman wrote: »
    @ersmith I actually prefer function calls to have parenthesis. Following old Spin1 code is difficult when you can’t tell what is what ...

    fastspin is happy either way. In both Spin1 and Spin2 the parentheses are optional. I like them too, but I can't force them for Spin1 code (for compatibility) and didn't feel like adding the extra code to make them mandatory for Spin2.
  • @ersmith I am *really* liking the BASIC syntax highlighting in V4.1.9!
  • @ersmith In FlexBASIC version 4.1.9, is there a way to OPEN a file (using Mount then Open) in append mode? The docs only mention "input" and "output" mode (which will truncate an existing file to zero bytes before writing).
  • JRoark wrote: »
    @ersmith In FlexBASIC version 4.1.9, is there a way to OPEN a file (using Mount then Open) in append mode? The docs only mention "input" and "output" mode (which will truncate an existing file to zero bytes before writing).

    No, there is no append mode (yet).
Sign In or Register to comment.