Skip to content

Commit

Permalink
Merge pull request #52 from CleoQc/master
Browse files Browse the repository at this point in the history
import libraries on a computer that doesn't have the hardware
  • Loading branch information
CleoQc authored Jul 3, 2017
2 parents 31ec446 + 03e5624 commit 4c115d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 40 deletions.
45 changes: 12 additions & 33 deletions Software/Python/easygopigo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
# import tty
# import select
import time
import gopigo3
hardware_connected = True
try:
import gopigo3
except ImportError:
hardware_connected = False
print("Cannot import gopigo3 library")
except Exception as e:
hardware_connected = False
print("Unknown issue while importing gopigo3")
print(e)


# from datetime import datetime

Expand Down Expand Up @@ -290,40 +300,9 @@ def turn_degrees(self, degrees, blocking=False):
StartPositionRight - WheelTurnDegrees) is False:
time.sleep(0.1)

# the following functions may be redundant
my_gpg = EasyGoPiGo3()


# these functions are here because we need direct access to these
# for the Drive functionality in Sam
# they do not need locking as the fct they call handles that.
def volt():
return_value = my_gpg.volt()
return return_value


def stop():
my_gpg.stop()


def forward():
my_gpg.forward()


def backward():
my_gpg.backward()


def left():
my_gpg.left()


def right():
my_gpg.right()


#############################################################
#
# SENSORS
#############################################################


Expand Down
21 changes: 14 additions & 7 deletions Software/Python/gopigo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@
from __future__ import print_function
from __future__ import division
#from builtins import input
hardware_connected = True

import subprocess # for executing system calls
import spidev
try:
import spidev
import fcntl # for lockf mutex support
except:
hardware_connected = False
print ("Can't import spidev or fcntl")

import math # import math for math.pi constant
import fcntl # for lockf mutex support
import time

FIRMWARE_VERSION_REQUIRED = "0.3.x" # Make sure the top 2 of 3 numbers match

GPG_SPI = spidev.SpiDev()
GPG_SPI.open(0, 1)
GPG_SPI.max_speed_hz = 500000
GPG_SPI.mode = 0b00
GPG_SPI.bits_per_word = 8
if hardware_connected:
GPG_SPI = spidev.SpiDev()
GPG_SPI.open(0, 1)
GPG_SPI.max_speed_hz = 500000
GPG_SPI.mode = 0b00
GPG_SPI.bits_per_word = 8


class Enumeration(object):
Expand Down

0 comments on commit 4c115d0

Please sign in to comment.