def __updateDisplay(self, digit):
     """Display Bar graph"""
     for i in range(10):
         if digit > i:
             GPIO.output(self.bar[i], GPIO.HIGH)
         else:
             GPIO.output(self.bar[i], GPIO.LOW) 
 def processValueAssignment(self, roundconfig, value, ctrlid, override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid, override):
         if self.ctrltype == 'toggle':
             if value:
                 GPIO.output(self.pins['LED'], GPIO.HIGH)
             else:
                 GPIO.output(self.pins['LED'], GPIO.LOW)
 def __updateDisplay(self, digit):
     """Display Bar graph"""
     for i in range(10):
         if digit > i:
             GPIO.output(self.bar[i], GPIO.HIGH)
         else:
             GPIO.output(self.bar[i], GPIO.LOW)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     SHControlPot.__init__(self, controlconfig, ctrlid)
     self.bar = []
     for barnum in range(10):
         pin = self.pins['BAR_' + str(barnum + 1)]
         GPIO.setup(pin, GPIO.OUT)
         GPIO.output(pin, GPIO.LOW)
         self.bar.append(pin)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     SHControlPot.__init__(self, controlconfig, ctrlid)
     self.bar = []
     for barnum in range(10):
         pin = self.pins['BAR_' + str(barnum+1)]
         GPIO.setup(pin, GPIO.OUT)
         GPIO.output(pin, GPIO.LOW)
         self.bar.append(pin)
 def processValueAssignment(self, roundconfig, value, ctrlid, override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid, override):
         if self.ctrltype == 'toggle':
             if self.controlsetup['display']['height']>3:
                 if value:
                     myLcdManager.displayValueLine("On", ctrlid)
                     GPIO.output(self.pins['LED'], GPIO.LOW)
                 else:
                     myLcdManager.displayValueLine("Off", ctrlid)
                     GPIO.output(self.pins['LED'], GPIO.HIGH)
 def processValueAssignment(self,
                            roundconfig,
                            value,
                            ctrlid,
                            override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid,
                                         override):
         if self.ctrltype == 'toggle':
             if value:
                 GPIO.output(self.pins['LED'], GPIO.HIGH)
             else:
                 GPIO.output(self.pins['LED'], GPIO.LOW)
 def poll(self, controlsetup, ctrldef, ctrltype, ctrlstate, ctrlvalue):
     value = ctrlvalue
     btn = GPIO.input(self.pins['BTN'])
     state = btn
     if ctrlstate != state:
         if ctrltype == 'button':
             value = state
             GPIO.output(self.pins['LED'], value)
         elif ctrltype == 'toggle':
             if state:
                 value = int(not ctrlvalue)
                 GPIO.output(self.pins['LED'], value)
     return value, state
 def poll(self, controlsetup, ctrldef, ctrltype, ctrlstate, ctrlvalue):
     value = ctrlvalue
     btn = GPIO.input(self.pins['BTN'])
     state = btn
     if ctrlstate != state:
         if ctrltype == 'button':
             value = state
             GPIO.output(self.pins['LED'], value)
         elif ctrltype == 'toggle':
             if state:
                 value = int(not ctrlvalue)
                 GPIO.output(self.pins['LED'], value)
     return value, state
 def processValueAssignment(self,
                            roundconfig,
                            value,
                            ctrlid,
                            override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid,
                                         override):
         if self.ctrltype == 'toggle':
             if self.controlsetup['display']['height'] > 3:
                 if value:
                     myLcdManager.displayValueLine("On", ctrlid)
                     GPIO.output(self.pins['LED'], GPIO.LOW)
                 else:
                     myLcdManager.displayValueLine("Off", ctrlid)
                     GPIO.output(self.pins['LED'], GPIO.HIGH)
 def processValueAssignment(self,
                            roundconfig,
                            value,
                            ctrlid,
                            override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid,
                                         override):
         RGB = [0, 0, 0]
         if self.ctrltype == 'toggle':
             if self.controlsetup['display']['height'] > 3:
                 if value:
                     myLcdManager.displayValueLine("On", ctrlid)
                     RGB = [1, 0, 0]
                 else:
                     myLcdManager.displayValueLine("Off", ctrlid)
         elif self.ctrltype == 'selector':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(str(value), ctrlid)
         elif self.ctrltype == 'colour':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(str(value), ctrlid)
             #Light the LED the right colours
             RGB = self.controlsetup['colours'][str(value)]
         elif self.ctrltype == 'words':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(value, ctrlid)
         GPIO.output(self.pins['RGB_R'], RGB[0])
         GPIO.output(self.pins['RGB_G'], RGB[1])
         GPIO.output(self.pins['RGB_B'], RGB[2])
    def processValueAssignment(self,
                               roundconfig,
                               value,
                               ctrlid,
                               override=False):
        print("combo process value - value = '" + str(value) + "'")
        if SHControl.processValueAssignment(self, roundconfig, value, ctrlid,
                                            override):
            print("ebabled = '" + str(self.roundsetup['enabled']) +
                  "' type = '" + str(self.ctrltype) + "'")
            RGB = [0, 0, 0]
            if self.roundsetup['enabled']:
                if self.ctrltype == 'toggle':
                    if value:
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, 'On')
                        RGB = [1, 0, 0]
                    else:
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, 'Off')
                        #Switch off LED
                elif self.ctrltype == 'button':
                    if value:
                        RGB = [1, 0, 0]
                elif self.ctrltype == 'selector':
                    SHControlCombo7SegColourRotary.__displayDigits(
                        self, str(value))
                    #Switch off LED
                elif self.ctrltype == 'colour':
                    #Light LED appropriate colour
                    if value == 'red':
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, "RED")
                    elif value == 'green':
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, "GREN")
                    elif value == 'blue':
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, "BLUE")
                    elif value == 'yellow':
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, "YELO")
                    elif value == 'cyan':
                        SHControlCombo7SegColourRotary.__displayDigits(
                            self, "CYAN")
                    RGB = self.controlsetup['colours'][str(value)]
                elif self.ctrltype == 'words':
                    #Switch off LED
                    SHControlCombo7SegColourRotary.__displayDigits(
                        self, value.upper())
            else:
                SHControlCombo7SegColourRotary.__displayDigits(self, "    ")

            GPIO.output(self.pins['RGB_R'], RGB[0])
            GPIO.output(self.pins['RGB_G'], RGB[1])
            GPIO.output(self.pins['RGB_B'], RGB[2])
        else:
            print("Combo reports not valid for processing control value")
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     #segment defined at module scope
     GPIO.setup(self.pins['BTN'], GPIO.IN, GPIO.PUD_DOWN)
     GPIO.setup(self.pins['RGB_R'], GPIO.OUT)
     GPIO.setup(self.pins['RGB_G'], GPIO.OUT)
     GPIO.setup(self.pins['RGB_B'], GPIO.OUT)
     GPIO.output(self.pins['RGB_R'], GPIO.LOW)
     GPIO.output(self.pins['RGB_G'], GPIO.LOW)
     GPIO.output(self.pins['RGB_B'], GPIO.LOW)
     SHControlCombo7SegColourRotary.__displayDigits(self, "    ")
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     #segment defined at module scope
     GPIO.setup(self.pins['BTN'], GPIO.IN, GPIO.PUD_DOWN)
     GPIO.setup(self.pins['RGB_R'], GPIO.OUT)
     GPIO.setup(self.pins['RGB_G'], GPIO.OUT)
     GPIO.setup(self.pins['RGB_B'], GPIO.OUT)
     GPIO.output(self.pins['RGB_R'], GPIO.LOW)
     GPIO.output(self.pins['RGB_G'], GPIO.LOW)
     GPIO.output(self.pins['RGB_B'], GPIO.LOW)
     SHControlCombo7SegColourRotary.__displayDigits(self, "    ")
 def poll(self, controlsetup, ctrldef, ctrltype, ctrlstate, ctrlvalue):
     value = ctrlvalue
     sw1 = GPIO.input(self.pins['SW_1'])
     sw2 = GPIO.input(self.pins['SW_2'])
     sw3 = GPIO.input(self.pins['SW_3'])
     sw4 = GPIO.input(self.pins['SW_4'])
     GPIO.output(self.pins['LED_1'], sw1)
     GPIO.output(self.pins['LED_2'], sw2)
     GPIO.output(self.pins['LED_3'], sw3)
     GPIO.output(self.pins['LED_4'], sw4)
     state = [sw1, sw2, sw3, sw4]
     if not ctrlstate == state:
         if ctrltype == 'toggle':
             if state == [1, 1, 1, 1]:
                 value = 1
             elif state == [0, 0, 0, 0]:
                 value = 0
             else:
                 value = 2
     return value, state
 def poll(self, controlsetup, ctrldef, ctrltype, ctrlstate, ctrlvalue):
     value = ctrlvalue
     sw1 = GPIO.input(self.pins['SW_1'])
     sw2 = GPIO.input(self.pins['SW_2'])
     sw3 = GPIO.input(self.pins['SW_3'])
     sw4 = GPIO.input(self.pins['SW_4'])
     GPIO.output(self.pins['LED_1'], sw1)
     GPIO.output(self.pins['LED_2'], sw2)
     GPIO.output(self.pins['LED_3'], sw3)
     GPIO.output(self.pins['LED_4'], sw4)
     state = [sw1, sw2, sw3, sw4]
     if not ctrlstate == state:
         if ctrltype == 'toggle':
             if state == [1, 1, 1, 1]:
                 value = 1
             elif state == [0, 0, 0, 0]:
                 value = 0
             else:
                 value = 2
     return value, state
 def processValueAssignment(self, roundconfig, value, ctrlid, override=False):
     print("combo process value - value = '" + str(value) + "'")
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid, override):
         print("ebabled = '" + str(self.roundsetup['enabled']) + "' type = '" + str(self.ctrltype) + "'")
         RGB = [0, 0, 0]
         if self.roundsetup['enabled']:
             if self.ctrltype == 'toggle':
                 if value:
                     SHControlCombo7SegColourRotary.__displayDigits(self, 'On')
                     RGB = [1, 0, 0]
                 else:
                     SHControlCombo7SegColourRotary.__displayDigits(self, 'Off')
                     #Switch off LED
             elif self.ctrltype == 'button':
                 if value:
                     RGB = [1, 0, 0]
             elif self.ctrltype == 'selector':
                 SHControlCombo7SegColourRotary.__displayDigits(self, str(value))
                 #Switch off LED
             elif self.ctrltype == 'colour':
                 #Light LED appropriate colour
                 if value == 'red':
                     SHControlCombo7SegColourRotary.__displayDigits(self, "RED")
                 elif value == 'green':
                     SHControlCombo7SegColourRotary.__displayDigits(self, "GREN")
                 elif value == 'blue':
                     SHControlCombo7SegColourRotary.__displayDigits(self, "BLUE")
                 elif value == 'yellow':
                     SHControlCombo7SegColourRotary.__displayDigits(self, "YELO")
                 elif value == 'cyan':
                     SHControlCombo7SegColourRotary.__displayDigits(self, "CYAN")
                 RGB = self.controlsetup['colours'][str(value)]
             elif self.ctrltype == 'words':
                 #Switch off LED
                 SHControlCombo7SegColourRotary.__displayDigits(self, value.upper())
         else:
             SHControlCombo7SegColourRotary.__displayDigits(self, "    ")
         
         GPIO.output(self.pins['RGB_R'], RGB[0])
         GPIO.output(self.pins['RGB_G'], RGB[1])
         GPIO.output(self.pins['RGB_B'], RGB[2])
     else:
         print("Combo reports not valid for processing control value")            
 def processValueAssignment(self, roundconfig, value, ctrlid, override=False):
     if SHControl.processValueAssignment(self, roundconfig, value, ctrlid, override):
         RGB = [0, 0, 0]
         if self.ctrltype == 'toggle':
    	        if self.controlsetup['display']['height'] > 3:
                 if value:
                     myLcdManager.displayValueLine("On", ctrlid)
                     RGB = [1, 0, 0]
                 else:
                     myLcdManager.displayValueLine("Off", ctrlid)
         elif self.ctrltype == 'selector':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(str(value), ctrlid)
         elif self.ctrltype == 'colour':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(str(value), ctrlid)
             #Light the LED the right colours
             RGB = self.controlsetup['colours'][str(value)]
         elif self.ctrltype == 'words':
             if self.controlsetup['display']['height'] > 3:
                 myLcdManager.displayValueLine(value, ctrlid)
         GPIO.output(self.pins['RGB_R'], RGB[0])
         GPIO.output(self.pins['RGB_G'], RGB[1])
         GPIO.output(self.pins['RGB_B'], RGB[2])
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     GPIO.setup(self.pins['SW'], GPIO.IN, GPIO.PUD_DOWN)    
     GPIO.setup(self.pins['LED'], GPIO.OUT)
     GPIO.output(self.pins['LED'], GPIO.HIGH) #common anode, so HIGH for off, LOW for on
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     GPIO.setup(self.pins['BTN'], GPIO.IN, GPIO.PUD_DOWN)
     GPIO.setup(self.pins['LED'], GPIO.OUT)
     GPIO.output(self.pins['LED'], GPIO.LOW)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     for i in range(1,5):
         GPIO.setup(self.pins['SW_' + str(i)], GPIO.IN, GPIO.PUD_DOWN)
         GPIO.setup(self.pins['LED_' + str(i)], GPIO.OUT)
         GPIO.output(self.pins['LED_' + str(i)], GPIO.LOW)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     for i in range(1, 5):
         GPIO.setup(self.pins['SW_' + str(i)], GPIO.IN, GPIO.PUD_DOWN)
         GPIO.setup(self.pins['LED_' + str(i)], GPIO.OUT)
         GPIO.output(self.pins['LED_' + str(i)], GPIO.LOW)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     GPIO.setup(self.pins['BTN'], GPIO.IN, GPIO.PUD_DOWN)
     GPIO.setup(self.pins['LED'], GPIO.OUT)
     GPIO.output(self.pins['LED'], GPIO.LOW)
 def __init__(self, controlconfig, ctrlid):
     SHControl.__init__(self, controlconfig, ctrlid)
     GPIO.setup(self.pins['SW'], GPIO.IN, GPIO.PUD_DOWN)
     GPIO.setup(self.pins['LED'], GPIO.OUT)
     GPIO.output(self.pins['LED'],
                 GPIO.HIGH)  #common anode, so HIGH for off, LOW for on