Compare commits

..

No commits in common. "a808d58758472f5ead848ba34751c3345af2e017" and "07a6d3fa7613a9ec2950f1cb26083e1d2c105b73" have entirely different histories.

2 changed files with 14 additions and 21 deletions

View File

@ -12,9 +12,9 @@ except:
| GPIO | LED | | GPIO | LED |
| -- | - - | | -- | - - |
| 0 | 红色 | | 0 | 红色 |
| 1 | | | 1 | |
| 2 | 绿色 | | 2 | 绿色 |
| 3 | | | 3 | |
| 4 | 白色 | | 4 | 白色 |
| GPIO | BUTTON | | GPIO | BUTTON |
@ -28,9 +28,9 @@ class OrangePi(BaseHardware):
super().__init__(hd_trigger, hd_detect_threshold) super().__init__(hd_trigger, hd_detect_threshold)
self.LED_PIN_red = 0 self.LED_PIN_red = 0
self.LED_PIN_blue = 1 self.LED_PIN_yellow = 1
self.LED_PIN_green = 2 self.LED_PIN_green = 2
self.LED_PIN_yellow = 3 self.LED_PIN_blue = 3
self.LED_PIN_white = 4 self.LED_PIN_white = 4
self.BUTTON_PIN_1 = 6 self.BUTTON_PIN_1 = 6
@ -50,9 +50,9 @@ class OrangePi(BaseHardware):
wiringpi.wiringPiSetup() wiringpi.wiringPiSetup()
# GPIO 输出模式 # GPIO 输出模式
wiringpi.pinMode(self.LED_PIN_red, GPIO.OUTPUT) wiringpi.pinMode(self.LED_PIN_red, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_blue, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_green, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_yellow, GPIO.OUTPUT) wiringpi.pinMode(self.LED_PIN_yellow, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_green, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_blue, GPIO.OUTPUT)
wiringpi.pinMode(self.LED_PIN_white, GPIO.OUTPUT) wiringpi.pinMode(self.LED_PIN_white, GPIO.OUTPUT)
# GPIO 输入模式 # GPIO 输入模式
wiringpi.pinMode(self.BUTTON_PIN_1, GPIO.INPUT) wiringpi.pinMode(self.BUTTON_PIN_1, GPIO.INPUT)
@ -80,9 +80,6 @@ class OrangePi(BaseHardware):
if press_duration > 1: if press_duration > 1:
self.long_power_status = not self.long_power_status self.long_power_status = not self.long_power_status
# print(f"{datetime.now()}: long_power_status: {self.long_power_status} {self.short_power_status}") # print(f"{datetime.now()}: long_power_status: {self.long_power_status} {self.short_power_status}")
elif press_duration > 5:
time.sleep(1) # 防止短按误触发
subprocess.Popen('sudo shutdown now', shell=True)
else: else:
self.short_power_status = True self.short_power_status = True
# print(f"{datetime.now()}: short_power_status: {self.short_power_status} {self.long_power_status}") # print(f"{datetime.now()}: short_power_status: {self.short_power_status} {self.long_power_status}")
@ -93,14 +90,14 @@ class OrangePi(BaseHardware):
# 更新LED状态 # 更新LED状态
if self.long_power_status: if self.long_power_status:
self.set_led_on('green') self.set_led_on('white')
if self.short_power_status: if self.short_power_status:
self.set_led_on('blue') self.set_led_on('yellow')
else: else:
self.set_led_off('blue') self.set_led_off('yellow')
else: else:
self.short_power_status = False self.short_power_status = False
self.set_led_off('green') self.set_led_off('white')
def set_led_on(self, color='red'): def set_led_on(self, color='red'):
@ -111,10 +108,10 @@ class OrangePi(BaseHardware):
def start_status_light(self): def start_status_light(self):
for i in range(2): for i in range(2):
self.set_led_on("green") self.set_led_on("white")
time.sleep(0.5) time.sleep(1)
self.set_led_off("green") self.set_led_off("white")
time.sleep(0.5) time.sleep(1)
if __name__ == '__main__': if __name__ == '__main__':
orangepi = OrangePi() orangepi = OrangePi()

View File

@ -258,11 +258,7 @@ class WebSocketClinet:
recorder.hardware.set_led_off("blue") recorder.hardware.set_led_off("blue")
elif self.speaking_event.is_set(): elif self.speaking_event.is_set():
print(f"{datetime.now()}: wait for speaking close and listening start.") print(f"{datetime.now()}: wait for speaking close and listening start.")
if board == 'orangepi':
recorder.hardware.set_led_on("red")
self.listening_event.wait() self.listening_event.wait()
if board == 'orangepi':
recorder.hardware.set_led_off("red")
# 重新计时 # 重新计时
slience_bgn_t = time.time() slience_bgn_t = time.time()