PimoroniããpHATãä¸ç¨®è²·ã£ã。
pHATã¨ããã®ã¯Pimoroniãä½ã£ã¦ããRaspberryPiç¨ã®æ¡å¼µãã¼ãã§ä»åè²·ã£ãã®ã¯Raspberry Pi Zeroã®ãµã¤ãºã«ã´ã£ããã®ãã®。è£
çããã¨ã¡ããã©RpiZeroã®ãã¼ãã¨åããµã¤ãºã§éãªããããªæã。
è²·ã£ãã®ã¯ã¹ãã¼ã«ã¼æ¡å¼µã®Sperker pHATã¨、LEDãããªã¯ã¹ã®Scroll pHAT HD、ã«ã©ã¼LEDãããªã¯ã¹ã®Unicorn pHAT。ã©ã®ã¢ã¸ã¥ã¼ã«ãPythonã®ã©ã¤ãã©ãªãå
¬éããã¦ãã¦、ã¡ããã£ã¨ä½¿ããªãç°¡åãã。
Pimoroniã¯éæãå®ãã¦、å±ãã®ãä¸é±éç¨åº¦ãªã®ã§ä½¿ããããã§ã。
ã¹ã¤ãããµã¤ã¨ã³ã¹ã§è²·ã£ã¦ãããã¾ã§ã®å¤æ®µã®å·®ããªãã®ã§、ã±ãããªããªããã£ã¡ã§ãè¯ããããããªã。
2017å¹´6æ28æ¥æ°´ææ¥
2017å¹´6æ13æ¥ç«ææ¥
ããã°ããªã
ä»äºã§ããã°ã©ã ãæ¸ãã¨ã、ãããããã£ãã、大ãããªããããªç®æã«å·®ãæããã¨、ã¨ã«ãã「ãã£ãããã、ãã£ãããã、ããã°ããªã、ããã°ããªã」ã¨å¿µãã¦æ¸ãã¦ã。ããããã¨éä¸åã®éåããã¾ã§ã®æéãå¤å°ã¯ä¼¸ã³ã。ãã£ãããããã¨æã£ãã¨ããã§、ãã»ã©æã®é度ãè½ã¡ãããã§ããªãã、ãã¼ã¿ã«æ©ãã楽ã«ãªã。ãããªæ°ããã。ã©ã¤ãããã¯。
2017å¹´6æ7æ¥æ°´ææ¥
npm-run-scriptå®è¡æã«windowsã¨linuxã§çµ±ä¸çã«ç°å¢å¤æ°ãæ±ã
Node.jsã§ããã°ã©ã éçºæãªããã«npm run scriptãå©ç¨ãããã¨ããããã。ã§、éçºä¸ãªã®ã§ãããã°ç¨ã®å¼æ°ã¨ãç°å¢å¤æ°ãªããã渡ãã¦å®è¡ãããã¨ãããã®ã ãã©、ããã¯ãã ã®ã³ãã³ããªã®ã§ç°å¢å¤æ°ã®æå®ã®ä»æ¹ã¯OSã«ä¾åããæ¸ãæ¹ã«ãªã。
Windowsã®cmd.exeãªãset hoge=fuga&& node index.jsã¿ãããªæãã«ãªãã、Linuxç³»ã®shã®å ´åã¯hoge=fuga node index.jsã¨ããæ¸ãæ¹ã«ãªã。PowerShellã®å ´åã¾ãéãã¯ãã ãã©ããç¥ããªã。
ã§、å®å ¨ã«å®è¡ãéçºç°å¢ãåOSã§åºå®ããã¦ããã°ãªãã®åé¡ããªãã®ã ãã©、ãããããªãã¨ãããã。ä¾ãã°、ã¯ã©ã¤ã¢ã³ãã¨ãµã¼ãã¼ãWindowsã¨Linuxã§、åãã¹ã¯ãªãããå©ç¨ããã¨ãããããªã¨ãããã。ãã¡ãã、OSãã¨ã«scriptsã«æ¸ãã¦ãè¯ããã ãã©、é¢åããã。ã§、調ã¹ã¦ã¿ãã¨cross-envã¨ããããã±ã¼ã¸ã使ãã®ãå®çªããã。
https://www.npmjs.com/package/cross-env
scriptã®é ã«cross-envãèªãã§、ãã¨ã¯shã¨åãæ¸ãæ¹ã§è¨å®ããã°、OSåããç°å¢å¤æ°ãè¨å®ãã¦ãããããã«ãªã。ã¤ã¾ã、"cross-env hoge=fuga node index.js"ã¨ããã°ãã¨ã¯cmd.exeä¸ã§ãåé¡ãªãç°å¢å¤æ°ã«è¨å®ãã¦ããã。便å©。
Windowsã®cmd.exeãªãset hoge=fuga&& node index.jsã¿ãããªæãã«ãªãã、Linuxç³»ã®shã®å ´åã¯hoge=fuga node index.jsã¨ããæ¸ãæ¹ã«ãªã。PowerShellã®å ´åã¾ãéãã¯ãã ãã©ããç¥ããªã。
ã§、å®å ¨ã«å®è¡ãéçºç°å¢ãåOSã§åºå®ããã¦ããã°ãªãã®åé¡ããªãã®ã ãã©、ãããããªãã¨ãããã。ä¾ãã°、ã¯ã©ã¤ã¢ã³ãã¨ãµã¼ãã¼ãWindowsã¨Linuxã§、åãã¹ã¯ãªãããå©ç¨ããã¨ãããããªã¨ãããã。ãã¡ãã、OSãã¨ã«scriptsã«æ¸ãã¦ãè¯ããã ãã©、é¢åããã。ã§、調ã¹ã¦ã¿ãã¨cross-envã¨ããããã±ã¼ã¸ã使ãã®ãå®çªããã。
https://www.npmjs.com/package/cross-env
scriptã®é ã«cross-envãèªãã§、ãã¨ã¯shã¨åãæ¸ãæ¹ã§è¨å®ããã°、OSåããç°å¢å¤æ°ãè¨å®ãã¦ãããããã«ãªã。ã¤ã¾ã、"cross-env hoge=fuga node index.js"ã¨ããã°ãã¨ã¯cmd.exeä¸ã§ãåé¡ãªãç°å¢å¤æ°ã«è¨å®ãã¦ããã。便å©。
2017å¹´6æ6æ¥ç«ææ¥
Node.jsãã¤ãã£ãã®asyncã¨await
Node.jsã®v7.6ããasync awaitã使ããããã«ãªã£ã。ããã¯éåæå¦çã®å¯èªæ§ãåä¸ãããããã®æ©è½ã§、asyncã§å®£è¨ããé¢æ°ã¯ãã¹ã¦ã®æ»ãå¤ãPromiseã¨ãã¦è¿ãããããã«ãªã。ã¤ã¾ã、
ã¿ãããªæãã«ãªã。ããã¯ãã®é¢æ°ãéåæã ã¨ãã宣è¨ã ããã ãã©、ããå ·ä½çãªå©ä¾¿æ§ã®åä¸ã¨ãã¦ã¯、asyncé¢æ°å ã§ã¯awaitãå©ç¨ã§ããã¨ãããã¨ããã。awaitã¯ä»ã®éåæã®é¢æ°(Promiseãè¿ããã®。asyncé¢æ°ãããªãã¦ãè¯ã)ãåæçãªå¦çã®ããã«å¾ ã¡åãã§ããã¨ãããã¨ã«ãã。
awaitãå¾ ã¤ã¨ã¯ãã、ããã¯async宣è¨ããããéåæå¦çå ãªã®ã§å¦çããããã¯ãããã¨ãããã¨ã§ã¯ãªã。é åºãã©ããã«å¦çãå¼ã³åºãããã¨ããã ãã§ãã(Promiseããã§ã¤ã³ããããã«æ¸ããã¨ãã¨åãããã«)。
ã¡ãªã¿ã«awaitã§å®£è¨ããå ´å、resolveã«æ¸¡ããããã®ã¯ãã®ã¾ã¾æ»ãå¤ã«ãªã、rejectããããã®ã¯ä¾å¤ã¨ãã¦æãããã。ãã®ããrejectãããå¯è½æ§ãããå ´åã¯try,catchã§å¦çããªããã°ãªããªã。
ãã¨æå¤ã¨å¿ããã¡ãªã®ã、awaitã使ãã¨ãã¯、ãããç´æ¥å«ã¾ããé¢æ°ãasyncã§ã¯ãªããã°ãªããªãã¨ãããã¨。ããã¯ã¢ãã¼é¢æ°ãå«ã¾ããã®ã§、forEachã¨ãmapã¨ãã«callbackã渡ãã¦ä½¿ã£ãã¨ãã«å¿ããã¡。
ã¡ãªã¿ã«ä¸è¨ã®å¦çã®å ´å、listå ã®è¦ç´ ã¸ã®å¦çãé çªã«å®è¡ãããã¨ããä¿è¨¼ã¯ãªã。(åè¦ç´ eã«a,bã®é çªã§å¼ã³åºããããã¨ã¯ä¿è¨¼ããã¦ã)。ãã®å ´åã ã¨listã®åè¦ç´ ã¸ã®å¦çé åºãå®ãããå ´åã¯、æ®éã«foræã使ã£ã¦å¦çããã®ãæã£åãæ©ã。
async function hoge(){ return 1; //return Promise.resolve(1)ã¨åã }
ã¿ãããªæãã«ãªã。ããã¯ãã®é¢æ°ãéåæã ã¨ãã宣è¨ã ããã ãã©、ããå ·ä½çãªå©ä¾¿æ§ã®åä¸ã¨ãã¦ã¯、asyncé¢æ°å ã§ã¯awaitãå©ç¨ã§ããã¨ãããã¨ããã。awaitã¯ä»ã®éåæã®é¢æ°(Promiseãè¿ããã®。asyncé¢æ°ãããªãã¦ãè¯ã)ãåæçãªå¦çã®ããã«å¾ ã¡åãã§ããã¨ãããã¨ã«ãã。
async function hoge(){ const result = await fuga();//promiseãè¿ãéåæã®å¦ç return hogefuga(result);//fugaãpromiseã解決ãã¦ããå¦çããã }
awaitãå¾ ã¤ã¨ã¯ãã、ããã¯async宣è¨ããããéåæå¦çå ãªã®ã§å¦çããããã¯ãããã¨ãããã¨ã§ã¯ãªã。é åºãã©ããã«å¦çãå¼ã³åºãããã¨ããã ãã§ãã(Promiseããã§ã¤ã³ããããã«æ¸ããã¨ãã¨åãããã«)。
ã¡ãªã¿ã«awaitã§å®£è¨ããå ´å、resolveã«æ¸¡ããããã®ã¯ãã®ã¾ã¾æ»ãå¤ã«ãªã、rejectããããã®ã¯ä¾å¤ã¨ãã¦æãããã。ãã®ããrejectãããå¯è½æ§ãããå ´åã¯try,catchã§å¦çããªããã°ãªããªã。
ãã¨æå¤ã¨å¿ããã¡ãªã®ã、awaitã使ãã¨ãã¯、ãããç´æ¥å«ã¾ããé¢æ°ãasyncã§ã¯ãªããã°ãªããªãã¨ãããã¨。ããã¯ã¢ãã¼é¢æ°ãå«ã¾ããã®ã§、forEachã¨ãmapã¨ãã«callbackã渡ãã¦ä½¿ã£ãã¨ãã«å¿ããã¡。
function hoge(list){ list.forEach(async (e)=>{ // ← ãããã¡ããã¨asyncã«ãªã£ã¦ããå¿ è¦ããã await a(e); await b(e); }); }
ã¡ãªã¿ã«ä¸è¨ã®å¦çã®å ´å、listå ã®è¦ç´ ã¸ã®å¦çãé çªã«å®è¡ãããã¨ããä¿è¨¼ã¯ãªã。(åè¦ç´ eã«a,bã®é çªã§å¼ã³åºããããã¨ã¯ä¿è¨¼ããã¦ã)。ãã®å ´åã ã¨listã®åè¦ç´ ã¸ã®å¦çé åºãå®ãããå ´åã¯、æ®éã«foræã使ã£ã¦å¦çããã®ãæã£åãæ©ã。
2017å¹´6æ4æ¥æ¥ææ¥
æ¯åã¨å調æ§ã¨èªå
å観æ¥ãªã©ã§è¦ãã、妻ã®è©±ãèãéã、æ¯åã¯å調æ§ã«æ¬ ã、å
çã®è©±ãèãã¦ãªã。ããã¯åé¡ããªã¨èãã¦ã¿ãã、æ¯ãè¿ã£ã¦è¦ãã«èªåãå®å
¨ã«ããã§ãã£ã。ã¨ããã、å観æ¥ã§å
çãæè²æ¹éãã©ãã®ã¨ã説æãå§ããç¬é、ãããéå±ã«ãªã£ã¦ç ãå§ãããããã、親御ããæ¹ã並ãã§æ··éãã¦ããããã¨ããè¯ããã¨æã£ã¦é©å½ã«å¤ãã¦åº§ã£ã¦ããããã、ä»ç¾å¨ã§ãå®å
¨ã«ãã®ã¾ã¾ã§ãã。
ããã ã¨ããã¨、å¥ã«è¯ãã®ã ãããªã¨æã。
å¤ããããã¨åé¡ãªã®ãããããªãã、èªåã§å«ã ã£ããã¨ã¯ãªãã、ç§ã®ä¸¡è¦ªãããã「ãµã¤ã」ã«ç´ããã¨ã¯ããªãã£ã。ãããå調æ§ãå ±æã®å¿ è¦ãªè·æ¥ã«ã¯åããªãã®ã§、ä¸äººã§ãªãã§ãåºæ¥ãããã«、ç¬å¦ã§ç©äºãç¿å¾ããæ¹æ³ã¨ãã¯ãã¾ãä¼ãã¦ãããªããã°ã¨æã。
ããã ã¨ããã¨、å¥ã«è¯ãã®ã ãããªã¨æã。
å¤ããããã¨åé¡ãªã®ãããããªãã、èªåã§å«ã ã£ããã¨ã¯ãªãã、ç§ã®ä¸¡è¦ªãããã「ãµã¤ã」ã«ç´ããã¨ã¯ããªãã£ã。ãããå調æ§ãå ±æã®å¿ è¦ãªè·æ¥ã«ã¯åããªãã®ã§、ä¸äººã§ãªãã§ãåºæ¥ãããã«、ç¬å¦ã§ç©äºãç¿å¾ããæ¹æ³ã¨ãã¯ãã¾ãä¼ãã¦ãããªããã°ã¨æã。
2017å¹´6æ3æ¥åææ¥
electronã§Windowsåãã«exeä½ã
electron-packagerã¨electron-builderããããã ãã©、builderã®ãè¯ãã¨ã®ãã¨。
https://stackoverflow.com/questions/37113815/electron-builder-vs-electron-packager
ãã«ãã®ããã®ãªãã·ã§ã³ã¯package.jsonã®buildããããã£ä¸ã«è¨å®ãã。
installerè¦ããªãå ´å、targetãportableã«ããã°è¯ã。targetèªä½ã¯OSã«ãã£ã¦éãã®ã§、å®éã«ã¯、"win":{"target":"portable"}ã¿ããã«è¨å®ãã。
ã¿ã¹ã¯ãã¬ã¤ã®ã¢ã¤ã³ã³ã¨ã、èªã¿è¾¼ããã¡ã¤ã«ã追å ããã®ã¯extraFilesã§æå®ããã¨è¯ããã。ã¡ãªã¿ã«ãã©ã«ãå ã«ããå ´åã¯ãã®ã¾ã¾ãã©ã«ããã³ãã¼ããã。extraResourcesã ã¨resourcesãã©ã«ãã«ã³ãã¼ããããã ãã©、ãã®ãããã®ä½¿ãåããã¾ã è¯ãããã£ã¦ãªã。resourcesãã©ã«ãã ãã¯ä½ãããã®æ¹æ³ã§ããã£ã¨èªã¿è¾¼ããããããããããããªããã¨æã。
https://stackoverflow.com/questions/37113815/electron-builder-vs-electron-packager
ãã«ãã®ããã®ãªãã·ã§ã³ã¯package.jsonã®buildããããã£ä¸ã«è¨å®ãã。
installerè¦ããªãå ´å、targetãportableã«ããã°è¯ã。targetèªä½ã¯OSã«ãã£ã¦éãã®ã§、å®éã«ã¯、"win":{"target":"portable"}ã¿ããã«è¨å®ãã。
ã¿ã¹ã¯ãã¬ã¤ã®ã¢ã¤ã³ã³ã¨ã、èªã¿è¾¼ããã¡ã¤ã«ã追å ããã®ã¯extraFilesã§æå®ããã¨è¯ããã。ã¡ãªã¿ã«ãã©ã«ãå ã«ããå ´åã¯ãã®ã¾ã¾ãã©ã«ããã³ãã¼ããã。extraResourcesã ã¨resourcesãã©ã«ãã«ã³ãã¼ããããã ãã©、ãã®ãããã®ä½¿ãåããã¾ã è¯ãããã£ã¦ãªã。resourcesãã©ã«ãã ãã¯ä½ãããã®æ¹æ³ã§ããã£ã¨èªã¿è¾¼ããããããããããããªããã¨æã。
2017å¹´6æ1æ¥æ¨ææ¥
webpackã§electronã®ã¬ã³ãã©ããã»ã¹ã®jsããã«ããã
Vue.jsã§electronã®ã¢ããªæ¸ããã¨æã£ããã ãã©、åä¸ãã¡ã¤ã«ã³ã³ãã¼ãã³ãã¨ã使ã£ã¦、webpackã§ãã«ããããã¨ããã¨、å½ç¶ãã¾ããããªã。ã³ã³ãã¼ãã³ãå
ã®requireã¯webpackã«è§£æ±ºããã¦ãã¾ãã®ã§、ipcã¨ãrequireãããã¨ããã¨ã¨ã©ã¼ã«ãªã£ã¦ãã¾ã。
ã§、webpackå ¬å¼ããã¥ã¡ã³ããçºãã¦ããæ¸ãã¦ãã£ã。
https://webpack.github.io/docs/configuration.html#target
webpack.config.jsã®targetã«electronãè¨å®ãããããã¨ã®ãã¨。
ã§、webpackå ¬å¼ããã¥ã¡ã³ããçºãã¦ããæ¸ãã¦ãã£ã。
https://webpack.github.io/docs/configuration.html#target
webpack.config.jsã®targetã«electronãè¨å®ãããããã¨ã®ãã¨。
ç»é²:
æ稿 (Atom)