Skip to content

Commit

Permalink
cleaned up code
Browse files Browse the repository at this point in the history
very minor changes to clean up code to prepare for new semester
  • Loading branch information
radarjd committed Aug 26, 2016
1 parent 46a23c4 commit ba0a7d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/sparki_learning_quick_reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ <h2><a class="toc-backref" href="#id42">askQuestion(message, options, title = &q
<div class="section" id="gamepad">
<h2><a class="toc-backref" href="#id43">gamepad()</a></h2>
<blockquote>
Control Sparki using the remote control. The Sparki will not accept commands while it is under remote control. Press + or – on the remote to end remote control.</blockquote>
Control Sparki using the remote control. The Sparki will not accept commands while it is under remote control. Press + or - on the remote to end remote control.</blockquote>
</div>
<div class="section" id="input-message">
<h2><a class="toc-backref" href="#id44">input(message)</a></h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/sparki_learning_quick_reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ askQuestion(message, options, title = "Question")

gamepad()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Control Sparki using the remote control. The Sparki will not accept commands while it is under remote control. Press + or on the remote to end remote control.
Control Sparki using the remote control. The Sparki will not accept commands while it is under remote control. Press + or - on the remote to end remote control.



Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#
# written by Jeremy Eglen
# Created: February 24, 2016
# Last Modified: July 5, 2016
# written targeting Python 3.4, but likely works with other versions, and has been lightly tested with Python 2.7
# Last Modified: August 26, 2016
# originally written targeting Python 3.4, but recently developed on Python 3.5, and has been lightly tested with Python 2.7

from setuptools import setup, find_packages
setup(
name = "sparki_learning",
version = "1.3.4",
version = "1.3.5",
packages = find_packages(),

# Project uses pyserial for bluetooth, so ensure that package gets
Expand Down
22 changes: 14 additions & 8 deletions sparki_learning/sparki_myro.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# written by Jeremy Eglen
# Created: November 2, 2015
# Last Modified: July 5, 2016
# Last Modified: July 25, 2016
# written targeting Python 3.4, but likely works with other versions; limited testing has been successful with Python 2.7

from __future__ import division, print_function # in case this is run from Python 2.6 or greater, but less than Python 3
Expand All @@ -37,7 +37,7 @@

########### CONSTANTS ###########
# ***** VERSION NUMBER ***** #
SPARKI_MYRO_VERSION = "1.2.6" # this may differ from the version on Sparki itself and from the library as a whole
SPARKI_MYRO_VERSION = "1.2.7" # this may differ from the version on Sparki itself and from the library as a whole


# ***** MESSAGE TERMINATOR ***** #
Expand Down Expand Up @@ -1385,11 +1385,12 @@ def joystick():
"""
printDebug("In joystick", DEBUG_INFO)

# grid is 4 rows by 3 columns
# grid is 5 rows by 3 columns
# | forward |
# left | stop | right
# | backward |
# open | | close
# left | center | right (these are for the "head" servo)
if USE_GUI:
# start a new window
control = tk.Toplevel()
Expand All @@ -1402,22 +1403,27 @@ def joystick():
tk.Button(control, text="forward", command=lambda: forward(1)).grid(row=0, column=1)

# 2nd row
tk.Button(control, text="left", command=lambda: turnLeft(1)).grid(row=1, column=0)
tk.Button(control, text="turn left", command=lambda: turnLeft(1)).grid(row=1, column=0)
tk.Button(control, text="stop", command=stop).grid(row=1, column=1) # no argument needed for stop
tk.Button(control, text="right", command=lambda: turnRight(1)).grid(row=1, column=2)
tk.Button(control, text="turn right", command=lambda: turnRight(1)).grid(row=1, column=2)

# 3rd row
tk.Button(control, text="backward", command=lambda: backward(1)).grid(row=2, column=1)

# 4th row
tk.Button(control, text="open grip", command=lambda: gripperOpen(.5)).grid(row=3, column=0)
tk.Button(control, text="close grip", command=lambda: gripperClose(.5)).grid(row=3, column=2)
tk.Button(control, text="open grip", command=lambda: gripperOpen(1)).grid(row=3, column=0)
tk.Button(control, text="close grip", command=lambda: gripperClose(1)).grid(row=3, column=2)

# 5th row
tk.Button(control, text="head left", command=lambda: servo(SERVO_LEFT)).grid(row=4, column=0)
tk.Button(control, text="head center", command=lambda: servo(SERVO_CENTER)).grid(row=4, column=1)
tk.Button(control, text="head right", command=lambda: servo(SERVO_RIGHT)).grid(row=4, column=2)

# weights for resizing
for i in range(3):
control.columnconfigure(i, weight=1)

for i in range(4):
for i in range(5):
control.rowconfigure(i, weight=1)

control.wait_window(control)
Expand Down
4 changes: 2 additions & 2 deletions sparki_learning/sync_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def start_sync_client(server_ip = None, server_port = PORT):
returns:
nothing
"""
if server_ip == None:
if server_ip is None:
server_ip = input("What is the server's IP? ")

wait_time = _sync_client(server_ip, server_port)
Expand All @@ -153,7 +153,7 @@ def start_sync_server(wait_time = 15, port = PORT):
returns:
nothing
"""
max_wait_time = 24 * 60 * 60
max_wait_time = 24 * 60 * 60 # 60 seconds * 60 minutes * 24 hours = number of seconds in a day

if wait_time > max_wait_time: # can't wait more than 24 hours
raise RuntimeError("wait time given was more than 24 hours")
Expand Down

0 comments on commit ba0a7d8

Please sign in to comment.