Skip to content

Commit 05b16eb

Browse files
WebsolderIRISZZW
authored andcommitted
XDU_Bluetooth_speaker
1 parent c49b412 commit 05b16eb

22 files changed

+2116
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Smart Bluetooth Speaker
2+
This application is a specific example of using wearable devices to control smart home devices.
3+
This application uses a wearable device to perform remote gesture control of the Bluetooth speaker, and supports voice control and touch screen control at the same time, providing users with more convenience.
4+
5+
6+
- [Smart Bluetooth Speaker](#smart-bluetooth-speaker)
7+
- [Introduction](#introduction)
8+
- [Function](#function)
9+
- [System Architecture](#system-architecture)
10+
- [Hardware Architecture](#hardware-architecture)
11+
- [Software Flow](#software-flow)
12+
- [Smart Screen UI](#smart-screen-ui)
13+
- [Hardware and Software Setup](#hardware-and-software-setup)
14+
- [Required Hardware](#required-hardware)
15+
- [Required Software](#required-software)
16+
- [Hardware Connection](#hardware-connection)
17+
- [User Manual](#user-manual)
18+
- [Before Running This Application](#before-running-this-application)
19+
- [Run This Application](#run-this-application)
20+
- [Build Arduino program](#build-arduino-program)
21+
- [Build EMSK program](#build-emsk-program)
22+
23+
24+
25+
## Introduction
26+
### Function
27+
This smart Bluetooth speaker can accept three control inputs of gesture, voice, and touch screen, and can playing music from Bluetooth master devices or local Micro SD card.
28+
Seeeduino receives and processes gesture signals, and send corresponding data to EMSK through HC-06 Bluetooth transceiver. Voice recognition is implemented by LD3320A module using Auto Speech Recognition algorithm. Touch buttons on smart screen have touch feedback to provide intuitive human-computer interaction.
29+
After receiving control signals, the system sends corresponding instructions to the Bluetooth audio module, and the smart screen displays the current system operating status, as well as environmental temperature and humidity data and real-time clock.
30+
The detailed control commands are as followed:
31+
32+
| Command | Gesture | Voice(Chinese Pinyin) | Touch Screen |
33+
| ---------------------- | -------------- | -------------------------- | ------------------------ |
34+
| Switch control mode | forward | "qie huan kong zhi mo shi" | |
35+
| Switch play mode | up | "qie huan bo fang mo shi" | |
36+
| Previous song | left | "shang yi qu" | "previous song" button |
37+
| Next song | right | "xia yi qu" | "next song" button |
38+
| Play song | down | "bo fang" | "play/pause song" button |
39+
| Pause song | down | "zan ting" | "play/pause song" button |
40+
| Volume up | clockwise | "jia da yin liang" | |
41+
| Volume down | anti-clockwise | "jian xiao yin liang" | |
42+
| Enable gesture control | backward | | |
43+
44+
45+
46+
### System Architecture
47+
#### Hardware Architecture
48+
![hardware_architecture](./doc/screenshots/hardware_architecture.png)
49+
50+
51+
#### Software Flow
52+
![software_flow](./doc/screenshots/software_flow.png)
53+
54+
55+
### Smart Screen UI
56+
![screen_ui](./doc/screenshots/screen_ui.png)
57+
58+
59+
60+
## Hardware and Software Setup
61+
### Required Hardware
62+
- 1 DesignWare ARC EM Starter Kit(EMSK)
63+
- 1 Seeeduino, Arduino minimum system board
64+
- 1 HSC025A Bluetooth audio module
65+
- 1 DWIN's DMT48320C035_06W touchable smart screen
66+
- 1 I2C to UART module
67+
- 1 Power converter module for the smart screen
68+
- 1 LD3320A Voice recognition module
69+
- 1 PAJ7620U2 gesture sensor
70+
- 2 HC-06 Bluetooth to UART transceivers
71+
- 1 DS1302 real-time clock module
72+
- 1 DHT11 temperature and relative humidity sensor
73+
- 1 SD Card for EMSK second bootloader
74+
- 2 Micro SD Card, one for HSC025A, one for the initialization of the smart screen
75+
76+
77+
78+
79+
### Required Software
80+
- embARC Open Software Platform(OSP)
81+
- ARC GNU Tool Chain
82+
- Serial Port Utility or other serial port terminal
83+
- Arduino IDE
84+
- [DGUS_V3788](http://www.dwin.com.cn/home/Index/download_file?download_id=1753) for smart screen UI development
85+
86+
87+
### Hardware Connection
88+
1. **EMSK connection**
89+
EMSK implement speaker node, it can be controlled by touch screen input, Voice recognition and remote gesture recognition, and can execute the following command: next/previous song, play/pause, volume up/down, switch control/play mode, etc.. EMSK is powered by a 5V/4A AC power adapter.
90+
The smart screen it connect can display current control status and play status.
91+
92+
| Device | Bus | Connector | Description |
93+
| ------------------ | ------ | ------------ | ---------------------------------------------- |
94+
| HSC025A | UART_0 | PMOD_1[4:3] | Bluetooth audio module |
95+
| HC-06 | UART_2 | PMOD_5[9:8] | Bluetooth transceiver for connecting Seeeduino |
96+
| LD3320A | I2C_0 | PMOD_2[4:3] | Voice recognition module |
97+
| I2C to UART module | I2C_1 | PMOD_4[4:3] | Convert I2C port to UART to connect the screen |
98+
| DS1302 | GPIO | PMOD_3[10:8] | Real-time clock module |
99+
| DHT11 | GPIO | PMOD_3[4] | Temperature and relative humidity sensor |
100+
101+
1. **Seeeduino connection**
102+
Seeeduino implements wearable controller node, it processes received gesture signals and send the gesture number to EMSK through HC-06 Bluetooth transceiver. Seeeduino is powered by a 5V lithium battery through USB type-C port.
103+
104+
| Device | Bus | Connector | Description |
105+
| --------- | ---- | --------- | ----------------------------------------- |
106+
| PAJ7620U2 | I2C | D[5:4] | Gesture recognition module |
107+
| HC-06 | UART | D[7:6] | Bluetooth transceiver for connecting EMSK |
108+
109+
110+
111+
## User Manual
112+
### Before Running This Application
113+
1. Download [Arduino project](https://github.com/Websolder/SmartBluetoothSpeaker/tree/main/Arduino_Project) and [DGUS project](https://github.com/Websolder/SmartBluetoothSpeaker/tree/main/DGUS_Project)
114+
115+
2. Initialize Smart Screen UI
116+
Copy the whole directory `/DGUS_Project/DWIN_SET` to an empty Micro SD card, and then insert it to the slot on the smart screen. Power up the screen and complete the initialization, then pull out the Micro SD card and reboot the screen.
117+
the UI project file `DGUS_Project/DWprj.hmi` can be modified with DGUS_V7388 IDE.
118+
119+
120+
121+
122+
### Run This Application
123+
#### Build Arduino program
124+
Open [Arduino project file](https://github.com/Websolder/SmartBluetoothSpeaker/tree/main/Arduino_Project/HC06-GS.ino) with Arduino IDE, compile the program and download to Seeeduino.
125+
126+
127+
#### Build EMSK program
128+
Before programming EMSK, PMOD mux must be configured in order to use bus drivers of embARC.
129+
```c
130+
// In file "embarc_osp-master/board/emsk/common/emsk_init.c"
131+
set_pmod_mux(mux_regs, PM1_UR_UART_0 | PM1_LR_SPI_S \
132+
| PM2_I2C_HRI \
133+
| PM3_GPIO_AC \
134+
| PM4_I2C_GPIO_D \
135+
| PM5_UR_SPI_M1 | PM5_LR_SPI_M2 \
136+
| PM6_UR_SPI_M0 | PM6_LR_GPIO_A );
137+
```
138+
139+
Makefile target options about EMSK and toolchain:
140+
```makefile
141+
APPL ?= bluetooth_speaker
142+
BOARD ?= emsk
143+
TOOLCHAIN ?= gnu
144+
OLEVEL ?= 02
145+
BD_VER ?= 22
146+
CUR_CORE ?= arcem7d
147+
```
148+
149+
The middleware used in this application:
150+
```makefile
151+
MID_SEL = common
152+
```
153+
154+
Directories of source files and header files:
155+
156+
```makefile
157+
EMBARC_ROOT = ../../../../..
158+
# application source dirs
159+
APPL_CSRC_DIR = .
160+
APPL_ASMSRC_DIR = .
161+
162+
# application include dirs
163+
APPL_INC_DIR = .
164+
165+
# include current project makefile
166+
COMMON_COMPILE_PREREQUISITES += makefile
167+
168+
### Options above must be added before include options.mk ###
169+
# include key embARC build system makefile
170+
include $(EMBARC_ROOT)/options/options.mk
171+
```
172+
173+
In this application, embARC 2nd bootloader is used to automatically load program binary for EMSK and run. To run this application, execute command `make run` in the terminal, and execute `make bin` to generate binary file for embARC 2nd bootloader. Then, rename the binary file as `boot.bin` and copy it to an empty SD card together with bootloader binary file `bt.bin`. Insert the SD card in the slot on EMSK, power up and this application will start to run.
174+
The initial control mode is voice mode, and the initial play mode is SD mode, and users can control this speaker through method mentioned above.
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include "HC_06.h"
2+
3+
DEV_UART * UART2 = NULL;
4+
5+
uint32_t UART2_init(uint32_t baudrate)
6+
{
7+
/*
8+
* UART 2 initialization
9+
* Modify \embARC\board\emsk\common\emsk_init.c
10+
* PM5_LR_GPIO_A to PM5_LR_SPI_M2 -name BUG
11+
* J5.12 3V3
12+
* J5.11 GND
13+
* J5.9 UART2_RXD
14+
* J5.8 UART2_TXD
15+
*/
16+
17+
UART2 = uart_get_dev(HC_06_UART_ID);
18+
19+
int32_t uart2_stat = UART2->uart_open(baudrate);
20+
21+
if (UART2 == NULL)
22+
return -1;
23+
else if (uart2_stat == E_OPNED || uart2_stat == E_OK) {
24+
UART2->uart_control(UART_CMD_SET_BAUD, (void *)(baudrate)) ;
25+
return 1;
26+
} else
27+
return 0;
28+
}
29+
30+
uint32_t UART2_write(uint8_t *buf, uint32_t cnt)
31+
{
32+
if (UART2 == NULL)
33+
return 0;
34+
35+
return UART2->uart_write(buf, cnt);
36+
}
37+
38+
uint32_t UART2_read(uint8_t *buf, uint32_t cnt)
39+
{
40+
if (UART2 == NULL)
41+
return 0;
42+
43+
uint32_t rd_avail;
44+
45+
UART2->uart_control(UART_CMD_GET_RXAVAIL, (void *)(&rd_avail));
46+
cnt = (cnt > rd_avail)?rd_avail:cnt;
47+
{
48+
if (cnt > 0)
49+
return UART2->uart_read(buf, cnt);
50+
51+
}
52+
return cnt;
53+
}
54+
55+
uint8_t get_ges_cmd(void)
56+
{
57+
uint8_t RECbuf;
58+
uint32_t data_avail = 0;
59+
60+
UART2->uart_control(UART_CMD_GET_RXAVAIL, (void *)(&data_avail));
61+
if (data_avail > 0) {
62+
UART2_read(&RECbuf, 1);
63+
return RECbuf;
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef _HC_06_H_
2+
#define _HC_06_H_
3+
4+
#include "embARC.h"
5+
#include "embARC_debug.h"
6+
#include "embARC_error.h"
7+
8+
#include "board.h"
9+
#include "dev_common.h"
10+
#include "delay.h"
11+
12+
#include "stdio.h"
13+
#include "string.h"
14+
15+
#define HC_06_UART_ID DW_UART_2_ID
16+
17+
/*
18+
* J5.12 3V3
19+
* J5.11 GND
20+
* J5.9 UART2_RXD
21+
* J5.8 UART2_TXD
22+
*/
23+
24+
// gesture definition
25+
#define GES_UP 0x01
26+
#define GES_DOWN 0x02
27+
#define GES_LEFT 0x03
28+
#define GES_RIGHT 0x04
29+
#define GES_CLOCKWISE 0x05
30+
#define GES_ANTI_CLOCKWISE 0x06
31+
#define GES_FORWARD 0x07
32+
#define GES_BACKWARD 0x08
33+
#define GES_WAVE 0x09
34+
35+
uint32_t UART2_init(uint32_t baudrate);
36+
uint32_t UART2_write(uint8_t *buf, uint32_t cnt);
37+
uint32_t UART2_read(uint8_t *buf, uint32_t cnt);
38+
uint8_t get_ges_cmd(void);
39+
40+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "IIC.h"
2+
3+
DEV_IIC * iic_master_0;
4+
5+
/*****************
6+
* I2C device initialization
7+
* I2C_0
8+
* Conenction:
9+
* J2.6: 3V3
10+
* J2.5: GND
11+
* J2.4: SDA
12+
* J2.3: SCL
13+
****************/
14+
15+
void Master0_slvdev_init(uint32_t slv_addr)
16+
{
17+
iic_master_0 = iic_get_dev(IIC_MASTER_0);/* get IIC Master_0 device */
18+
19+
iic_master_0->iic_open(DEV_MASTER_MODE, IIC_SPEED_FAST);/* open IIC device in master mode */
20+
21+
iic_master_0->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(slv_addr));/* Set target slave device address */
22+
}
23+
24+
/*write data to slvdev*/
25+
int32_t Master0_slvdev_write_reg(uint8_t regaddr, uint8_t regvalue)
26+
{
27+
uint8_t buf[2]; /* reg buffer */
28+
29+
iic_master_0->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));/* Set next condition for following transmit operation */
30+
buf[0] = regaddr;
31+
buf[1] = regvalue;
32+
return iic_master_0->iic_write(buf, 2);
33+
}
34+
35+
/*read data from slvdev*/
36+
int32_t Master0_slvdev_read_reg(uint8_t regaddr, uint8_t *data)
37+
{
38+
uint8_t buf[1];
39+
int32_t ercd;
40+
41+
iic_master_0->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
42+
buf[0] = regaddr;
43+
iic_master_0->iic_write(buf, 1); /* Master write IIC_slv addr to IIC wire */
44+
iic_master_0->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
45+
ercd = iic_master_0->iic_read(buf, 1); /* Read data from slvdev */
46+
*data = buf[0];
47+
48+
return ercd;
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef _IIC_H_
2+
#define _IIC_H_
3+
4+
#include "embARC.h"
5+
#include "embARC_debug.h"
6+
7+
#define IIC_MASTER_0 0
8+
9+
void Master0_slvdev_init(uint32_t slv_addr);
10+
int32_t Master0_slvdev_write_reg(uint8_t regaddr, uint8_t regvalue);
11+
int32_t Master0_slvdev_read_reg(uint8_t regaddr, uint8_t *data);
12+
13+
#endif

0 commit comments

Comments
 (0)