Exemple #1
0
def init(caption, use_framebuffer, fps_max, scene, task_handler):
	"""Initializes a frontend and starts rendering it to the display using pygame.

	Can be used with X or direct framebuffer access (to use framebuffer root 
	priviligese is needed).
	
	Provides the basic functionality for a frontend: pygame setup, basic data retrieval 
	and fps trottled main loop. Instead of having a abstract class that the user extends, 
	there are two objects the user passes to this function:

	1) 	Task handler, handles data retrieval etc, 
	2)	Scene renderer, uses the data from the task handler to render it to screen. 

	How they are setup is up to the user, except for:

	1) 	Task handler needs a prepare method which takes a user config and a system config. 
	2) 	a) 	Scene needs a prepare method which takes the task handler, display width and 
			display height.
		b) 	Scene needs a render method which takes the pygame window and clock to be 
			run on every frame.	

	"""

	pygame.init()
	pygame.font.init()
	pygame.mouse.set_visible(0)
	pygame.display.set_caption(caption)

	video_info = pygame.display.Info()

	display_width = video_info.current_w
	display_height = video_info.current_h
	display_size = (display_width, display_height)

	clock = pygame.time.Clock()
	window = pygame.display.set_mode(display_size, pygame.FULLSCREEN)

	uconfig = user_config.retrieve_config()
	sconfig = system_config.retrieve_config()

	task_handler.prepare(uconfig, sconfig)
	scene.prepare(task_handler, display_width, display_height)

	while True:
		check_events()
		scene.render(window, clock)
	
		pygame.display.update()
		clock.tick(fps_max)
Exemple #2
0
	def run(self):
		"""Daemons main loop."""

		self.system_config = system_config.retrieve_config()	
		self.user_config = user_config.retrieve_config()	
		system_status.set_uptime_start()

		self.internet_test_time = external_resources.test_internet_connection()
		self.dropbox_test_time = external_resources.test_dropbox_connection()
		self.download_image_time = external_resources.sync_dropbox_images()

		while True:
			if not self.paused:
				self.check_task_timing()

			time.sleep(1)