GithubHelp home page GithubHelp logo

myolib's Introduction

This is an Android library to communicate with Myo devices.

It was created for a research project at the mHealth - Uniklinik RWTH Aachen deparment. The projected required receiving sensor data (Gyro, Accl., EMG) from multiple Myo devices simultaneously, which was not possible at that time (August 2015) through the official Android SDK for Myo from Thalmic Labs.

Contributions are welcome. If you submit pull-requests please adhere to the projects current coding style. If you are using this library, i would love mention your project here, feel free to contact me.

Setup

Include this in your apps build.gradle file:

compile 'eu.darken.myolib:myolib:0.0.4'

Download

Examples

Utilizing callbacks

MyoConnector connector = new MyoConnector(getContext());
connector.scan(5000, new MyoConnector.ScannerCallback() {
    @Override
    public void onScanFinished(List<Myo> myos) {
        Myo myo = myos.get(0);
        myo.connect();
        myo.writeUnlock(MyoCmds.UnlockType.HOLD, new Myo.MyoCommandCallback() {
            @Override
            public void onCommandDone(Myo myo, MyoMsg msg) {
                myo.writeVibrate(MyoCmds.VibrateType.LONG, null);
            }
        });
    }
});

Receiving sensor data

/**
 * ...
 */
Myo myo = myos.get(0);
myo.connect();
EmgProcessor emgProcessor = new EmgProcessor();
myo.addProcessor(emgProcessor);
emgProcessor.addListener(new EmgProcessor.EmgDataListener() {
    @Override
    public void onNewEmgData(EmgData emgData) {
        Log.i("EMG-Data", Arrays.toString(emgData.getData()));
    }
});

Advanced use

BaseMyo baseMyo = new BaseMyo(getContext(), bluetoothDevice);
baseMyo.connect();
ReadMsg readMsg = new ReadMsg(Battery.BATTERYLEVEL, new MyoMsg.Callback() {
    @Override
    public void onResult(MyoMsg msg) {
        byte[] result = ((ReadMsg) msg).getValue();
    }
});
baseMyo.submit(readMsg);

Advanced advanced use

BaseMyo baseMyo = new BaseMyo(getContext(), bluetoothDevice);
baseMyo.connect();
WriteMsg writeMsg = new WriteMsg(
        UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"),
        UUID.fromString("00002A00-0000-1000-8000-00805f9b34fb"),
        null,
        new byte[]{ /*....*/},
        new MyoMsg.Callback() {
            @Override
            public void onResult(MyoMsg msg) {
                if(msg.getGattStatus() == BluetoothGatt.GATT_SUCCESS)
                    Log.i("MYOAPP", "Data written!");
            }
        }

);
baseMyo.submit(writeMsg);

License

This library is licensed under Apache 2.0, see LICENSE

If you use "Android Myo library by darken" for your publication, please cite the following publication:

  • Kutafina E, Laukamp D, Jonas SM. Wearable Sensors in Medical Education: Supporting Hand Hygiene Training with a Forearm EMG. Stud Health Technol Inform. 2015;211:286-91.

Example app

myolib's People

Contributors

d4rken 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.