This repository was archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (53 loc) · 1.7 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import time
import datetime
import RPi.GPIO as GPIO
import sys
import motorControll
import mic
import weather_forecast
import jikanwari
import distance
while True:
try:
mic_id=mic.speechInput()
if "こっち来て" in mic_id or "おいで" in mic_id:
mic_id = 1
elif "時間割" in mic_id or "日課" in mic_id :
mic_id = 2
elif "天気" in mic_id :
mic_id = 3
#ゴミ箱移動(接近)
if mic_id == 1:
motorControll.goAlong()
time_bg=time.time()
while True:
motorControll.goAlong()
cm = distance.read_distance()
print("distance=", int(cm), "cm")
if cm<10:
break
time_en=time.time()
# 来るまでの時間を計測
dis_time=time_en-time_bg
motorControll.stop()
time.sleep(10)
motorControll.back()
time.sleep(dis_time)
motorControll.stop()
# 時間割
elif mic_id == 2:
# 曜日の取得
Day=datetime.datetime.now().weekday()
# 8時前だったら当日, 8時以降だったら翌日
now_hour=datetime.datetime.now().hour
if now_hour>=8:
Day+=1
jikanwari.jikanwariSpeech(Day)
# 天気予報
elif mic_id == 3:
weather_inf=weather_forecast.weatherNotice()
print(weather_inf)
except KeyboardInterrupt: #Ctrl+Cキーが押された
motorControll.stop()
GPIO.cleanup() #GPIOをクリーンアップ
sys.exit() #プログラム終了