def Init():
	global curPic
	global canvas
	global disp
	global soundTex
	global q
	
	#Max out the analog volume
	os.system("amixer cset numid=1 400") 
	
	#Create black display with 2D flat shader and Canvas object
	disp = Display.create(background=(0.0, 0.0, 0.0, 1.0), x=0, y=0)
	shader = Shader("/home/pi/Frame/pi3d/shaders/2d_flat")
	canvas = Canvas()
	canvas.set_shader(shader)
	
	#Queue for gmail thread
	q = Queue.Queue()
	
	InitGmail()
	
	random.seed()
	
	#The image to be displayed whilst a sound is being played
	soundTex = Texture("/home/pi/Frame/pi3d/sound.jpg")
	
	#Init GPIO pins. Buttons on 7 and 8 for shutdown and snapchat functions. Snapchat indicator LED on 25.
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(25, GPIO.OUT, initial=GPIO.LOW)
	
	#Process all unprocessed pics
	ResizePics()
	
	#Load all processed pics
	FindPics()
	
	#Shuffle the list
	Shuffle()
	
	#Load the first, but wait until it's done
	LoadPic(0, True)
	curPic = 1
	
	#Display the loaded pic
	SwapBuffers()
Exemple #2
0
  yi = (DISPLAY.height - hi)/2
  sz[j] = [wi, hi, xi, yi]

for i in range(5):
  thr = threading.Thread(target=tex_load,
                        args=(iFiles[(i+nFiles-1)%nFiles], i, slide, sz))
  thr.daemon = True #allows the program to exit even if a Thread is still running
  thr.start()
  if i > 3:
    thr.join() #makes the main thread wait so the loop doesn't start too early!

# Setup sprite
""" Canvas is just the Shape to draw the 2d onto, it needs to be bigger
than the screen, that's all. z value will be used as depth by the shader
as it decides what to draw and what to discard """
canvas = Canvas()
canvas.set_shader(shader)

i = 1
canvas.set_texture(slide[i])
canvas.set_2d_size(w=sz[i][0], h=sz[i][1], x=sz[i][2], y=sz[i][3])
i += 1

# Fetch key presses
mykeys = Keyboard()
CAMERA = Camera.instance()
CAMERA.was_moved = False #to save a tiny bit of work each loop

while DISPLAY.loop_running():
  canvas.draw()