-
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.
bring develop to master for DexterOS 2.0 (#44)
* Add Line Follower drivers and example * Update dexter_i2c.py Update dexter_i2c.py to be simpler and more universal by combining functions. * Update line_follower.py Update line_follower.py for recent dexter_i2c.py update * Feature/easy libraries (#35) * Move Distance Sensor and Line Follower in here * remove dependency on mock_package * remove alias for read_sensors until we know if we need it (probably not) * Feature/system wide mutex+ easydi_sensors library (#36) * Move Distance Sensor and Line Follower in here * remove dependency on mock_package * remove alias for read_sensors until we know if we need it (probably not) * get easydi_sensors from DexterOS * Check for overall mutex need * Add systemwide mutex comment * Add license header and description * Add license header * change year in license header * split easydi_sensors into 3 components for systematic naming convention * Remove copies of ifMutexAcquire and ifMutexRelease. Keep them in one file * Be more strict in what we're pulling in from easy_mutex * poll overall_mutex each time * remove print statement (#37) reconfig_bus() is now mutex protected * 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 * minor fixes to docs (#42) * minor fixes to docs * minor fixes to doc * fix grammar * rename safe_heading to heading_name and re-instate the parameter (#43) * rename safe_heading to heading_name and re-instate the parameter * rename from heading_name to convert_heading * add punctuation * fix - change name of method in library description section * Remove references to line follower (#45)
- Loading branch information
1 parent
d6b6e69
commit 8c72f81
Showing
32 changed files
with
1,484 additions
and
246 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/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 | ||
|
||
from time import sleep | ||
from di_sensors.easy_temp_hum_press import EasyTHPSensor | ||
|
||
print("Example program for reading a Dexter Industries Temperature Humidity Pressure Sensor on an I2C port.") | ||
|
||
my_thp = EasyTHPSensor() | ||
|
||
while True: | ||
# Read the temperature | ||
temp = my_thp.safe_celsius() | ||
|
||
# Read the relative humidity | ||
hum = my_thp.safe_humidity() | ||
|
||
# Read the pressure | ||
press = my_thp.safe_pressure() | ||
|
||
# Print the values | ||
print("Temperature: {:5.3f} Humidity: {:5.3f} Pressure: {:5.3f}".format(temp, hum, press)) | ||
|
||
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.