def setDigit(self, position=0, digit=0):
        """
		set a particular digit at a particular position
		position 0 - 3 (0 = leftmost position)
		digit 0 - 15 (0-9A-F)
		by default set digit 0 at position 0
		"""
        grovepi.fourDigit_digit(self.display, position, digit)
        grovepi.fourDigit_number(display,1234,leading_zero)
        time.sleep(.5)

        print ("Test 4) Set number with leading zeros")
        leading_zero = 1
        grovepi.fourDigit_number(display,5,leading_zero)
        time.sleep(.5)
        grovepi.fourDigit_number(display,56,leading_zero)
        time.sleep(.5)
        grovepi.fourDigit_number(display,567,leading_zero)
        time.sleep(.5)
        grovepi.fourDigit_number(display,5678,leading_zero)
        time.sleep(.5)

        print ("Test 5) Set individual digit")
        grovepi.fourDigit_digit(display,0,2)
        grovepi.fourDigit_digit(display,1,6)
        grovepi.fourDigit_digit(display,2,9)
        grovepi.fourDigit_digit(display,3,15) # 15 = F
        time.sleep(.5)

        print ("Test 6) Set individual segment")
        grovepi.fourDigit_segment(display,0,118) # 118 = H
        grovepi.fourDigit_segment(display,1,121) # 121 = E
        grovepi.fourDigit_segment(display,2,118) # 118 = H
        grovepi.fourDigit_segment(display,3,121) # 121 = E
        time.sleep(.5)

        grovepi.fourDigit_segment(display,0,57) # 57 = C
        grovepi.fourDigit_segment(display,1,63) # 63 = O
        grovepi.fourDigit_segment(display,2,63) # 63 = O
Exemplo n.º 3
0
def on_message(client, userdata, msg):
    information = str(msg.payload)
    print(information)
    level = information[0]
    if (level == 'e'):
        print("No Person")
        grovepi.ledBar_setLevel(ledbar, 0)
        grovepi.fourDigit_digit(display, 0, 9)
        grovepi.fourDigit_digit(display, 1, 0)
        grovepi.fourDigit_digit(display, 2, 0)
        grovepi.fourDigit_digit(display, 3, 125)
        time.sleep(5)
        #grovepi.fourDigit_off(display)
        print("NEXT")

    else:
        num = information[1:]
        i = int(num)

        binary5 = i // 32
        binary6 = (i % 32) // 16
        binary7 = (i % 16) // 8
        binary8 = (i % 8) // 4
        binary9 = (i % 4) // 2
        binary10 = i % 2

        print("Client " + information)

        if (level == 'A'):
            grovepi.ledBar_setLevel(ledbar, 3)
            grovepi.ledBar_setLed(ledbar, 5, binary5)
            grovepi.ledBar_setLed(ledbar, 6, binary6)
            grovepi.ledBar_setLed(ledbar, 7, binary7)
            grovepi.ledBar_setLed(ledbar, 8, binary8)
            grovepi.ledBar_setLed(ledbar, 9, binary9)
            grovepi.ledBar_setLed(ledbar, 10, binary10)
            grovepi.fourDigit_digit(display, 0, 10)
            grovepi.fourDigit_digit(display, 3, i)
            time.sleep(5)
            #grovepi.fourDigit_off(display)
            print("NEXT")

        if (level == 'B'):
            grovepi.ledBar_setLevel(ledbar, 2)
            grovepi.ledBar_setLed(ledbar, 5, binary5)
            grovepi.ledBar_setLed(ledbar, 6, binary6)
            grovepi.ledBar_setLed(ledbar, 7, binary7)
            grovepi.ledBar_setLed(ledbar, 8, binary8)
            grovepi.ledBar_setLed(ledbar, 9, binary9)
            grovepi.ledBar_setLed(ledbar, 10, binary10)
            grovepi.fourDigit_digit(display, 0, 11)
            grovepi.fourDigit_digit(display, 3, i)
            time.sleep(5)
            #grovepi.fourDigit_off(display)
            print("NEXT")

        if (level == 'C'):
            grovepi.ledBar_setLevel(ledbar, 1)
            grovepi.ledBar_setLed(ledbar, 5, binary5)
            grovepi.ledBar_setLed(ledbar, 6, binary6)
            grovepi.ledBar_setLed(ledbar, 7, binary7)
            grovepi.ledBar_setLed(ledbar, 8, binary8)
            grovepi.ledBar_setLed(ledbar, 9, binary9)
            grovepi.ledBar_setLed(ledbar, 10, binary10)
            grovepi.fourDigit_digit(display, 0, 12)
            grovepi.fourDigit_digit(display, 3, i)
            time.sleep(5)
            #grovepi.fourDigit_off(display)
            print("NEXT")
Exemplo n.º 4
0
 def setDigit(self, digit, value):
     print("set digit ", digit, " value to", value)
     grovepi.fourDigit_digit(self.port, digit, value)
     return