示例#1
0
        public InfraredService(Context context)
        {
            var irManager = (ConsumerIrManager)context.GetSystemService(Context.ConsumerIrService);

            if (irManager != null && irManager.HasIrEmitter)
            {
                _irManager = irManager;
            }
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.Hide();   //Not necessary in home screen
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            if (mCIR == null)
            {
                mCIR = (ConsumerIrManager)GetSystemService(Context.ConsumerIrService);
            }
            prefs = PreferenceManager.GetDefaultSharedPreferences(this.ApplicationContext);

            glbl_temperature = prefs.GetInt("TEMPERATURE", 20);
            glbl_mode        = (byte)prefs.GetInt("MODE", 0x06);
            //
            FindViewById <TextView>(Resource.Id.editTemp).SetText(FormatTemp(glbl_temperature), TextView.BufferType.Normal);
            //
            Spinner spinner = FindViewById <Spinner>(Resource.Id.spinnerMode);
            var     adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.modes_array, Resource.Layout.spinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter       = adapter;
            spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);

            if (glbl_mode == 0x01)
            {
                spinner.SetSelection(0);    //< item > FAN </ item >
            }
            else if (glbl_mode == 0x02)
            {
                spinner.SetSelection(1);   // < item > COOL </ item >
            }
            else if (glbl_mode == 0x03)
            {
                spinner.SetSelection(2);   // < item > DRY </ item >
            }
            else if (glbl_mode == 0x04)
            {
                spinner.SetSelection(3);   // < item > HEAT </ item >
            }
            else if (glbl_mode == 0x06)
            {
                spinner.SetSelection(4);   // < item > AUTO </ item >
            }

            //....
#if false
            irService = GetSystemService("irda");
            readIR    = irService.Class.GetMethod("read_irsend", new Class[0]);
            sendIR    = irService.Class.GetMethod("write_irsend", Java.Lang.Class.FromType(typeof(Java.Lang.String)));
            sendIR.Invoke(irService, new Java.Lang.Object[]);
#endif
        }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Get a reference to the ConsumerIrManager
            mCIR = (ConsumerIrManager)GetSystemService(Context.ConsumerIrService);

            // See assets/res/any/layout/consumer_ir.xml for this
            // view layout definition, which is being set here as
            // the content of our screen.
            SetContentView(Resource.Layout.consumer_ir);

            // Set the OnClickListener for the button so we see when it's pressed.
            FindViewById(Resource.Id.send_button).Click      += mSendClickListener;
            FindViewById(Resource.Id.get_freqs_button).Click += mGetFreqsClickListener;
            mFreqsText = FindViewById <TextView> (Resource.Id.freqs_text);
        }
示例#4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            FindViewById(Resource.Id.offButton).Click += (object sender, EventArgs e) =>
            {
                ConsumerIrManager manager = ConsumerIrManager.getSupportConsumerIrManager(this);

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

                // Build IR Command with predefined schemes.

                IrCommand necCommand = IrCommand.NEC.BuildNEC(32, 0x00FF00FF);
                manager.transmit(necCommand);
            };
        }