Git Product home page Git Product logo

androidinfrared's Introduction

AndroidInfrared

Android Infrared is a infrared library drives IR LED built in Samsung devices, such as S4, Note 3.

Protocol Supported

Android Infrared supports most of popular protocols avaiable nowadays, including:

  • NEC
  • Sony
  • RC5
  • RC6
  • DISH
  • Sharp
  • Panasonic
  • JVC

Code Sample

        // Create ConsumerIrManager instance, which provides the unified and enhanced API across Samsung private API and KitKat API.
        ConsumerIrManager manager = ConsumerIrManager.getSupportConsumerIrManager(context);

        // Check whether IrEmitter is avaiable on the device.
        if (!manager.hasIrEmitter()) {
            Log.e("AndroidInfraredDemo", "Cannot found IR Emitter on the device");
        }

        // Build IR Command with predefined schemes.
        IrCommand necCommand = IrCommand.NEC.buildNEC(32, 0x723F);
        manager.transmit(necCommand);

        // Build IR Command from Pronto code
        IrCommand prontoCommand = IrCommand.Pronto.buildPronto("0000 0067 0000 0015 0060 0018 0018 0018 0030 0018 0030 0018 0030 0018 0018 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0030 0018 0030 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 03f6");
        manager.transmit(prontoCommand);

        int FREQUENCY = 38028;  // T = 26.296 us
        int HDR_MARK = 342;
        int HDR_SPACE = 171;
        int BIT_MARK = 21;
        int ONE_SPACE = 60;
        int ZERO_SPACE = 21;

        // Build IR Command with Builder
        IrCommandBuilder builder = IrCommandBuilder.irCommandBuilder(NEC_FREQUENCY); // Static factory method
        IrCommand builderCommand = builder
                .pair(HDR_MARK, HDR_SPACE)  // Lead-in sequence
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ONE_SPACE)  // 1
                .pair(BIT_MARK, ZERO_SPACE) // 0
                .pair(BIT_MARK, ZERO_SPACE) // 0
                .mark(BIT_MARK)             // lead-out sequence
                .build();

        // Simplify Sequence building process by using Sqeuence Definition
        IrCommandBuilder.SequenceDefinition necSequence = IrCommandBuilder.simpleSequence(BIT_MARK, ONE_SPACE, BIT_MARK, ZERO_SPACE);
        IrCommandBuilder sequenceBuilder = IrCommandBuilder.irCommandBuilder(NEC_FREQUENCY); // Static factory method
        IrCommand sequenceCommand = builder
                .pair(HDR_MARK, HDR_SPACE)  // Lead-in sequence
                .sequence(necSequence, 8, 0xFC000000) // As same as previous one
                .mark(BIT_MARK)             // lead-out sequence
                .build();

        // Build IR Command from Raw Data
        int[] sequence = IrCommandBuilder.buildRawSequence(
            HDR_MARK, HDR_SPACE,  // Lead-in sequence
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ONE_SPACE,  // 1
            BIT_MARK, ZERO_SPACE, // 0
            BIT_MARK, ZERO_SPACE, // 0
            BIT_MARK              // lead-out sequence
        );
        manager.transmit(40000, sequence);
        

Sister Project

To decode and record the ir code from a existing remote control, such as TV remote or AirCon Remote, you can try IRRecorder.

Known Issue

Android Infrared uses the Samsung customized IR Blast API, and doesn't compatible with Android 4.4 KitKat standard ConsumerIrManager. The Adpoting to support KitKat standard API process is already in progress.

Road Map

  • Support Android 4.4 KitKat ConsumerIrManager API
  • Auto adpative between KitKat API and Samsung API
  • Support Proto code

androidinfrared's People

Contributors

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