Shop OBEX P1 Docs P2 Docs Learn Events
global variable block problem — Parallax Forums

global variable block problem

RimoRimo Posts: 3
edited 2011-03-04 05:02 in Propeller 1
HI all!

I'm a newbie in spin language.
And have one question.I could not find it become.
For example:

VAR

byte time[7]

PUB clockSecond

return ?? how to return complete time block?

or how to accessing variable block in other object?

thanks to reply

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-02 11:55
    clockSecond could return a pointer to the time array, or you could use another method to return the pointer as follow:
    PUB getTime
      return @time
    
  • RimoRimo Posts: 3
    edited 2011-03-02 13:35
    this is an pointer reference...
    temp := long[ds1307.getTime]   'get pointer reference and load local variable long
          vga.dec(temp.byte[1])            '0...7 block
    

    thanks but not working perfectly 0..3 index is ok but 4..7 so no good .. how to access next long ?

    i reply:
    vga.dec(byte[ds1307.getTime][1]) 'all block accessing

    this is ok
  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-02 13:48
    temp := long[ds1307.getTime][1]
    vga.dec(temp.byte[1])
    
    It's much better to do:
    temp := ds1307.getTime
    vga.dec(byte[temp][1]) ' for byte 1 or you can do
    vga.dec(long[temp][1]) ' for bytes 7..4 as a long
    
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-03-02 13:57
    Mike's suggestion is good, except that the time array only contains 7 bytes, and it may not be long aligned. It's better to access each element as a byte, such as byte[temp][0], byte[temp][1], ... byte[temp][6]. Technically, the index is not needed with the first byte, and you can access it as byte[temp].
  • RimoRimo Posts: 3
    edited 2011-03-04 00:47
    I like to read the per-byte value that then one i/o pins can convert martix controll.
    This is "temp" variable i do no need.
    I close my unit, so they:
    vga.dec(byte[ds1307.getTime][N]) /where N is the requested block
    But is it too will be so slow?
    vga.dec only can use the debugging..
    this is an matrix controll program proto version :smile:
    repeat i from 0 to 7
          outa[i + iopincol[i]]~~                           'set colum pins high
          outa[iopinrow[((byte[timer.getfulltime][1]) / 10 + i)]]~~ 'set row pins high( / 10, one digit)
          waitcnt(clkfreq / 1000 * MartixMS + cnt
          'and set low etc.. etc...
    dat
    iopinrow   byte  0,1,2,3,4,5,6,7,8,9               'i/o pins directiva for rows
    iopincol   byte  12,13,14,15,16,17                 'I/O pins directiva for colums
     
    
    This is a nixie tube controller colums in anode(six tubes) rows in 0....9 digits katode...
  • RS_JimRS_Jim Posts: 1,768
    edited 2011-03-04 05:02
    Rimo,
    First of all welcome to this forum. I struggled for a long time with using global variables and Jonny Mac was very helpfull in extending my understanding of it. For a newbe, there are some great articles about the prop and the latest one is about passing global vars here http://http://www.parallax.com/Resources/NutsVoltsColumns/TheSpinZone/tabid/781/Default.aspxHere is a thread where he shows the passing of some vars to both a spin cog and a pasm cog: http://http://forums.parallax.com/showthread.php?128922-Passing-Memory-Address-I-am-stumped!
    Hope this helps.
    RS_Jim
Sign In or Register to comment.