Skip to content

Commit

Permalink
Merge branch 'victorhook-issue_406'
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Jul 20, 2020
2 parents d8df16b + 18497fc commit a483f7d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 12 deletions.
28 changes: 20 additions & 8 deletions src/cfclient/ui/dialogs/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def __init__(self, helper, *args):
self.clt.disconnectedSignal.connect(
lambda: self.setUiState(UIState.DISCONNECTED))

# set radiobutton for flashing both mcu's (default)
self.radioBoth.setChecked(True)

self.clt.start()

def _ui_connection_fail(self, message):
Expand All @@ -110,7 +113,6 @@ def setUiState(self, state):
self.progressBar.setTextVisible(False)
self.progressBar.setValue(0)
self.statusLabel.setText('Status: <b>IDLE</b>')
self.imagePathLine.setText("")
elif (state == UIState.CONNECTING):
self.resetButton.setEnabled(False)
self.programButton.setEnabled(False)
Expand All @@ -130,7 +132,6 @@ def setUiState(self, state):
self.resetButton.setEnabled(False)
self.programButton.setEnabled(False)
self.coldBootButton.setEnabled(False)
self.imagePathLine.setText("")

def setStatusLabel(self, text):
self.connectionStatus.setText("Status: <b>%s</b>" % text)
Expand Down Expand Up @@ -170,13 +171,23 @@ def programAction(self):
self.resetButton.setEnabled(False)
self.programButton.setEnabled(False)
self.imagePathBrowseButton.setEnabled(False)

# by default, both of the mcu:s are flashed
mcu_to_flash = None

if self.radioStm32.isChecked():
mcu_to_flash = 'stm32'
elif self.radioNrf51.isChecked():
mcu_to_flash = 'nrf51'

# call the flasher
if self.imagePathLine.text() != "":
self.clt.program.emit(self.imagePathLine.text(),
self.verifyCheckBox.isChecked())
self.verifyCheckBox.isChecked(),
mcu_to_flash)
else:
msgBox = QtWidgets.QMessageBox()
msgBox.setText("Please choose an image file to program.")

msgBox.exec_()

@pyqtSlot()
Expand Down Expand Up @@ -215,7 +226,7 @@ def initiateColdboot(self):
# event loop which is what we want
class CrazyloadThread(QThread):
# Input signals declaration (not sure it should be used like that...)
program = pyqtSignal(str, bool)
program = pyqtSignal(str, bool, str)
verify = pyqtSignal()
initiateColdBootSignal = pyqtSignal(str)
resetCopterSignal = pyqtSignal()
Expand Down Expand Up @@ -262,10 +273,11 @@ def initiateColdBoot(self, linkURI):
except Exception as e:
self.failed_signal.emit("{}".format(e))

def programAction(self, filename, verify):
def programAction(self, filename, verify, mcu_to_flash):

targets = {}
if str(filename).endswith("bin"):
targets["stm32"] = ("fw",)
if mcu_to_flash:
targets[mcu_to_flash] = ("fw",)
try:
self._bl.flash(str(filename), targets)
self.programmed.emit(True)
Expand Down
40 changes: 36 additions & 4 deletions src/cfclient/ui/dialogs/bootloader.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<x>0</x>
<y>0</y>
<width>825</width>
<height>338</height>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -112,7 +112,17 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLineEdit" name="imagePathLine"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Select which chip to flash (.zip = both, .bin = stm32 or nrf51):</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="verifyCheckBox">
<property name="enabled">
<bool>false</bool>
Expand All @@ -122,16 +132,38 @@
</property>
</widget>
</item>
<item row="2" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QRadioButton" name="radioBoth">
<property name="text">
<string>Both</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioStm32">
<property name="text">
<string>stm32</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioNrf51">
<property name="text">
<string>nrf51</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Select package to flash:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="imagePathLine"/>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit a483f7d

Please sign in to comment.