def getLeds(self): grovepi.ledBar_getBits(self.__pin)
grovepi.ledBar_toggleLed(ledbar, 10) time.sleep(.5) print "Test 5) Set state - control all leds with 10 bits" # ledbar_setBits(ledbar, state) # state: (0-1023) or (0x00-0x3FF) or (0b0000000000-0b1111111111) or (int('0000000000',2)-int('1111111111',2)) for i in range(0, 32): grovepi.ledBar_setBits(ledbar, i) time.sleep(.2) time.sleep(.3) print "Test 6) Get current state" # state = ledbar_getBits(ledbar) # state: (0-1023) a bit for each of the 10 LEDs state = grovepi.ledBar_getBits(ledbar) print "with first 5 leds lit, the state should be 31 or 0x1F" print state # bitwise shift five bits to the left state = state << 5 # the state should now be 992 or 0x3E0 # when saved the last 5 LEDs will be lit instead of the first 5 LEDs time.sleep(.5) print "Test 7) Set state - save the state we just modified" # ledbar_setBits(ledbar, state) # state: (0-1023) a bit for each of the 10 LEDs grovepi.ledBar_setBits(ledbar, state) time.sleep(.5)
time.sleep(.5) print "Test 5) Set state - control all leds with 10 bits" # ledbar_setBits(ledbar, state) # state: (0-1023) or (0x00-0x3FF) or (0b0000000000-0b1111111111) or (int('0000000000',2)-int('1111111111',2)) for i in range(0,32): grovepi.ledBar_setBits(ledbar, i) time.sleep(.2) time.sleep(.3) print "Test 6) Get current state" # state = ledbar_getBits(ledbar) # state: (0-1023) a bit for each of the 10 LEDs state = grovepi.ledBar_getBits(ledbar) print "with first 5 leds lit, the state should be 31 or 0x1F" print state # bitwise shift five bits to the left state = state << 5 # the state should now be 992 or 0x3E0 # when saved the last 5 LEDs will be lit instead of the first 5 LEDs time.sleep(.5) print "Test 7) Set state - save the state we just modified" # ledbar_setBits(ledbar, state) # state: (0-1023) a bit for each of the 10 LEDs grovepi.ledBar_setBits(ledbar, state) time.sleep(.5)
def getBits(self): print "get bits" bits = grovepi.ledBar_getBits(self.port) print "bits = ", bits return bits