NASA Space Apps - incalescence
by Mountain Computers Inc., Publication Date: Thursday, November 5, 2020
View Count: 2258, Keywords: NASA, Space Apps, Challenge, incalescence, Hashtags: #NASA #SpaceApps #Challenge #incalescence
I was looking at some future coding and going back at some old coding, and found my .asp and .io code and found the github source and branches were incomplete and missing all the good stuff.
Let me rebuild it and share with you what was done and what was missing.
the .io code in github
// add clone to array prototype |
Array.prototype.clone = function() { |
api.token = "35b232f3538f0e157751f04136e2a0b4"; |
api.rest({url:"https://api.pinocc.io/v1/account"}, function(err, data){ |
console.log("success?", err, data); |
// There are only 6 sensors |
for(var i = 0; i < 6; i++) { |
/////////////////////////////// |
// listening to the data stream |
/////////////////////////////// |
s.on('data',function(data){ |
var index = parseInt(data.scout) -1; |
led[index] = new LED(data); |
// console.log((index+1) + " ", led[index]); |
temp[index] = new Temp(data); |
// console.log((index+1) + " ", temp[index]); |
power[index] = new Power(data); |
// console.log((index+1) + " ", power[index]); |
// updateCanvas(whichArray, index+1); |
}).on('error',function(error){ |
console.log('sync error',error); |
// parse useless information out of objects |
this.currentColor = scout.value.led.clone(); |
this.idColor = scout.value.torch.clone(); |
this.currentTemp = scout.value.current; |
this.localHigh = scout.value.high; |
this.localLow = scout.value.low; |
this.batteryRemaining = scout.value.battery; |
this.charging = scout.value.charging; |
this.currentVoltage = scout.value.voltage; |
}
the .asp client side and the .io cloud stuff.
<html>
<body>
<h1>Pinocc.io - incalescence</h1>
<script src="https://api.pinocc.io/pinoccio.js"></script>
<canvas id="myCanvas" width="1000" height="100"></canvas>
<script>
// define scouts
var c = document.getElementById("myCanvas");
var ctxlead = c.getContext("2d");
ctxlead.beginPath();
// scout body
ctxlead.arc(50,50,40,0,2*Math.PI);
ctxlead.stroke();
ctxlead.font = "10px Arial";
ctxlead.fillText("Leader:",35,45);
var ctxscout1 = c.getContext("2d");
ctxscout1.beginPath();
ctxscout1.arc(150,50,40,0,2*Math.PI);
ctxscout1.stroke();
ctxscout1.font = "10px Arial";
ctxscout1.fillText("Scout1:",135,45);
var ctxscout2 = c.getContext("2d");
ctxscout2.beginPath();
ctxscout2.arc(250,50,40,0,2*Math.PI);
ctxscout2.stroke();
ctxscout2.font = "10px Arial";
ctxscout2.fillText("Scout2:",235,45);
var ctxscout3 = c.getContext("2d");
ctxscout3.beginPath();
ctxscout3.arc(350,50,40,0,2*Math.PI);
ctxscout3.stroke();
ctxscout3.font = "10px Arial";
ctxscout3.fillText("Scout3:",335,45);
var ctxscout4 = c.getContext("2d");
ctxscout4.beginPath();
ctxscout4.arc(450,50,40,0,2*Math.PI);
ctxscout4.stroke();
ctxscout4.font = "10px Arial";
ctxscout4.fillText("Scout4:",435,45);
var ctxscout5 = c.getContext("2d");
ctxscout5.beginPath();
ctxscout5.arc(550,50,40,0,2*Math.PI);
ctxscout5.stroke();
ctxscout5.font = "10px Arial";
ctxscout5.fillText("Scout5:",535,45);
// this example works both on server and browser with browserify.
// To get your auth token run ```pinoccio token``` in your terminal
// You may need to login. To install the cli run ```sudo npm install -g pinoccio```
var api = pinoccioAPI();
api.token = "notoken";
var s = api.sync();
s.on('data',function(data){
// if the event is not type data or token its something you can query from /v1/stats as report={type}
console.log('event!',data);
// update scouts with temp
if (data.scout == '1' && data.type == 'temp') {
console.log('Scout Temp Lead', data.value.current);
ctxlead.clearRect(34 , 50 , 50 , 14);
ctxlead.fillStyle = '#000000';
ctxlead.fillText('Temp: ' + data.value.current,34,60);
}
if (data.scout == '2' && data.type == 'temp') {
console.log('Scout Temp 1', data.value.current);
ctxscout1.clearRect(134 , 50 , 50 , 14);
ctxscout1.fillStyle = '#000000';
ctxscout1.fillText('Temp: ' + data.value.current,135,60);
}
if (data.scout == '3' && data.type == 'temp') {
console.log('Scout Temp 2', data.value.current);
ctxscout2.clearRect(234 , 50 , 50 , 14);
ctxscout2.fillStyle = '#000000';
ctxscout2.fillText('Temp: ' + data.value.current,235,60);
}
if (data.scout == '4' && data.type == 'temp') {
console.log('Scout Temp 3', data.value.current);
ctxscout3.clearRect(334 , 50 , 50 , 14);
ctxscout3.fillStyle = '#000000';
ctxscout3.fillText('Temp: ' + data.value.current,335,60);
}
if (data.scout == '5' && data.type == 'temp') {
console.log('Scout Temp 4', data.value.current);
ctxscout4.clearRect(434 , 50 , 50 , 14);
ctxscout4.fillStyle = '#000000';
ctxscout4.fillText('Temp: ' + data.value.current,435,60);
}
if (data.scout == '6' && data.type == 'temp') {
console.log('Scout Temp 5', data.value.current);
ctxscout5.clearRect(534 , 50 , 50 , 14);
ctxscout5.fillStyle = '#000000';
ctxscout5.fillText('Temp: ' + data.value.current,535,60);
}
}).on('error',function(error){
// after an error a new sync stream will have to be created.
// errors will happen due to connectivity etc.
console.log('sync error',error);
});
</script>
<hr>
<h2>PROJECT CENTRAL</h2>
<br>Project Code Name: incalescence
<br>Challenge Project Website <a href='https://2014.spaceappschallenge.org/project/-incalescence/'>https://2014.spaceappschallenge.org/project/-incalescence/</a>
<br>Vendor Hardware / Software : Pinoccio (website: <a href='https://pinocc.io/'>https://pinocc.io/</a>
<br>Project Team: Eric, Michael, Andy
<br>Project Date Windows: April 12-14, 2014
<br>Project Location: University of Nevada, Reno -
<br>Mission Plan - Project Cool IT! 2014 - <a href='https://2014.spaceappschallenge.org/challenge/cool-it/'>https://2014.spaceappschallenge.org/challenge/cool-it/</a>
<br>Mission Category - Earth Watch - <a href='https://2014.spaceappschallenge.org/challenge/category/earth-watch/'>https://2014.spaceappschallenge.org/challenge/category/earth-watch/</a>
</body>
</html>
if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.
© 2025 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.