Rev 4140 Rev 4141
Line 17... Line 17...
17 import time 17 import time
18 import numpy as np 18 import numpy as np
19   19  
20 t = [1 + i for i in range(0, 70)] 20 t = [1 + i for i in range(0, 70)]
21 s = [-30 + i for i in range(0, 70)] 21 s = [-30 + i for i in range(0, 70)]
-   22 s2 = [-30 + i for i in range(0, 70)]
22   23  
23 plot(t, s, linewidth=3.0) 24 plot(t, s, linewidth=3.0)
24 xlabel('time (s)') 25 xlabel('time (s)')
25 ylabel('temperature (C)') 26 ylabel('temperature (C)')
26 title('Temperature') 27 title('Temperature external')
27 f = gcf() 28 f = gcf()
28 ax = f.gca() 29 ax = f.gca()
29   30  
-   31 f2 = figure()
30 show(block=False) 32 ax2 = f2.gca()
-   33 ax2.set_xlabel('time (s)')
-   34 ax2.set_ylabel('temperature (C)')
31 # show the figure manager but don't block script execution so animation works.. 35 ax2.set_title('Temperature internal')
-   36 ax2.plot(t, s, linewidth=3.0)
32   37  
-   38 show(block=False, layout=2, open_plot=True)
-   39 # show the figure manager but don't block script execution so animation works..
33   40  
34 while True: 41 while True:
35 #### Sensor Configuration ########################################### 42 #### Sensor Configuration ###########################################
36 cfg = config.Config( 43 cfg = config.Config(
37 i2c = { 44 i2c = {
Line 67... Line 74...
67   74  
68 time.sleep(0.5) 75 time.sleep(0.5)
69   76  
70 # refresh graph 77 # refresh graph
71 s = s[1:] + [temp] 78 s = s[1:] + [temp]
-   79 s2 = s2[1:] + [temperature]
72 t = t[1:] + [n] 80 t = t[1:] + [n]
73 n += 1 81 n += 1
74 if (n % 10) == 0: 82 if (n % 10) == 0:
75 ax.text(n, temp-5, "{0:.1f}".format(temp), 83 ax.text(n, temp-5, "{0:.1f}".format(temp),
76 verticalalignment='bottom', horizontalalignment='right', 84 verticalalignment='bottom', horizontalalignment='right',
-   85 color='red', fontsize=16)
-   86 ax2.text(n, temperature-5, "{0:.1f}".format(temperature),
-   87 verticalalignment='bottom', horizontalalignment='right',
77 color='green', fontsize=16) 88 color='green', fontsize=16)
78   89  
79 ax.lines[0].set_xdata(t) 90 ax.lines[0].set_xdata(t)
80 ax.lines[0].set_ydata(s) 91 ax.lines[0].set_ydata(s)
81 ax.set_xlim(t[0],t[-1]) 92 ax.set_xlim(t[0],t[-1])
-   93 ax2.lines[0].set_xdata(t)
-   94 ax2.lines[0].set_ydata(s2)
-   95 ax2.set_xlim(t[0],t[-1])
82 f.canvas.draw() 96 f.canvas.draw()
-   97 f2.canvas.draw()
83 time.sleep(0.5) 98 time.sleep(0.5)
84   99  
85   100  
-   101  
-   102  
86 except IOError: 103 except IOError:
87 print "IOError" 104 print "IOError"
88 continue 105 continue
89   106  
90 except KeyboardInterrupt: 107 except KeyboardInterrupt: