def updateProgress(self, fileTypeStr, current, total, speedStr): currBurnPos = self.burnPositionCombobox.currentText() if currBurnPos == tr("SRAM") or currBurnPos == tr_en("SRAM"): fileTypeStr = tr("ToSRAM") percent = current/float(total)*100 hint = "<font color=%s>%s %s:</font> <font color=%s> %.2f%%</font> <font color=%s> %s</font>" %("#ff7575", tr("Downloading"), fileTypeStr, "#2985ff", percent, "#1aac2d", speedStr) self.progressHint.setText(hint) self.progressbar.setValue(percent)
def __init__(self): self.files = [] # [ (path, addr, firmware, enable), ...] self.board = 0 self.burnPosition = tr_en("Flash") self.baudRate = 2 self.skin = 2 self.language = default_lang self.slowMode = True
def __init__(self): self.files = [] # kfpkg: [file path] # bin files: [(path,addr,prefix), ...] self.board = parameters.SipeedMaixBit self.burnPosition = tr_en("Flash") self.baudRate = 2 self.skin = 2 self.language = translation.language_en self.slowMode = True
def download(self): if self.burning: self.terminateBurn() return self.burning = True filename = self.filePathWidget.text() if not self.checkFileName(filename): self.errorSignal.emit(tr("Error"), tr("FilePathError")) self.burning = False return color = False board = "dan" boardText = self.boardCombobox.currentText() if boardText == parameters.SipeedMaixGoE: board = "goE" elif boardText == parameters.SipeedMaixGoD: board = "goD" elif boardText == parameters.SipeedMaixBit: board = "bit" elif boardText == parameters.KendriteKd233: board = "kd233" sram = False if self.burnPositionCombobox.currentText()==tr("SRAM") or \ self.burnPositionCombobox.currentText()==tr_en("SRAM"): sram = True try: baud = int(self.serailBaudrateCombobox.currentText()) except Exception: self.errorSignal.emit(tr("Error"), tr("BaudrateError")) self.burning = False return dev = self.serialPortCombobox.currentText().split()[0] if dev=="": self.errorSignal.emit(tr("Error"), tr("PleaseSelectSerialPort")) self.burning = False return # hide setting widgets self.setFrameStrentch(1) self.settingWidget.hide() self.progressbar.setValue(0) self.progressbarRootWidget.show() self.progressHint.show() self.downloadButton.setText(tr("Cancel")) self.downloadButton.setProperty("class", "redbutton") self.downloadButton.style().unpolish(self.downloadButton) self.downloadButton.style().polish(self.downloadButton) self.downloadButton.update() self.statusBarStauts.setText("<font color=%s>%s ...</font>" %("#1aac2d", tr("Downloading"))) hint = "<font color=%s>%s</font>" %("#ff0d0d", tr("DownloadStart")) self.progressHint.setText(hint) # download self.burnThread = threading.Thread(target=self.flashBurnProcess, args=(dev, baud, board, sram, filename, self.progress, color,)) self.burnThread.setDaemon(True) self.burnThread.start()
class ParametersToSave: filePath = "" board = parameters.SipeedMaixBit burnPosition = tr_en("Flash") baudRate = 2 skin = 2 language = translation.language_en def __init__(self): return def __del__(self): return
def download(self): if self.packing: self.hintSignal.emit(tr("Busy"), tr("Please wait, packing ...")) return if self.burning: self.terminateBurn() return fileType, filesInfo = self.getBurnFilesInfo() if not fileType or not filesInfo: self.errorSignal.emit(tr("Error"), tr("File path error")) return self.burning = True # if not self.checkFileName(filename): # self.errorSignal.emit(tr("Error"), tr("FilePathError")) # self.burning = False # return color = False board = "dan" boardText = self.boardCombobox.currentText() if boardText == parameters.SipeedMaixGo: board = "goE" elif boardText == parameters.SipeedMaixGoD: board = "goD" elif boardText == parameters.SipeedMaixduino: board = "maixduino" elif boardText == parameters.SipeedMaixBit: board = "bit" elif boardText == parameters.SipeedMaixBitMic: board = "bit_mic" elif boardText == parameters.KendryteKd233: board = "kd233" elif boardText == parameters.kendryteTrainer: board = "trainer" elif boardText == parameters.M5StickV: board = "goE" elif boardText == parameters.Auto: board = None sram = False if self.burnPositionCombobox.currentText()==tr("SRAM") or \ self.burnPositionCombobox.currentText()==tr_en("SRAM"): sram = True try: baud = int(self.serailBaudrateCombobox.currentText()) except Exception: self.errorSignal.emit(tr("Error"), tr("BaudrateError")) self.burning = False return dev = "" try: dev = self.serialPortCombobox.currentText().split()[0] except Exception: pass if dev == "": self.errorSignal.emit(tr("Error"), tr("PleaseSelectSerialPort")) self.burning = False return slow = self.slowModeCombobox.currentIndex() == 0 # hide setting widgets self.setFrameStrentch(1) self.settingWidget.hide() self.progressbar.setValue(0) self.progressbar.setGeometry(10, 0, self.downloadWidget.width() - 25, 40) self.progressbarRootWidget.show() self.progressHint.show() self.downloadButton.setText(tr("Cancel")) self.downloadButton.setProperty("class", "redbutton") self.downloadButton.style().unpolish(self.downloadButton) self.downloadButton.style().polish(self.downloadButton) self.downloadButton.update() self.statusBarStauts.setText("<font color=%s>%s ...</font>" % ("#1aac2d", tr("Downloading"))) hint = "<font color=%s>%s</font>" % ("#ff0d0d", tr("DownloadStart")) self.progressHint.setText(hint) # download self.burnThread = threading.Thread(target=self.flashBurnProcess, args=(dev, baud, board, sram, fileType, filesInfo, self.progress, color, slow)) self.burnThread.setDaemon(True) self.burnThread.start()