Exemplo n.º 1
0
def start_recording():
    seconds = int(seconds_entry.get())
    samples = int(samples_entry.get())
    axis = np.arange(0, seconds, 1 / samples)
    gdx.start(1000 // samples)
    red = []
    green = []
    blue = []
    # fig, ax = plt.subplots(1,1)
    ax.cla()

    for _ in range(seconds * samples):
        # print(gdx.read())
        vals = gdx.read()
        if vals == None:
            break
        r, g, b = vals
        red.append(r)
        green.append(g)
        blue.append(b)

    gdx.stop()

    print(axis)
    ax.plot(axis, red, color='r')
    ax.plot(axis, green, color='g')
    ax.grid()
    ax.plot(axis, blue, color='b')
    ax.legend(['r', 'g', 'b'])
    ax.set_title("Lights")
    ax.set_xlabel('Time (s)')
    ax.set_ylabel('lux')
Exemplo n.º 2
0
def take_sample():
    gdx.open_usb()
    gdx.select_sensors([5, 6, 7])
    gdx.start(period=1)
    sample = gdx.read()
    print(sample)
    gdx.stop()
    gdx.close()
Exemplo n.º 3
0
def start_reading():
    seconds = int(seconds_field.get())
    samples = int(samples_field.get())
    sound_a, sound_c = [], []
    rate = 1000 // samples
    gdx.start(rate)
    interval = 1 / samples
    length = np.arange(0, seconds, interval)
    ax.cla()
    for i in range(samples * seconds):
        measure = gdx.read()
        sound_a.append(measure[0])
        sound_c.append(measure[1])
        if measure == None:
            break

    plt.yscale('linear')
    ax.plot(length, sound_a, c='red')
    ax.plot(length, sound_c, c='blue')
    plt.ylabel(ylabel='Sound(decibels)')
    plt.xlabel(xlabel='Time(seconds)')
    plt.show()
    gdx.stop()
Exemplo n.º 4
0
gdx.device_info()
gdx.enabled_sensor_info()
gdx.sensor_info()
gdx.discover_ble_devices()
monitor_rssi()

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Below is a simple starter program. Note that this program does not pass any 
arguments in the functions. Go to the gdx_getting_started_2.py example to 
see how you can pass arguments to the open(), select sensors(), and start() 
functions, and avoid the prompts.

**** This example assumes the Go Direct sensor is connected via USB.

'''
import gdx #the gdx function calls are from a gdx.py file inside the gdx folder.
gdx = gdx.gdx()

gdx.open_usb()
gdx.select_sensors()
gdx.start() 

for i in range(0,5):
    measurements = gdx.read() #returns a list of measurements from the sensors selected.
    if measurements == None: 
        break 
    print(measurements)

gdx.stop()
gdx.close()