Post-Merge Cleanup

pull/1/head
Trivernis 6 years ago
parent 66379ea24d
commit 5fa2bb7fca

@ -2,7 +2,7 @@ import os
import pygame import pygame
class Joystick(): class Joystick:
def __init__(self, navigator, light, configuration, camera): def __init__(self, navigator, light, configuration, camera):
# joystick # joystick
pygame.joystick.init() pygame.joystick.init()

@ -1,6 +1,7 @@
import pygame, pygame.camera
import picamera import picamera
import picamera.array import picamera.array
import pygame
import pygame.camera
from pygame import * from pygame import *
@ -13,6 +14,7 @@ class Screen:
"""The Screen for the Terminal""" """The Screen for the Terminal"""
def __init__(self, size=(100, 100), title="Screen"): def __init__(self, size=(100, 100), title="Screen"):
self.fullscreen = True
pygame.display.init() pygame.display.init()
self.size = size self.size = size
self.screen = pygame.display.set_mode(self.size) self.screen = pygame.display.set_mode(self.size)
@ -29,7 +31,6 @@ class Screen:
displayinfo = pygame.display.Info() displayinfo = pygame.display.Info()
fullsize = (displayinfo.current_w, displayinfo.current_h) fullsize = (displayinfo.current_w, displayinfo.current_h)
pygame.display.set_mode(fullsize, FULLSCREEN | DOUBLEBUF) pygame.display.set_mode(fullsize, FULLSCREEN | DOUBLEBUF)
self.fullscreen = True
class List(pygame.sprite.Sprite): class List(pygame.sprite.Sprite):

@ -24,7 +24,7 @@ def read_word(reg):
def read_word_2c(reg): def read_word_2c(reg):
val = read_word(reg) val = read_word(reg)
if (val >= 0x8000): if val >= 0x8000:
return -((65535 - val) + 1) return -((65535 - val) + 1)
else: else:
return val return val

@ -4,7 +4,7 @@ import RPi.GPIO as GPIO
import time import time
class Navigator(): class Navigator:
"""Forward Motor with relais, Steering with servo""" """Forward Motor with relais, Steering with servo"""
def __init__(self, mrelaispin): def __init__(self, mrelaispin):

@ -5,10 +5,13 @@ GPIO.setmode(GPIO.BOARD)
class Sensor(object): class Sensor(object):
def init(self, TRIG, ECHO): def __init__(self):
self.TRIGGER = TRIG self.TRIGGER = TRIG
self.ECHO = ECHO self.ECHO = ECHO
self.lastValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] self.lastValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
self.lastValues = self.lastValues[1:]
def init(self, TRIG, ECHO):
GPIO.setup(self.TRIGGER, GPIO.OUT) GPIO.setup(self.TRIGGER, GPIO.OUT)
GPIO.setup(self.ECHO, GPIO.IN) GPIO.setup(self.ECHO, GPIO.IN)
GPIO.output(self.TRIGGER, False) GPIO.output(self.TRIGGER, False)
@ -36,7 +39,6 @@ class Sensor(object):
distance = pulse_duration * 17150 distance = pulse_duration * 17150
distance = round(distance, 2) distance = round(distance, 2)
self.lastValues.append(distance) self.lastValues.append(distance)
self.lastValues = self.lastValues[1:]
distance = round((sum(self.lastValues)) / (len(self.lastValues)), 2) distance = round((sum(self.lastValues)) / (len(self.lastValues)), 2)
# print(self.lastValues) # print(self.lastValues)
# print("Distance: {}".format(distance)) # print("Distance: {}".format(distance))

@ -129,10 +129,10 @@ if __name__ == '__main__':
while True: while True:
try: try:
start = time.time() start = time.time()
while (time.time() < start + 10): while time.time() < start + 10:
forward(pins) forward(pins)
start = time.time() start = time.time()
while (time.time() < start + 10): while time.time() < start + 10:
backward(pins) backward(pins)
except KeyboardInterrupt: except KeyboardInterrupt:
break break

Loading…
Cancel
Save