Chromium Code Reviews| Index: sky/examples/shell/sensor.sky |
| diff --git a/sky/examples/shell/sensor.sky b/sky/examples/shell/sensor.sky |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5690372cc24ca6074ff0e243fdf9c635d23a3469 |
| --- /dev/null |
| +++ b/sky/examples/shell/sensor.sky |
| @@ -0,0 +1,37 @@ |
| +<script> |
| +import '/sky/framework/shell.dart' as shell; |
| +import 'dart:sky'; |
| +import 'package:sky/services/sensors/sensors.mojom.dart'; |
| + |
| +int count = 0; |
|
eseidel
2015/02/27 22:29:25
member
|
| + |
| +class MyListener extends SensorListener { |
| + void onAccuracyChanged(int accuracy) { |
| + print("onAccuracyChanged $accuracy"); |
| + } |
| + void onSensorChanged(SensorData data) { |
| + double value = data.values[0] + data.values[1] + data.values[2]; |
| + if (value > 40.0) { |
| + document.querySelector('div').textContent = |
| + "Shake count " + (count++).toString(); |
| + } |
| + } |
| + |
| + MyListener.unbound() { |
| + stub = new SensorListenerStub.unbound() |
| + ..delegate = this; |
| + } |
| + |
| + SensorListenerStub stub; |
| +} |
| + |
| +void main() { |
| + var sensorService = new SensorServiceProxy.unbound(); |
| + shell.requestService(sensorService); |
| + |
| + var listener = new MyListener.unbound(); |
| + sensorService.ptr.addListener(SensorType_ACCELEROMETER, listener.stub); |
| + listener.stub.listen(); |
| +} |
| +</script> |
| +<div>Hello, world.</div> |
|
eseidel
2015/02/27 22:29:25
Instructions here?
|