def convert_movement(rega, regb): direction = bus.read_byte_data(add, regb) Axis = bus.read_byte_data(add, rega) if direction == 255: new = (Axis - 255) else: new = Axis return new / 17
def tilt_detected(): tiltdegree = bus.read_byte_data(add, regZa) z2 = bus.read_byte_data(add, regZb) if z2 == 0: tiltdegree = (tiltdegree - 255) if abs(tiltdegree) > 200: return True else: return False
def quit2(): regPs = 0x2D powerSave = bus.read_byte_data(add, regPs) powerSave -= 8 bus.write_byte_data(add, regPs, powerSave) bus.close() pygame.quit()
def Z_movement_detected(): Z1 = bus.read_byte_data(add, regZb) if Z1 == 1: return True else: return False
# Modified by Evan Loughlin, Teale Masrani, and Joseph Gorespe # Date: 2017.11.03 # This version of the the game utilizes the ADXL345 Digital Accelerometer # 2017-09-19 - modified by JE Boyd for python3 import time import mySMBus as bus running = True add = 0x53 reg = 0x00 bus.open(1) devID = bus.read_byte_data(add, reg) regPs = 0x2D powerSave = bus.read_byte_data(add, regPs) powerSave += 8 bus.write_byte_data(add, regPs, powerSave) regXa = 0x32 regXb = 0x33 regYa = 0x34 regYb = 0x35 regZa = 0x36 regZb = 0x37