Fri, 21 Mar 2025 15:15:44 +0100
MicroPython
- Added the capability to show the RPi Pico board temperature.
--- a/src/eric7/APIs/Python3/eric7.api Thu Mar 20 19:31:39 2025 +0100 +++ b/src/eric7/APIs/Python3/eric7.api Fri Mar 21 15:15:44 2025 +0100 @@ -3094,6 +3094,7 @@ eric7.MicroPython.Devices.RP2Devices.RP2Device.enableWebrepl?4(password) eric7.MicroPython.Devices.RP2Devices.RP2Device.forceInterrupt?4() eric7.MicroPython.Devices.RP2Devices.RP2Device.getBluetoothStatus?4() +eric7.MicroPython.Devices.RP2Devices.RP2Device.getBoardInformation?4() eric7.MicroPython.Devices.RP2Devices.RP2Device.getConnectedClients?4() eric7.MicroPython.Devices.RP2Devices.RP2Device.getDeviceScan?4(timeout=10) eric7.MicroPython.Devices.RP2Devices.RP2Device.getDocumentationUrl?4()
--- a/src/eric7/Documentation/Help/source.qhp Thu Mar 20 19:31:39 2025 +0100 +++ b/src/eric7/Documentation/Help/source.qhp Fri Mar 21 15:15:44 2025 +0100 @@ -14923,6 +14923,7 @@ <keyword name="RP2Device.enableWebrepl" id="RP2Device.enableWebrepl" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.enableWebrepl" /> <keyword name="RP2Device.forceInterrupt" id="RP2Device.forceInterrupt" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.forceInterrupt" /> <keyword name="RP2Device.getBluetoothStatus" id="RP2Device.getBluetoothStatus" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.getBluetoothStatus" /> + <keyword name="RP2Device.getBoardInformation" id="RP2Device.getBoardInformation" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.getBoardInformation" /> <keyword name="RP2Device.getConnectedClients" id="RP2Device.getConnectedClients" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.getConnectedClients" /> <keyword name="RP2Device.getDeviceScan" id="RP2Device.getDeviceScan" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.getDeviceScan" /> <keyword name="RP2Device.getDocumentationUrl" id="RP2Device.getDocumentationUrl" ref="eric7.MicroPython.Devices.RP2Devices.html#RP2Device.getDocumentationUrl" />
--- a/src/eric7/Documentation/Source/eric7.MicroPython.Devices.RP2Devices.html Thu Mar 20 19:31:39 2025 +0100 +++ b/src/eric7/Documentation/Source/eric7.MicroPython.Devices.RP2Devices.html Fri Mar 21 15:15:44 2025 +0100 @@ -180,6 +180,10 @@ <td>Public method to get Bluetooth status data of the connected board.</td> </tr> <tr> +<td><a href="#RP2Device.getBoardInformation">getBoardInformation</a></td> +<td>Public method to get some information data of the connected board.</td> +</tr> +<tr> <td><a href="#RP2Device.getConnectedClients">getConnectedClients</a></td> <td>Public method to get a list of connected clients.</td> </tr> @@ -874,6 +878,36 @@ raised to indicate an issue with the device </dd> </dl> +<a NAME="RP2Device.getBoardInformation" ID="RP2Device.getBoardInformation"></a> +<h4>RP2Device.getBoardInformation</h4> +<b>getBoardInformation</b>(<i></i>) +<p> + Public method to get some information data of the connected board. +</p> +<p> + This method amends the base class result with the board temperature + determined via the built in temperature sensor of the RPi Pico. +</p> + +<dl> +<dt>Return:</dt> +<dd> +dictionary containing the determined data +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +dict +</dd> +</dl> +<dl> + +<dt>Raises <b>OSError</b>:</dt> +<dd> +raised to indicate an issue with the device +</dd> +</dl> <a NAME="RP2Device.getConnectedClients" ID="RP2Device.getConnectedClients"></a> <h4>RP2Device.getConnectedClients</h4> <b>getConnectedClients</b>(<i></i>)
--- a/src/eric7/MicroPython/Devices/RP2Devices.py Thu Mar 20 19:31:39 2025 +0100 +++ b/src/eric7/MicroPython/Devices/RP2Devices.py Fri Mar 21 15:15:44 2025 +0100 @@ -417,6 +417,53 @@ """ ################################################################## + ## Method to determine the processor temperatur + ################################################################## + + def getBoardInformation(self): + """ + Public method to get some information data of the connected board. + + This method amends the base class result with the board temperature + determined via the built in temperature sensor of the RPi Pico. + + @return dictionary containing the determined data + @rtype dict + @exception OSError raised to indicate an issue with the device + """ + temp_command = """def get_board_temperature(): + from machine import ADC + + try: + # RP2040, RP2350A: Temp. sensor is connected to ADC channel 4 + # RP2350B: Temp. sensor is connected to ADC channel 8 + temp_sensor = ADC(ADC.CORE_TEMP) + except AttributeError: + # older MPy implementation, use 4 for RP2040 and RP2350A + temp_sensor = ADC(4) + + adc_value = temp_sensor.read_u16() # Read the raw ADC value + + # Convert ADC value to voltage + voltage = adc_value * 3.3 / 65535.0 + + # Temperature calculation based on sensor characteristics + return 27 - (voltage - 0.706) / 0.001721 + +print(get_board_temperature()) +del get_board_temperature +""" + res = super().getBoardInformation() + + # add the RPi Pico board temperature + out, err = self.executeCommands(temp_command, mode=self._submitMode) + if err: + raise OSError(self._shortError(err)) + res["mc_temp_c"] = ast.literal_eval(out.decode("utf-8")) + + return res + + ################################################################## ## Methods below implement WiFi related methods ##################################################################