-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not use the ir_sensor_pluguin library
- Loading branch information
1 parent
a34c2b5
commit 7e859ba
Showing
6 changed files
with
99 additions
and
13 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
android/app/src/main/kotlin/com/example/osram_controller/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,52 @@ | ||
package org.talkingpanda.osram_remote | ||
|
||
import android.content.Context | ||
import android.content.ContextWrapper | ||
import android.content.Intent | ||
import android.content.IntentFilter | ||
import android.hardware.ConsumerIrManager | ||
import android.os.BatteryManager | ||
import android.os.Build.VERSION | ||
import android.os.Build.VERSION_CODES | ||
import androidx.annotation.NonNull | ||
import androidx.annotation.RequiresApi | ||
import io.flutter.embedding.android.FlutterActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugin.common.MethodChannel | ||
import kotlin.reflect.typeOf | ||
|
||
|
||
class MainActivity: FlutterActivity() { | ||
private val CHANNEL = "org.talkingpanda/irtransmitter" | ||
private lateinit var irManager: ConsumerIrManager | ||
private fun convertIntegers(integers: List<Int>): IntArray? { | ||
val ret = IntArray(integers.size) | ||
val iterator = integers.iterator() | ||
for (i in ret.indices) { | ||
ret[i] = iterator.next() | ||
} | ||
return ret | ||
} | ||
@RequiresApi(VERSION_CODES.O) | ||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { | ||
super.configureFlutterEngine(flutterEngine) | ||
irManager = getSystemService(Context.CONSUMER_IR_SERVICE) as ConsumerIrManager; | ||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { | ||
call, result -> | ||
if (call.method == "transmit") { | ||
val list = call.argument<ArrayList<Int>>("list") | ||
if(list == null) { | ||
result.error( "NOPATTERN","No pattern given",null) | ||
} else { | ||
irManager.transmit(38028,list.toIntArray()); | ||
} | ||
result.success(null); | ||
} else | ||
{ | ||
result.notImplemented() | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
import 'dart:typed_data'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
class IRTransmitter { | ||
static const platform = MethodChannel('org.talkingpanda/irtransmitter'); | ||
void transmit(List<int> list) async { | ||
await platform.invokeMethod("transmit", {"list": list}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters