ã¯ããã«
ã¹ãã¼ãã¦ã©ããã® Pebble 㯠Simply.js ãå©ç¨ãããã¨ã§ JavaScript ã®ã¿ã®éçºãå¯è½ã§ãã
ã¾ããPebble ã¯éçºç°å¢ã¨ã㦠CloudPebble ã¨ãããªã³ã©ã¤ã³ IDE ãç¨æãã¦ããã以å解説ãã C / JavaScript ã«ããéçºï¼Pebble SDK 2.0 Beta の JavaScript framework で Hello World してみた - 凹みTipsï¼ã«å ãããã® Simply.js ã®éçºããµãã¼ããã¦ãã¾ãã
ããã§ãCloudPebble ä¸ã§ Simply.js ã使ã£ãéçºãè¡ã£ã¦ã¿ã¾ããã
CloudPebble ã®ä½¿ãæ¹
Hello World
CloudPebble ä¸ã§ Pebble ã®ã¢ã«ã¦ã³ãã§ãã°ã¤ã³ãã¾ããããã¨ä»¥ä¸ã®æ§ãªããã·ã¥ãã¼ãã表示ããã¾ãã
Create Project 㧠Project Type ã ãSimply.jsãã«è¨å®ããããã¸ã§ã¯ãåãå ¥åã㦠Create ãã¾ãã
ãã㧠Simply.js ã®éå½¢ãåºæ¥ã¾ãã
ã¾ããµã¤ããã¼ã®ãSettingsãããããã¸ã§ã¯ãã®è¨å®ãå¯è½ã§ããCompilationãããã¯ãã«ãã®ç®¡çããã¹ããã® IP ãè¨å®ããã° Pebble ã¸ã¢ããªãèªåçã«ã¤ã³ã¹ãã¼ã«ãã¦å®è¡ãããããã®ãã°ï¼console.log()ï¼ãè¦ãããã¹ã¯ãªã¼ã³ã·ã§ãããæ®ããã¨ãå¯è½ã§ãã
ãã®éã¯ãã¹ããã® Pebble ã¢ããªã®è¨å®ã®ãDeveloper OptionsããããEnable Develiper Connectionãã«ãã§ãã¯ãå ¥ãã¦ãããã¨ãå¿ è¦ã§ããIP ã¯ã¢ããªãµã¤ããã¼ã®ãDeveloperããã確èªã§ãã¾ãã
é©å®ãapp.js ãä¿®æ£ãã¦ãSave and runããã¯ãªãã¯ãã¦ãããã°ãã«ãã»è»¢éããå¾ã« Pebble ã§èªåã§æ¸ããã¢ããªãèµ·åããããã«ãªãã¾ãã
IDE ã«ã¤ãã¦
ãããã«ãã IDE Settings ããè²ã ã¨ãããã°ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãï¼ããã©ã«ã㯠Sublime 風ï¼ã好ã¿ã®ãã®ã«å¤ãããããã¼ãã¤ã³ãã emacs / vim 風ã«ãããåºæ¥ã¾ããã¾ããã·ã³ã¿ãã¯ã¹ã¨ã©ã¼ããªã¢ã«ã¿ã¤ã ã«æãã¦ããã¦ä¾¿å©ã§ãã
Simply.js ã®ä½¿ãæ¹
Simply.js ã®ãµã¤ãã«ã¢ã¯ã»ã¹ããã¨ãã¥ã¼ããªã¢ã«ãæ¸ãã¦ããã¾ãã
ã³ã¼ãã®ä¸ãã¯ãªãã¯ããã¨ç»é¢å³é¨ã«ã¨ãã¥ã¬ã¼ã¿é¢¨ã® UI ã表示ãããããã«åã³ã¼ããå®è¡ããçµæãåºåããã¾ããåºæ¬çã«ã¯ simply åå空é以ä¸ã« Simply.js ç¹æã® API ããããã°ãã¼ãã«ç©ºéã« HTTP ãªã¯ã¨ã¹ããæãã ajax é¢æ°ã¨ãå¤é¨ã¢ã¸ã¥ã¼ã«ãèªã¿è¾¼ã require é¢æ°ãå®ç¾©ããã¦ããå½¢ã«ãªãã¾ãã以ä¸ã«å ¬å¼ã®ãã¥ã¼ããªã¢ã«ãè£è¶³ããªããã¾ã¨ãã¦ã¿ã¾ããã
app.js
// æåã®è¡¨ç¤º simply.title('Title'); simply.subtitle('Sub Title'); simply.body('Body'); // ãã¤ãã¬ã¼ã·ã§ã³ï¼short, long, doubleï¼ simply.vibe('short'); // ã¯ãªãã¯ããã¨ãã®ã¤ãã³ããã³ãã© simply.on('singleClick', function(e) { // e.button 㯠backãupãselectãdown ã®ãããã simply.subtitle(e.button); }); // HTML5 ç¸å½ã®ãã¼ã¿ã®æ°¸ç¶å var count = parseInt(localStorage.getItem('count')) || 0; // å é度ã»ã³ãµã®å©ç¨ simply.on('accelTap', function(e) { if (e.axis === 'y') { count += e.direction; localStorage.setItem('count', count); // æåã¯ã¾ã¨ãã¦ã»ããåºæ¥ã simply.text({ title : 'Counter', subtitle : count, body : '' }); } }); // Pebble ã® API ã使ããï¼ããã§ã¯ navigator.geolocation ãå©ç¨ï¼ var drawWeather = function() { navigator.geolocation.getCurrentPosition(function(pos) { var coords = pos.coords; var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?' + 'lat=' + coords.latitude + '&lon=' + coords.longitude + '&units=metric'; // ajax ã¯ã°ãã¼ãã«ãªé¢æ° ajax({ url: weatherUrl, type: 'json' }, function(data) { simply.text({ title : data.name, subtitle : data.main.temp }); }); }); }; // é·æ¼ãã®ãã³ãã«ãå¯è½ simply.on('longClick', drawWeather); // require ã«ããå¤é¨ã¢ã¸ã¥ã¼ã«ã®èªã¿è¾¼ã¿ãå¯è½ // ï¼ãã ããCloudPebble ã® Simply.js ç°å¢ã§ã¯è¤æ°ãã¡ã¤ã«ã®ãã³ãã«ãä¸å¯ï¼ // simply.on('longClick', require('handler/longClick.js'));
å®è¡çµæ
ã¨ã¦ãç°¡åã§ãããAPI ã®è©³ç´°ãç¥ãããå ´å㯠API Document ãè¦ãã¨è©³ããæ¸ãã¦ããã¾ãã
å®è·µçãªã³ã¼ããã覧ã«ãªãããå ´åã¯ä»¥ä¸ã®ã¨ã³ããªãã¨ã¦ãåèã«ãªãã¨æãã¾ãã
oauth.js ãå©ç¨ã㦠OAuth èªè¨¼ã㦠Twitter ããå¤é¨ãµã¼ãã¹ã¨é£æºãããã¤ã¼ããæ稿ãããã®ã«ãªã£ã¦ãã¾ãã
ãããã«
Pebble ã¯ä½ã¬ãã« APIï¼CãPebble å´ï¼ã¨é«ã¬ãã« APIï¼JavaScriptãAndroid å´ï¼ã§åãåããããã¢ã¼ããã¯ãã£ã«ãªã£ã¦ãããæ´ã«ã¹ããå´ã®åãåãã¦è²ã
åºæ¥ããããï¼éç¥ãç»ååãªã©ï¼ãããªãé¢ç½ãè¨è¨ã«ãªã£ã¦ããã¨æãã¾ãããã®è¨è¨ã®æ¬ ç¹ã¯ C å´ã®ã³ã¼ããæ¸ãã®ãããªãé¢åã ã£ãç¹ã§ãå
¨é¨ JS ã§ããããè¯ãã®ã«...ã¨åãã¦ããã®ã§ããããã㯠Simply.js ã®å°å
¥ã«ãã£ã¦ããªã軽æ¸ãããã¨æãã¾ãï¼ããããå½¢ã§ã©ããã§ãã API è¨è¨ã«ãªã£ã¦ããã¨ãè¨ããããããã¾ããï¼ãæ´ã« CloudPebble ã«ãã£ã¦éçºãã¨ã¦ãç°¡åã«åºæ¥ãç¹ãç´ æ´ãããã§ããå¾ã¯ç»åç³»ã®è¡¨ç¤ºãç°¡åã« JS ããåºæ¥ãããã«ãªãã¨è¯ããªããã¨æãã¾ãã
ãã¾ã
ä¸ã§ã¡ãã£ã¨è§¦ãã¾ããããéç¥ã Android å´ã§ç»ååã㦠Pebble ã«éããã¨ã§ä»è¨èªåãå¯è½ã«ãã Pebble Plus Proãããããªã¹ã¹ã¡ãªã®ã§å°å ¥ããã¨ã¨ã¦ãæãã¾ãã
Pebble
- åºç社/ã¡ã¼ã«ã¼: Pebble
- ã¡ãã£ã¢: Wireless Phone Accessory
- ãã®ååãå«ãããã°ãè¦ã