31.07.2015 Views

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

59 | Using <strong>the</strong> <strong>Galileo</strong> as a Computer# print HTTP header firstself.send_response(200)self.send_header("Content-type", "text/html")self.end_headers()lines = []tempFile = open("currentTemperature","r")lines = tempFile.readlines()global currentTempcurrentTemp = float(lines[0])print 'Temp is ' + lines[0]html = """var currentTemp;var data;var options;var chart;google.load('visualization','1.0',{'packages':['gauge']});google.setOnLoadCallback(initChart);function initChart() {data = new google.visualization.DataTable();data.addColumn('string', 'Label');data.addColumn('number', 'Value');data.addRows(1);data.setValue(0,0,'Temperature');data.setValue(0,1,%s);options = {width: 300, height: 300, greenFrom: 0, greenTo: 50, redFrom: 75, redTo:100, yellowFrom:50, yellowTo:75, minorTicks:5};chart = new google.visualization.Gauge(document.getElementById('gauge_div'));chart.draw(data, options);}""" %(currentTemp)self.wfile.write(html)httpd = MyTCPServer(("",PORT), HandleRequests)print "Serving from port", PORThttpd.serve_forever()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!