-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature - update documentation for the latest (#41)
* feature - configuring the environment for RTD * feature - bulk changes to docs * feature - add comment on how to build documentation * feature - add part of the documentation * feature - completing the documentation for easy sensors + tutorials * feature - work on the tutorials + other stuff * feature - fix the mutexes tutorial * feature - change organization of documentation * feature - remove an unnecessary section * feature - show the right command for installing di-sensors * feature - small changes * feature - fix documentation & and missing parts * feature - fix naming of the package * Revert commit
- Loading branch information
1 parent
2b4c98b
commit 8dbf4c1
Showing
25 changed files
with
753 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python | ||
# | ||
# https://www.dexterindustries.com | ||
# | ||
# Copyright (c) 2017 Dexter Industries | ||
# Released under the MIT license (http://choosealicense.com/licenses/mit/). | ||
# For more information see https://github.com/DexterInd/DI_Sensors/blob/master/LICENSE.md | ||
# | ||
# Python example program for the Dexter Industries Distance Sensor | ||
|
||
from __future__ import print_function | ||
from __future__ import division | ||
|
||
# import the modules | ||
from di_sensors.easy_distance_sensor import EasyDistanceSensor | ||
from time import sleep | ||
|
||
# instantiate the distance object | ||
my_sensor = EasyDistanceSensor() | ||
|
||
# and read the sensor iteratively | ||
while True: | ||
read_distance = my_sensor.read() | ||
print("distance from object: {} mm".format(read_distance)) | ||
|
||
sleep(0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# | ||
# https://www.dexterindustries.com | ||
# | ||
# Copyright (c) 2017 Dexter Industries | ||
# Released under the MIT license (http://choosealicense.com/licenses/mit/). | ||
# For more information see https://github.com/DexterInd/DI_Sensors/blob/master/LICENSE.md | ||
# | ||
# Python example program for the Dexter Industries Temperature Humidity Pressure Sensor | ||
|
||
from __future__ import print_function | ||
from __future__ import division | ||
|
||
# do the import stuff | ||
from di_sensors.easy_distance_sensor import EasyDistanceSensor | ||
from time import time, sleep | ||
from threading import Thread, Event, get_ident | ||
|
||
# instantiate the distance object | ||
my_sensor = EasyDistanceSensor(use_mutex = True) | ||
start_time = time() | ||
runtime = 2.0 | ||
# create an event object for triggering the "shutdown" of each thread | ||
stop_event = Event() | ||
|
||
# target function for each thread | ||
def readingSensor(): | ||
while not stop_event.is_set(): | ||
thread_id = get_ident() | ||
distance = my_sensor.read() | ||
print("Thread ID = {} with distance value = {}".format(thread_id, distance)) | ||
sleep(0.001) | ||
|
||
# create an object for each thread | ||
thread1 = Thread(target = readingSensor) | ||
thread2 = Thread(target = readingSensor) | ||
|
||
# and then start them | ||
thread1.start() | ||
thread2.start() | ||
|
||
# let it run for [runtime] seconds | ||
while time() - start_time <= runtime: | ||
sleep(0.1) | ||
|
||
# and then set the stop event variable | ||
stop_event.set() | ||
|
||
# and wait both threads to end | ||
thread1.join() | ||
thread2.join() |
56 changes: 28 additions & 28 deletions
56
Python/Examples/LightColorSensor.py → Python/Examples/EasyLightColorSensor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
#!/usr/bin/env python | ||
# | ||
# https://www.dexterindustries.com | ||
# | ||
# Copyright (c) 2017 Dexter Industries | ||
# Released under the MIT license (http://choosealicense.com/licenses/mit/). | ||
# For more information see https://github.com/DexterInd/DI_Sensors/blob/master/LICENSE.md | ||
# | ||
# Python example program for the Dexter Industries Light Color Sensor | ||
|
||
from __future__ import print_function | ||
from __future__ import division | ||
|
||
import time | ||
from di_sensors.light_color_sensor import LightColorSensor | ||
|
||
print("Example program for reading a Dexter Industries Light Color Sensor on an I2C port.") | ||
|
||
lcs = LightColorSensor(led_state = True) | ||
|
||
while True: | ||
# Read the R, G, B, C color values | ||
red, green, blue, clear = lcs.get_raw_colors() | ||
|
||
# Print the values | ||
print("Red: {:5.3f} Green: {:5.3f} Blue: {:5.3f} Clear: {:5.3f}".format(red, green, blue, clear)) | ||
|
||
time.sleep(0.02) | ||
#!/usr/bin/env python | ||
# | ||
# https://www.dexterindustries.com | ||
# | ||
# Copyright (c) 2017 Dexter Industries | ||
# Released under the MIT license (http://choosealicense.com/licenses/mit/). | ||
# For more information see https://github.com/DexterInd/DI_Sensors/blob/master/LICENSE.md | ||
# | ||
# Python example program for the Dexter Industries Light Color Sensor | ||
|
||
from __future__ import print_function | ||
from __future__ import division | ||
|
||
from time import sleep | ||
from di_sensors.easy_light_color_sensor import EasyLightColorSensor | ||
|
||
print("Example program for reading a Dexter Industries Light Color Sensor on an I2C port.") | ||
|
||
my_lcs = EasyLightColorSensor(led_state = True) | ||
|
||
while True: | ||
# Read the R, G, B, C color values | ||
red, green, blue, clear = my_lcs.safe_raw_colors() | ||
|
||
# Print the values | ||
print("Red: {:5.3f} Green: {:5.3f} Blue: {:5.3f} Clear: {:5.3f}".format(red, green, blue, clear)) | ||
|
||
sleep(0.02) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.