Fri, 12 Feb 2021 16:15:18 +0100
MicroPython
- added a generic dialog for flashing UF2 capable devices (with device detection)
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the device interface class for CircuitPython boards. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
10 | import shutil |
7138
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
11 | import os |
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
12 | |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
13 | from PyQt5.QtCore import pyqtSlot |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
14 | from PyQt5.QtWidgets import QDialog |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
15 | |
7138
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
16 | from E5Gui import E5MessageBox, E5FileDialog |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from .MicroPythonDevices import MicroPythonDevice |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7132
diff
changeset
|
19 | from .MicroPythonWidget import HAS_QTCHART |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
7100
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
21 | import Utilities |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
22 | import Preferences |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | class CircuitPythonDevice(MicroPythonDevice): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Class implementing the device for CircuitPython boards. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
7132
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
29 | DeviceVolumeName = "CIRCUITPY" |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
30 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | def __init__(self, microPythonWidget, parent=None): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | Constructor |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @param microPythonWidget reference to the main MicroPython widget |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7132
diff
changeset
|
36 | @type MicroPythonWidget |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @param parent reference to the parent object |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @type QObject |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | super(CircuitPythonDevice, self).__init__(microPythonWidget, parent) |
8062
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
41 | |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
42 | self.__workspace = self.__findWorkspace() |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
43 | |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
44 | self.__nonUF2devices = { |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
45 | "teensy": self.__flashTeensy, |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
46 | } |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | def setButtons(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | Public method to enable the supported action buttons. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | super(CircuitPythonDevice, self).setButtons() |
7100
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
53 | self.microPython.setActionButtons( |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
54 | run=True, repl=True, files=True, chart=HAS_QTCHART) |
7092
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
55 | |
7132
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
56 | if self.__deviceVolumeMounted(): |
7092
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
57 | self.microPython.setActionButtons(open=True, save=True) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | def forceInterrupt(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | Public method to determine the need for an interrupt when opening the |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | serial connection. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | @return flag indicating an interrupt is needed |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | @rtype bool |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | return False |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | |
7125
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
69 | def deviceName(self): |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
70 | """ |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
71 | Public method to get the name of the device. |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
72 | |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
73 | @return name of the device |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
74 | @rtype str |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
75 | """ |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
76 | return self.tr("CircuitPython") |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7122
diff
changeset
|
77 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | def canStartRepl(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | Public method to determine, if a REPL can be started. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @return tuple containing a flag indicating it is safe to start a REPL |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | return True, "" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | def canStartPlotter(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | Public method to determine, if a Plotter can be started. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | @return tuple containing a flag indicating it is safe to start a |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | Plotter and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | return True, "" |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | |
7092
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
98 | def canRunScript(self): |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
99 | """ |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
100 | Public method to determine, if a script can be executed. |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
101 | |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
102 | @return tuple containing a flag indicating it is safe to start a |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
103 | Plotter and a reason why it cannot. |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
104 | @rtype tuple of (bool, str) |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
105 | """ |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
106 | return True, "" |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
107 | |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
108 | def runScript(self, script): |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
109 | """ |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
110 | Public method to run the given Python script. |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
111 | |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
112 | @param script script to be executed |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
113 | @type str |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
114 | """ |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
115 | pythonScript = script.split("\n") |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
116 | self.sendCommands(pythonScript) |
7414b3b012b1
CircuitPythonDevices: started the adaption for 'CircuitPython' based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7084
diff
changeset
|
117 | |
7100
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
118 | def canStartFileManager(self): |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
119 | """ |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
120 | Public method to determine, if a File Manager can be started. |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
121 | |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
122 | @return tuple containing a flag indicating it is safe to start a |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
123 | File Manager and a reason why it cannot. |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
124 | @rtype tuple of (bool, str) |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
125 | """ |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
126 | return True, "" |
c4d9c28ebcd8
Devices.py files: removed some methods no longer needed after the recent improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7092
diff
changeset
|
127 | |
7129
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
128 | def supportsLocalFileAccess(self): |
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
129 | """ |
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
130 | Public method to indicate file access via a local directory. |
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
131 | |
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
132 | @return flag indicating file access via local directory |
7145
ceb3e8b242c1
Regenerated source docu after merge with 'micropython' branch.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7138
diff
changeset
|
133 | @rtype bool |
7129
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
134 | """ |
7132
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
135 | return self.__deviceVolumeMounted() |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
136 | |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
137 | def __deviceVolumeMounted(self): |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
138 | """ |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
139 | Private method to check, if the device volume is mounted. |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
140 | |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
141 | @return flag indicated a mounted device |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
142 | @rtype bool |
c4682cfcd160
CircuitPythonDevice: only report local access if the well known volume is mounted.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7129
diff
changeset
|
143 | """ |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
144 | if self.__workspace and not os.path.exists(self.__workspace): |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
145 | self.__workspace = "" # reset |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
146 | |
8062
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
147 | return self.DeviceVolumeName in self.getWorkspace(silent=True) |
7129
3cc19aec959a
MicroPythonDevicces: added a method to indicate that a device allows access to its file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
148 | |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
149 | def getWorkspace(self, silent=False): |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Public method to get the workspace directory. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
153 | @param silent flag indicating silent operations |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
154 | @type bool |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | @return workspace directory used for saving files |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | @rtype str |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
8062
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
158 | if self.__workspace: |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
159 | # return cached entry |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
160 | return self.__workspace |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
161 | else: |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
162 | self.__workspace = self.__findWorkspace(silent=silent) |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
163 | return self.__workspace |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
164 | |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
165 | def __findWorkspace(self, silent=False): |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
166 | """ |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
167 | Private method to find the workspace directory. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | |
8062
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
169 | @param silent flag indicating silent operations |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
170 | @type bool |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
171 | @return workspace directory used for saving files |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
172 | @rtype str |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
173 | """ |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
174 | # Attempts to find the paths on the filesystem that represents the |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
175 | # plugged in CIRCUITPY boards. |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
176 | deviceDirectories = Utilities.findVolume(self.DeviceVolumeName, |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
177 | findAll=True) |
8062
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
178 | |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
179 | if deviceDirectories: |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
180 | if len(deviceDirectories) == 1: |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
181 | return deviceDirectories[0] |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
182 | else: |
8dc5acb30a8b
MicroPython: implemented code to deal with multiple devices attached to the computer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
183 | return self.selectDeviceDirectory(deviceDirectories) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | else: |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
185 | # return the default workspace and give the user a warning (unless |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
186 | # silent mode is selected) |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
187 | if not silent: |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
188 | E5MessageBox.warning( |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
189 | self.microPython, |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
190 | self.tr("Workspace Directory"), |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
191 | self.tr("Python files for CircuitPython can be edited in" |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
192 | " place, if the device volume is locally" |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
193 | " available. Such a volume was not found. In" |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
194 | " place editing will not be available." |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
195 | ) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8062
diff
changeset
|
196 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | return super(CircuitPythonDevice, self).getWorkspace() |
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
199 | |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
200 | def addDeviceMenuEntries(self, menu): |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
201 | """ |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
202 | Public method to add device specific entries to the given menu. |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
203 | |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
204 | @param menu reference to the context menu |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
205 | @type QMenu |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
206 | """ |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
207 | connected = self.microPython.isConnected() |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
208 | |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
209 | act = menu.addAction(self.tr("Flash CircuitPython Firmware"), |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
210 | self.__flashCircuitPython) |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
211 | act.setEnabled(not connected) |
7138
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
212 | menu.addSeparator() |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
213 | act = menu.addAction(self.tr("Install Library Files"), |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
214 | self.__installLibraryFiles) |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
215 | act.setEnabled(self.__deviceVolumeMounted()) |
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
216 | |
8096 | 217 | def hasFlashMenuEntry(self): |
218 | """ | |
219 | Public method to check, if the device has its own flash menu entry. | |
220 | ||
221 | @return flag indicating a specific flash menu entry | |
222 | @rtype bool | |
223 | """ | |
224 | return True | |
225 | ||
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
226 | @pyqtSlot() |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
227 | def __flashCircuitPython(self): |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
228 | """ |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
229 | Private slot to flash a CircuitPython firmware to the device. |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
230 | """ |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
231 | lBoardName = self.microPython.getCurrentBoard().lower() |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
232 | if lBoardName: |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
233 | for name in self.__nonUF2devices: |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
234 | if name in lBoardName: |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
235 | self.__nonUF2devices[name]() |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
236 | break |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
237 | else: |
8096 | 238 | from .UF2FlashDialog import UF2FlashDialog |
239 | dlg = UF2FlashDialog(boardType="circuitpython") | |
240 | dlg.exec() | |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
241 | |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
242 | def __flashTeensy(self): |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
243 | """ |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
244 | Private method to show a message box because Teens does not support |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
245 | the UF2 bootloader yet. |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
246 | """ |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
247 | E5MessageBox.information( |
7116
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
248 | self.microPython, |
233b6e62ca2b
CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
249 | self.tr("Flash CircuitPython Firmware"), |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
250 | self.tr("""<p>Teensy 4.0 and Teensy 4.1 do not support the UF2""" |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
251 | """ bootloader. Please use the 'Teensy Loader'""" |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
252 | """ application to flash CircuitPython. Make sure you""" |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
253 | """ downloaded the CircuitPython .hex file.</p>""" |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
254 | """<p>See <a href="{0}">the PJRC Teensy web site</a>""" |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
255 | """ for details.</p>""") |
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8067
diff
changeset
|
256 | .format("https://www.pjrc.com/teensy/loader.html")) |
7138
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
257 | |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
258 | @pyqtSlot() |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
259 | def __installLibraryFiles(self): |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
260 | """ |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
261 | Private slot to install Python files into the onboard library. |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
262 | """ |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
263 | if not self.__deviceVolumeMounted(): |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
264 | E5MessageBox.critical( |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
265 | self.microPython, |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
266 | self.tr("Install Library Files"), |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
267 | self.tr("""The device volume "<b>{0}</b>" is not available.""" |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
268 | """ Ensure it is mounted properly and try again.""")) |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
269 | return |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
270 | |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
271 | target = os.path.join(self.getWorkspace(), "lib") |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
272 | # ensure that the library directory exists on the device |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
273 | if not os.path.isdir(target): |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
274 | os.makedirs(target) |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
275 | |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
276 | libraryFiles = E5FileDialog.getOpenFileNames( |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
277 | self.microPython, |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
278 | self.tr("Install Library Files"), |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
279 | os.path.expanduser("~"), |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
280 | self.tr("Compiled Python Files (*.mpy);;" |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
281 | "Python Files (*.py);;" |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
282 | "All Files (*)")) |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
283 | |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
284 | for libraryFile in libraryFiles: |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
285 | if os.path.exists(libraryFile): |
a2a53535d855
CircuitPythonDevices: added capability to install library files onto the device to the device menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
286 | shutil.copy2(libraryFile, target) |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
287 | |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
288 | def getDocumentationUrl(self): |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
289 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
290 | Public method to get the device documentation URL. |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
291 | |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
292 | @return documentation URL of the device |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
293 | @rtype str |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
294 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7145
diff
changeset
|
295 | return Preferences.getMicroPython("CircuitPythonDocuUrl") |
7328 | 296 | |
8053
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
297 | def getDownloadMenuEntries(self): |
7328 | 298 | """ |
8053
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
299 | Public method to retrieve the entries for the downloads menu. |
7328 | 300 | |
8053
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
301 | @return list of tuples with menu text and URL to be opened for each |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
302 | entry |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
303 | @rtype list of tuple of (str, str) |
7328 | 304 | """ |
8053
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
305 | return [ |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
306 | (self.tr("CircuitPython Firmware"), |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
307 | Preferences.getMicroPython("CircuitPythonFirmwareUrl")), |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
308 | (self.tr("CircuitPython Libraries"), |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
309 | Preferences.getMicroPython("CircuitPythonLibrariesUrl")) |
5316e335722f
CircuitPython: added downloads menu for Firmware and Libraries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
310 | ] |