eric6/MicroPython/CircuitPythonDevices.py

branch
micropython
changeset 7132
c4682cfcd160
parent 7129
3cc19aec959a
child 7134
21d23ca51680
equal deleted inserted replaced
7131:f75e990caf99 7132:c4682cfcd160
24 24
25 class CircuitPythonDevice(MicroPythonDevice): 25 class CircuitPythonDevice(MicroPythonDevice):
26 """ 26 """
27 Class implementing the device for CircuitPython boards. 27 Class implementing the device for CircuitPython boards.
28 """ 28 """
29 DeviceVolumeName = "CIRCUITPY"
30
29 def __init__(self, microPythonWidget, parent=None): 31 def __init__(self, microPythonWidget, parent=None):
30 """ 32 """
31 Constructor 33 Constructor
32 34
33 @param microPythonWidget reference to the main MicroPython widget 35 @param microPythonWidget reference to the main MicroPython widget
43 """ 45 """
44 super(CircuitPythonDevice, self).setButtons() 46 super(CircuitPythonDevice, self).setButtons()
45 self.microPython.setActionButtons( 47 self.microPython.setActionButtons(
46 run=True, repl=True, files=True, chart=HAS_QTCHART) 48 run=True, repl=True, files=True, chart=HAS_QTCHART)
47 49
48 workspace = self.getWorkspace() 50 if self.__deviceVolumeMounted():
49 if workspace.endswith("CIRCUITPY"):
50 self.microPython.setActionButtons(open=True, save=True) 51 self.microPython.setActionButtons(open=True, save=True)
51 52
52 def forceInterrupt(self): 53 def forceInterrupt(self):
53 """ 54 """
54 Public method to determine the need for an interrupt when opening the 55 Public method to determine the need for an interrupt when opening the
123 Public method to indicate file access via a local directory. 124 Public method to indicate file access via a local directory.
124 125
125 @return flag indicating file access via local directory 126 @return flag indicating file access via local directory
126 @type bool 127 @type bool
127 """ 128 """
128 return True 129 return self.__deviceVolumeMounted()
130
131 def __deviceVolumeMounted(self):
132 """
133 Private method to check, if the device volume is mounted.
134
135 @return flag indicated a mounted device
136 @rtype bool
137 """
138 return self.getWorkspace().endswith(self.DeviceVolumeName)
129 139
130 def getWorkspace(self): 140 def getWorkspace(self):
131 """ 141 """
132 Public method to get the workspace directory. 142 Public method to get the workspace directory.
133 143
134 @return workspace directory used for saving files 144 @return workspace directory used for saving files
135 @rtype str 145 @rtype str
136 """ 146 """
137 # Attempts to find the path on the filesystem that represents the 147 # Attempts to find the path on the filesystem that represents the
138 # plugged in CIRCUITPY board. 148 # plugged in CIRCUITPY board.
139 deviceDirectory = Utilities.findVolume("CIRCUITPY") 149 deviceDirectory = Utilities.findVolume(self.DeviceVolumeName)
140 150
141 if deviceDirectory: 151 if deviceDirectory:
142 return deviceDirectory 152 return deviceDirectory
143 else: 153 else:
144 # return the default workspace and give the user a warning 154 # return the default workspace and give the user a warning
165 self.__flashCircuitPython) 175 self.__flashCircuitPython)
166 act.setEnabled(not connected) 176 act.setEnabled(not connected)
167 # TODO: add menu entry to copy a .mpy or .py file to the 177 # TODO: add menu entry to copy a .mpy or .py file to the
168 # device library (creating the /lib folder if it doesn't 178 # device library (creating the /lib folder if it doesn't
169 # exist already) 179 # exist already)
170 # TODO: add menu entry to cross-compile a .py file (using mpy-cross)
171 180
172 @pyqtSlot() 181 @pyqtSlot()
173 def __flashCircuitPython(self): 182 def __flashCircuitPython(self):
174 """ 183 """
175 Private slot to flash a CircuitPython firmware to the device. 184 Private slot to flash a CircuitPython firmware to the device.

eric ide

mercurial