Skip to content

Next#15

Merged
georgevigelette merged 2 commits intomainfrom
next
Mar 26, 2026
Merged

Next#15
georgevigelette merged 2 commits intomainfrom
next

Conversation

@georgevigelette
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

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 console initialization and safety polling behavior in motion_connector.py, focusing on safer mutex handling, improved status propagation, and gating safety-clear logic on TEC status.

Changes:

  • Wraps laser-power I2C initialization in a try/finally to guarantee console mutex unlock.
  • Propagates TEC status “ok” from tec_status() and uses it in the console status thread’s safety gating logic.
  • Adjusts DRIVE CL user-config override calculation logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread motion_connector.py
Comment on lines +1553 to +1561
def _write_drive_cl(ch: int, thresh, gain: float, label: str) -> bool:
if thresh is None:
return True
set_value = thresh
gain_f = float(gain) if gain is not None else 0.0
if gain_f != 0.0:
set_value = thresh/gain_f
raw = max(0, min(0xFFFF, int(round(set_value)))) # uint16 raw value
data = bytearray([raw & 0xFF, (raw >> 8) & 0xFF]) # LSB first
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

In _write_drive_cl, the raw uint16 written to DRIVE CL is currently computed as round(thresh / gain) only when gain != 0, and otherwise uses thresh directly. Given DRIVE CL’s default scale is 1.86 mA/LSB (see FpgaModel), a missing/0 gain should still apply the default scale; otherwise a user-config threshold in mA will be written ~1.86× too high. Consider computing an effective_scale = gain_f if gain_f > 0 else 1.86 and always converting raw = round(thresh / effective_scale) (and update the comment that currently says thresh is already a raw register value). Also, since cfg_obj.json_data may hold strings, cast thresh (and optionally gain) to float with validation before arithmetic to avoid TypeError/ValueError at startup.

Copilot uses AI. Check for mistakes.
Comment thread motion_connector.py
Comment thread motion_connector.py Outdated
@georgevigelette georgevigelette merged commit e3beb01 into main Mar 26, 2026
1 check passed
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