mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 09:51:14 +03:00
python: Added upm directory for python modules
* Grouped UPM python modules into upm directory, for example: /usr/local/lib/python2.7/dist-packages/upm * Updated UPM example import statements * Removed unused RPATH statements from UPM src CMakeLists.txt, currently build collateral contains an explicit RPATH which is stripped from the install collateral. * Converted python examples to work on both python2 AND python3 * Added ctest for loading examples w/python3 * Removed returns from swig macros * UPM python module use will change... Before: import pyupm_dfrph After: from upm import pyupm_dfrph or import upm.pyupm_dfrph etc... * This commit fixes #468 Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -22,7 +23,7 @@
|
||||
|
||||
import time
|
||||
import array
|
||||
import pyupm_ldt0028 as ldt0028
|
||||
from upm import pyupm_ldt0028 as ldt0028
|
||||
|
||||
def main():
|
||||
NUMBER_OF_SECONDS = 10
|
||||
@ -33,8 +34,8 @@ def main():
|
||||
sensor = ldt0028.LDT0028(0)
|
||||
|
||||
# Read the signal every 20 milliseconds for 10 seconds
|
||||
print 'For the next', NUMBER_OF_SECONDS, 'seconds,', \
|
||||
SAMPLES_PER_SECOND, 'samples will be taken every second.\n'
|
||||
print('For the next', NUMBER_OF_SECONDS, 'seconds,', \
|
||||
SAMPLES_PER_SECOND, 'samples will be taken every second.\n')
|
||||
buffer = array.array('H')
|
||||
for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND):
|
||||
buffer.append(sensor.getSample())
|
||||
@ -45,15 +46,15 @@ def main():
|
||||
for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND):
|
||||
if buffer[i] > THRESHOLD:
|
||||
count += 1
|
||||
print sensor.name(), ' exceeded the threshold value of', \
|
||||
THRESHOLD, 'a total of', count, 'times,'
|
||||
print 'out of a total of', NUMBER_OF_SECONDS*SAMPLES_PER_SECOND, \
|
||||
'reading.\n'
|
||||
print(sensor.name(), ' exceeded the threshold value of', \
|
||||
THRESHOLD, 'a total of', count, 'times,')
|
||||
print('out of a total of', NUMBER_OF_SECONDS*SAMPLES_PER_SECOND, \
|
||||
'reading.\n')
|
||||
|
||||
# Print a graphical representation of the average value sampled
|
||||
# each second for the past 10 seconds, using a scale factor of 15
|
||||
print 'Now printing a graphical representation of the average reading '
|
||||
print 'each second for the last', NUMBER_OF_SECONDS, 'seconds.'
|
||||
print('Now printing a graphical representation of the average reading ')
|
||||
print('each second for the last', NUMBER_OF_SECONDS, 'seconds.')
|
||||
SCALE_FACTOR = 15
|
||||
for i in range(0, NUMBER_OF_SECONDS):
|
||||
sum = 0
|
||||
@ -61,7 +62,7 @@ def main():
|
||||
sum += buffer[i*SAMPLES_PER_SECOND+j]
|
||||
average = sum / SAMPLES_PER_SECOND
|
||||
stars_to_print = int(round(average / SCALE_FACTOR))
|
||||
print '(' + repr(int(round(average))).rjust(4) + ') |', '*' * stars_to_print
|
||||
print('(' + repr(int(round(average))).rjust(4) + ') |', '*' * stars_to_print)
|
||||
|
||||
# Delete the sensor object
|
||||
del sensor
|
||||
|
Reference in New Issue
Block a user