123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Thu Jan 30 18:16:23 2019
- @author: moetom
- --------------------------------------------------------------------------
- This file is part of Verrücktes Gemüse.
- Verrücktes Gemüse is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Verrücktes Gemüse is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
- --------------------------------------------------------------------------
- """
- 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
-
|