Skip to content

Commit 51b3002

Browse files
authored
Update getcpu.py
1 parent c38709a commit 51b3002

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

getcpu.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
from __future__ import division
66
import copy
77
import math
8-
import sys
9-
import os
10-
import psutil
11-
import time
8+
import sys, os, time
9+
#import psutil
10+
1211

1312
class led_display(object):
1413
def __init__(self):
@@ -17,7 +16,6 @@ def __init__(self):
1716
def toggle(self):
1817
pass
1918

20-
2119
# Function to draw a pretty pattern to the display.
2220
def animate(self):
2321
pass
@@ -33,19 +31,35 @@ def translate(value, leftMin, leftMax, rightMin, rightMax):
3331
# Convert the 0-1 range into a value in the right range.
3432
return rightMin + (valueScaled * rightSpan)
3533

36-
3734
def sensorget():
38-
statusram = psutil.virtual_memory()
35+
# statusram = psutil.virtual_memory()
3936

40-
sensordict = {'humidity': 0, 'temp':0, 'humidtemp':0, 'pressuretemp':0,'pressure':0,'compass':0}
41-
sensordict['humidity'] = psutil.cpu_percent()
42-
sensordict['temp'] = psutil.sensors_temperatures()['acpitz'][0].current
43-
sensordict['humidtemp'] = psutil.cpu_percent()
44-
sensordict['pressuretemp'] = psutil.cpu_percent()
45-
sensordict['pressure'] = translate(statusram.percent, 0, 100, 260, 1260)
46-
#psutil.disk_usage('/').percent + 260
47-
sensordict['compass'] = {"x" : 2, "y" : 2, "z" : 3}
48-
return sensordict
37+
# sensordict = {'humidity': 0, 'temp':0, 'humidtemp':0, 'pressuretemp':0,'pressure':0,'compass':0}
38+
# sensordict['humidity'] = psutil.cpu_percent()
39+
# sensordict['temp'] = psutil.sensors_temperatures()['acpitz'][0].current
40+
# sensordict['humidtemp'] = psutil.cpu_percent()
41+
# sensordict['pressuretemp'] = psutil.cpu_percent()
42+
# sensordict['pressure'] = translate(statusram.percent, 0, 100, 260, 1260)
43+
# #psutil.disk_usage('/').percent + 260
44+
# sensordict['compass'] = {"x" : 2, "y" : 2, "z" : 3}
45+
# return sensordict
46+
47+
# also commented import psutil in favor of vanilla/built-in option os, sys, and or subsystem
48+
# place holder to read and pass data
49+
# error handeling and data compatiblity
50+
51+
sensordict = {'humidity': 0, 'temp':0, 'humidtemp':0, 'pressuretemp':0,'pressure':0,'compass':0}
52+
# BPE680 Temprature in c
53+
sensordict['temp'] = float(os.popen("python3 /home/beta/bme680-python/examples/its_bme680PHT.py -c").read())
54+
# BMP Pressure in hPa
55+
sensordict['pressure'] = float(os.popen("python3 /home/beta/its_bmp280/its_bmp280.py -p").read())
56+
# BME humidity in rh%
57+
sensordict['humidity'] = float(os.popen("python3 /home/beta/bme680-python/examples/its_bme680PHT.py -h").read())
58+
# mpu60xx motion/magnet in x, y, z
59+
sensordict['compass'] = {os.popen("python3 /home/beta/its-i2cpnpWebApp/its_mpu60xx.py").read()}
60+
61+
print(sensordict)
62+
return sensordict
4963

5064
def printscreen(sensordict):
5165
print("Temperature: %s C" % sensordict['temp'])
@@ -54,4 +68,3 @@ def printscreen(sensordict):
5468
print("Pressure: %s Millibars" % sensordict['pressure'])
5569
print("Humidity: %s %%rH" % sensordict['humidity'])
5670
print("North: %s" % sensordict['compass'])
57-

0 commit comments

Comments
 (0)