Skip to content

Commit

Permalink
connection update (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigh authored Aug 1, 2024
2 parents e6a6cf4 + 903f882 commit 7b83f06
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 138 deletions.
10 changes: 5 additions & 5 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
Binary file added src/lib/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="flex justify-center w-full px-6 py-2">
<div class="flex lg:flex-row flex-col lg:w-[90%] w-full">
<Chart {dataTypesArrayU} bind:device />
<Info {dataTypesArrayU}/>
<Info {dataTypesArrayU} />
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/routes/chartData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
display: true,
position: 'right',
suggestedMin: -2.0,
suggestedMax: 6
suggestedMax: 6
},
mv: {
type: 'linear',
Expand Down
150 changes: 75 additions & 75 deletions src/routes/dataHandler.js
Original file line number Diff line number Diff line change
@@ -1,132 +1,132 @@
let temperatureDataSet = {
name: "温度",
name: '温度',
head: 0x00,
postfix: "℃",
postfix: '℃',
v: 0,
postProc: (v) => {
let temp
let temp;
if (v >= 0x8000) {
temp = 0x10000 - v
temp = 0x10000 - v;
} else {
temp = v
temp = v;
}
return temp / 10
return temp / 10;
},
print: (self) => {
return self.v.toFixed(1) + self.postfix
},
}
return self.v.toFixed(1) + self.postfix;
}
};
let freqDataSet = {
name: "输出频率",
name: '输出频率',
head: 0x10,
postfix: "Hz",
postfix: 'Hz',
v: 0,
postProc: (v) => {
return v / 10
return v / 10;
},
print: (self) => {
return self.v.toFixed(1) + self.postfix
},
}
return self.v.toFixed(1) + self.postfix;
}
};
let voltPostProc = (adc) => {
let mv = 1.277 * adc - 96
let mv = 1.277 * adc - 96;
if (mv < 50) {
mv = 0
mv = 0;
}
return mv / 1000
}
return mv / 1000;
};
let currentPostProc = (adc) => {
let mA = 4.07 * adc - 12610
let mA = 4.07 * adc - 12610;
if (mA < 140 && mA > -80) {
mA = 0
mA = 0;
}
return mA / 1000
}
return mA / 1000;
};
let voltOutDataSet = {
name: "输出电压",
name: '输出电压',
head: 0x11,
postfix: "V",
postfix: 'V',
v: 0,
postProc: voltPostProc,
print: (self) => {
return self.v.toFixed(2) + self.postfix
},
}
return self.v.toFixed(2) + self.postfix;
}
};
let currentInDataSet = {
name: "输入电流",
name: '输入电流',
head: 0x12,
postfix: "A",
postfix: 'A',
v: 0,
postProc: currentPostProc,
print: (self) => {
return self.v.toFixed(2) + self.postfix
},
}
return self.v.toFixed(2) + self.postfix;
}
};
let voltInDataSet = {
name: "输入电压",
name: '输入电压',
head: 0x13,
postfix: "V",
postfix: 'V',
v: 0,
postProc: voltPostProc,
print: (self) => {
return self.v.toFixed(2) + self.postfix
},
}
return self.v.toFixed(2) + self.postfix;
}
};
let currentOutDataSet = {
name: "输出电流",
name: '输出电流',
head: 0x14,
postfix: "A",
postfix: 'A',
v: 0,
postProc: currentPostProc,
print: (self) => {
return self.v.toFixed(2) + self.postfix
},
}
return self.v.toFixed(2) + self.postfix;
}
};
let ratioDataSet = {
name: "输出占空比",
name: '输出占空比',
head: 0x18,
postfix: "%",
postfix: '%',
v: 0,
postProc: (v) => {
return v / 10
return v / 10;
},
print: (self) => {
return self.v.toFixed(1) + self.postfix
},
}
return self.v.toFixed(1) + self.postfix;
}
};
let powerDataSet = {
name: "峰值功率",
name: '峰值功率',
head: 0xf0,
postfix: "W",
postfix: 'W',
v: 0,
print: (self) => {
return self.v.toFixed(1) + self.postfix
},
}
return self.v.toFixed(1) + self.postfix;
}
};
let delayDataSet = {
name: "点火延迟",
name: '点火延迟',
head: 0x72,
postfix: "ms",
postfix: 'ms',
v: 0,
print: (self) => {
return (self.v / 1000).toFixed(1) + self.postfix
},
}
return (self.v / 1000).toFixed(1) + self.postfix;
}
};
let worktimeDataSet = {
name: "燃烧时间",
name: '燃烧时间',
head: 0x74,
postfix: "ms",
postfix: 'ms',
v: 0,
print: (self) => {
return (self.v / 1000).toFixed(0) + self.postfix
},
}
return (self.v / 1000).toFixed(0) + self.postfix;
}
};
let timestampDataSet = {
name: "时间戳",
name: '时间戳',
head: 0x7f,
postfix: "us",
v: 0,
}
postfix: 'us',
v: 0
};

export let dataTypesArray = new Array(
temperatureDataSet,
Expand All @@ -140,7 +140,7 @@ export let dataTypesArray = new Array(
delayDataSet,
worktimeDataSet,
timestampDataSet
)
);
export const dataTypes = new Map([
[0x00, temperatureDataSet],
[0x10, freqDataSet],
Expand All @@ -152,16 +152,16 @@ export const dataTypes = new Map([
[0xf0, powerDataSet],
[0x72, delayDataSet],
[0x74, worktimeDataSet],
[0x7f, timestampDataSet],
])
[0x7f, timestampDataSet]
]);
export function dataUpdate(datas) {
datas.forEach((element) => {
if (dataTypes.has(element.head)) {
dataTypes.get(element.head).v = element.v
dataTypes.get(element.head).v = element.v;
}
})
powerDataSet.v = voltOutDataSet.v * currentInDataSet.v
});
powerDataSet.v = voltOutDataSet.v * currentInDataSet.v;
if (freqDataSet.v > 0.0 && freqDataSet.v < 100.0) {
powerDataSet.v = (powerDataSet.v * freqDataSet.v) / 100
powerDataSet.v = (powerDataSet.v * freqDataSet.v) / 100;
}
}
3 changes: 2 additions & 1 deletion src/routes/nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const dispatch = createEventDispatcher();
import { IconSun } from '@tabler/icons-svelte';
import { IconMoon } from '@tabler/icons-svelte';
import Favicon from '$lib/favicon.png';
import Webhid from './webhid.svelte';
import RealtimeData from './realtimeData.svelte';
Expand All @@ -16,7 +17,7 @@

<div class="navbar bg-base-100">
<div class="flex-none">
<img src="favicon.png" class="max-h-16" alt="LOGO" />
<img src={Favicon} class="max-h-16" alt="LOGO" />
</div>
<div class="flex-none">
<a class="btn btn-ghost normal-case text-xl" href="#">Volwave TT</a>
Expand Down
4 changes: 1 addition & 3 deletions src/routes/realtimeData.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script>
export let dataTypesArrayU;
// 显示过滤
const filter = [
0x10, 0x11, 0x12, 0x13, 0x14, 0x18, 0xf0,
];
const filter = [0x10, 0x11, 0x12, 0x13, 0x14, 0x18, 0xf0];
</script>

<div class="flex-1">
Expand Down
Loading

0 comments on commit 7b83f06

Please sign in to comment.