1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Thu Jan 30 18:16:23 2019
- @author: moetom
- """
- from gpiozero import LED
- activMode = 0
- modeList = []
- class Mode:
-
- def __init__ (self, name, gpio):
- self.name = str(name)
- self.led = LED(gpio)
- self.activ = 0
- modeList.append(self)
-
- def ModeOn(self):
- """ Activates the Mode """
- self.led.on()
- self.activ = 1
- global activMode
- activMode = modeList.index(self)
- print ("\n[MODE] - " + self.name + "\n")
-
- def ModeOff(self):
- """ Deactivates the Mode """
- self.led.off()
- self.activ = 0
- drums = Mode ("DRUMS", 17)
- jokes = Mode ("WITZE", 27)
- crazy = Mode ("CRAZY", 22)
- modeList[0].ModeOn() # Startmode
- def NextMode ():
- """ Cecks which Mode is activ, then change to next """
- for mode in range(len(modeList)):
- if modeList[mode].activ == 1:
- modeList[mode].ModeOff()
- if mode == len(modeList)-1:
- modeList[0].ModeOn() # Return to the first Mode on list
- else:
- modeList[mode+1].ModeOn() # Activate the next Mode on list
- break
-
|