Skip to content

feat: Disable TEC when default_temperature is None for Toupcam#499

Merged
Alpaca233 merged 2 commits into
Cephla-Lab:masterfrom
Alpaca233:feat/toupcam-tec-disable-on-none
Feb 27, 2026
Merged

feat: Disable TEC when default_temperature is None for Toupcam#499
Alpaca233 merged 2 commits into
Cephla-Lab:masterfrom
Alpaca233:feat/toupcam-tec-disable-on-none

Conversation

@Alpaca233
Copy link
Copy Markdown
Collaborator

@Alpaca233 Alpaca233 commented Feb 27, 2026

Summary

  • Disable TEC (thermoelectric cooler) when default_temperature is set to None in camera config
  • Fix Windows toupcam library path ('win' -> 'windows')

Test plan

  • Test Toupcam camera with default_temperature: None - verify TEC is disabled
  • Test Toupcam camera with a temperature value - verify TEC is enabled and target is set
  • Verify Windows library path works on Windows systems

🤖 Generated with Claude Code

Alpaca233 and others added 2 commits February 27, 2026 11:42
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>
@Alpaca233 Alpaca233 requested a review from Copilot February 27, 2026 19:46
@Alpaca233 Alpaca233 merged commit bcad608 into Cephla-Lab:master Feb 27, 2026
4 of 5 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_temperature is None; 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.

Comment on lines 2322 to 2326
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'):
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +390 to +393
if self._capabilities.has_TEC:
self._camera.put_Option(toupcam.TOUPCAM_OPTION_TEC, 0)
self._log.info("TEC disabled (default_temperature is None)")
else:
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants