Shop OBEX P1 Docs P2 Docs Learn Events
A question about code in SpinOneWire-test — Parallax Forums

A question about code in SpinOneWire-test

ElectricAyeElectricAye Posts: 4,561
edited 2008-08-16 06:21 in Propeller 1
Hello,
I've recently been working with SpinOneWire-test (thank you Micah Dowty!). It works great. But now I'm trying to understand how it works.
What baffles me is the use of this:

addr := @addrs + (i << 3)

I can see that this is a bitwise shift left operation. But why is it necessary?
It seems to do something to the 64-bit address of the DS18B20 that makes it possible to be used by the readTemperature method, but I can't figure out what it does.

thanks,
Mark

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-08-16 03:55
    Okay, nevermind. I see what it does. It increments the pointer of the address by a value of 8, thus moving to the next "mailbox" full of DS18B20 laser ROM codes.
    I guess you can see how thrilling my Friday nights are. I'm reduced to answering my own questions on a forum visited only by nerds.

    somebody get me a doctor,
    Mark
  • mparkmpark Posts: 1,305
    edited 2008-08-16 06:21
    Nerd? I resemble that remark.

    What would you rather be doing on a Friday night?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Michael Park

    PS, BTW, and FYI:
    To search the forum, use search.parallax.com (do not use the Search button).
    Check out the Propeller Wiki: propeller.wikispaces.com/
Sign In or Register to comment.