コード例 #1
0
    def lightControllLoop(self):
        """
		動作: 人との距離でライトを制御する
		"""
        notice = '[Interaction]: lightControllLoop start!\n'
        print(termcolor.colored(notice, 'yellow'))

        port = "/dev/ttyACM1"
        baudrate = 115200
        led = serialled.SerialLed(port, baudrate)
        color = [0, 0, 0, 0]
        closer = 300
        far = 100

        isOn = False
        while True:
            if self.state == 0 and isOn:
                led.setColor(5, 10, 10, 0)
                led.setColor(5, 10, 10, 0)
                isOn = False
                time.sleep(1)
            if self.state == 1 and not isOn:
                led.setColor(255, 200, 30, 0)
                led.setColor(255, 200, 30, 0)
                isOn = True
                time.sleep(1)
コード例 #2
0
    def lightControllLoop(self):
        """
		動作: 人との距離でライトを制御する
		"""
        notice = '[Interaction]: lightControllLoop start!\n'
        print(termcolor.colored(notice, 'yellow'))

        port = "/dev/ttyACM0"
        baudrate = 115200
        led = serialled.SerialLed(port, baudrate)
        color = [0, 0, 0, 0]
        closer = 300
        far = 100
        while True:
            key = okaomanager.getMaxAttentionKey("size")
            size = okaomanager.getAttension(key, "size")
            #print(size)
            size = min(closer, max(far, size))

            size_rate = 1.0 * (size - far) / (closer - far)  # 近いと1.0、遠いと0.0
            for i in range(4):
                color[i] = int(self.WARM[i] * size_rate + self.COOL[i] *
                               (1 - size_rate))
            led.setColor(color[0], color[1], color[2], color[3])
            led.setColor(color[0], color[1], color[2], color[3])
            time.sleep(0.1)
コード例 #3
0
    def lightControllLoop(self):
        """
		動作: 人との距離でライトを制御する
		"""
        notice = '[Interaction]: lightControllLoop start!\n'
        print(termcolor.colored(notice, 'yellow'))

        baudrate = 115200
        led = serialled.SerialLed(SERIAL_PORT, baudrate)
        color = [0, 0, 0, 0]
        closer = 300
        far = 100
        rate = 0

        while True:

            #key = okaomanager.getMaxAttentionKey("size")
            size = 300
            #print(size)
            size = min(closer, max(far, size))

            if rate > 1.0:
                rate = 0

            for i in range(4):
                color[i] = int(self.WARM[i] * rate + self.COOL[i] * (1 - rate))

            led.setColor(color[0], color[1], color[2], color[3])
            led.setColor(color[0], color[1], color[2], color[3])

            rate += 0.1

            time.sleep(0.4)
コード例 #4
0
    def musicRecognizeLoop(self):
        global state
        """
		動作: 人との距離でライトを制御する
		"""
        notice = '[Interaction]: lightControllLoop start!\n'
        print(termcolor.colored(notice, 'yellow'))

        port = "/dev/ttyACM2"
        baudrate = 115200
        led = serialled.SerialLed(port, baudrate)
        color = [0, 0, 0, 0]
        closer = 300
        far = 100
        while True:
            #print("state: ", state)
            print(":: ", self.state_flag)
            if self.state_flag[1]:
                print("action1")
                self.state_flag = [False, False, False, False]
                self.action1(led)
            elif self.state_flag[2]:
                print("action2")
                self.state_flag = [False, False, False, False]
                self.action2(led)
            elif self.state_flag[3]:
                print("action3")
                self.state_flag = [False, False, False, False]
                self.action3(led)
            elif self.state_flag[0]:
                print("action0")
                self.state_flag = [False, False, False, False]
                #self.action0(led)
            self.state_flag = [False, False, False, False]