File tree Expand file tree Collapse file tree 4 files changed +52
-10
lines changed
Expand file tree Collapse file tree 4 files changed +52
-10
lines changed Original file line number Diff line number Diff line change 1111 <!-- 右半屏幕 -->
1212 <el-col :span =" 12" >
1313 <el-row justify =" end" style =" height :32px ;" >
14- <el-form-item label =" 深色模式" >
14+ <el-form-item label =" 连接设备" style =" margin-right : 20px ;" >
15+ <el-switch v-model =" isConnected" @change =" connectDevice()" inline-prompt active-text =" 开" inactive-text =" 关" />
16+ </el-form-item >
17+ <el-form-item label =" 深色模式" style =" margin-right : 20px ;" >
1518 <el-switch v-model =" switchVal" @change =" toggleDark(), UseDarkMode()" inline-prompt active-text =" 开"
1619 inactive-text =" 关" />
1720 </el-form-item >
3942 </style >
4043<script setup lang="ts">
4144import { ref } from ' vue'
45+ import { onMounted } from ' vue'
4246import {
4347 ElNotification ,
4448 ElRow ,
@@ -52,11 +56,19 @@ import { useDark, useToggle } from '@vueuse/core'
5256const isDark = useDark ()
5357const toggleDark = useToggle (isDark )
5458let switchVal = ref (isDark .value )
59+ let isConnected = ref (false )
5560
5661function UseDarkMode() {
5762 WaveGenChart .darkMode (isDark .value );
5863 OSChart .darkMode (isDark .value );
5964};
65+ function connectDevice() {
66+ console .log (" 连接设备" );
67+ }
68+ onMounted (() => {
69+ UseDarkMode ();
70+ switchVal = ref (isDark .value );
71+ });
6072
6173 </script >
6274<script lang="ts">
Original file line number Diff line number Diff line change 11<template >
22 <div :style =" `width:${width}px;height:${height}px;`" :id =" container" class =" OSChart" ></div >
3-
3+ <div class =" OSCForm" >
4+ <el-form-item size =" large" >
5+ <el-button type =" primary" @click =" OSCRun" style =" width : 45% ; margin-right : 5% ;" >运行</el-button >
6+ <el-button @click =" OSCStop" style =" width : 45% ; margin-left : 5% ;" >停止</el-button >
7+ </el-form-item >
8+ <el-form-item size =" large" label =" 采样频率/Hz" >
9+ <el-input-number v-model =" sampleRate" @change =" sampleRateChange(sampleRate)" :min =" 1000" :max =" 128000" :step =" 1000" step-strictly label =" 采样频率/Hz" >
10+ </el-input-number >
11+ </el-form-item >
12+ </div >
413</template >
514
615<script lang="ts" setup>
@@ -21,6 +30,13 @@ import { CanvasRenderer } from 'echarts/renderers';
2130import { onMounted } from ' vue' ;
2231import { EChartsType } from ' echarts/core' ;
2332
33+ import { ref } from " vue" ;
34+ import {
35+ ElFormItem ,
36+ ElInputNumber ,
37+ ElButton ,
38+ } from ' element-plus'
39+
2440echarts .use ([
2541 ToolboxComponent ,
2642 TooltipComponent ,
@@ -76,6 +92,17 @@ var option: EChartsOption;
7692var myChart: EChartsType ;
7793var chartDom: HTMLElement ;
7894
95+ let isRun = true ;
96+ const sampleRate = ref (8000 );
97+ const sampleRateChange = (value : number ) => {
98+ console .log (value );
99+ }
100+ function OSCRun(){
101+ isRun = true ;
102+ };
103+ function OSCStop(){
104+ isRun = false ;
105+ };
79106function func(x : number ) {
80107 x /= 10 ;
81108 return Math .sin (x ) * 3.3 ;
@@ -193,4 +220,8 @@ export default {
193220.OSChart {
194221 margin : 0 auto ;
195222}
223+ .OSCForm {
224+ width : 50% ;
225+ margin : 0 auto ;
226+ }
196227 </style >
Original file line number Diff line number Diff line change 1111 <el-option label =" 锯齿波" value =" 3" ></el-option >
1212 </el-select >
1313 </el-form-item >
14- <el-form-item label =" 频率" style =" width :100% s " >
14+ <el-form-item label =" 频率" style =" width :100% " >
1515 <el-input-number v-model =" freq" @change =" freqChange(freq)" :min =" 1" :max =" 1500" :step =" 1" label =" 频率" >
1616 </el-input-number >
1717 </el-form-item >
2828 :step =" 0.2" label =" 频率" ></el-input-number >
2929 </el-form-item >
3030 <el-form-item >
31- <el-button type =" primary" @click =" onSubmit" style =" width : 40 % ; margin-right : 5% ;" >立即设置</el-button >
32- <el-button style =" width : 40 % ; margin-left : 0 % ;" >取消</el-button >
31+ <el-button type =" primary" @click =" onSubmit" style =" width : 45 % ; margin-right : 5% ;" >立即设置</el-button >
32+ <el-button style =" width : 45 % ; margin-left : 5 % ;" >取消</el-button >
3333 </el-form-item >
3434 </el-form >
3535 </div >
@@ -108,7 +108,7 @@ export default {
108108
109109<style >
110110.waveGen {
111- width : 50 % ;
111+ width : 55 % ;
112112 height : auto ;
113113 margin : 0 auto ;
114114 font-size : 2em ;
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ option = {
134134 {
135135 show: true ,
136136 type: ' inside' ,
137- filterMode: ' filter ' ,
137+ filterMode: ' none ' ,
138138 xAxisIndex: [0 ],
139139 startValue: 0 ,
140140 endValue: 300 ,
@@ -145,7 +145,7 @@ option = {
145145 type: ' inside' ,
146146 // disabled: true,
147147 // zoomLock: true,
148- filterMode: ' empty ' ,
148+ filterMode: ' none ' ,
149149 yAxisIndex: [0 ],
150150 startValue: - 1 ,
151151 endValue: 5
@@ -197,8 +197,7 @@ function wave_gen(index: number) {
197197 else if (index == 3 ) // 锯齿波
198198 {
199199 for (var i = - 128 ; i < 128 ; i ++ ) {
200- waveTab1 [i + 128 ] = ((i + (offSetValue * 255 / 3.3 )) * (uMaxValue / 3.3 ));
201-
200+ waveTab1 [i + 128 ] = (i * (uMaxValue / 3.3 ) + (offSetValue * 255 / 3.3 ));
202201 }
203202 console .log (" 波形表重设成功,当前为锯齿波\n " );
204203 }
You can’t perform that action at this time.
0 commit comments