mirror of
https://github.com/silenty4ng/k5web
synced 2025-01-15 16:22:44 +00:00
Compare commits
2 commits
cafe42297e
...
6b8e6c7a52
Author | SHA1 | Date | |
---|---|---|---|
6b8e6c7a52 | |||
a08cb86ab0 |
4 changed files with 154 additions and 74 deletions
|
@ -1110,9 +1110,62 @@ async function eeprom_reboot(port) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function check_eeprom(port) {
|
async function check_eeprom(port, protocol = "official") {
|
||||||
alert('TODO')
|
let eepromSize = 0;
|
||||||
return null;
|
const random = [
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256),
|
||||||
|
Math.round(Math.random() * 256)
|
||||||
|
]
|
||||||
|
await eeprom_init(port);
|
||||||
|
const rawEEPROM = new Uint8Array(random);
|
||||||
|
if(protocol == 'official'){
|
||||||
|
const bk1 = await eeprom_read(port, 0, 0x08, protocol);
|
||||||
|
await eeprom_write(port, 0, rawEEPROM, 0x08, protocol);
|
||||||
|
const check1 = await eeprom_read(port, 0, 0x08, protocol);
|
||||||
|
if(rawEEPROM.toString() == check1.toString()){
|
||||||
|
eepromSize = 0x2000
|
||||||
|
}
|
||||||
|
await eeprom_write(port, 0, bk1, 0x08, protocol);
|
||||||
|
}else{
|
||||||
|
const bk1 = await eeprom_read(port, 0, 0x08, protocol);
|
||||||
|
await eeprom_write(port, 0, rawEEPROM, 0x08, protocol);
|
||||||
|
const check1 = await eeprom_read(port, 0, 0x08, protocol);
|
||||||
|
if(rawEEPROM.toString() == check1.toString()){
|
||||||
|
eepromSize = 0x2000
|
||||||
|
}
|
||||||
|
await eeprom_write(port, 0, bk1, 0x08, protocol);
|
||||||
|
|
||||||
|
const bk2 = await eeprom_read(port, 0x1FFF8, 0x08, protocol);
|
||||||
|
await eeprom_write(port, 0x1FFF8, rawEEPROM, 0x08, protocol);
|
||||||
|
const check2 = await eeprom_read(port, 0x1FFF8, 0x08, protocol);
|
||||||
|
if(rawEEPROM.toString() == check2.toString()){
|
||||||
|
eepromSize = 0x20000
|
||||||
|
}
|
||||||
|
await eeprom_write(port, 0x1FFF8, bk2, 0x08, protocol);
|
||||||
|
|
||||||
|
const bk3 = await eeprom_read(port, 0x3FFF8, 0x08, protocol);
|
||||||
|
await eeprom_write(port, 0x3FFF8, rawEEPROM, 0x08, protocol);
|
||||||
|
const check3 = await eeprom_read(port, 0x3FFF8, 0x08, protocol);
|
||||||
|
if(rawEEPROM.toString() == check3.toString()){
|
||||||
|
eepromSize = 0x40000
|
||||||
|
}
|
||||||
|
await eeprom_write(port, 0x3FFF8, bk3, 0x08, protocol);
|
||||||
|
|
||||||
|
const bk4 = await eeprom_read(port, 0x7FFF8, 0x08, protocol);
|
||||||
|
await eeprom_write(port, 0x7FFF8, rawEEPROM, 0x08, protocol);
|
||||||
|
const check4 = await eeprom_read(port, 0x7FFF8, 0x08, protocol);
|
||||||
|
if(rawEEPROM.toString() == check4.toString()){
|
||||||
|
eepromSize = 0x80000
|
||||||
|
}
|
||||||
|
await eeprom_write(port, 0x7FFF8, bk4, 0x08, protocol);
|
||||||
|
}
|
||||||
|
return eepromSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
function uint8ArrayToString(uint8Array, charset = "official") {
|
function uint8ArrayToString(uint8Array, charset = "official") {
|
||||||
|
|
|
@ -30,12 +30,24 @@
|
||||||
<a-button type="text" @click="checkEeprom">自动检测</a-button>
|
<a-button type="text" @click="checkEeprom">自动检测</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="3" title="清空数据">
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" @click="showClearDialog">清空数据</a-button>
|
||||||
|
</a-space>
|
||||||
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
<a-divider />
|
<a-divider />
|
||||||
<div id="statusArea" style="height: 20em; background-color: azure; color: silver; overflow: auto; padding: 20px" v-html="state.status"></div>
|
<div id="statusArea" style="height: 20em; background-color: azure; color: silver; overflow: auto; padding: 20px" v-html="state.status"></div>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<t-dialog
|
||||||
|
v-model:visible="state.showDialog"
|
||||||
|
theme="warning"
|
||||||
|
:header="state.dialogTitle >= 3 ? '第 ' + state.dialogTitle + ' 次警告(最后警告)' : '第 ' + state.dialogTitle + ' 次警告'"
|
||||||
|
body="这将会清空 EEPROM 所有内容,包括配置及校准数据!!!"
|
||||||
|
@confirm="onClickConfirm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -50,12 +62,59 @@ const state = reactive({
|
||||||
status: "点击备份按钮将生成 EEPROM 备份文件<br/><br/>",
|
status: "点击备份按钮将生成 EEPROM 备份文件<br/><br/>",
|
||||||
eepromType: "",
|
eepromType: "",
|
||||||
showHide: 0,
|
showHide: 0,
|
||||||
startInfo: "0x00"
|
startInfo: "0x00",
|
||||||
|
showDialog: false,
|
||||||
|
dialogTitle: 1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const onClickConfirm = () => {
|
||||||
|
if(state.dialogTitle >= 3){
|
||||||
|
state.showDialog = false;
|
||||||
|
clearEEPROM();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.dialogTitle += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const showClearDialog = () => {
|
||||||
|
state.dialogTitle = 1;
|
||||||
|
state.showDialog = true;
|
||||||
|
}
|
||||||
|
|
||||||
const checkEeprom = async () => {
|
const checkEeprom = async () => {
|
||||||
if(appStore.connectState != true){alert('请先连接手台!'); return;};
|
if(appStore.connectState != true){alert('请先连接手台!'); return;};
|
||||||
await check_eeprom();
|
const eepromSize = await check_eeprom(appStore.connectPort, appStore.configuration?.uart);
|
||||||
|
switch(eepromSize){
|
||||||
|
case 0x2000:
|
||||||
|
state.eepromType = "1";
|
||||||
|
break;
|
||||||
|
case 0x20000:
|
||||||
|
state.eepromType = "2";
|
||||||
|
break;
|
||||||
|
case 0x40000:
|
||||||
|
state.eepromType = "3";
|
||||||
|
break;
|
||||||
|
case 0x80000:
|
||||||
|
state.eepromType = "4";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearEEPROM = async () => {
|
||||||
|
if(appStore.connectState != true){alert('请先连接手台!'); return;};
|
||||||
|
const eepromSize = await check_eeprom(appStore.connectPort, appStore.configuration?.uart);
|
||||||
|
let rawEEPROM = new Uint8Array(0x80);
|
||||||
|
for (let i = 0; i < eepromSize; i += 0x80) {
|
||||||
|
await eeprom_write(appStore.connectPort, i, rawEEPROM, 0x80, appStore.configuration?.uart);
|
||||||
|
state.status = state.status + "清空进度:" + (((i - 0) / eepromSize) * 100).toFixed(1) + "%<br/>";
|
||||||
|
nextTick(()=>{
|
||||||
|
const textarea = document?.getElementById('statusArea');
|
||||||
|
if(textarea)textarea.scrollTop = textarea?.scrollHeight;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await eeprom_reboot(appStore.connectPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
const backupRange = async (start: any, end: any, name: any = new Date() + '_backup.bin') =>{
|
const backupRange = async (start: any, end: any, name: any = new Date() + '_backup.bin') =>{
|
||||||
|
|
|
@ -10,16 +10,15 @@
|
||||||
<a-space>
|
<a-space>
|
||||||
<t-card bordered>
|
<t-card bordered>
|
||||||
<template #header>
|
<template #header>
|
||||||
117 版本 LOSEHU 固件写入
|
LOSEHU 固件字库写入
|
||||||
</template>
|
</template>
|
||||||
<a-button @click="restore(1)">写入 117 字库</a-button>
|
<a-button @click="restore(1)">自动写入字库</a-button>
|
||||||
</t-card>
|
</t-card>
|
||||||
<t-card bordered>
|
<t-card bordered>
|
||||||
<template #header>
|
<template #header>
|
||||||
LOSEHU H版固件需同时写入字库及索引表,K版只需写入字库。
|
LOSEHU H 版固件拼音索引表
|
||||||
</template>
|
</template>
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button @click="restore(2)">写入 118+ 字库</a-button>
|
|
||||||
<a-button @click="restore(4)">写入拼音检索表</a-button>
|
<a-button @click="restore(4)">写入拼音检索表</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</t-card>
|
</t-card>
|
||||||
|
@ -65,61 +64,8 @@ const restore = async(type: any = 1) => {
|
||||||
alert('固件版本不匹配');
|
alert('固件版本不匹配');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((type == 1 && appStore.configuration?.charset != "losehu") || (type == 1 && appStore.configuration?.K != true)){
|
|
||||||
alert('固件版本不匹配');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(type == 2 && appStore.configuration?.charset != "gb2312"){
|
|
||||||
alert('固件版本不匹配');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state.status = state.status + "正在下载字库...<br />"
|
state.status = state.status + "正在下载字库...<br />"
|
||||||
let fontPacket = undefined
|
let fontPacket = undefined
|
||||||
if(type == 1){
|
|
||||||
fontPacket = await fetch('/old_font.bin')
|
|
||||||
const reader = fontPacket.body.getReader();
|
|
||||||
const chunks = [];
|
|
||||||
while(true) {
|
|
||||||
const {done, value} = await reader.read();
|
|
||||||
if (done) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chunks.push(...value)
|
|
||||||
}
|
|
||||||
const binary = new Uint8Array(chunks)
|
|
||||||
await restoreRange(0x02000, binary)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(type == 2){
|
|
||||||
fontPacket = await fetch('/new_font_k.bin')
|
|
||||||
const reader = fontPacket.body.getReader();
|
|
||||||
const chunks = [];
|
|
||||||
while(true) {
|
|
||||||
const {done, value} = await reader.read();
|
|
||||||
if (done) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chunks.push(...value)
|
|
||||||
}
|
|
||||||
const binary = new Uint8Array(chunks)
|
|
||||||
await restoreRange(0x02480, binary)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(type == 3){
|
|
||||||
fontPacket = await fetch('/new_font_h.bin')
|
|
||||||
const reader = fontPacket.body.getReader();
|
|
||||||
const chunks = [];
|
|
||||||
while(true) {
|
|
||||||
const {done, value} = await reader.read();
|
|
||||||
if (done) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chunks.push(...value)
|
|
||||||
}
|
|
||||||
const binary = new Uint8Array(chunks)
|
|
||||||
await restoreRange(0x02480, binary)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(type == 4){
|
if(type == 4){
|
||||||
if(appStore.configuration?.newpinyin){
|
if(appStore.configuration?.newpinyin){
|
||||||
fontPacket = await fetch('/pinyin_plus.bin')
|
fontPacket = await fetch('/pinyin_plus.bin')
|
||||||
|
@ -139,6 +85,38 @@ const restore = async(type: any = 1) => {
|
||||||
await restoreRange(0x20000, binary)
|
await restoreRange(0x20000, binary)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(type == 1){
|
||||||
|
if(appStore.configuration?.charset == "losehu"){
|
||||||
|
fontPacket = await fetch('/old_font.bin')
|
||||||
|
const reader = fontPacket.body.getReader();
|
||||||
|
const chunks = [];
|
||||||
|
while(true) {
|
||||||
|
const {done, value} = await reader.read();
|
||||||
|
if (done) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chunks.push(...value)
|
||||||
|
}
|
||||||
|
const binary = new Uint8Array(chunks)
|
||||||
|
await restoreRange(0x02000, binary)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(appStore.configuration?.charset == "gb2312"){
|
||||||
|
fontPacket = await fetch('/new_font_k.bin')
|
||||||
|
const reader = fontPacket.body.getReader();
|
||||||
|
const chunks = [];
|
||||||
|
while(true) {
|
||||||
|
const {done, value} = await reader.read();
|
||||||
|
if (done) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chunks.push(...value)
|
||||||
|
}
|
||||||
|
const binary = new Uint8Array(chunks)
|
||||||
|
await restoreRange(0x02480, binary)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,6 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<t-pagination style="margin: 10px;" :total="6" showPageNumber :showPageSize="false" />
|
<t-pagination style="margin: 10px;" :total="6" showPageNumber :showPageSize="false" />
|
||||||
<a-tabs :active-key="state.activeKey" @change="(e)=>{state.activeKey = e}">
|
|
||||||
<a-tab-pane :key="1" title="LOSEHU 117"></a-tab-pane>
|
|
||||||
<a-tab-pane :key="2" title="LOSEHU 118+"></a-tab-pane>
|
|
||||||
</a-tabs>
|
|
||||||
<div id="canvasDiv" style="zoom: 250%;"></div>
|
<div id="canvasDiv" style="zoom: 250%;"></div>
|
||||||
<br>
|
<br>
|
||||||
<a-space>
|
<a-space>
|
||||||
|
@ -62,11 +58,9 @@ import { eeprom_write, eeprom_reboot, eeprom_init } from '@/utils/serial.js';
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
const state : {
|
const state : {
|
||||||
activeKey: any,
|
|
||||||
binaryFile: any,
|
binaryFile: any,
|
||||||
loading: boolean
|
loading: boolean
|
||||||
} = reactive({
|
} = reactive({
|
||||||
activeKey: 1,
|
|
||||||
binaryFile: undefined,
|
binaryFile: undefined,
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
|
@ -197,17 +191,13 @@ const flashIt = async () => {
|
||||||
alert('固件版本不匹配');
|
alert('固件版本不匹配');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(state.activeKey == 2 && appStore.configuration?.charset != "gb2312"){
|
if(appStore.configuration?.charset != "losehu" && appStore.configuration?.charset != "gb2312"){
|
||||||
alert('固件版本不匹配');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(state.activeKey == 1 && appStore.configuration?.charset != "losehu"){
|
|
||||||
alert('固件版本不匹配');
|
alert('固件版本不匹配');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.loading = true
|
state.loading = true
|
||||||
let position = 0x1E350;
|
let position = 0x1E350;
|
||||||
if(state.activeKey == 2)position = 0x2080;
|
if(appStore.configuration?.charset == "gb2312")position = 0x2080;
|
||||||
await eeprom_init(appStore.connectPort);
|
await eeprom_init(appStore.connectPort);
|
||||||
const rawEEPROM = state.binaryFile;
|
const rawEEPROM = state.binaryFile;
|
||||||
for (let i = position; i < rawEEPROM.length + position; i += 0x80) {
|
for (let i = position; i < rawEEPROM.length + position; i += 0x80) {
|
||||||
|
|
Loading…
Reference in a new issue