Пример #1
0
def quit(screensaver=True):
	head.aim(1430, 1200)
	head.laser(False)
	if screensaver:
		oled.show_logo()
	else:
		oled.clear()
	time.sleep(0.2)
	duino.disable()
Пример #2
0
def quit(screensaver=True):
	head.aim(1430, 1200)
	head.laser(False)
	if screensaver:
		oled.clear_buffer()
		oled.write("Booted.")
		oled.refresh()
		time.sleep(0.2)
	else:
		oled.clear()
		time.sleep(0.2)
	duino.disable()
Пример #3
0
def begin(splashscreen=True):
	log.log("Lobsang.begin() called.")
	duino.disable()
	time.sleep(0.1)
	duino.enable()
	for i in range(0, 4):
		time.sleep(0.1)
		if duino.online():
			log.log("Duino responded to 'OK?' query. Duino Online.")
			break
		else:
			log.warning("Duino did not respond to 'OK?' query. Resetting...")
			duino.reset()
			time.sleep(0.5)
	if not duino.online():
		log.error("Duino is not responding to 'OK?' query. Cannot continue running program.")
		raise IOError("Duino is not responding.")
	wheels.calibrate_speeds(wheels.calibration)
	if splashscreen:
		oled.splashscreen()
		oled.refresh()
Пример #4
0
def halt():
	duino.enable()
	time.sleep(0.1)
	tries = 0
	while not duino.online() and tries < 5:
		print "Resetting..."
		duino.reset()
		time.sleep(2)
		tries += 1
	duino.shutdown()
	terminal.info("Shutting down Lobsang...")
	log.log("Halting Lobsang. Raspbian is shutting down.")
	log.new_log() # If Lobsang halted through this code (it generally does) then create a new logfile.
	oled.clear_buffer()
	oled.write("Shutting down Lobsang...", pos=(0,0))
	oled.write("Wait until Duino light goes out before switching off.", pos=(0, 24))
	oled.refresh()
	os.system("sudo halt")
Пример #5
0
import machine

import Random
import Oled

SCREEENWIDTH = 128
SCREEENHEIGHT = 32
GROUND = SCREEENHEIGHT
oled = Oled.Oled(SCREEENWIDTH, SCREEENHEIGHT)
oled.erase()
robj = Random.Random()


class GameHandler:
    jumpButton = None
    gravity = 0.0
    player = None
    enemies = []
    score = 0

    def __init__(self):
        self.jumpButton = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)

        global GROUND

        self.player = GameObject(5, GROUND - 15, 10, 15)
        self.enemies = []

        self.score = 0

        self.gravity = GROUND / 30
Пример #6
0
import machine

import Random
import Oled

oled = Oled.Oled()
oled.erase()

robj = Random.Random()
delay = 0.5
screenWidth = 128
screenHeight = 32

drawButton = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)
eraseButton = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_UP)


def drawSquare(x, y, size):
    oled.rectangle(int(x), int(y), int(size))


def drawCircle(x, y, radius):
    oled.circle(int(x), int(y), int(radius))


def drawShape(x, y, size):
    shape = robj.randRange(1)

    if shape == 0:
        drawCircle(x, y, size/1.5)
    elif shape == 1:
Пример #7
0
# Created Nov 2015 by Finley Watson

print "Auto Run: Initialising."

# Import the necessary libraries
import Oled
import Padlock
import random
import time
import subprocess
import os
import sys

# Display a message on the oled, if it works.
try: # We have not yet checked if the OLED is connected, so only "try:" to do this.
	Oled.write("Starting Auto Run.")
	Oled.refresh()
except: # Oled failed, but don't cause a fuss.
	pass

# Variables to be set lower down
camera_online = True
oled_online = True
duino_online = True

# Run boot.py, a system checkup script.
boot_errors = subprocess.call(["python", "boot.py"])

# Script exit code gives info about systems: 0 is all online,
# +4 == camera offline, +2 == oled offline, +1 == duino offline.
# So an error code of 6 == oled and cam offline but error of