+ Reply to Thread
Page 4 of 43 FirstFirst 1234567814 ... LastLast
Results 61 to 80 of 851

Thread: Download PropBASIC here... 00.01.14 LAST VERSION FOR BST

  1. #61

    Default

    JonnyMac said...
    Here's a version of Terry's program that lets you store the lighting sequences in a DATA table (does not use program space as tables are stored in the Hub) -- this will let you define sequences using Terry's color scheme, which is FAR EASIER than the high-low mash-up strategy you started with. You simply call the PLAY subroutine with the sequence you want to use and the step timing.

    Thanks again!

    This is wayyyy cool, at least to me.

    I'm still working to understand exactly·how it all does what it does on this version, this is a lot of new ground for me, but it's coming.


    Darlene
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  2. #62

    Default

    There's a hidden trick in there: When you pass a Hub variable or xDATA symbol to a subroutine or function it is passed by address, not by value. In order to read from the hub you have to use RDxxxx, in this case we use RDBYTE as the sequence is a table of bytes. The syntax for RDBYTE is RDBYTE hubaddress, value. This gets used six times (for your six RGB led groups) in PLAY checking for an end-of-sequence value ($FF) each time, and then incrementing (adding one to) the address for the next group. After all the LEDs are updated the delay value you passed is used with DELAY_MS (shell for PAUSE).

    There is a compiler trick in use, as well. You see, PropBASIC knows how to adjust outputs for a pin group, based on the location of that pin group. The [internal] code isn't difficult, nor is it trivial. For example, if you want to do this:

    Code:
    CSG6 = PURPLE


    ... the compiler actually generates the following code. I've added comments to explain what each line does

    Code:
    ' CS6 = PURPLE
                    mov         __temp1,#PURPLE                     ' copy PURPLE (%101) to __temp1
                    shl         __temp1,#15                         ' align with base pin of CS6 group
                    and         __temp1,CS6                         ' clear non-CS6 bits from __temp1
                    andn        outa,CS6                            ' clear old CS6 group outputs
                    or          outa,__temp1                        ' write new value to CS6 group outputs

    Post Edited (JonnyMac) : 1/1/2010 2:36:52 AM GMT
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  3. #63

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    Geekgirl,
    · Yeah if you're coming from PBASIC "pin groups" are great.
    · If you need more assistance please ask. It's nice to see what forum members are "up to" with PropBASIC.

    · P.S. Jon must have downloaded my code before I fixed the color names.· ORANGE should be YELLOW, and PURPLE should be MAGENTA, and AQUA should be CYAN.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Try BASIC on the Propeller.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    Post Edited (Bean (Hitt Consulting)) : 12/31/2009 9:54:16 PM GMT
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  4. #64

    Default

    A little more development on using Bean's method to talk to Spin objects from PropBASIC, running on Rayman's PSM.
    The following makes two Spin objects available on demand to the main BASIC program;
    This time there actually is some code in the BASIC program; which generates a tone, then displays version detail on the LCD.
    The object of posting this is so that newcomers like myself can have an easy example, with a low level of abstraction.
    T o n y

    Code:
    DEVICE P8X32A, XTAL1, PLL16X 
    FREQ 80_000_000 
    
     
    tonegenStart CON 1 
    psmStart CON 2 
    psmDeviceinfo CON 3 
    
     
    spinCmd HUB BYTE = 0 
    hub_long1 HUB LONG 
    hub_long2 HUB LONG 
    hub_long3 HUB LONG 
    
     
    temp VAR LONG 
    
     
    ASM 
    OBJ 
      soundmachine: "psm_tonegenerator" 
      psmmachine: "psm_serialcontrol_a" 
    
     
    PUB SpinStart 
      CogInit(1, @__Init, @__DATASTART) 
      Repeat 
        case spinCmd 
          tonegenStart: 
            soundmachine.tonegen(hub_long1,hub_long2,hub_long3) 
            spinCmd := 0 
    
          psmStart: 
            psmmachine.main 
            spinCmd := 0 
    
          psmDeviceinfo: 
            psmmachine.showdeviceinfo 
            spinCmd := 0 
    ENDASM 
    
     
    PROGRAM Start 
    
     
    Start: 
    
     
    'start tonegen driver 
    
     
    WRLONG hub_long1, 400 
    WRLONG hub_long2, 500 
    WRLONG hub_long3, 3 
    WRBYTE spinCmd, tonegenStart 
    'wait for driver to process 
    DO 
      RDBYTE spinCmd, temp 
    LOOP UNTIL temp = 0 
    
    'start psm driver 
    WRBYTE spinCmd, psmStart 
    'wait for driver to process 
    DO 
      RDBYTE spinCmd, temp 
    LOOP UNTIL temp = 0 
    
    'start deviceinfo driver 
    WRBYTE spinCmd, psmDeviceinfo 
    'wait for driver to process 
    DO 
      RDBYTE spinCmd, temp 
    LOOP UNTIL temp = 0 
    END

    Post Edited By Moderator (Bean (Hitt Consulting)) : 1/1/2010 12:55:35 AM GMT
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  5. #65

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    Tony,
    · If you put your code inside the "Formatted Code" area (the # icon), it will keep the spacing.
    ·
    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Try BASIC on the Propeller.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  6. #66

    Default

    Here's another demo using the tone generator. Note that the psm_tonegenerator object hard-codes the output pins so you may need to change this (as I did) if you're using the Propeller Demo Board (I may *liberate* this code to create my own version that can pass pins and be stopped while playing).

    This demo plays three tones and then goes into a random loop -- somewhat reminiscent of old sci-fi computer sounds.

    Post Edited (JonnyMac) : 1/1/2010 1:18:15 AM GMT
    Attached Files Attached Files
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  7. #67

    Default

    JonnyMac,
    Thanks for the wonderful tonegenerator example!
    It's running in the background, playing music while I'm studying the code.
    It's 0130 here, back to some nightwork after the party.
    T o n y
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  8. #68

    Default

    That is what I like about this forum. IT ROCKS!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  9. #69

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    I have posted version 00.00.53.

    Along with a couple of bug fixes, PropBASIC now supports inline strings.
    Inline strings can be used anywhere a DATA label can be used.

    NOTE: Inline strings are Z-strings, so the compiler will automatically add a zero·to the end of them as a "end of string" indicator byte.

    Here is a demo showing inline strings:

    Code:
    DEVICE P8X32A, XTAL1, PLL16X
    FREQ   80_000_000
     
    Baud   CON "T115200"
     
    TX     PIN 30 HIGH
     
    temp   VAR     Long
     
    SendChar  SUB 1
    SendStr   SUB 1
     
    Message DATA "GoodBye", 0
     
    PROGRAM Start
     
    Start:
      GETADDR "Testing 1,2,3", temp
      SendStr temp
      PAUSE 1000
     
      SendStr "Hello"
      PAUSE 1000
     
      SendStr Message
      PAUSE 1000
     
      GOTO Start
    END
    
    SUB SendChar
      SEROUT TX, Baud, __param1
    ENDSUB
    
    SUB SendStr
      __param2 = __param1 ' SendChar uses __param1
      DO
        RDBYTE __param2, __param3
        IF __param3 = 0 THEN EXIT
        SendChar __param3
        INC __param2
      LOOP
      SendChar 13
    ENDSUB


    Bean.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    Post Edited (Bean (Hitt Consulting)) : 1/2/2010 3:25:57 PM GMT
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  10. #70

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    Coley found a bug in "var = const * [power of 2]" and "var = const / [power of 2]".

    The bug has been fixed in version 00.00.54 in the first post in this thread.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  11. #71

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    Jon found a bug when using serial open baud modes.
    I have fixed it and posted version 00.00.55 in the first post.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  12. #72

    Default

    PropBASIC/FUNC question:

    Hi all,
    May I tempt you with the following easy question?

    The following compiles nicely; but how do I do the three steps in one?

    Code:
    FUNC GetToneNumberSteps 
      Temp1=Duration*clkfreq 
      Temp1=Temp1/1000
      ToneNumberSteps=Temp1/200
      RETURN ToneNumberSteps
    ENDFUNC
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  13. #73

    Bean's Avatar
    Location
    Near Harrisburg PA
    Posts
    7,621
    Blog Entries
    4

    Default

    Assuming you don't need the temp1 value you can do:

    · ToneNumberSteps·= Duration * clkfreq
    · ToneNumberSteps = ToneNumberSteps / 200_000
    RETURN ToneNumberSteps

    Bean

    TonyWaite said...
    PropBASIC/FUNC question:

    Hi all,
    May I tempt you with the following easy question?

    The following compiles nicely; but how do I do the three steps in one?

    Code:
    FUNC GetToneNumberSteps 
      Temp1=Duration*clkfreq 
      Temp1=Temp1/1000
      ToneNumberSteps=Temp1/200
      RETURN ToneNumberSteps
    ENDFUNC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  14. #74

    Default

    TonyWaite said...
    PropBASIC/FUNC question:

    Hi all,
    May I tempt you with the following easy question?

    The following compiles nicely; but how do I do the three steps in one?

    Code:
    FUNC GetToneNumberSteps 
      Temp1=Duration*clkfreq 
      Temp1=Temp1/1000
      ToneNumberSteps=Temp1/200
      RETURN ToneNumberSteps
    ENDFUNC

    You need to be careful with duration -- if it goes more than 25 or so then you could get a rollover problem (from positive to negative) with the values. Since the *typical* clkfreq setting of a Propeller project is 80MHz and you have a constant value of 1000 you could boil the division down to 80_000, like this:

    Code:
    FUNC GetToneNumberSteps
      __param1 = __param1 * 80_000
      __param1 = __param1 / 200  
      ENDFUNC



    The duration is passed in __param1 and we don't need to use RETURN (just consumes a line of precious code space) because functions use __paramx variables to send values back to the caller.
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  15. #75

    Default

    Whoops, now that I look at it, the function can be even simpler given a clkfreq of 80MHz

    Code:
    FUNC GetToneNumberSteps
      __param1 = __param1 * 400
      ENDFUNC



    If you need to accommodate clkfreq I think you can simplify to:

    Code:
    FUNC GetToneNumberSteps
      __param2 = clkfreq / 200_000
      __param1 = __param1 * __param2
      ENDFUNC

    Post Edited (JonnyMac) : 1/3/2010 9:28:31 PM GMT
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  16. #76

    Default

    Bean & JonnyMac: many thanks!
    Now to improve my code ...
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  17. #77

    Default

    PropBASIC/FUNC question
    /Continued
    (Project is to attempt re-write of Rayman's PSM_ToneGenerator in PropBASIC)

    I've tried to work in the FUNC calls; the following gets past the compiler - which is encouraging.
    I'm uncertain whether I've used the __paramx variables correctly to get information in and out of the FUNC.
    My progress certainly improved when my blurry eyesight spotted the 'double-underscore' typography!
    Thank you, T o n y

    Code:
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN                5_000_000
    
    ToneNumberSteps       VAR LONG
    ToneLeftPhaseStep     VAR LONG
    ToneRightPhaseStep    VAR LONG
    ToneLeftAttenuation   VAR LONG
    ToneRightAttenuation  VAR LONG
    ToneLeftPin           VAR LONG
    ToneRightPin          VAR LONG
    ToneRunning           VAR LONG
    Frequency             VAR LONG
    Duration              VAR LONG
    Attenuation           VAR LONG
    LeftFrequency         VAR LONG
    RightFrequency        VAR LONG
    
    Tonegen               SUB  3,5
    GetToneNumberSteps    FUNC 1
    GetTonePhaseStep      FUNC 1
       
    PROGRAM               Start
    Start:
      DO
        Tonegen(400,500,3)                      'outputs test-tone of 400Hz, 500mS, attenuation level 3
        PAUSE 3000 
      LOOP 
    END
    
    FUNC GetToneNumberSteps 
      ' use duration as __param1
      __param2 = clkfreq / 200_000
      __param1 = __param1 * __param2
      'return of __param1 required
      RETURN __param1
      ENDFUNC
    
    FUNC GetTonePhaseStep
      ' use Frequency as __param1 
      __param2 = 1 << 15
      __param1 = __param1 * __param2
      __param2 = clkfreq / 200
      __param1 = __param1 / __param2
      __param2 = 1 << 13
      __param1 = __param1 * __param2
      __param2 = 1 << 4
      __param1 / __param1 * __param2
      'return of _param1 required  
      RETURN __param1
      ENDFUNC
    
    SUB Tonegen (frequency,duration,attenuation)ŠLeftFrequency,RightFrequency)
      ToneLeftPin=5
      ToneRightPin=4
      LeftFrequency=Frequency
      RightFrequency=Frequency
      
    
      ToneNumberSteps=GetToneNumberSteps Duration
      ToneLeftPhaseStep=GetTonePhaseStep LeftFrequency
      ToneRightPhaseStep=GetTonePhaseStep RightFrequency 
      
      ToneLeftAttenuation=Attenuation
      ToneRightAttenuation=Attenuation
      ToneRunning=true
      'COGSTART ......assembly stuff to come here with DAT etc to follow
    ENDSUB
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  18. #78

    Default

    Out of curiosity, what's the rationale behind using cogstart instead of cognew and swapping the parameters for RDxxx/WRxxx (compared to their PASM equivalents)? Regarding the latter, not that I mind that much but people starting with BASIC and going for PASM later might find this confusing.
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  19. #79

    Default

    The idea behind PropBASIC is to help those coming from PBASIC make the transition, hence the RDxxxx and WRxxxx more closely match READ and WRITE from PBASIC (and SX/B) where the address is the first parameter. Mind you, that's a guess on my part -- I do docs, but didn't design the compiler.
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

  20. #80

    Default

    JonnyMac said...
    The idea behind PropBASIC is to help those coming from PBASIC make the transition, hence the RDxxxx and WRxxxx more closely match READ and WRITE from PBASIC (and SX/B) where the address is the first parameter.
    Fair enough, not having used PBASIC I didn't/couldn't make that connection but that sounds reasonable :)
    Last edited by ForumTools; 09-30-2010 at 05:19 AM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts