Skip to content

Commit

Permalink
Merge pull request #8 from Ledger-Donjon/fix-agc
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouchous-ledger authored Aug 5, 2024
2 parents a7c05b6 + 8a407af commit 2250c20
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions laserstudio/widgets/toolbars/cameranittoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ def __init__(self, laser_studio: "LaserStudio"):
hbox.addWidget(w)
# Button to trigger the NIT camera gain
# Checkbox to activate/deactivate the timer
w = QPushButton("AGC")
self.button_agc = w = QPushButton("AGC")
w.setToolTip("Auto gain control (every 1 second)")
w.setCheckable(True)
w.setChecked(True)
w.clicked.connect(
lambda state: self.timer.setInterval(1000) if state else self.timer.stop()
)
w.clicked.connect(self.agc_changed)
hbox.addWidget(w)
# Timer to trigger gain autoset every 1 seconds
self.timer = QTimer()
self.timer.timeout.connect(self.gain_autoset)
self.timer.start(1000) # 1 seconds interval
self.timer.setInterval(1000) # 1 second interval
self.agc_changed(self.button_agc.isChecked())

# Averaging management
hbox = QHBoxLayout()
Expand Down Expand Up @@ -179,3 +178,19 @@ def shade_load(self):
self.camera.shade_correction = pickle.load(f)
except FileNotFoundError:
QMessageBox().critical(None, "Error", "Shading correction file not found.")

def agc_changed(self, state: bool):
"""
Called when AGC button is toggled.
Enables or disables Automatic Gain Correction.
:param state: True when button is checked, which enables AGC. False otherwise.
"""
if state:
# Apply gain correcttion immediately, don't wait 1 second for the timer to
# expire.
self.gain_autoset()
# Re-enabled timer
self.timer.start()
else:
self.timer.stop()

0 comments on commit 2250c20

Please sign in to comment.