ilabs-flir 2.2.14 → 2.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -53,6 +53,16 @@ object FlirManager {
|
|
|
53
53
|
fun setTextureCallback(callback: TextureUpdateCallback?) {
|
|
54
54
|
textureCallback = callback
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
interface TemperatureUpdateCallback {
|
|
58
|
+
fun onTemperatureUpdate(temperature: Double)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private var temperatureCallback: TemperatureUpdateCallback? = null
|
|
62
|
+
|
|
63
|
+
fun setTemperatureCallback(callback: TemperatureUpdateCallback?) {
|
|
64
|
+
temperatureCallback = callback
|
|
65
|
+
}
|
|
56
66
|
|
|
57
67
|
fun getLatestBitmap(): Bitmap? = latestBitmap
|
|
58
68
|
|
|
@@ -130,6 +140,10 @@ object FlirManager {
|
|
|
130
140
|
emitError("Device not found: $deviceId")
|
|
131
141
|
}
|
|
132
142
|
}
|
|
143
|
+
|
|
144
|
+
fun switchToDevice(deviceId: String) {
|
|
145
|
+
connectToDevice(deviceId)
|
|
146
|
+
}
|
|
133
147
|
|
|
134
148
|
/**
|
|
135
149
|
* Disconnect
|
|
@@ -241,6 +255,13 @@ object FlirManager {
|
|
|
241
255
|
return
|
|
242
256
|
}
|
|
243
257
|
|
|
258
|
+
// THROTTLE: Limit to ~15 FPS to prevent UI thread flooding
|
|
259
|
+
val now = System.currentTimeMillis()
|
|
260
|
+
if (now - lastEmitMs.get() < 66) { // 66ms ~= 15 FPS
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
lastEmitMs.set(now)
|
|
264
|
+
|
|
244
265
|
latestBitmap = bitmap
|
|
245
266
|
|
|
246
267
|
// If this is the first frame, notify JS that we are now streaming
|
|
@@ -249,16 +270,18 @@ object FlirManager {
|
|
|
249
270
|
emitDeviceState("streaming")
|
|
250
271
|
}
|
|
251
272
|
|
|
252
|
-
// NON-BLOCKING TEXTURE UPDATE
|
|
273
|
+
// NON-BLOCKING TEXTURE UPDATE
|
|
253
274
|
if (textureCallback != null) {
|
|
275
|
+
// We use try-lock to ensure we don't pile up parallel calls,
|
|
276
|
+
// though usually onFrame is serial.
|
|
254
277
|
if (isUpdatingTexture.compareAndSet(false, true)) {
|
|
255
278
|
try {
|
|
256
279
|
textureCallback?.onTextureUpdate(bitmap, 0)
|
|
280
|
+
} catch (e: Exception) {
|
|
281
|
+
Log.e(TAG, "Texture update failed", e)
|
|
257
282
|
} finally {
|
|
258
283
|
isUpdatingTexture.set(false)
|
|
259
284
|
}
|
|
260
|
-
} else {
|
|
261
|
-
// Log.v(TAG, "Dropping frame - texture update busy")
|
|
262
285
|
}
|
|
263
286
|
}
|
|
264
287
|
|