回到顶部 回到顶部

【挑战一】基于行空板、Mind+图形化编程的公交语音广播及交互系统 简单

头像 豆爸 2022.10.19 167 2

1 项目背景

 

对于公交车而言,一套完整的到站语音广播及交互系统能给乘客提供良好的用户体验。本系统旨在通过星空板、Mind+图形化编程,模拟实现公交语音广播及交互系统。

 

 

2 系统架构

 

本系统由司乘语音广播终端、乘客人机交互终端、公交站点交互终端组成。

 

 

 

3 系统功能

 

车载语音广播终端:设置于公交车驾驶位附近,用于实现列车进站、出站手动TTS语音广播、自动TTS语音广播(未开发)、人工话筒广播(未开发);并驾驶员显示公交线路、列车运行方向、站点等信息显示。

 

乘客人机交互终端:设置于公交车下客车门附近,用于向乘客显示公交线路、行驶方向、到达站点等信息,并设置按钮,用于乘客提醒驾驶员有乘客在前方站点下车。

 

公交站点交互终端:设置于公交站点,用于向乘客显示线路公交车辆线路信息、车辆位置、运营时间等。

 

 

4 硬件设计

 

司乘语音广播终端:行空板 1 块,USB免驱3W小喇叭 1块

 

 

乘客人机交互终端:行空板 1 块,按钮模块 1块

 

 

公交站点交互终端:行空板 1 块,USB免驱3W小喇叭 1块

 

硬件介绍

 

(1)行空板    

 

行空板

 

行空板是一款拥有自主知识产权的国产教学用开源硬件,采用微型计算机架构,集成LCD彩屏、WiFi蓝牙、多种常用传感器和丰富的拓展接口。同时,其自带Linux操作系统和python环境,还预装了常用的python库,让广大师生只需两步就能开始python教学。

 

购买链接:https://www.dfrobot.com.cn/goods-3404.html

     

(2)USB免驱3W小喇叭

 

 

 

 

 

 

5 UI设计

 

司乘语音广播终端

 

2ffbb3f07ed34bb55c25896d42252ce.png

启动UI

 

96494b2673aaad7842b7c448d7b13c3.png

列车起动出站

 

 

d6d38734c4bb25e01714f7d5f87815a.png

列车进站

 

 

 

乘客人机交互终端

 

1666232536990.png

 

1666232798378.png

 

 

公交站点交互终端

 

 

1666236410235.png

 

 

6 软件设计

 

司乘语音广播终端

c8f5f4197f97fdc6be713a494a1f120.png

乘客人机交互终端

 

02乘客人机交互终端.png

 

公交站点交互终端:

c97a018e2510bea86deef1c292656bf.png

代码
# 司乘语音广播终端
# MicroPython
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from unihiker import GUI
import pyttsx3
import time
import siot

# 事件回调函数
def bnt_leave_click():
    global direction
    global destination
    global station_number
    if (station_number < 9):
        # 出某站
        siot.publish(topic="3czPz9SVR", data=(station_name[station_number]))
        txt_station_number.config(text="")
        txt_station_name.config(text="        列车启动")
        txt_next_station_name.config(text=(str("下一站:") + str((station_name[(station_number + 1)]))))
        (str("engine.say('") + str((str("列车起步,请扶好坐好") + str("')"))))
        (str("engine.say('") + str((str((str("下一站:") + str((station_name[station_number])))) + str("')"))))
        engine.runAndWait()
        buzzer.play(buzzer.DADADADUM,buzzer.Once)
def bnt_enter_click():
    global direction
    global station_number
    global flag
    if (station_number < 9):
        station_number = (station_number + 1)
        # 进某站
        siot.publish(topic="Dytv18SVR", data=(str((station_number + 1)) + str("站")))
        txt_station_number.config(text=(str("NO.:第") + str((str((station_number + 1)) + str("站")))))
        txt_station_name.config(text=(str("列车到达:") + str((station_name[station_number]))))
        txt_next_station_name.config(text=(str("下一站:") + str((station_name[(station_number + 1)]))))
        (str("engine.say('") + str((str((station_name[station_number])) + str("站到了')"))))
        (str("engine.say('") + str((str("下车请准备") + str("')"))))
        engine.runAndWait()
        buzzer.play(buzzer.DADADADUM,buzzer.Once)
    else:
        txt_next_station_name.config(text=(str("         终点站")))
