Shop OBEX P1 Docs P2 Docs Learn Events
Question about calling a DATA Label in a subroutine — Parallax Forums

Question about calling a DATA Label in a subroutine

T&E EngineerT&E Engineer Posts: 1,396
edited 2009-08-19 23:02 in General Discussion
Please reference this link: http://forums.parallax.com/showthread.php?p=810347

I have tried to incorporate a left scrolling routine based on some code that JonnyMac wrote for an 8x8 LED display. I can get it to work well if I include the actual name of the DATA label in the subroutine. But if I use something like tmpW1 it does not work. I have attached the updated code and summarized below. Please help me in what I am missing here.


DRAW_SCROLL_LEFT SUB 3   ' Scrolls left a 32 x 8 picture

DRAW_SCROLL_LEFT Picture1, 1 'Scrolls left data picture in Label "Picture1:"

 
 
SUB DRAW_SCROLL_LEFT
  tmpW1 = __WPARAM12    ' start of label
  cs = __PARAM3
 
  FOR tmpB2 = 0 TO 64 STEP 2
  tmpB3 = tmpB2
  FOR addr = 0 TO 63 
    READINC [b]Picture1 +[/b] tmpB3, tmpB1  ' read picture data
    SENDDATA addr, tmpB1, cs
  NEXT addr  
  DELAY_MS 50
  NEXT tmpB2  
  ENDSUB 
 
 
[b]THIS DRAW ROUTINE BELOW WORKS AND DOES NOT USE THE ACTUAL LABEL NAME[/b]
 
 
[b]' Use: e.g. DRAW Picture1, DispNo(1-4) [/b]
[b]SUB DRAW
  tmpW1 = __WPARAM12    ' start of label
  cs = __PARAM3
  FOR addr = 0 TO 63 
    READINC tmpW1, tmpB1  ' read picture data
    SENDDATA addr, tmpB1, cs
  NEXT addr   
  ENDSUB[/b] 
 
 
 
Picture1:  'Picture1 Label (sideways picture)
DATA %1111, %1111
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1000, %0001
DATA %1111, %1111
 
Pad1:
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0
DATA 0,0

Comments

  • BeanBean Posts: 8,129
    edited 2009-08-19 15:19
    ·Because READINC will increment the pointer, you will need to subtract from the pointer the value of the number of bytes read.

    Something like this:

    SUB DRAW_SCROLL_LEFT
      tmpW1 = __WPARAM12    ' start of label
      cs = __PARAM3
     
      FOR tmpB2 = 0 TO 64 STEP 2
        tmpW1 = tmpW1 + tmpB2
        FOR addr = 0 TO 63 
          READINC tmpW1, tmpB1  ' read picture data
          SENDDATA addr, tmpB1, cs
        NEXT addr
     
        tmpW1 = tmpW1 - 64
        tmpW1 = tmpW1 - tmpB2
     
        DELAY_MS 50
      NEXT tmpB2  
    ENDSUB 
    
     
    

    ·Bean.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Does that byte of memory hold "A", 65, $41 or %01000001 ?
    Yes it does...


    ·
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-08-19 23:02
    Bean,

    I think a problem in what you gave me is related to the "STEP 2" portion of the FOR NEXT routine. I just get a bunch of scrambled LEDs scrolling accross. How can this be compensated for?


    How does one know to use a READ vs a READINC?

    Is there any other posts besides the HELP file on this?


    Thanks.

    Post Edited (T&E Engineer) : 8/20/2009 12:25:15 PM GMT
Sign In or Register to comment.