Last active
November 13, 2017 09:56
-
-
Save JotaroS/18d7e0c4958c407b81f6 to your computer and use it in GitHub Desktop.
Intel Edisonでスマートウォッチもどきを作ってみた話 ref: https://qiita.com/JotaroS/items/58a9a0b4e53709ce19b8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screen /dev/tty.usbserial 115200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ping www.google.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh jotaro@192.xxx.xxx.xx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main.js | |
var SSD1306 = require('./ssd1306.js'); | |
var AFGFX = require('./Adafruit_GFX.js'); | |
var lcdTest = null; var ada = null; | |
function startLCD() { | |
lcdTest = new SSD1306(); | |
ada = new AFGFX(128,64); | |
lcdTest.init(); | |
lcdTest.clear(); | |
lcdTest.display(); | |
setInterval(function(){drawMenu();},10); | |
} | |
function drawMenu(){ | |
lcdTest.clear(); | |
//header | |
ada.drawString(0,0,"JTRWatch",1,1,1); | |
ada.drawString(100,0,"100%",1,1,1); | |
ada.drawLine(0,10,128,10,1); | |
//clock | |
ada.drawCircle(25,37,18,1); | |
ada.drawLine(25,37,parseInt(25+17*Math.sin(-_min*6.0*Math.PI/180+Math.PI)), parseInt(37+17*Math.cos(-_min*6.0*Math.PI/180+Math.PI)),1); | |
ada.drawLine(25,37,parseInt(25+14*Math.sin(-(_hr*30.0+_min*0.5)*Math.PI/180+Math.PI)), parseInt(37+14*Math.cos(-(_hr*30.0+_min*0.5)*Math.PI/180+Math.PI)),1); //cal | |
ada.drawString(52,20,""+day,1,1,1); | |
//time | |
ada.drawString(52,31,""+time,1,2,2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main.js | |
var SSD1306 = require('./ssd1306.js'); | |
var AFGFX = require('./Adafruit_GFX.js'); | |
var lcdTest = null; var ada = null; | |
function startLCD() { | |
lcdTest = new SSD1306(); | |
ada = new AFGFX(128,64); | |
lcdTest.init(); | |
lcdTest.clear(); | |
lcdTest.display(); | |
setInterval(function(){drawMenu();},10); | |
} | |
function drawMenu(){ | |
lcdTest.clear(); | |
//header | |
ada.drawString(0,0,"JTRWatch",1,1,1); | |
ada.drawString(100,0,"100%",1,1,1); | |
ada.drawLine(0,10,128,10,1); | |
//clock | |
ada.drawCircle(25,37,18,1); | |
ada.drawLine(25,37,parseInt(25+17*Math.sin(-_min*6.0*Math.PI/180+Math.PI)), parseInt(37+17*Math.cos(-_min*6.0*Math.PI/180+Math.PI)),1); | |
ada.drawLine(25,37,parseInt(25+14*Math.sin(-(_hr*30.0+_min*0.5)*Math.PI/180+Math.PI)), parseInt(37+14*Math.cos(-(_hr*30.0+_min*0.5)*Math.PI/180+Math.PI)),1); //cal | |
ada.drawString(52,20,""+day,1,1,1); | |
//time | |
ada.drawString(52,31,""+time,1,2,2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//weather.js | |
module.exports={ | |
getRain : function(callback){ | |
var rain; | |
request(url,function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
parseString(body, function (err, result) { | |
rain=result.weatherforecast.pref[0].area[3].info[0].rainfallchance[0].period[3]._; | |
callback(null,rain); | |
}); | |
} else { | |
console.log(error + " : " + response); | |
} | |
}); | |
return rain; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//weather.js | |
module.exports={ | |
getRain : function(callback){ | |
var rain; | |
request(url,function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
parseString(body, function (err, result) { | |
rain=result.weatherforecast.pref[0].area[3].info[0].rainfallchance[0].period[3]._; | |
callback(null,rain); | |
}); | |
} else { | |
console.log(error + " : " + response); | |
} | |
}); | |
return rain; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startLCD(){ | |
//... | |
setInterval(function(){getWeather.getRain(returnRainResult);},30000); | |
//... | |
} | |
//... | |
function returnRainResult(err,result){ | |
console.log("hi"); | |
console.log(result); | |
str = result+"%"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startLCD(){ | |
//... | |
setInterval(function(){getWeather.getRain(returnRainResult);},30000); | |
//... | |
} | |
//... | |
function returnRainResult(err,result){ | |
console.log("hi"); | |
console.log(result); | |
str = result+"%"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment