| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 /// API for accessing the devices on the Raspberry Pi Sense HAT add-on board. | 5 /// API for accessing the devices on the Raspberry Pi Sense HAT add-on board. |
| 6 /// See: https://www.raspberrypi.org/products/sense-hat/. | 6 /// See: https://www.raspberrypi.org/products/sense-hat/. |
| 7 /// | 7 /// |
| 8 /// Currently this has only been tested with a Raspberry Pi 2 and the Sense HAT. | 8 /// Currently this has only been tested with a Raspberry Pi 2 and the Sense HAT. |
| 9 /// | 9 /// |
| 10 /// The following sample code show how to access the devices on the Raspberry Pi | 10 /// The following sample code show how to access the devices on the Raspberry Pi |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 /// var temp = hat.readTemperature(); | 42 /// var temp = hat.readTemperature(); |
| 43 /// var humidity = hat.readHumidity(); | 43 /// var humidity = hat.readHumidity(); |
| 44 /// var pressure = hat.readPressure(); | 44 /// var pressure = hat.readPressure(); |
| 45 /// var accel = hat.readAccel(); | 45 /// var accel = hat.readAccel(); |
| 46 /// print('${accel.pitch} ${accel.roll} $temp $humidity $pressure'); | 46 /// print('${accel.pitch} ${accel.roll} $temp $humidity $pressure'); |
| 47 /// } | 47 /// } |
| 48 /// } | 48 /// } |
| 49 /// ``` | 49 /// ``` |
| 50 library raspberry_pi.sense_hat; | 50 library raspberry_pi.sense_hat; |
| 51 | 51 |
| 52 import 'dart:fletch.ffi'; | 52 import 'dart:dartino.ffi'; |
| 53 | 53 |
| 54 import 'package:i2c/i2c.dart'; | 54 import 'package:i2c/i2c.dart'; |
| 55 import 'package:i2c/devices/hts221.dart'; | 55 import 'package:i2c/devices/hts221.dart'; |
| 56 import 'package:i2c/devices/lps25h.dart'; | 56 import 'package:i2c/devices/lps25h.dart'; |
| 57 import 'package:i2c/devices/lsm9ds1.dart'; | 57 import 'package:i2c/devices/lsm9ds1.dart'; |
| 58 | 58 |
| 59 // Foreign functions used. | 59 // Foreign functions used. |
| 60 final ForeignFunction _open = ForeignLibrary.main.lookup('open'); | 60 final ForeignFunction _open = ForeignLibrary.main.lookup('open'); |
| 61 final ForeignFunction _mmap = ForeignLibrary.main.lookup('mmap'); | 61 final ForeignFunction _mmap = ForeignLibrary.main.lookup('mmap'); |
| 62 | 62 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 /// Read the current gyroscope measurement. | 221 /// Read the current gyroscope measurement. |
| 222 GyroMeasurement readGyro() => _lsm9ds1.readGyro(); | 222 GyroMeasurement readGyro() => _lsm9ds1.readGyro(); |
| 223 | 223 |
| 224 /// Read the current accelerometer measurement. | 224 /// Read the current accelerometer measurement. |
| 225 AccelMeasurement readAccel() => _lsm9ds1.readAccel(); | 225 AccelMeasurement readAccel() => _lsm9ds1.readAccel(); |
| 226 | 226 |
| 227 /// Read the current magnetometer measurement. | 227 /// Read the current magnetometer measurement. |
| 228 MagnetMeasurement readMagnet() => _lsm9ds1.readMagnet(); | 228 MagnetMeasurement readMagnet() => _lsm9ds1.readMagnet(); |
| 229 } | 229 } |
| OLD | NEW |