2025年05月26日16:57:13
@ -5,6 +5,7 @@ export default defineAppConfig({
|
||||
"pages/deviceList/index",
|
||||
"pages/game/index",
|
||||
"pages/history/index",
|
||||
"pages/lampEffect/index",
|
||||
],
|
||||
|
||||
window: {
|
||||
|
BIN
src/assets/lamp.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
src/assets/nextpiece_def.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/assets/picture_01.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/assets/picture_02.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
src/assets/picture_03.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/assets/picture_04.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src/assets/picture_05.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
src/assets/picture_06.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/assets/prepiece_def.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
@ -10,12 +10,10 @@ import './index.less'
|
||||
export default function Index() {
|
||||
const [isLink, setIsLink] = useState(BLESDK.deviceInfo.state)
|
||||
const [deviceInfo, setDeviceInfo] = useState(BLESDK.deviceInfo)
|
||||
|
||||
const addDevice = () => {
|
||||
router.navigate('/pages/deviceList/index')
|
||||
}
|
||||
const deviceCallBack = () => {
|
||||
console.log(BLESDK.deviceInfo, '解绑2');
|
||||
setDeviceInfo({ ...BLESDK.deviceInfo })
|
||||
setIsLink(BLESDK.deviceInfo.state)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { Switch, Slider } from "@taroify/core"
|
||||
import ble from "@/assets/ble.png";
|
||||
// import soundCard from "@/assets/soundCard.png";
|
||||
import game from "@/assets/game.png";
|
||||
import ai from "@/assets/ai.png";
|
||||
import lamp from "@/assets/lamp.png";
|
||||
import Taro, { useDidHide, useDidShow } from '@tarojs/taro';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { hex, strInsert, getInitData } from '@/utils/sendOrder';
|
||||
@ -31,11 +31,14 @@ export default function Index() {
|
||||
})
|
||||
// let timeout = null
|
||||
const musicModeEnum = ['标准', '动感', '轻柔', '安静']
|
||||
const reverbEnum = ['KTV', '实力唱将', '朗诵主持', '萌萌卡通', '魔鬼猫', '原声']
|
||||
|
||||
|
||||
const toPage = () => {
|
||||
const toGame = () => {
|
||||
Taro.navigateTo({ url: '/pages/game/index' })
|
||||
}
|
||||
const toLampEffect = () => {
|
||||
Taro.navigateTo({ url: '/pages/lampEffect/index' })
|
||||
}
|
||||
const sendCode = useCallback(debounce((e) => {
|
||||
BLESDK.writeBleValue(new Uint8Array(strInsert(e)).buffer)
|
||||
}), [])
|
||||
@ -95,13 +98,14 @@ export default function Index() {
|
||||
str = `7B05EA0AB2${hex(e)}`
|
||||
break;
|
||||
case 'nextAndPre':
|
||||
if (ruleForm.source == 0) return
|
||||
str = `7B05EA0BB2${hex(e)}`
|
||||
break;
|
||||
}
|
||||
sendCode(str)
|
||||
}
|
||||
|
||||
const handelMusicMode = (type) => {
|
||||
const handleMusicMode = (type) => {
|
||||
let num = ruleForm.musicMode
|
||||
if (type == "+" && ruleForm.musicMode < 3) {
|
||||
num++
|
||||
@ -112,6 +116,19 @@ export default function Index() {
|
||||
handleChange(num, 'musicMode')
|
||||
}
|
||||
|
||||
//混响模式
|
||||
const handleReverb = (type) => {
|
||||
let num = ruleForm.reverb
|
||||
if (type == "+" && ruleForm.reverb < 6) {
|
||||
num++
|
||||
} else if (type == "-" && ruleForm.reverb > 1) {
|
||||
num--
|
||||
}
|
||||
if (num == ruleForm.reverb) return
|
||||
setRuleForm({ ...ruleForm, reverb: num })
|
||||
handleChange(num, 'reverb')
|
||||
}
|
||||
|
||||
// const control = (type) => {
|
||||
// let num = ruleForm.girth
|
||||
// if (type == "+" && ruleForm.girth < 3) {
|
||||
@ -128,18 +145,31 @@ export default function Index() {
|
||||
}
|
||||
|
||||
if (bytes[4] == 0xB3) {
|
||||
let nameEnum = {
|
||||
5: 'volume',
|
||||
6: 'music',
|
||||
7: 'source',
|
||||
8: 'bleSwitch',
|
||||
10: 'musicMode',
|
||||
11: 'playPause',
|
||||
13: 'reverb',
|
||||
14: 'microphoneReverberation',
|
||||
}
|
||||
ruleForm[nameEnum[bytes[3]]] = bytes[5]
|
||||
setRuleForm({ ...ruleForm })
|
||||
// 音乐音量(1B)+话筒音量(1B)+音源设置(1B)+蓝牙开关(1B)
|
||||
// +声卡开关(1B)+音乐模式(1B)+音乐控制(1B)+超低音强度(1B)+混响模式(1B)+话筒混响(1B)
|
||||
setRuleForm(state => {
|
||||
//音乐音量
|
||||
state.music = bytes[5]
|
||||
//话筒音量
|
||||
state.volume = bytes[6]
|
||||
//音源设置
|
||||
state.source = bytes[7]
|
||||
//蓝牙开关
|
||||
state.bleSwitch = bytes[8]
|
||||
//声卡开关
|
||||
state.soundCadSwitch = bytes[9]
|
||||
//音乐模式
|
||||
state.musicMode = bytes[10]
|
||||
//音乐控制
|
||||
state.playPause = bytes[11]
|
||||
//超低音强度
|
||||
state.girth = bytes[12]
|
||||
//混响模式
|
||||
state.reverb = bytes[13]
|
||||
//话筒混响
|
||||
state.microphoneReverberation = bytes[14]
|
||||
return { ...state }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +180,6 @@ export default function Index() {
|
||||
useDidHide(() => {
|
||||
// clearTimeout(timeout)
|
||||
})
|
||||
|
||||
return (
|
||||
<PullDownScrollView
|
||||
className='PullDownScrollView'
|
||||
@ -191,20 +220,20 @@ export default function Index() {
|
||||
</View>
|
||||
</View>
|
||||
<View className='play'>
|
||||
<View className='play-icon pre' onClick={() => handleChange(3, 'nextAndPre')}></View>
|
||||
<View className={`play-icon ${ruleForm.source == 0 ? 'pre_def' : 'pre'}`} onClick={() => handleChange(3, 'nextAndPre')}></View>
|
||||
<View className={ruleForm.playPause ? 'play-pause' : 'play-play'} onClick={() => {
|
||||
handleChange(!ruleForm.playPause, 'playPause')
|
||||
}}
|
||||
></View>
|
||||
<View className='play-icon next' onClick={() => handleChange(4, 'nextAndPre')}></View>
|
||||
<View className={`play-icon ${ruleForm.source == 0 ? 'next_def' : 'next'}`} onClick={() => handleChange(4, 'nextAndPre')}></View>
|
||||
</View>
|
||||
<View className='card'>
|
||||
<View className='funitem'>
|
||||
<View className='funitem-text'>音乐模式</View>
|
||||
<View className='mode'>
|
||||
<View className='icon l' onClick={() => handelMusicMode("-")}></View>
|
||||
<View className='icon l' onClick={() => handleMusicMode("-")}></View>
|
||||
<View className='input'>{musicModeEnum[ruleForm.musicMode]}</View>
|
||||
<View className='icon r' onClick={() => handelMusicMode("+")}></View>
|
||||
<View className='icon r' onClick={() => handleMusicMode("+")}></View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
@ -256,7 +285,12 @@ export default function Index() {
|
||||
</View> */}
|
||||
<View className='funitem'>
|
||||
<View className='funitem-text'>话筒混响模式</View>
|
||||
<View className='numlist'>
|
||||
<View className='mode'>
|
||||
<View className='icon l' onClick={() => handleReverb("-")}></View>
|
||||
<View className='input'>{reverbEnum[ruleForm.reverb - 1]}</View>
|
||||
<View className='icon r' onClick={() => handleReverb("+")}></View>
|
||||
</View>
|
||||
{/* <View className='numlist'>
|
||||
{[1, 2, 3, 4, 5, 6].map(item => {
|
||||
return <View className={`numlist-num ${ruleForm.reverb == item ? 'active' : ''} `} key={item} onClick={() => {
|
||||
if (item == ruleForm.reverb) return
|
||||
@ -264,17 +298,17 @@ export default function Index() {
|
||||
}}
|
||||
>{item}</View>
|
||||
})}
|
||||
</View>
|
||||
</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className='btns'>
|
||||
<View className='btn-item' onClick={toPage}>
|
||||
<View className='btn-item' onClick={toGame}>
|
||||
<Image src={game} className='img' />
|
||||
GAME
|
||||
</View>
|
||||
<View className='btn-item'>
|
||||
<Image src={ai} className='img' />
|
||||
AI
|
||||
<View className='btn-item' onClick={toLampEffect}>
|
||||
<Image src={lamp} className='img' />
|
||||
灯效
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -138,19 +138,33 @@
|
||||
.play-icon {
|
||||
width: 46rpx;
|
||||
height: 39rpx;
|
||||
}
|
||||
|
||||
.pre {
|
||||
background: url('../../assets/prepiece.png') no-repeat;
|
||||
background-size: 46rpx 39rpx;
|
||||
|
||||
&:active {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
.pre {
|
||||
background: url('../../assets/prepiece.png') no-repeat;
|
||||
.next {
|
||||
background: url('../../assets/nextpiece.png') no-repeat;
|
||||
background-size: 46rpx 39rpx;
|
||||
|
||||
&:active {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
.pre_def {
|
||||
background: url('../../assets/prepiece_def.png') no-repeat;
|
||||
background-size: 46rpx 39rpx;
|
||||
}
|
||||
|
||||
.next {
|
||||
background: url('../../assets/nextpiece.png') no-repeat;
|
||||
.next_def {
|
||||
background: url('../../assets/nextpiece_def.png') no-repeat;
|
||||
background-size: 46rpx 39rpx;
|
||||
}
|
||||
|
||||
@ -337,4 +351,4 @@
|
||||
height: 60rpx;
|
||||
background: url('../../assets/sliding.png') no-repeat;
|
||||
background-size: 60rpx 60rpx;
|
||||
}
|
||||
}
|
4
src/pages/lampEffect/index.config.js
Normal file
@ -0,0 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: "灯效",
|
||||
navigationBarBackgroundColor: "#F7F7F7",
|
||||
});
|
31
src/pages/lampEffect/index.jsx
Normal file
@ -0,0 +1,31 @@
|
||||
import { View, Image } from "@tarojs/components";
|
||||
import picture_01 from "@/assets/picture_01.png";
|
||||
import picture_02 from "@/assets/picture_02.png";
|
||||
import picture_03 from "@/assets/picture_03.png";
|
||||
import picture_04 from "@/assets/picture_04.png";
|
||||
import picture_05 from "@/assets/picture_05.png";
|
||||
import picture_06 from "@/assets/picture_06.png";
|
||||
import { setLampEffect } from "@/utils/sendOrder";
|
||||
import BLESDK from '@/utils/ble'
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.less";
|
||||
|
||||
|
||||
export default function Index() {
|
||||
const images = [picture_01, picture_02, picture_03, picture_04, picture_05, picture_06]
|
||||
BLESDK.onBLECharacteristicValueChange((bytes) => {
|
||||
let str = '操作成功'
|
||||
if (bytes[0] == 0x7A && bytes[4] == 0xB3 && bytes[5] != 0x00) {
|
||||
str = '操作失败'
|
||||
}
|
||||
Taro.showToast({ title: str, icon: 'none' })
|
||||
})
|
||||
|
||||
return (
|
||||
<View className='lampEffect index'>
|
||||
<View className='list'>
|
||||
{images.map((item, index) => <Image src={item} className='img' key={index} onClick={() => setLampEffect(index)} />)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
19
src/pages/lampEffect/index.less
Normal file
@ -0,0 +1,19 @@
|
||||
.lampEffect {
|
||||
padding: 32rpx;
|
||||
box-sizing: border-box;
|
||||
background: #F7F7F7;
|
||||
|
||||
.list {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.img {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -45,7 +45,7 @@ class Bluetooth {
|
||||
|
||||
platform = Taro.getSystemInfoSync().platform;
|
||||
appAuthorize = Taro.getAppAuthorizeSetting();
|
||||
deviceInfo = {}
|
||||
deviceInfo = Taro.getStorageSync('deviceInfo') || {}
|
||||
callBack = () => { };
|
||||
searchBack = () => { };
|
||||
|
||||
@ -91,7 +91,6 @@ class Bluetooth {
|
||||
success: () => {
|
||||
console.log("初始化蓝牙模块");
|
||||
this.isInit = true;
|
||||
this.deviceInfo = Taro.getStorageSync('deviceInfo') || {}
|
||||
if (this.deviceInfo.name) {
|
||||
this.createBleConnection()
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ export function handshake2() {
|
||||
TASK.addTask(list)
|
||||
}
|
||||
|
||||
|
||||
// 同步时间
|
||||
export function asyncDate() {
|
||||
const now = new Date();
|
||||
@ -58,38 +59,53 @@ export function asyncDate() {
|
||||
TASK.addTask(strInsert(aes128Encrypt(str)));
|
||||
}
|
||||
|
||||
// -----------------获取---------------------
|
||||
|
||||
// 获取设备状态
|
||||
export function getInitData() {
|
||||
// 音源设置
|
||||
TASK.addTask(strInsert(`7B05EA07B100`));
|
||||
|
||||
// 蓝牙开关
|
||||
TASK.addTask(strInsert(`7B05EA08B100`));
|
||||
|
||||
// 声卡开关
|
||||
TASK.addTask(strInsert(`7B05EA09B100`));
|
||||
|
||||
// 播放模式 (音乐模式)
|
||||
TASK.addTask(strInsert(`7B05EA0AB100`));
|
||||
|
||||
// 超低音强度
|
||||
TASK.addTask(strInsert(`7B05EA0CB100`));
|
||||
|
||||
// 音乐音量
|
||||
TASK.addTask(strInsert(`7B05EA06B100`));
|
||||
|
||||
// 话筒音量
|
||||
TASK.addTask(strInsert(`7B05EA05B100`));
|
||||
|
||||
// 话筒混响音量
|
||||
TASK.addTask(strInsert(`7B05EA0EB100`));
|
||||
|
||||
// 话筒混响模式
|
||||
TASK.addTask(strInsert(`7B05EA0DB100`));
|
||||
|
||||
// 音乐控制
|
||||
TASK.addTask(strInsert(`7B05EA0BB100`));
|
||||
let list = strInsert(`7B05EA12B100`)
|
||||
TASK.addTask(list)
|
||||
}
|
||||
|
||||
// 设置灯效
|
||||
export function setLampEffect(num) {
|
||||
let list = strInsert(`7B05EA13B2${hex(num)}`)
|
||||
TASK.addTask(list)
|
||||
}
|
||||
|
||||
|
||||
// export function getInitData() {
|
||||
// // 音源设置
|
||||
// TASK.addTask(strInsert(`7B05EA07B100`));
|
||||
|
||||
// // 蓝牙开关
|
||||
// TASK.addTask(strInsert(`7B05EA08B100`));
|
||||
|
||||
// // 声卡开关
|
||||
// TASK.addTask(strInsert(`7B05EA09B100`));
|
||||
|
||||
// // 播放模式 (音乐模式)
|
||||
// TASK.addTask(strInsert(`7B05EA0AB100`));
|
||||
|
||||
// // 超低音强度
|
||||
// TASK.addTask(strInsert(`7B05EA0CB100`));
|
||||
|
||||
// // 音乐音量
|
||||
// TASK.addTask(strInsert(`7B05EA06B100`));
|
||||
|
||||
// // 话筒音量
|
||||
// TASK.addTask(strInsert(`7B05EA05B100`));
|
||||
|
||||
// // 话筒混响音量
|
||||
// TASK.addTask(strInsert(`7B05EA0EB100`));
|
||||
|
||||
// // 话筒混响模式
|
||||
// TASK.addTask(strInsert(`7B05EA0DB100`));
|
||||
|
||||
// // 音乐控制
|
||||
// TASK.addTask(strInsert(`7B05EA0BB100`));
|
||||
|
||||
// // // 获取设备状态
|
||||
// // TASK.addTask(strInsert(`7B05EA12B100`));
|
||||
// }
|
||||
|
||||
|
||||
|