... | ... | @@ -41,7 +41,7 @@ Read `/sys/class/thermal/thermal_zone0/temp` to get a temperature measured in mi |
|
|
|
|
|
## Devices
|
|
|
|
|
|
LEDs:
|
|
|
### LEDs
|
|
|
Write 1 or 0 to `/sys/devices/platform/leds/leds/LED 1/brightness` or `/sys/class/leds/LED 1/brightness` to turn the red LED on or off. ([Issue 68](https://source.puri.sm/Librem5/developer.puri.sm/issues/68))
|
|
|
Using Python with [python-periphery](https://python-periphery.readthedocs.io/en/latest/):
|
|
|
```
|
... | ... | @@ -52,18 +52,59 @@ led1.write(1) |
|
|
led1.write(0)
|
|
|
```
|
|
|
|
|
|
PWM links:
|
|
|
### PWM
|
|
|
* https://lwn.net/Articles/553755/
|
|
|
* https://developer.toradex.com/knowledge-base/pwm-(linux)
|
|
|
|
|
|
PPS links:
|
|
|
### PPS
|
|
|
* http://linuxpps.org/doku.php/start
|
|
|
* http://linuxpps.org/doku.php/technical_information
|
|
|
* https://community.nxp.com/thread/381834
|
|
|
|
|
|
I2C:
|
|
|
### I2C
|
|
|
* https://elinux.org/Interfacing_with_I2C_Devices
|
|
|
* `/usr/sbin/i2cdetect -r 2`
|
|
|
* https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial/all
|
|
|
* `i2cdetect -l`
|
|
|
* https://github.com/vsergeev/python-periphery |
|
|
\ No newline at end of file |
|
|
* `/usr/sbin/i2cdetect -l`
|
|
|
* https://github.com/vsergeev/python-periphery
|
|
|
|
|
|
Add the user to the `i2c` group:
|
|
|
```
|
|
|
sudo usermod -a -G i2c <user>
|
|
|
```
|
|
|
|
|
|
**Magnetometer:**
|
|
|
* https://github.com/sparkfun/LSM9DS1_Breakout
|
|
|
* https://learn.sparkfun.com/tutorials/lsm9ds1-breakout-hookup-guide?_ga=2.53511264.972233989.1546204376-751046110.1546204376
|
|
|
|
|
|
Inspect the chip addresses available:
|
|
|
```
|
|
|
/usr/sbin/i2cdetect -y 2
|
|
|
```
|
|
|
|
|
|
Read the `WHO_AM_I_M` register for the magnetometer:
|
|
|
```
|
|
|
/usr/sbin/i2cget -y 2 0x1e 0x0f
|
|
|
```
|
|
|
This should return `0x3d` for the magnetometer.
|
|
|
|
|
|
Read the `CTRL_REG3_M` register:
|
|
|
```
|
|
|
/usr/sbin/i2cget -y 2 0x1e 0x22
|
|
|
```
|
|
|
This should return `0x03`, indicating an operating mode of binary `11` (power-down mode). Set it to `00` (continuous-conversion mode):
|
|
|
```
|
|
|
/usr/sbin/i2cset -y 2 0x1e 0x22 0
|
|
|
```
|
|
|
|
|
|
Now read the values for each axis (x, y, z respectively):
|
|
|
```
|
|
|
/usr/sbin/i2cget -y 2 0x1e 0x28 w
|
|
|
/usr/sbin/i2cget -y 2 0x1e 0x2a w
|
|
|
/usr/sbin/i2cget -y 2 0x1e 0x2c w
|
|
|
```
|
|
|
|
|
|
Set the operating mode to power-down again:
|
|
|
```
|
|
|
/usr/sbin/i2cset -y 2 0x1e 0x22 3
|
|
|
``` |