Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions BB8_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@

class BTInterface(btle.DefaultDelegate):
def __init__(self, deviceAddress):
self.deviceAddress = deviceAddress
btle.DefaultDelegate.__init__(self)

# Address type must be "random" or it won't connect.
Expand Down Expand Up @@ -188,7 +189,7 @@ def send(self, data):
def handleNotification(self, cHandle, data):
# print 'Notification:', cHandle, data.encode('hex')
# print 'BB8 Response:', cHandle,
Sphero().recv(data)
Sphero(self.deviceAddress).recv(data)
# print data
return data

Expand Down Expand Up @@ -236,12 +237,12 @@ def disconnect(self):


class Sphero(threading.Thread):
def __init__(self, target_name='Sphero'):
def __init__(self, deviceAddress, target_name='Sphero'):
threading.Thread.__init__(self)
self.target_name = target_name
self.bt = None
# Use "sudo hcitool lescan" to find BB8's MAC address input it at deviceAddress =
self.deviceAddress = 'DF:79:DD:9C:B6:1D'
self.deviceAddress = deviceAddress
self.shutdown = False
self.is_connected = False
self.mask_list = None
Expand Down
4 changes: 2 additions & 2 deletions BB8joyDrive.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pygame
from pygame.locals import *
from sys import exit
from sys import exit, argv
from bluepy import btle
import math
import struct
import BB8_driver

bb8 = BB8_driver.Sphero()
bb8 = BB8_driver.Sphero(argv[1])
bb8.connect()


Expand Down
5 changes: 4 additions & 1 deletion BB8test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import time
import BB8_driver
import sys
bb8 = BB8_driver.Sphero()
bb8 = BB8_driver.Sphero(sys.argv[1])
bb8.connect()


bb8.start()
time.sleep(2)
print('red')
bb8.set_rgb_led(255,0,0,0,False)
time.sleep(1)
print('green')
bb8.set_rgb_led(0,255,0,0,False)
time.sleep(1)
print('blue')
bb8.set_rgb_led(0,0,255,0,False)
time.sleep(3)
bb8.join()
Expand Down