Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling inverted for DigitalOutput set_DO #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions labscript_utils/qtwidgets/digitaloutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def __init__(self,*args,**kwargs):
self._DO = None

# Setting and getting methods for the Digitl Out object in charge of this button
def set_DO(self,DO,notify_old_DO=True,notify_new_DO=True):
def set_DO(self,DO,notify_old_DO=True,notify_new_DO=True,inverted=False):
# If we are setting a new DO, remove this widget from the old one (if it isn't None) and add it to the new one (if it isn't None)
if DO != self._DO:
if self._DO is not None and notify_old_DO:
self._DO.remove_widget(self)
if DO is not None and notify_new_DO:
DO.add_widget(self)
DO.add_widget(self, inverted)
# Store a reference to the digital out object
self._DO = DO

Expand Down Expand Up @@ -93,6 +93,9 @@ def state(self,state):


class InvertedDigitalOutput(DigitalOutput):
def set_DO(self,DO,notify_old_DO=True,notify_new_DO=True,inverted=True):
DigitalOutput.set_DO(self, DO, notify_old_DO, notify_new_DO, inverted)

@property
def state(self):
return not DigitalOutput.state.fget(self)
Expand Down