-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataboard.py
More file actions
59 lines (46 loc) · 1.58 KB
/
databoard.py
File metadata and controls
59 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
__author__ = 'bhavinpatel'
from ledPallet import Pallet
from weatherData import WeatherData
from fbNotification import fbNotification
from pprint import pprint
from led import LED
import time
class DataBoard:
temperature = dict()
defaultWait = 5
def __init__(self):
self.weatherDataObj = WeatherData()
self.palletObj = Pallet()
self.fbNotificationObj = fbNotification()
self.fb_led = LED(22)
def show_temperature(self, temperature = None):
self.weatherDataObj.get_weather()
if temperature is not None:
print "\n Temperature : %f" % temperature
else:
print "\n Temperature : %f" % self.weatherDataObj.weather['temperature']
self.__temperature_gradient(temperature)
self.palletObj.color( self.temperature['led']['r'],
self.temperature['led']['g'],
self.temperature['led']['b'])
time.sleep( self.defaultWait )
def __temperature_gradient(self, temperature=None):
leds = dict()
if temperature is None:
leds['r'] = self.__calculate_temperature_gradient( self.weatherDataObj.weather['temperature'] )
else:
leds['r'] = temperature
leds['b'] = 255 - leds['r']
leds['g'] = 0
self.temperature['led'] = leds
def __calculate_temperature_gradient(self, temperature):
return round( (255 * temperature )/ 90 )
def fb_notification(self):
fb_notifications = self.fbNotificationObj.notifications(True)
if len( fb_notifications ) :
self.fb_led.pulse()
if __name__ == "__main__":
db = DataBoard()
db.fb_notification()
db.show_temperature()
db.show_temperature(10)