Exemplo n.º 1
0
 def buzz(self,pitch, duration):   #create the function buzz and feed it the pitch and duration)
     period = 1.0 / pitch     #in physics, the period (sec/cyc) is the inverse of the frequency (cyc/sec)
     delay = period / 2     #calcuate the time for half of the wave
     cycles = int(duration * pitch)   #the number of waves to produce is the duration times the frequency
     for i in range(cycles):
         self.__gpio.output(self.pin, True)   #set pin 18 to high
         time.sleep(delay)
         self.__gpio.output(self.pin, False)
         time.sleep(delay)
     evt = Event(Event.EVT_COMPLETE)
     evt.target = self
     self.dispatchEvent(evt)
     return;
Exemplo n.º 2
0
 def flash(self,times,delay):
     for i in range(times):
         self.__gpio.output(self.pin,self.__gpio.HIGH)
         time.sleep(delay)
         self.__gpio.output(self.pin,self.__gpio.LOW)
         time.sleep(delay)
         evt = Event(SingleColorLed.EVT_FLASH)
         evt.target = self
         self.dispatchEvent(evt)
     evt = Event(Event.EVT_COMPLETE)
     evt.target = self
     self.dispatchEvent(evt)
     return;
Exemplo n.º 3
0
 def off(self):
     self.__gpio.output(self.pin,self.__gpio.LOW)
     evt = Event(Event.EVT_OFF)
     evt.target= self
     self.dispatchEvent(evt)
     return;
Exemplo n.º 4
0
 def on(self):
     self.__gpio.output(self.pin,self.__gpio.HIGH)
     evt = Event(Event.EVT_ON)
     evt.target= self
     self.dispatchEvent(evt)
     return;