Giter Club home page Giter Club logo

zeemote-sample's Introduction

== Zeemote + WebSocket + WebGL(three.js) ==

edy555 _at_ gmail.com
2/13/2012

* 概要

Zeemote, WebSocket, three.jsを使ったサンプルです。
MacBook Proで動作します。その他のプラットフォームの場合は、
Bluetoothとの接続部分に改造が必要だと思います。

Zeemote(ジョイスティックモード)はプロファイルとしてSPPを持ったBluetooth
デバイスです。Zeemoteを操作すると、バイナリメッセージを送ってきます。
メッセージフォーマットはシンプルですので、これをRuby+EventMachine
によるサーバにより解釈して、WebSocketのメッセージとして送信します。
ブラウザでは、WebGL+Three.jsによりモデルを表示し、スティック操作で
動くようにしてみました。


* 準備

$ gem install eventmachine
$ gem install em-websocket


* ペアリング

ZeemoteのDボタン(親指)を長押しして電源を入れる(LEDが点滅する)
Set Up Bluetooth Device... からBluetooth Setup Assistantを
開き、"Zeemote JS1 H"を選択してペアリングする。
ペアリングが完了すると、/dev/tty.ZeemoteJS1H-ZeemoteSPP という
デバイスノードが作られているはずです。
もしZeemoteが別のモード(キーボードもしくはマウスモード)になっている
場合は、電源を入れる際にCボタンを押しながら、Dボタンを長押ししてください。
詳しくは取り扱い説明書を参照してください。


* サーバを起動する

$ ruby ./server.rb

Zeemoteとの接続が確立すると、スティックやボタンを操作するとメッセージが
流れていきます。
Zeemoteの電源が切れている場合、エラーが発生するので、LEDの点滅を確認すること。


* ページを開く

Chromeでindex.htmlを開くとトーラスが表示されます。
WebSocketサーバとの接続が成功している場合は、サーバ側に"connected"と
表示され、Zeemoteのスティック操作で角度がぐりぐり変化します。


* 注意

BluetoothならびにWebSocketの再接続を実装していないので、Zeemoteの電源、
サーバの起動、ページの表示(リロード)の順序で行う必要があります。


* 参考

Zeemote JS1 H 取扱説明書
http://www.aplix.co.jp/zeemote/jp/js1h/Zeemote-JS1H-manual-JP.pdf

#devfestxj「WebGL & three.js 最新の話題 ライブラリ紹介」講演スライド
http://webos-goodies.jp/attachments/devfestx_sapporo_2012_webgl

橋本商会 EventMachine::WebSocketでチャットを作る
http://shokai.org/blog/archives/5434

EOF

zeemote-sample's People

Contributors

edy555 avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.