def on_message_callback(client, userdata, msg):
    u_gui.draw_text(text=msg.payload.decode(),x=150,y=40,font_size=15, color="#FF0000")


u_gui=GUI()
siot.init(client_id="",server="iot.dfrobot.com.cn",port=1883,user="hmmyqjZMR",password="2imsqCWGgz")
Board().begin()
siot.connect()
siot.loop()
siot.set_callback(on_message_callback)
global direction
global destination
global flag
global station_number
global station_number
station_name = [ "永宁门","长乐门","安定门","安远门","文昌门","和平门","建国门","中山门","朝阳门","尚勤门"]
station_number = 0
direction = "下行"
destination = 9
flag = 0
engine = pyttsx3.init()
data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
u_gui.fill_rect(x=0,y=0,w=240,h=320,color="#000000")
u_gui.fill_rect(x=0,y=0,w=240,h=30,color="#006600")
txt_direction=u_gui.draw_text(text=direction,x=10,y=40,font_size=15, color="#FFFF00")
txt_destination=u_gui.draw_text(text=(str("开往:") + str((station_name[destination]))),x=90,y=40,font_size=15, color="#FFFF00")
txt_station_number=u_gui.draw_text(text=(str("NO.:第") + str((str((station_number + 1)) + str("站")))),x=10,y=80,font_size=15, color="#FFFF00")
txt_station_name=u_gui.draw_text(text=(str("本站:") + str((station_name[station_number]))),x=10,y=120,font_size=15, color="#FFFF00")
txt_next_station_name=u_gui.draw_text(text=(str("下一站:") + str((station_name[(station_number + 1)]))),x=10,y=160,font_size=15, color="#FFFF00")
siot.getsubscribe(topic="t8Hmb8I4g")
txt_time=u_gui.draw_text(text=data_time,x=10,y=0,font_size=15, color="#FFFFFF")
bnt_enter=u_gui.add_button(text="进站",x=130,y=220,w=80,h=60,onclick=bnt_enter_click)
bnt_leave=u_gui.add_button(text="出站",x=20,y=220,w=80,h=60,onclick=bnt_leave_click)

while True:
    data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    txt_time.config(text=data_time)
    time.sleep(1)

代码
# 乘客人机交互交互终端
# MicroPython
from unihiker import GUI
import time
import siot

# 事件回调函数
def on_message_callback(client, userdata, msg):
    if (msg.topic == (str("Dytv18SVR"))):
        msg2.config(text=(str(msg.payload.decode()) + str("站")))
        msg4.config(text="到了")
        msg3.config(text="下车请准备")
        msg5.config(text="")
        msg6.config(text="")
        msg7.config(text="")
    elif (msg.topic == (str("3czPz9SVR"))):
        msg5.config(text="车辆启动,请扶好坐好")
        msg6.config(text="下一站:")
        msg7.config(text=(str(msg.payload.decode()) + str("站")))
        msg2.config(text="")
        msg4.config(text="")
        msg3.config(text="")
def on_buttona_click_callback():
    siot.publish(topic="t8Hmb8I4g", data="1")


