Skip to content

Commit

Permalink
feat: add flash progress
Browse files Browse the repository at this point in the history
  • Loading branch information
wutiange authored and LynnL4 committed Jan 18, 2024
1 parent 7b5a5b4 commit 4fade02
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/locale/en-US/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default {
'workplace.device.message.tip.connecting': 'Connecting',
'workplace.device.message.tip.downloading.firmware': 'Downloading firmware',
'workplace.device.message.tip.downloading.model': 'Downloading model',
'workplace.device.message.tip.flashing': 'Flashing',
'workplace.device.message.tip.flashing': 'Flashing, {progress}',
'workplace.device.message.tip.resetting': 'Resetting',
'workplace.device.message.tip.erasing': 'Erasing',
'workplace.firmware.eraseflash': 'Erase Device',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/zh-CN/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
'workplace.device.message.tip.connecting': '连接中',
'workplace.device.message.tip.downloading.firmware': '固件下载中',
'workplace.device.message.tip.downloading.model': '模型下载中',
'workplace.device.message.tip.flashing': '烧录中',
'workplace.device.message.tip.flashing': '烧录中,{progress}',
'workplace.device.message.tip.resetting': '重置中',
'workplace.device.message.tip.erasing': '擦除中',
'workplace.firmware.eraseflash': '擦除设备',
Expand Down
16 changes: 15 additions & 1 deletion src/pages/setup/process/components/Device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@
}
}
}
loadingTip.value = t('workplace.device.message.tip.flashing');
deviceStore.setFlashProgress('0%');
loadingTip.value = t('workplace.device.message.tip.flashing', {
progress: deviceStore.flashProgress,
});
deviceStore.setDeviceStatus(DeviceStatus.Flashing);
const result = await props.flasher.onWriteFlash(fileArray);
if (result) {
Expand Down Expand Up @@ -655,6 +658,17 @@
router.push('/setup/config');
};
watch(
() => deviceStore.flashProgress,
() => {
if (deviceStore.deviceStatus === DeviceStatus.Flashing) {
loadingTip.value = t('workplace.device.message.tip.flashing', {
progress: deviceStore.flashProgress,
});
}
}
);
watch(
() => deviceStore.currentModel,
(model?: Model | null) => {
Expand Down
1 change: 1 addition & 0 deletions src/sscma/grove_ai_we2/deviceHimax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Himax extends Device {
const xmodem = new Xmodem({});
const progress = (current: number, total: number, percent: number) => {
console.log(`progress ${current}/${total} ${percent}%`);
this.deviceStore.setFlashProgress(`${percent}%`);
};
if (!this.serial) {
return;
Expand Down
3 changes: 3 additions & 0 deletions src/sscma/xiao_esp32s3/Flasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Flasher implements FlasherInterface {
compress: true,
reportProgress: (fileIndex, written, total) => {
console.log('written ', fileIndex, ' file:', (written / total) * 100);
this.deviceStore.setFlashProgress(
`${Math.floor((written / total) * 100)}%`
);
},
} as FlashOptions;
await this.espLoader?.write_flash(flashOptions);
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/device/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const useDeviceStore = defineStore('device', {
currentAvailableModel: false,
comeToSenseCraftAI: {} as ComeToSenseCraftAIType,
flashWay: FlashWayType.Prefabricated,
flashProgress: '0%',
}),
persist: {
enabled: true,
Expand Down Expand Up @@ -140,6 +141,9 @@ const useDeviceStore = defineStore('device', {
setIsCanMqtt(isCanMqtt: boolean) {
this.isCanMqtt = isCanMqtt;
},
setFlashProgress(progress: string) {
this.flashProgress = progress;
},

clearDeviceInfo() {
this.deviceName = null;
Expand Down

0 comments on commit 4fade02

Please sign in to comment.