Shop OBEX P1 Docs P2 Docs Learn Events
RGB LED Array accessory for Eval type header - Page 2 — Parallax Forums

RGB LED Array accessory for Eval type header

2»

Comments

  • RaymanRayman Posts: 16,161

    Hmm... Ok, guess overkill... Still if can strobe at 40*900/8 = 4.5 kHz... Maybe good as a flash for high speed camera...

  • TonyB_TonyB_ Posts: 2,273
    edited 2026-03-17 13:11

    @JonnyMac said:
    This code is the equivalent of pinwrite() after the signals from each stream have been moved into a parallel group.

    wr_outs                 testb     outs, #5              wc      ' lsb pin in outa or outb?
            if_nc           setq      outsmask                      ' mux pixouts into outa using outsmask
            if_nc           muxq      outa, pixouts
            if_c            setq      outsmask                      ' mux pixouts into outb using outsmask
            if_c            muxq      outb, pixouts
    

    SETQ does not have to be immediately before MUXQ, unlike most instances of SETQ. It can be a few or many instructions earlier, as long as Q is not changed in the interim. (Another SETQ is not required before the next MUXQ if the mask is the same and nothing else modifies Q.) Therefore the following code is possible:

    wr_outs                 setq      outsmask                      ' 
                            testb     outs, #5              wc      ' lsb pin in outa or outb?
            if_nc           muxq      outa, pixouts                 ' mux pixouts into outa using outsmask
            if_c            muxq      outb, pixouts                 ' mux pixouts into outb using outsmask
    
  • I wondered about that, Tony, but ended up duplicating what Chip does in the interpreter. The docs on setq are a little confusing; I interpreted them as saying that q gets reset after the next instruction.

    From the latest interpreter:

    ' PINWRITE(pins,val)
    '
    pinwrite_       mov     w,x                     'w=val
    
                    setq    #2-1                    'pop pins and new top of stack
                    rdlong  x,--ptra                'y=pins
    
                    ror     y,#6    wc              'get outa/outb flag into c
    
                    bmask   v,y                     'make mask
                    rol     y,#6
    
                    rol     v,y                     'justify mask
                    rol     w,y                     'justify val
    
            if_nc   setq    v                       'mux val into outa using mask
            if_nc   muxq    outa,w
    
            if_c    setq    v                       'mux val into outb using mask
            if_c    muxq    outb,w
    
            _ret_   dirh    y                       'enable outputs
    

    Moments later....

    Okay, that works. Thanks for the feedback.

Sign In or Register to comment.