Shop OBEX P1 Docs P2 Docs Learn Events
Bit Range Constants — Parallax Forums

Bit Range Constants

Chuck RiceChuck Rice Posts: 210
edited 2009-04-17 03:48 in Propeller 1
I think that the answer to my question is "It cannot be done: SPIN limitation", but I thought that I would ask.

What I would like to do is setup a CONstant:

CON
    digitalInputsBasePin = 8
    digitalInputsRange   = digitalInputsBasePin..digitalInputsBasePin+8

VAR
    long digitalInputs
PUB  xxx(yyy)

   digitalInputs  := INA(digitalInputsRange)



I know that I can do

digitalInputs := INA(8..15)



but that hides those pins down in the code. Bad programming practice.
Or I could read them a bit at a time, but I would rather read all 8 bits at once.

Post Edited (Chuck Rice) : 4/17/2009 2:43:20 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-04-17 03:37
    What would be wrong with:

    CON
        digitalInputsBasePin = 8
        digitalInputsHiPin  = digitalInputsBasePin+7
    
    VAR
        long digitalInputs
    PUB  xxx(yyy)
    
       digitalInputs  := INA[noparse][[/noparse]digitalInputsBasePin..digitalInputsHiPin]
    
    
    


    -Phil
  • Chuck RiceChuck Rice Posts: 210
    edited 2009-04-17 03:48
    Duh... Thanks Phil. I thought I tried that and it did not work. I must have misread the error.
Sign In or Register to comment.