圌ããã»ãŒãã¹ãŠã®åºãåã£ããšãããã®ãããªå®¶å ·ãèªåã§äœãã®ãæãç°¡åã§ããããšãæããã«ãªããŸããã 倧ããã ãã§ãªããæ£ã®æ©èœã䜿ã£ãŠåã ã®ãã®ãäœãããšãã§ããéšå±ã®ç©ºãã¹ããŒã¹ãç¯çŽã§ããŸãã
ç§ãã¡ãããããšããŠããããšã話ãåã£ãããã£ãŒã³ãšç§ã¯å¥ããŸããã圌女ã¯é»åãžã°ãœãŒããã©ã€ããŒããã³ãã§æŠè£ ããããžã¢ããåæ¿ã®æ®éªžãåãåºããŸããã ãããŠå°ãããŠãããRaspberry PIãšããã°ã©ãã³ã°ãæ§æããããã«åº§ã£ãã
ã€ã³ã¿ãŒãããã©ãžãªã®èšå®ãšãœãããŠã§ã¢ã®éçºã®ã¿ã«èå³ãããå Žåã¯ãé³æ¥œããŒã¢ã³ã䜿çšããbcm2835ã®å®å®ããåäœã®ç§å¯ã Apache Camelãããã³ãã®ããã®MPDã³ã³ããŒãã³ãã®éçºã«ã€ããŠèª¬æããŸãã
Nadineã¯ãæãè€éã§éªšã®æããéšå-倧工ä»äºãã¯ãã ä»ããèšçœ®ãè¡ããŸããã çŽ1æéç¶ããã¥ãŒããªã¢ã«ãã芧ã«ãªãããšããå§ãããŸãïŒ å®éã«ã¯ã3ã4æéåããŸãã
ãã¹ãŠã¯ãã¢ãã«ãŸãã¯ã¹ã±ããã52 x 52 cmã®åæ¿ã2ã€ã®18 x 52 cmã®é·æ¹åœ¢ã«ããŒã¯ããæ£æ¹åœ¢ã®ã·ãŒãããå§ãŸããŸãã æ®ãã®çŽ15x52cmã3çªç®ã®æ£ã§åœ¹ç«ã¡ãŸããã
ãžã°ãœãŒãããå Žåãã«ããã¯éåžžã«ç°¡åã§ãã
ãã¡ãããäžžéžãšçŽç·ã¬ã€ãã¯ãåæ¿ãããéããããåäžã«åæããã®ã«åœ¹ç«ã¡ãŸãããããã¯ã¯ãŒã¯ã·ã§ããã§ã®ã¿å¯èœã§ãã
ç¹°ãè¿ãã«ãªããŸãããå¬ã«ã¯å¡æã®çš®é¡ãéžæããããã®ãªãã·ã§ã³ã¯ããŸããããŸããã ãªãã³ã°ã«ãŒã ã®å¯ãå Žæã§ææ°ããããšã¯é£ãããããç¡èã®æ°Žæº¶æ§å¡æã®æ¹ãåªããŠããŸãã
ããžã³ã¯å¡æãç®ã§çè²ãããšã¡ã©ã«ãã®å¡æãçœãæ°ŽããŒã¹ã®ãšãã«ãžã§ã³ã§æªæããŸããã å®¶å ·ãå£ãé£ã³æ£ãããã«ãããã«ãªããªãããã«ããã«ã¯ããã©ãŒã ã¹ãã³ãžã§å®¶ãå¡ãã®ãè¯ãã§ãããã ããŒã©ãŒãŸãã¯ã¹ãã¬ãŒã¬ã³ã§å¡è£ ããå Žåããã¹ãŠã®å®¶å ·ãå£ãè¡£æãå¡æã«å«ãŸããŸãã
ããžã³ããŒã¹ã®æ¶²äœãã©ãã¯ã¹ã䜿çšããPOS-61ã¯ãã ã§é«ã¡ããããåã«ãããæ¥ç¹ã«é©çšããå ŽåãLEDã¹ããªãããã¯ãã ä»ãããããšã¯é£ãããããŸããã ããã¯ã©ã€ããæ©èœããããã«ã¯ãããŒãéã®GNDã+ 5Vé»æºã¯ã€ã€ã®æ¥µæ§ãæ··åããªãããšãéèŠã§ãã SP002Eã³ã³ãããŒã©ãŒã®åºåããDãšããŒã¯ãããåºåããã®å¶åŸ¡ä¿¡å·ã¯ãããŒãã®ãã³DïŒINïŒã«éä¿¡ãããŸãã
ããã¯ã©ã€ããšã¹ããŒã«ãŒã«é»åãäŸçµŠããããã«ãNadiaã¯USBã¹ããŒã«ãŒã¯ã€ã€ãŒã䜿çšããã³ã³ãããŒã©ãŒã®é»æºãã¯ãã ä»ãããŸããã USBãã¯ãŒãã¹ããŒã«ãŒã®å°å£²äŸ¡æ Œã¯çŽ400rã§ãã å°äœã絶çžããããã«ãç±åçž®ãã¥ãŒããšé»æ°ããŒãã䜿çšãããŸããã
æ£ãçµã¿ç«ãŠãããã«ãNadineã¯2çš®é¡ã®çãå ·ã䜿çšããŸãããã³ãŒããŒãåºå®ããæšããžãRaspberryãããã³æ£ã®LEDã¹ããªãããšã¹ããŒã«ãŒã§ãããã¡ã€ã«ãåºå®ããæ¥çã¬ã³ã§ãã å£ã«æããããšãããšãè§ã¯ãã匷ããã®ã«çœ®ãæããããŸããã
LEDç §æãšã¹ããŒããã¯ã»ã«RGBïŒWS2812BïŒ
å°å£²åºã§500rã®RGB LEDãããWS2812BãæèŒããLEDã¹ããªããã¯ã1ã¡ãŒãã«ããããŸããã
ã¯ãã ä»ãã¯é£ãããããŸãããã¯ããã¯ä¿¡å·ãªãã§3æ¬ã®ã¯ã€ã€ã®ã¿ã䜿çšãããŸãã ãã®ããŒãã¯ã³ã³ãããŒã©ãŒãªãã§ã¯æ©èœããªãããšã«æ³šæããŠãã ããã é»æºã«ã¯ãUSBã³ãã¯ã¿ãåãã5V 1Aé»æºãå¿ èŠã§ãã ãšããã§ãç§ãæã£ãŠããããŒãã®å¶åŸ¡ä¿¡å·ã«ã¯3.3Vã§ååã ã£ãã®ã§ãã¬ãã«ã³ã³ããŒã¿ãŒãªãã§ARMã³ã³ãããŒã©ãŒãGPIOã«æ¥ç¶ããããšãå¯èœã§ãã
Raspberry PI GPIOã䜿çšããŠWS2812B LEDã¹ããªãããå¶åŸ¡ã§ããŸããããªãŒãã£ãªããŒããšåãPWM SoCãžã§ãã¬ãŒã¿ãŒã䜿çšããããããçµã¿èŸŒã¿ã®ãªãŒãã£ãªåºåã§é³æ¥œãåçããéã«åé¡ãçºçããŸãã ãããã£ãŠããã®ãªãã·ã§ã³ã¯ã€ã³ã¿ãŒãããã©ãžãªã§ã¯æ©èœããªããããããã«ç Žæ£ãããŸããã
STM8 MKãæèŒããSP002E LEDã³ã³ãããŒã©ãŒã䜿çšãããšããã·ã¢ã®å°å£²åºã®270rã§ãã®ããŒãã管çããæ¹ãç°¡åã§ãã ãã¯ã»ã«å€ãéä¿¡ããããã®USBæ¥ç¶ã䜿çšããŠãSTM32ã¹ããã¯ãããã®ããŒãçšã®ã³ã³ãããŒã©ãŒãçµã¿ç«ãŠãããšããã®ã¯èå³æ·±ãã§ãããã githubã§ããã€ãã®ã©ã€ãã©ãªãããžã§ã¯ããèŠã€ããŸããã 軜ãé³æ¥œãäœããšããã¢ã€ãã¢ããããŸã-TODOãªã¹ãã«æžã蟌ã¿ãŸãã
ã€ã³ã¿ãŒãããã©ãžãªãã€ã³ã¹ããŒã«ããŠæ§æãã
ãªã¢ãŒãé³æ¥œåçã®ããã€ãã®ãªãã·ã§ã³ãæ€èšã§ããŸãã
- Bluetooth A2DP-ããã¯ãBluetoothã¹ããŒã«ãŒã«å®è£ ãããŠãããã®ã§ãé³ã®å§çž®ã倱ãããŸãã Raspberry PIã¯åã«ããªã¢ãŒããã¹ããŒã«ãŒã«å€ãããé³æ¥œã¯å¥ã®ããã€ã¹ãããã¹ããªãŒãã³ã°ãããå¿ èŠãããããããã®ãªãã·ã§ã³ã¯é©åããŸããã§ããã
- ãããã¯ãŒã¯çµç±ã®PulseAudio-ã¢ãããŒãã¯A2DPã«äŒŒãŠããŸããã module-native-protocol-tcpãšã¯ã©ã€ã¢ã³ãã®æ§æãå¿ èŠã§ãã
- ãã¥ãŒãžãã¯ãã¬ãŒã€ãŒããŒã¢ã³ïŒMPDïŒ-ã€ã³ã¿ãŒãããã©ãžãªãŸãã¯ããŒã«ã«ãã£ã¹ã¯/ NASããã®ãã¬ã€ãªã¹ãã®ãªãã©ã€ã³åçã«æé©ã§ãã
ã¹ã¿ã³ãã¢ãã³ã®ã€ã³ã¿ãŒãããã©ãžãªãå¿ èŠãªã®ã§ãéžæã¯MPDã§ãïŒ MPDã®ãã©ãã¯ãå€æŽããMPD Controlãªã©ã®Androidã¯ã©ã€ã¢ã³ãããããã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ãŸãã¯Webã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããŠããã¬ã€ãªã¹ããšããªã¥ãŒã ã管çã§ããŸãã
bcm2835ããã³GPIOæ©èœããã³PWMã³ã³ãããŒã©ãŒãšã®ç«¶åã«ã€ããŠè¿°ã¹ãããã«ãããã¯ããªããã€ãºãå€ãåé¡ã®å€ããµãŠã³ãããã€ã¹ã§ãã å¯äžã®å©ç¹ã¯ãå èµãããŠããããšãšãRaspberryã«å¹æµããUSBââãªãŒãã£ãªãè³Œå ¥ããå¿ èŠããªãããšã§ãã
Mixer_typeãmixer_deviceãmixer_controlãmixer_indexãèšå®ããå¿ èŠããããŸãã ãããè¡ãããåã«ããã©ãã¯ãåãæ¿ãããšãã«ããŒã¢ã³ããã³ã°ããããã»ã¹ãåèµ·åããå¿ èŠããããŸããã
ã«ãŒããšããŠRaspbianã«ã€ã³ã¹ããŒã«ãå®è¡ãããŸããã
ã³ãã³ããå®è¡ããŸãïŒ
apt-get install mpd
çµ±åãããRaspberry PI 3ãªãŒãã£ãªãæ©èœãããã«ã¯ã/ etc / mpd.confæ§æã«ãã©ã¡ãŒã¿ãŒãè¿œå ããå¿ èŠããããŸãã
audio_output { type "alsa" name "My ALSA Device" device "hw:0,0" # optional mixer_type "software" # optional mixer_device "default" # optional mixer_control "PCM" # optional mixer_index "0" # optional } bind_to_address "192.168.1.68" port "6600" auto_update "yes"
ã192.168.1.68ãã¯ãããŒã«ã«ãããã¯ãŒã¯äžã®Raspberyã¢ãã¬ã¹ã§ãã
camel-mpdããã®é³æ¥œã®ç®¡çïŒApache Camelã®ã³ã³ããŒãã³ãéçº
JavaãšJVMã¯ãIoTã²ãŒããŠã§ã€äžã®ãã¢ãã®ã€ã³ã¿ãŒãããããèªååããããã®éåžžã«äžè¬çãªãã©ãããã©ãŒã ã§ãã ãããã£ãŠãCamelã®MPDã³ã³ããŒãã³ãã®éçºã«ãããé³æ¥œç®¡çãæ¢åã®èªååãœãããŠã§ã¢ã«çµ±åãããŸãã ãããŠãã¡ããã å·èµåº«ã®ç§ã®ãæ°ã«å ¥ãã®ã¢ã©ãŒã 㧠ïŒ
Apache Camelã®æ©èœãšæ©èœã«èå³ããã人ã®ããã«...
- Apache Camelã¯ã Eclipse SmartHomeãšKuraã§ããŸãæ©èœããŸã
- OpenHub2ã¯Eclipse SmartHomeã©ã³ã¿ã€ã ã§å®è¡ãããŸãã
- ã ããã°ã©ãã³ã°ã¹ãã«ãã»ãšãã©ãªãèªååçšã¢ããªã±ãŒã·ã§ã³ã®éçºæ¹æ³ã ã IoTã²ãŒããŠã§ã€çšã®ãœãããŠã§ã¢éçºã«ã€ããŠã§ãã
ã³ã³ããŒãã³ãã³ãŒãã¯camel-mpdãªããžããªgithubã§ãã¢ãŒãã£ãã¡ã¯ãcom.github.igor-suhorukovïŒ camel-mpd ïŒ1.0ãäžå€®ã®Mavenãªããžããªã«ãããŸãã Music Player Daemonãããã³ã«ã䜿çšããããã«ãnet.thejavashopã©ã€ãã©ãªjavampd ïŒ6.0.0ãéžæããŸããã ã³ãããããå€æãããšããã®ã©ã€ãã©ãªã¯éç解æã®ã¡ããªãã¯ããå€æããŠãåªããã³ãŒãå質ã§ãµããŒããããŠããŸãïŒ ç§ã®ä»äºã®äžéšã¯ãã©ã¯ãã³ã³ããŒãã³ãããšã³ããã€ã³ããããã³ãããã¥ãŒãµãŒãšã³ã³ã·ã¥ãŒããŒã®åå«ã®äœæã§ãã
Camelã¢ãŒããã¯ãã£ã«ã€ããŠäžèš
ã³ã³ããŒãã³ãã¯ãšã³ããã€ã³ããã¡ã¯ããªã§ãããã³ã³ããŒãã³ãã«ã¯ãããã³ã«/ã¹ããŒã ãé¢é£ä»ããããŠããŸãã Camelã®ã»ãšãã©ãã¹ãŠãUniversal Resource Identifierã§ãã äŸïŒhttpãhdfsãsmtpsãircãwebcamã ä»ã mpd ïŒ
ã³ã³ããŒãã³ãã¯ãããŒã¿ãå€æããããã®ã«ãŒãã«çµåãããŸãã ã«ãŒãã¯ã䜿çšå¯èœãªãã¡ã€ã³åºæèšèªïŒDSLïŒã®1ã€ã§èšè¿°ãããŸãïŒjavaãscalaãgroovyãspring / blueprint xml
ã«ãŒãã¯ãããšãã°
hawt.ioã³ã³ãœãŒã«ã
DSLã®æ¶è²»è ã¯ãã«ãŒãã®å é ã«ãããfromãæ§æäœã§ãã
DSLã®ãããã¥ãŒãµãŒã¯ "to"ã³ã³ã¹ãã©ã¯ãã§ã
Exchangeã¯ãã«ãŒãã«ãã£ãŠäœæããã³åŠçãããã¡ãã»ãŒãžã§ãã ã¡ãã»ãŒãžã®æ¬æïŒæ¬æïŒãšããããŒïŒããããŒïŒãå«ãŸããŸãã
mavenã䜿çšããŠãApacheã®ã©ã¯ãã³ã³ããŒãã³ããã¢ãã¯ã¢ããã§ããŸãã
mvn archetype:generate \ -DarchetypeGroupId=org.apache.camel.archetypes \ -DarchetypeArtifactId=camel-archetype-component \ -DarchetypeVersion=2.20.2 \ -DgroupId=myGroupId \ -DartifactId=myArtifactId
Apache Camelã³ã³ããã¹ãããããã³ã«ã§ã³ã³ããŒãã³ããèŠã€ããããšãã§ããããã«ããã«ã¯ãsrc / main / resources / META-INF / services / org / apache / camel / component / mpdãã¡ã€ã«ã§ã³ã³ããŒãã³ãã¯ã©ã¹ãæå®ããå¿ èŠããããŸã
class = com.github.igorsuhorukov.mpd.MpdClientComponent
MpdClientComponentã¯ã©ã¹ã¯ãã¡ã¯ããªãŒã§ã-com.github.igorsuhorukov.mpd.MpdEndpointã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãäœæããã³åæåããŸãã ã«ãŒãããã®èŠæ±ã«å¿ããŠMpdEndpointã¯Consumerã®ã€ã³ã¹ã¿ã³ã¹ãäœæãããã®ã¡ãã»ãŒãžã¯ã³ã³ããŒãã³ãã«ãã£ãŠRouteã«éä¿¡ãããŸãã æ¶è²»è ã¯ã«ãŒãã®å€ãè¿ããŸãã
- volume-çŸåšã®ããªã¥ãŒã å€ãç¯å²ã¯[0,100]ã§ãã
- currentã¯ãçŸåšã®æ²ã«é¢ããæ å ±ãè¿ããŸãã
- ãã¬ã€ãªã¹ãã¯ããªã¹ããšããŠãã¬ã€ãªã¹ããè¿ããŸãã
- total-ãã¬ã€ãªã¹ãããã®é³æ¥œã®åèšæéã
- çµé-æéå ã«ã©ãã ãèŽåããããã
- ãšã©ãŒã¡ãã»ãŒãžãæåŸã®ãšã©ãŒãçºçããŸããã
ãããã¥ãŒãµãŒ-Camelã®ã³ã³ããã¹ãã§RouteãçµäºããMPDã³ãã³ãã®çºè¡ãèš±å¯ããŸãã
- play-åçãéå§ããŸãã
- stop-åçãåæ¢ããŸãã
- next-次ã®æ²ãéžæããŸãã
- previous-åã®æ²ãéå§ããŸãã
- ã©ã³ãã å-次ã®æ²ãžã®é·ç§»ãã©ã³ãã ãªé åºã§ã¢ã¯ãã£ãã«ããŸãã
- unrandomize-ãã¬ã€ãªã¹ãã®é 次åçãæå¹ã«ããŸãã
- volume-åçããªã¥ãŒã ã0ã100ã®ç¯å²ã§èšå®ããŸã
- æ-ãã¬ã€ãªã¹ãã«æ²ã®ãªã¹ããè¿œå ã§ããŸãã ãããŠãããã¯ãã¡ã€ã«ã·ã¹ãã ã®ãã¹ããhttpãããã³ã«ã䜿çšããã€ã³ã¿ãŒãããã©ãžãªã§ãã ãã®é¢æ°ã®ã¡ãã»ãŒãžæ¬æã¯ãæååãŸãã¯org.bff.javampd.song.MPDSongãªããžã§ã¯ãã®ããããã§ãã å¥ã®ãªãã·ã§ã³ã¯ãæååã®ãªã¹ããŸãã¯MPDSongãªããžã§ã¯ãã®ãªã¹ãã§ãã
camel-url-handlerãããžã§ã¯ãã®java.net.URLãšã®çµ±åã«ããããã®ã³ã³ããŒãã³ããæäœããããšãå¯èœã«ãªããŸãã
ç§ãã©ã¯ãmpdãããã°ã©ãã³ã°ãããããªãç·šéããŠããéãããã£ãŒã³ã¯æ¢ãããããèªåãããããµã€ãã®ããŒãã«ã«ããŸããã
åç
ããããæé€æ©ã®é¡äŒŒç©ãäœãã®ã¯ããããšã ãšåè«ãèšã£ãã®ã§ã æ°ããããããµã€ãããŒãã«ã¯ã圌女ã®å®¶ã«è±å¯ã«ããã圌女ã®éŠ¬ã®ããã¹ã¿ã€ã«ã§åäœãããã¡ããªãã¯ã§ã®ã¿èŠãããšãã§ããŸãã
ã»ãŒããããŒãšã³ã
çªæ ãšåºã®éã®éå£éšãææ¿çšããããªãŒã®é£ã«ãã©ã€ãä»ãã®æ£ãèšçœ®ãããŸããã ã€ã³ã¿ãŒãããã©ãžãªã¯ããã¯ã°ã©ãŠã³ãã§åäœããã©ã€ããå ããç«ã¯å¹žãã§ã-ããŒãã«ãèµ°ãåãäœå°ããããŸãã ããŒãã«ããã®ãã®ãæ£ã«ãªããŸããã ãããŠãç§ã¯ãŸã 3æ8æ¥ã®èŽãç©ãæãã€ããŸããã§ãããããã£ãŒã³ã¯ã»ãšãã©ãã¹ãŠãèªåã§ããŸãã...