修复北斗授时的bug以及为字体设计新增显示到LED屏的功能
parent
a292e1aca6
commit
5120201397
|
@ -0,0 +1 @@
|
|||
{"font35":{"0":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"1":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"2":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"3":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"4":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"5":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"6":[false,true,true,false,false,true,true,true,false,false,true,false,false,false,true],"7":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"8":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"9":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],":":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],".":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"-":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]},"font47":{"0":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"1":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"2":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"3":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"4":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"5":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"6":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"7":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"8":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"9":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],":":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],".":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"-":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}
|
|
@ -20,7 +20,7 @@
|
|||
"echarts": "^5.4.0",
|
||||
"events": "^3.3.0",
|
||||
"naive-ui": "^2.34.3",
|
||||
"nmea": "git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git",
|
||||
"nmea": "http://git.hwasmart.com/bd_group/node-nmea.git",
|
||||
"node-wifi": "^2.0.16",
|
||||
"pinia": "^2.0.27",
|
||||
"systeminformation": "^5.17.12",
|
||||
|
|
|
@ -10,14 +10,23 @@
|
|||
</n-tab-pane>
|
||||
</Tabs>
|
||||
</Layout>
|
||||
<SerialPortManagementDrawer ref="serialportmanagementdrawer" />
|
||||
</Application>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { NTabPane } from 'naive-ui'
|
||||
import { Application } from '@/components/Application'
|
||||
import { Layout } from '@/layout/default'
|
||||
import { SerialPortManagementDrawer } from '@/components/SerialPortManagementDrawer'
|
||||
import { Tabs } from '@/components/Tabs'
|
||||
import { EditFontView } from '@/views/FontDesign/EditFontView'
|
||||
import { DotMatrixScreenDisplayView } from '@/views/FontDesign/DotMatrixScreenDisplayView'
|
||||
|
||||
const serialportmanagementdrawer = ref()
|
||||
|
||||
onMounted(()=>{
|
||||
serialportmanagementdrawer.value.appname('fontDesign')
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -220,8 +220,12 @@ const option = reactive({
|
|||
})
|
||||
|
||||
let date
|
||||
const update = (dateTime: Date) => {
|
||||
if (!dateTime) return
|
||||
const update = (handleDate: Date) => {
|
||||
|
||||
if (!handleDate) return
|
||||
|
||||
let dateTime = new Date(handleDate)
|
||||
|
||||
const seconds = dateTime.getSeconds()
|
||||
const minutes = dateTime.getMinutes()
|
||||
const hours = dateTime.getHours()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<n-button circle type="primary" size="large" class="drawer-control-button" @click="show = true">
|
||||
<n-button circle type="primary" size="large" :class=cvalue @click="show = true">
|
||||
<template #icon>
|
||||
<n-icon>
|
||||
<Cable />
|
||||
|
@ -21,6 +21,15 @@ import { CableFilled as Cable } from '@vicons/material'
|
|||
import { SerialPortManagementView } from '@/components/SerialPort'
|
||||
|
||||
const show = ref(false)
|
||||
const cvalue = ref('drawer-control-button')
|
||||
|
||||
const appname = (name) => {
|
||||
if(name == 'fontDesign'){
|
||||
cvalue.value = 'tobottom'
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose( { appname })
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
@ -29,5 +38,11 @@ const show = ref(false)
|
|||
right: 60px;
|
||||
top: 120px;
|
||||
}
|
||||
|
||||
.tobottom {
|
||||
position: fixed;
|
||||
right: 49%;
|
||||
bottom: 0.5%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ export const useSerialPortStore = defineStore('serialPort', {
|
|||
},
|
||||
|
||||
async open(options) {
|
||||
eventListeners[SerialPortEventType.beforeOpen]?.forEach((cb: Function) => cb(this))
|
||||
|
||||
if ( !options ) throw new Error('缺少串口配置参数')
|
||||
|
||||
if ( !this.instance ) throw new Error('未选择串口设备')
|
||||
|
@ -87,7 +89,11 @@ export const useSerialPortStore = defineStore('serialPort', {
|
|||
}
|
||||
}
|
||||
|
||||
eventListeners[SerialPortEventType.beforeClose]?.forEach((cb: Function) => cb(this))
|
||||
|
||||
await this.instance.close()
|
||||
|
||||
eventListeners[SerialPortEventType.afterClose]?.forEach((cb: Function) => cb(this))
|
||||
},
|
||||
|
||||
async close() {
|
||||
|
|
|
@ -27,15 +27,16 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { NGi, NGrid, NDatePicker, NButton } from 'naive-ui'
|
||||
import { NGi, NGrid, NDatePicker, NButton, useMessage } from 'naive-ui'
|
||||
import { Clock } from '@/components/Charts'
|
||||
import { useSerialPortStore, SerialPortEventType } from '@/stores/serialPort'
|
||||
import { useNMEAStore, NMEADataSource } from '@/stores/nmea'
|
||||
import { actions } from './data'
|
||||
import { LineBreakParser } from '@/utils/parser'
|
||||
|
||||
const serialPort = useSerialPortStore()
|
||||
const nmea = useNMEAStore()
|
||||
|
||||
const message = useMessage()
|
||||
const dataSource = new NMEADataSource()
|
||||
nmea.bindDataSource(dataSource)
|
||||
const decoder = new TextDecoder()
|
||||
|
@ -46,44 +47,90 @@ const onSerialPortData = (data: Uint8Array) => {
|
|||
}
|
||||
|
||||
const disabled = ref(true)
|
||||
|
||||
const clearset = ref(false)
|
||||
const mark = ref(false)
|
||||
const BJ_clock = ref(null)
|
||||
const system_clock = ref(null)
|
||||
|
||||
let firstintv
|
||||
let currentTimeStamp = (new Date()).valueOf()+1000
|
||||
|
||||
onMounted(() => {
|
||||
console.log(currentTimeStamp)
|
||||
firstintv =setInterval(() => {
|
||||
currentTimeStamp += 1000
|
||||
system_clock.value.update(currentTimeStamp)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
watch(() => nmea.handled, (value) => {
|
||||
if (!value) return
|
||||
|
||||
const BJDateTime = nmea.dateTime
|
||||
console.log(BJDateTime)
|
||||
if (BJDateTime === undefined) {
|
||||
disabled.value = true
|
||||
}else {
|
||||
disabled.value = false
|
||||
BJ_clock.value.update(BJDateTime)
|
||||
if(clearset.value){
|
||||
system_clock.value.update(BJDateTime)
|
||||
currentTimeStamp = BJDateTime
|
||||
}else{
|
||||
if(mark.value){
|
||||
system_clock.value.update(BJDateTime)
|
||||
mark.value = false
|
||||
clearInterval(firstintv)
|
||||
currentTimeStamp = new Date(currentTimeStamp).getTime()+1000
|
||||
firstintv = firstintv =setInterval(() => {
|
||||
currentTimeStamp += 1000
|
||||
system_clock.value.update(currentTimeStamp)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const system_clock = ref(null)
|
||||
let currentTimeStamp = (new Date()).valueOf()
|
||||
onMounted(() => {
|
||||
|
||||
setInterval(() => {
|
||||
currentTimeStamp += 1000
|
||||
system_clock.value.update(new Date(currentTimeStamp))
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
const onBDTimingBtnClick = () => {
|
||||
const date = BJ_clock.value.getDate()
|
||||
|
||||
currentTimeStamp = date.valueOf()
|
||||
clearInterval(firstintv)
|
||||
clearset.value = true
|
||||
mark.value = true
|
||||
}
|
||||
|
||||
|
||||
const dateTime = ref(null) // 值为时间戳
|
||||
const onDatePickerTimingBtnClick = () => {
|
||||
currentTimeStamp = dateTime.value
|
||||
clearInterval(firstintv)
|
||||
clearset.value = false
|
||||
currentTimeStamp = dateTime.value-1000
|
||||
firstintv = firstintv =setInterval(() => {
|
||||
currentTimeStamp += 1000
|
||||
system_clock.value.update(currentTimeStamp)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const resettime = () => {
|
||||
if(serialPort.isOpen){
|
||||
console.log('now open')
|
||||
}else{
|
||||
console.log('not open')
|
||||
if(clearset.value){
|
||||
clearInterval(firstintv)
|
||||
currentTimeStamp = new Date(currentTimeStamp).getTime()
|
||||
clearset.value = false
|
||||
disabled.value = true
|
||||
firstintv = firstintv =setInterval(() => {
|
||||
currentTimeStamp += 1000
|
||||
system_clock.value.update(currentTimeStamp)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const serialPort = useSerialPortStore()
|
||||
serialPort.addEventListener(SerialPortEventType.data, onSerialPortData)
|
||||
// serialPort.addEventListener(SerialPortEventType.beforeOpen, resettime)
|
||||
serialPort.addEventListener(SerialPortEventType.afterOpen, resettime)
|
||||
// serialPort.addEventListener(SerialPortEventType.beforeClose, resettime)
|
||||
serialPort.addEventListener(SerialPortEventType.afterClose, resettime)
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
|
|
@ -8,54 +8,95 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NGrid, NGi } from 'naive-ui'
|
||||
import { NGrid, NGi, useMessage } from 'naive-ui'
|
||||
import convert from 'color-convert'
|
||||
import LED from './components/LED.vue'
|
||||
import { useSerialPortStore } from '@/stores/serialPort'
|
||||
import { ROWS, COLS } from './data'
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const ledRefs = ref()
|
||||
|
||||
const serialPort = useSerialPortStore()
|
||||
|
||||
const showChar = (index, data, color) => {
|
||||
if (!data) return
|
||||
|
||||
if (!serialPort.isOpen) {
|
||||
message.error('请连接并打开串口设备')
|
||||
return
|
||||
}
|
||||
|
||||
clearArea(index)
|
||||
|
||||
if (data.length === 15) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (data[i]) {
|
||||
const x = Math.floor(i / 3)
|
||||
const y = i % 3 + index * 4
|
||||
if (!color) return
|
||||
|
||||
ledRefs.value[x * COLS + y].$el.children[0].style.backgroundColor = color
|
||||
}
|
||||
}
|
||||
if (data.length === 15) {
|
||||
data = [data[0],data[1],data[2],false,
|
||||
data[3],data[4],data[5],false,
|
||||
data[6],data[7],data[8],false,
|
||||
data[9],data[10],data[11],false,
|
||||
data[12],data[13],data[14],false,
|
||||
false,false,false,false,
|
||||
false,false,false,false]
|
||||
}
|
||||
|
||||
|
||||
if (data.length === 28) {
|
||||
let ledx = {
|
||||
0:[0,0,0,0,0,0,0,0],
|
||||
1:[0,0,0,0,0,0,0,0],
|
||||
2:[0,0,0,0,0,0,0,0],
|
||||
3:[0,0,0,0,0,0,0,0]
|
||||
}
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if(data[i]){
|
||||
const x = Math.floor(i / 4)
|
||||
const y = i % 4 + index * 4
|
||||
|
||||
ledRefs.value[x * COLS + y].$el.children[0].style.backgroundColor = color
|
||||
const x = i % 4 + index * 4
|
||||
const y = Math.floor(i / 4)
|
||||
const ledIndex = y * COLS + x
|
||||
ledRefs.value[ledIndex].$el.children[0].style.backgroundColor = color
|
||||
const rx = ledIndex % COLS
|
||||
const ry = Math.floor(ledIndex / COLS)
|
||||
ledx[rx-4*index][ry] = 1
|
||||
}
|
||||
}
|
||||
const origin = 4 * index
|
||||
const rgb = convert.hex.rgb(color)
|
||||
const I = parseInt(ledx[0].toString().replace(/,/gi,''),2)
|
||||
const II = parseInt(ledx[1].toString().replace(/,/gi,''),2)
|
||||
const III = parseInt(ledx[2].toString().replace(/,/gi,''),2)
|
||||
const IV = parseInt(ledx[3].toString().replace(/,/gi,''),2)
|
||||
let cmd = `$LEDAREA,${origin},0,${I},${II},${III},${IV},${rgb[0]},${rgb[1]},${rgb[2]}*`
|
||||
cmd += cmd.length
|
||||
cmd += '\r\n'
|
||||
serialPort.write(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
const clearArea = (areaIndex) => {
|
||||
for (let i = 0; i < 7; i++) {
|
||||
for(let i = 0; i < 8; i++){
|
||||
for (let j = 0; j < 4; j++){
|
||||
const ledIndex = i * COLS + areaIndex * 4 + j
|
||||
ledRefs.value[ledIndex].$el.children[0].style.backgroundColor = 'black'
|
||||
}
|
||||
}
|
||||
const origin = 4 * areaIndex
|
||||
let cmd = `$LEDAREA,${origin},0,0,0,0,0,0,0,0*`
|
||||
cmd += cmd.length
|
||||
cmd += '\r\n'
|
||||
serialPort.write(cmd)
|
||||
}
|
||||
|
||||
const clearAll = () => {
|
||||
if (!serialPort.isOpen) {
|
||||
message.error('请连接并打开串口设备')
|
||||
return
|
||||
}
|
||||
ledRefs.value.forEach(ledRef => {
|
||||
ledRef.$el.children[0].style.backgroundColor = 'black'
|
||||
});
|
||||
})
|
||||
serialPort.write('$LEDCL,0*9\r\n')
|
||||
}
|
||||
|
||||
defineExpose( { showChar, clearArea, clearAll })
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<n-space vertical>
|
||||
<div>
|
||||
<n-text v-if="!hasFont">字库未创建,请先创建字库</n-text>
|
||||
<n-text v-if="!hasFont">{{ fontmsg }}</n-text>
|
||||
|
||||
<n-radio-group v-else v-model:value="fontLibrarySelected" name="radiogroup">
|
||||
<n-space>
|
||||
|
@ -39,23 +39,31 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { NSpace, NGrid, NGi, NInput, NRadioGroup, NRadio, NText, NButton } from 'naive-ui'
|
||||
import { NSpace, NGrid, NGi, NInput, NRadioGroup, NRadio, NText, NButton, useMessage } from 'naive-ui'
|
||||
import { LEDPanelView } from './LEDPanelView'
|
||||
import { hasIpcRenderer } from '@/utils'
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const itemStyle = { textAlign: 'center', flex: '1 1 50%' }
|
||||
|
||||
const count = 8
|
||||
const hasFont = ref(false)
|
||||
const fontmsg = ref('字库未创建,请先创建字库后重启软件')
|
||||
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.', '-']
|
||||
const onlyAllow = (value: string) => !value || chars.indexOf(value) >= 0
|
||||
|
||||
const ledPanelViewRef = ref()
|
||||
const inputValues = ref(new Array(count).fill(null))
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
watch(
|
||||
() => inputValues.value[i],
|
||||
value => {
|
||||
const { data } = window.ipcRenderer.sendSync('LOAD_FONT_LIBRARY')
|
||||
if (!data) return
|
||||
fontLibrary = JSON.parse(data)
|
||||
hasFont.value = true
|
||||
if (!value) {
|
||||
ledPanelViewRef.value.clearArea(i)
|
||||
} else {
|
||||
|
@ -86,6 +94,7 @@ onMounted(() => {
|
|||
|
||||
const onClearBtnClick = () => {
|
||||
inputValues.value.fill(null)
|
||||
ledPanelViewRef.value.clearAll()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ const onClick = () => {
|
|||
|
||||
dialog.success({
|
||||
title: '系统消息',
|
||||
content: '保存字库成功,重启软件后生效',
|
||||
content: '保存字库成功',
|
||||
positiveText: '确定',
|
||||
closable: false,
|
||||
maskClosable: false,
|
||||
|
|
|
@ -3400,9 +3400,9 @@ needle@^3.1.0:
|
|||
iconv-lite "^0.6.3"
|
||||
sax "^1.2.4"
|
||||
|
||||
"nmea@git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git":
|
||||
"nmea@http://git.hwasmart.com/bd_group/node-nmea.git":
|
||||
version "0.1.2"
|
||||
resolved "git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git#7dbd7671aefebb73f820c51d76322ee96bdfe574"
|
||||
resolved "http://git.hwasmart.com/bd_group/node-nmea.git#94f58cd552a9b122816996c21047e34687f7157c"
|
||||
dependencies:
|
||||
JSONStream "0.7"
|
||||
through ">=2.2.7 <3"
|
||||
|
|
Loading…
Reference in New Issue