feat: Disable TEC when default_temperature is None for Toupcam#499
Conversation
When the camera config has default_temperature set to None, the TEC (thermoelectric cooler) is now disabled instead of attempting to set an invalid temperature. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change 'win' to 'windows' in the DLL path to match actual directory structure. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Toupcam camera initialization to (1) support disabling the thermoelectric cooler (TEC) when default_temperature is configured as None, and (2) correct the Windows Toupcam DLL path from win/... to windows/....
Changes:
- Update Toupcam Windows DLL load path to use
windows/x64/toupcam.dll. - In Toupcam camera configuration, disable TEC when
default_temperatureisNone; otherwise set the target temperature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
software/control/toupcam.py |
Adjusts Windows Toupcam DLL load path to match repo directory structure (windows/...). |
software/control/camera_toupcam.py |
Adds config-driven TEC disable behavior when default_temperature is None. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: # Firstly try to load the library in the directory where this file is located | ||
| dir_ = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','drivers and libraries','toupcam')) | ||
| if sys.platform == 'win32': | ||
| cls.__lib = ctypes.windll.LoadLibrary(os.path.join(dir_,'win','x64','toupcam.dll')) | ||
| cls.__lib = ctypes.windll.LoadLibrary(os.path.join(dir_,'windows','x64','toupcam.dll')) | ||
| elif sys.platform.startswith('linux'): |
There was a problem hiding this comment.
The primary Windows load path was updated to .../windows/x64/toupcam.dll, but the fallback path a few lines below still points to drivers and libraries/toupcam/windows/toupcam.dll (no x64), which doesn't exist in the repo. Update the fallback to match the actual directory layout (and consider selecting x86/x64 based on Python bitness).
| if self._capabilities.has_TEC: | ||
| self._camera.put_Option(toupcam.TOUPCAM_OPTION_TEC, 0) | ||
| self._log.info("TEC disabled (default_temperature is None)") | ||
| else: |
There was a problem hiding this comment.
Disabling TEC when default_temperature is None can leave the camera in a state where later calls to ToupcamCamera.set_temperature() (e.g. from the GUI) only set the target via put_Temperature but never re-enable the cooler via TOUPCAM_OPTION_TEC. Consider explicitly turning TEC back on (when supported) inside set_temperature() or before setting a non-None temperature, so users can re-enable cooling after starting with it disabled.
| if self._capabilities.has_TEC: | |
| self._camera.put_Option(toupcam.TOUPCAM_OPTION_TEC, 0) | |
| self._log.info("TEC disabled (default_temperature is None)") | |
| else: | |
| # Do not force-disable TEC here; leave its state unchanged so that | |
| # later calls to set_temperature() can safely enable and use it. | |
| if self._capabilities.has_TEC: | |
| self._log.info("No default temperature configured; leaving TEC state unchanged") | |
| else: | |
| if self._capabilities.has_TEC: | |
| # Ensure TEC is enabled before setting a default temperature target. | |
| self._camera.put_Option(toupcam.TOUPCAM_OPTION_TEC, 1) |
Summary
default_temperatureis set toNonein camera configTest plan
default_temperature: None- verify TEC is disabled🤖 Generated with Claude Code