init commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<n-space vertical justify="center" class="sound-detect-module-config-view">
|
||||
<div>
|
||||
<n-select
|
||||
placeholder="请设置声音检测模块事件"
|
||||
v-model:value="value"
|
||||
:options="options"
|
||||
@update:value="onSelectUpdate"
|
||||
class="mx-auto"
|
||||
style="width: 50%; "/>
|
||||
</div>
|
||||
|
||||
<ResetButtonView />
|
||||
</n-space>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NSpace, NSelect, useMessage } from 'naive-ui'
|
||||
import ResetButtonView from '../ResetButtonView.vue'
|
||||
import { options } from './data'
|
||||
import { useSerialPortStore } from '@/stores/serialPort'
|
||||
|
||||
const message = useMessage()
|
||||
const serialPort = useSerialPortStore()
|
||||
|
||||
const value = ref(null)
|
||||
const onSelectUpdate = () => {
|
||||
if (!serialPort.isOpen) {
|
||||
message.error('请先连接无线通信模块并打开串口')
|
||||
return
|
||||
}
|
||||
|
||||
let cmd = `$SDEVENT,${value.value}*`
|
||||
cmd += cmd.length
|
||||
cmd += '\r\n'
|
||||
|
||||
serialPort.write(cmd)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.sound-detect-module-config-view {
|
||||
row-gap: 48px !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user