record lux_fast and lux _slow

This commit is contained in:
2024-12-11 17:00:53 +08:00
parent 6d89725d65
commit 2a4e21fa25
9 changed files with 444 additions and 202 deletions

View File

@@ -3,9 +3,13 @@ import 'dart:ffi';
class LightSensorEvent {
final double lux;
final int timestamp;
LightSensorEvent(this.lux, this.timestamp);
final double lux_fast;
final double lux_slow;
LightSensorEvent(this.lux, this.timestamp, this.lux_fast, this.lux_slow);
Map<String, dynamic> toJson() => {
'lux': lux,
'timestamp': timestamp,
'lux': lux,
'lux_fast': lux_fast,
'lux_slow': lux_slow,
};
}

View File

@@ -174,8 +174,8 @@ class _MyHomePageState extends State<MyHomePage> {
Stream<LightSensorEvent> streamSensorEventFromNative() {
const eventChannel = EventChannel('tw.moonjuice.light_sensor.stream');
return eventChannel
.receiveBroadcastStream()
.map((event) => LightSensorEvent(event['lux'], event['timestamp']));
return eventChannel.receiveBroadcastStream().map((event) =>
LightSensorEvent(event['lux'], event['timestamp'], event['lux_fast'],
event['lux_slow']));
}
}