Ejemplo n.º 1
0
 def pumping(self, pumps):
     if not self.isReady():
         self.glassense.rgb(glassensor.RED)
         s.info(" - setze auf Rot")
         return States.NOK
     s.info("Starte Pumpen: " + s.toString(pumps))
     s.info(" - setze auf Grün")
     self.glassense.rgb(glassensor.GREEN)
     count = 1
     while count > 0:
         s.debug(" - Iteration: " + s.toString(pumps))
         count = 0
         idx = 0
         for pump in pumps:
             if pump > 0:
                 shiftpi.digitalWrite(idx, shiftpi.HIGH)
                 pump -= 1
                 pumps[idx] = pump
                 count+= pump
             else:
                 shiftpi.digitalWrite(idx, shiftpi.LOW)
             idx += 1
         shiftpi.delay(self.PUMP_INTERVAL);
     shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
     s.info(" - setze auf Blue")
     self.glassense.rgb(glassensor.BLUE)
     return States.OK
Ejemplo n.º 2
0
def led_flash(led, delay):
    global flashing
    while flashing:
        shiftpi.digitalWrite(led, shiftpi.HIGH)
        shiftpi.delay(delay)

        shiftpi.digitalWrite(led, shiftpi.LOW)
        shiftpi.delay(delay)
Ejemplo n.º 3
0
def standby_led_routine():
    # Cycle through LEDs to entice the player
    while standby:
        delay = 300
        for each in range(0, 10):
            shiftpi.digitalWrite(each, shiftpi.HIGH)
            shiftpi.delay(delay)

            shiftpi.digitalWrite(each, shiftpi.LOW)
            shiftpi.delay(delay)

            if not standby:
                for each in range(0, 10):
                    shiftpi.digitalWrite(each, shiftpi.LOW)
                break
Ejemplo n.º 4
0
def winner_led_routine():
    global standby
    # Fun flashing light routine
    delay = 300
    while delay > 10:
        for each in range(0, 10):
            shiftpi.digitalWrite(each, shiftpi.HIGH)
            shiftpi.delay(delay)

            shiftpi.digitalWrite(each, shiftpi.LOW)
            shiftpi.delay(delay)
        delay = delay * 0.75

    # Turn off all LEDs and then enter standby mode
    for each in range(0, 10):
        shiftpi.digitalWrite(each, shiftpi.LOW)
    standby = True
    standby_mode()
Ejemplo n.º 5
0
def spin(motor, sec):
    ticks = sec * 1000
    if motor == 1:
        shiftpi.digitalWrite(1, shiftpi.HIGH)
        shiftpi.digitalWrite(2, shiftpi.HIGH)
        shiftpi.digitalWrite(3, shiftpi.HIGH)
        shiftpi.digitalWrite(4, shiftpi.HIGH)
        shiftpi.delay(ticks)
        shiftpi.digitalWrite(1, shiftpi.LOW)
        shiftpi.digitalWrite(2, shiftpi.LOW)
        shiftpi.digitalWrite(3, shiftpi.LOW)
        shiftpi.digitalWrite(4, shiftpi.LOW)
    else:
        if motor == 2:
            shiftpi.digitalWrite(5, shiftpi.HIGH)
            shiftpi.digitalWrite(6, shiftpi.HIGH)
            shiftpi.digitalWrite(7, shiftpi.HIGH)
            shiftpi.digitalWrite(8, shiftpi.HIGH)
            shiftpi.delay(ticks)
            shiftpi.digitalWrite(5, shiftpi.LOW)
            shiftpi.digitalWrite(6, shiftpi.LOW)
            shiftpi.digitalWrite(7, shiftpi.LOW)
            shiftpi.digitalWrite(8, shiftpi.LOW)
        else:
            if motor == 3:
                shiftpi.digitalWrite(1, shiftpi.HIGH)
                shiftpi.digitalWrite(2, shiftpi.HIGH)
                shiftpi.digitalWrite(3, shiftpi.HIGH)
                shiftpi.digitalWrite(4, shiftpi.HIGH)
                shiftpi.digitalWrite(5, shiftpi.HIGH)
                shiftpi.digitalWrite(6, shiftpi.HIGH)
                shiftpi.digitalWrite(7, shiftpi.HIGH)
                shiftpi.digitalWrite(8, shiftpi.HIGH)
                shiftpi.delay(ticks)
                shiftpi.digitalWrite(1, shiftpi.LOW)
                shiftpi.digitalWrite(2, shiftpi.LOW)
                shiftpi.digitalWrite(3, shiftpi.LOW)
                shiftpi.digitalWrite(4, shiftpi.LOW)
                shiftpi.digitalWrite(5, shiftpi.LOW)
                shiftpi.digitalWrite(6, shiftpi.LOW)
                shiftpi.digitalWrite(7, shiftpi.LOW)
                shiftpi.digitalWrite(8, shiftpi.LOW)
            else:
                shiftpi.digitalWrite(1, shiftpi.LOW)
                shiftpi.digitalWrite(2, shiftpi.LOW)
                shiftpi.digitalWrite(3, shiftpi.LOW)
                shiftpi.digitalWrite(4, shiftpi.LOW)
                shiftpi.digitalWrite(5, shiftpi.LOW)
                shiftpi.digitalWrite(6, shiftpi.LOW)
                shiftpi.digitalWrite(7, shiftpi.LOW)
                shiftpi.digitalWrite(8, shiftpi.LOW)
    return 1
Ejemplo n.º 6
0
#import shiftpi
import shiftpi.shiftpi as shiftpi

shiftpi.shiftRegisters(8)

#initialize
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
shiftpi.delay(1000)

# turns shift register's pin to HIGH
shiftpi.digitalWrite(44, shiftpi.HIGH)
shiftpi.delay(500)

