title: Moving from one enum state to the next and cycling through
body: <p>I simply have enumerator with 3 modes ledOn, ledBlink, ledOFF and I have a variable mode that keeps track of modes for particular object. So for example I have one LED starting in mode ledOn i would like to for example after 5 seconds move to the next element which would be ledBlink then to ledOFF and then cycle through to ledON is there an easy way to achieve something like this?</p>
  
  <pre><code>import time
  from threading import Thread
  from enum import Enum
  
  class ledController(Thread):
      ledModes = Enum('ledModes', 'ledON ledBlink ledOFF')
      def __init__(self, GPIOID, state=False, blinkDuration=2, mode=ledModes.ledON):
          self.GPIOID = GPIOID
          self.state = state
          self.blinkDuration = blinkDuration
          self.mode = mode
          self.blinked = False
          Thread.__init__(self)
      def run(self):
          if(self.mode == self.ledModes.ledON):
              self.ledON()
          if(self.mode == self.ledModes.ledBlink):
              self.ledBlink()
          if(self.mode == self.ledModes.ledOFF):
              self.ledOFF()
          time.sleep(self.blinkDuration)
          self.mode.next()
      def ledSwitch(self):
          self.state = not self.state
          print(self.ledDetails())
      def ledON(self):
          self.state = True
          print(self.ledDetails())
      def ledOFF(self):
          self.state = False
          print(self.ledDetails())
      def ledBlink(self, duration):
          self.ledON()
          print(self.ledDetails())
          time.sleep(self.Blinkduration)
          self.ledOFF()
          print(self.ledDetails())
          time.sleep(self.Blinkduration)
      def ledDetails(self):
          return "Thread: "+self.getName()+", LED: "+str(self.GPIOID)+", State: "+str(self.state)+", Mode: "+str(self.mode.name)+", Blink duration: "+str(self.blinkDuration)
  
  redLED = ledController(17, blinkDuration = 3)
  blueLED = ledController(18, mode = ledController.ledModes.ledOFF)
  
  redLED.setName('1')
  blueLED.setName('2')
  
  redLED.start()
  blueLED.start()
  
  redLED.join()
  blueLED.join()
  </code></pre>