u_gui=GUI()
siot.init(client_id="",server="iot.dfrobot.com.cn",port=1883,user="hmmyqjZMR",password="2imsqCWGgz")
siot.connect()
siot.loop()
siot.set_callback(on_message_callback)
u_gui.on_a_click(on_buttona_click_callback)
station_name = [ "永宁门","长乐门","安定门","安远门","文昌门","和平门","建国门","中山门","朝阳门","尚勤门"]
global direction
global destination
global station_number
global station_number
destination = 9
data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
u_gui.fill_rect(x=0,y=0,w=240,h=320,color="#000000")
txt_time=u_gui.draw_text(text="",x=10,y=40,font_size=15, color="#FFFF00")
msg1=u_gui.draw_text(text=(str("开往:") + str((station_name[destination]))),x=50,y=90,font_size=15, color="#FFFF00")
msg2=u_gui.draw_text(text="",x=30,y=140,font_size=20, color="#FF0000")
msg3=u_gui.draw_text(text="",x=60,y=210,font_size=15, color="#FFFF00")
msg4=u_gui.draw_text(text="",x=150,y=145,font_size=15, color="#FFFF00")
msg5=u_gui.draw_text(text="",x=15,y=140,font_size=15, color="#FFFF00")
msg6=u_gui.draw_text(text="",x=20,y=205,font_size=15, color="#FFFF00")
msg7=u_gui.draw_text(text="",x=100,y=200,font_size=20, color="#FF0000")
siot.getsubscribe(topic="Dytv18SVR")
siot.getsubscribe(topic="3czPz9SVR")

while True:
    data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    txt_time.config(text=data_time)
    time.sleep(1)
代码
# 公交站点交互终端
# MicroPython
from unihiker import GUI
import time
import siot

# 事件回调函数
def on_message_callback(client, userdata, msg):
    if (msg.topic == (str("Dytv18SVR"))):
        msg2.config(text=(str(msg.payload.decode()) + str("站")))
        msg4.config(text="到了")
        msg3.config(text="下车请准备")
        msg5.config(text="")
        msg6.config(text="")
        msg7.config(text="")
    elif (msg.topic == (str("3czPz9SVR"))):
        msg5.config(text="车辆启动,请扶好坐好")
        msg6.config(text="下一站:")
        msg7.config(text=(str(msg.payload.decode()) + str("站")))
        msg2.config(text="")
        msg4.config(text="")
        msg3.config(text="")


u_gui=GUI()
siot.init(client_id="",server="iot.dfrobot.com.cn",port=1883,user="hmmyqjZMR",password="2imsqCWGgz")
siot.connect()
siot.loop()
siot.set_callback(on_message_callback)
station_name = [ "永宁门","长乐门","安定门","安远门","文昌门","和平门","建国门","中山门","朝阳门","尚勤门"]
global direction
global destination
global station_number
global station_number
destination = 9
data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
u_gui.fill_rect(x=0,y=0,w=240,h=320,color="#000000")
txt_time=u_gui.draw_text(text="",x=10,y=10,font_size=15, color="#FFFF00")
u_gui.draw_text(text="20路",x=10,y=55,font_size=20, color="#FF0000")
msg1=u_gui.draw_text(text=(str((station_name[0])) + str((str("→") + str((station_name[9]))))),x=80,y=60,font_size=15, color="#FFFF00")
msg2=u_gui.draw_text(text="本站:",x=30,y=120,font_size=15, color="#FFFF00")
msg3=u_gui.draw_text(text="永宁门",x=95,y=115,font_size=20, color="#FF0000")
msg6=u_gui.draw_text(text="下趟列车还有",x=10,y=180,font_size=15, color="#FFFF00")
msg6=u_gui.draw_text(text="   5   ",x=120,y=175,font_size=20, color="#FF0000")
msg6=u_gui.draw_text(text="分钟",x=180,y=180,font_size=15, color="#FFFF00")
msg4=u_gui.draw_text(text="首班车:06:30",x=30,y=240,font_size=15, color="#FFFF00")
msg5=u_gui.draw_text(text="末班车:20:30",x=30,y=270,font_size=15, color="#FFFF00")
siot.getsubscribe(topic="Dytv18SVR")
siot.getsubscribe(topic="3czPz9SVR")

while True:
    data_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    txt_time.config(text=data_time)
    time.sleep(1)

评论

user-avatar
  • 三春牛-创客

    三春牛-创客2023.01.09

    不错不错

    0
    • 三春牛-创客

      三春牛-创客2023.01.09

      厉害厉害

      0