Example #1
0
File: gui.py Project: uniite/imd
def menu_up ():
	print "Menu Up"
	#If we're in play mode, just put volume up
	if mode == "play":
		audeng.vol_up()
		return
	# Equaly as simple as menu_down, just have to decrease the index/cursor instead
	# First, we simply have to check to make sure the index isn't already at 0 (anything lower is invalid)
	if curmenu.index > 0:
		curmenu.index -= 1
		# Move the cursor up if possible
		if curmenu.cursor > menu_start:
			curmenu.cursor -= row_height
			menu_draw()
			oled.redraw(curmenu.cursor, curmenu.cursor + row_height * 2)
		else:
			# If the cursor can't move up, move up the menu
			curmenu.top -= 1
			oled.copy(y = curmenu.cursor + row_height,  y2 = menu_start + row_height * (menu_rows - 1) - 2, y3 = menu_start + row_height * 2)
			oled.flush()
			menu_draw()
			oled.redraw(menu_start, menu_start + row_height * 2)
		oled.flush()
Example #2
0
File: gui.py Project: uniite/imd
def menu_down ():
	print "Menu Down"
	#If we're in play mode, just put volume down
	if mode == "play":
		audeng.vol_down()
		return
	# Very simple...just increase the menu index to go down the list...
	# ...as long as it isn't already at the limit
	if curmenu.index < curmenu.len - 1:
		curmenu.index += 1
		# Move down the cursor if possible
		if curmenu.cursor < menu_end - row_height:
			curmenu.cursor += row_height
			menu_draw()
			oled.redraw(curmenu.cursor - row_height, curmenu.cursor + row_height)
		else:
			# Move the menu down if the cursor can't
			curmenu.top += 1
			oled.copy(y = menu_start + row_height, y2 = menu_start + row_height * (menu_rows - 1) - 1, y3 = menu_start)
			oled.flush()
			menu_draw()
			oled.redraw(menu_start + (menu_rows - 2) * row_height, menu_start + menu_rows * row_height)
		oled.flush()