shiftpi.digitalWrite(45, shiftpi.HIGH)
shiftpi.delay(500)

shiftpi.digitalWrite(46, shiftpi.HIGH)
shiftpi.delay(500)

# turns shift register's pin to LOW
shiftpi.digitalWrite(44, shiftpi.LOW)
shiftpi.delay(500)

# turns all shift register pins to HIGH
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.HIGH)
shiftpi.delay(1000)

#and to low
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
shiftpi.delay(1000)
Ejemplo n.º 7
0
 def slide():
   sp.digitalWrite(1, sp.HIGH)
   sp.digitalWrite(8, sp.HIGH)
   sp.digitalWrite(17, sp.HIGH)
   sp.digitalWrite(25, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(2, sp.HIGH)
   sp.digitalWrite(9, sp.HIGH)
   sp.digitalWrite(18, sp.HIGH)
   sp.digitalWrite(26, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(1, sp.LOW)
   sp.digitalWrite(8, sp.LOW)
   sp.digitalWrite(17, sp.LOW)
   sp.digitalWrite(25, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(3, sp.HIGH)
   sp.digitalWrite(10, sp.HIGH)
   sp.digitalWrite(19, sp.HIGH)
   sp.digitalWrite(27, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(2, sp.LOW)
   sp.digitalWrite(9, sp.LOW)
   sp.digitalWrite(18, sp.LOW)
   sp.digitalWrite(26, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(4, sp.HIGH)
   sp.digitalWrite(11, sp.HIGH)
   sp.digitalWrite(20, sp.HIGH)
   sp.digitalWrite(28, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(3, sp.LOW)
   sp.digitalWrite(10, sp.LOW)
   sp.digitalWrite(19, sp.LOW)
   sp.digitalWrite(27, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(5, sp.HIGH)
   sp.digitalWrite(12, sp.HIGH)
   sp.digitalWrite(21, sp.HIGH)
   sp.digitalWrite(29, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(4, sp.LOW)
   sp.digitalWrite(11, sp.LOW)
   sp.digitalWrite(20, sp.LOW)
   sp.digitalWrite(28, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(6, sp.HIGH)
   sp.digitalWrite(13, sp.HIGH)
   sp.digitalWrite(22, sp.HIGH)
   sp.digitalWrite(30, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(5, sp.LOW)
   sp.digitalWrite(12, sp.LOW)
   sp.digitalWrite(21, sp.LOW)
   sp.digitalWrite(29, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(7, sp.HIGH)
   sp.digitalWrite(14, sp.HIGH)
   sp.digitalWrite(23, sp.HIGH)
   sp.digitalWrite(31, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(6, sp.LOW)
   sp.digitalWrite(13, sp.LOW)
   sp.digitalWrite(22, sp.LOW)
   sp.digitalWrite(30, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(8, sp.HIGH)
   sp.digitalWrite(15, sp.HIGH)
   sp.digitalWrite(24, sp.HIGH)
   sp.digitalWrite(32, sp.HIGH)
   sp.delay(75)
   sp.digitalWrite(7, sp.LOW)
   sp.digitalWrite(14, sp.LOW)
   sp.digitalWrite(23, sp.LOW)
   sp.digitalWrite(31, sp.LOW)
   sp.delay(75)
   sp.digitalWrite(8, sp.LOW)
   sp.digitalWrite(15, sp.LOW)
   sp.digitalWrite(24, sp.LOW)
   sp.digitalWrite(32, sp.LOW)
   sp.delay(75)
Ejemplo n.º 8
0
 def circle():
   sp.digitalWrite(1, sp.HIGH)
   sp.digitalWrite(17, sp.HIGH)
   sp.delay(50)
   sp.digitalWrite(2, sp.HIGH)
   sp.digitalWrite(18, sp.HIGH)
   sp.delay(50)
   sp.digitalWrite(1, sp.LOW)
   sp.digitalWrite(17, sp.LOW)
   sp.delay(50)
   sp.digitalWrite(3, sp.HIGH)
   sp.digitalWrite(19, sp.HIGH)
   sp.delay(50)
   sp.digitalWrite(2, sp.LOW)
   sp.digitalWrite(18, sp.LOW)
   sp.delay(50)
   sp.digitalWrite(2, sp.HIGH)
   sp.digitalWrite(18, sp.HIGH)
   sp.delay(50)
   sp.digitalWrite(1, sp.LOW)
   sp.digitalWrite(17, sp.LOW)
   sp.delay(50)
   sp.digitalWrite(2, sp.High)
   sp.digitalWrite(18, sp.High)
Ejemplo n.º 9
0
#import shiftpi
import shiftpi.shiftpi as shiftpi

shiftpi.shiftRegisters(8) 

#initialize
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
shiftpi.delay(1000)

# turns shift register's pin to HIGH
shiftpi.digitalWrite(44, shiftpi.HIGH)
shiftpi.delay(500)

shiftpi.digitalWrite(45, shiftpi.HIGH)
shiftpi.delay(500)

shiftpi.digitalWrite(46, shiftpi.HIGH)
shiftpi.delay(500)


# turns shift register's pin to LOW
shiftpi.digitalWrite(44, shiftpi.LOW)
shiftpi.delay(500)


# turns all shift register pins to HIGH
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.HIGH)
shiftpi.delay(1000)

#and to low
shiftpi.digitalWrite(shiftpi.ALL, shiftpi.LOW)
Ejemplo n.º 10
0
def delay(ms):
	print "Waiting for " + str(ms) + "ms"
	if MODE == "production":
		shiftpi.delay(ms)
Ejemplo n.º 11
0
def delay(ms):
    print "Waiting for " + str(ms) + "ms"
    if MODE == "production":
        shiftpi.delay(ms)