Exemplo n.º 1
0
        if secondsLeft < 5:
            display.setdp(True)
        else:
            display.setdp(False)
        if secondsLeft < 0:
            gameOver = True
            mc.postToChat("Out of Time!")
            
        hits = mc.events.pollBlockHits()
        for hit in hits:
            blockHitType = mc.getBlock(hit.pos.x, hit.pos.y, hit.pos.z)
            if blockHitType == block.DIAMOND_BLOCK.id:
                mc.setBlock(hit.pos.x, hit.pos.y, hit.pos.z,
                            block.AIR.id)
                diamondsLeft = diamondsLeft - 1
                display.write(str(diamondsLeft))

        if levelComplete:
            points = points +(DIAMONDS[level] * int(secondsLeft))
            mc.postToChat("Level Complete - Points = " + str(points))
            level = level + 1
            if level == LEVELS:
                gameOver = True
                mc.postToChat("Congratulations - All levels complete")
        
        time.sleep(0.1)

mc.postToChat("Game Over - Points = " + str(points))
display.clear()
GPIO.cleanup()
      else:
        self.write4bits(ord(char),True)


if __name__ == '__main__':
  
  gpio.output(2, True)
  
  lcd = CharLCD()

  lcd.clear()
  lcd.message(("\\"*16) + "\n" + ("\\"*16))
  
  sleep(5)
  
  lcd.clear()
  lcd.message("       :)       \n       :)       ")
  
  sleep(3)
  
  lcd.clear()
  lcd.message(("\\"*16) + "\n" + ("\\"*16))
  
  sleep(5)
  
  lcd.clear()
  lcd.noDisplay()
  
  gpio.output(2, False)
  gpio.cleanup()
Exemplo n.º 3
0
def cleanup():
  running = False
  time.sleep(1)
  GPIO.cleanup()
Exemplo n.º 4
0
# testSeg7.py - Test a 7-segment display

import anyio.seg7 as display
import time

# Use this for Raspberry Pi
#import RPi.GPIO as GPIO
#LED_PINS = [10,22,25,8,7,9,11,15]

# Use this for Arduino
import anyio.GPIO as GPIO

LED_PINS = [7, 6, 14, 16, 10, 8, 9, 15]

GPIO.setmode(GPIO.BCM)

ON = False  # common-anode. Set to True for a common cathode display

display.setup(GPIO, LED_PINS, ON)

try:
    while True:
        for d in range(10):
            display.write(str(d))
            time.sleep(0.5)
finally:
    GPIO.cleanup()

# END
Exemplo n.º 5
0
def cleanup():
    running = False
    time.sleep(1)
    GPIO.cleanup()