实现指南针的数据更新

master
yezhichao 2021-11-23 07:44:22 +08:00
parent e8bbe58d7c
commit bad94bd96e
3 changed files with 24 additions and 8 deletions

View File

@ -132,9 +132,9 @@ const option = reactive({
const update = (dateTime: Date) => {
if (!dateTime) return
const seconds = dateTime.getSeconds()
const minutes = dateTime.getMinutes()
const hours = dateTime.getHours()
const seconds = dateTime.getSeconds()
const minutes = dateTime.getMinutes()
const hours = dateTime.getHours()
const second_data = seconds
const minute_data = second_data / 60 + minutes

View File

@ -9,7 +9,7 @@ import { TitleComponent } from "echarts/components";
import { GaugeChart } from "echarts/charts";
import VChart from "vue-echarts";
import { ref } from "vue";
import { reactive } from "vue";
use([
CanvasRenderer,
@ -17,7 +17,7 @@ use([
GaugeChart
]);
const option = ref({
const option = reactive({
title: {
text: '航向',
left: 'center'
@ -71,12 +71,28 @@ const option = ref({
detail: {
show:false
},
data: [{ value: 330 }]
data: [{ value: 0 }]
}
]
});
const update = console.log
const update = (variation: number, variationPole: string) => {
switch (variationPole) {
case 'N':
break;
case 'E':
variation += 90
break;
case 'S':
variation += 180
break;
case 'W':
variation += 270
break;
}
option.series[0].data[0].value = variation
}
defineExpose({ update })
</script>

View File

@ -50,7 +50,7 @@ const update = (nmeaStr: string) => {
const { dateTime, longitude, latitude, alt, variation, variationPole, numSat } = data
digitalFlopContainer.value.update(dateTime, longitude, latitude, alt, numSat)
clock.value.update(dateTime)
// compass.value.update(variation, variationPole)
compass.value.update(variation, variationPole)
// waterLevel.value.update(alt)
// map.value.update(lon, lonPole, lat, latPole)
}