Add support for APDS-9960, Digital Proximity, Ambient Light, RGB and Gesture Sensor (#308)

apds9960: add support for apds9960
This commit is contained in:
Alan Wang
2021-11-06 18:22:39 +08:00
committed by GitHub
parent 82e9e4a7f3
commit 65fd7aa1a1
8 changed files with 712 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
//go:build nano_33_ble
// +build nano_33_ble
package apds9960
import (
"machine"
"time"
"tinygo.org/x/drivers"
)
// New creates a new APDS-9960 connection. The I2C bus must already be
// configured.
//
// This function only creates the Device object, it does not touch the device.
func New(bus drivers.I2C) Device {
// turn on internal power pin (machine.P0_22) and I2C1 pullups power pin (machine.P1_00)
// and wait a moment.
ENV := machine.P0_22
ENV.Configure(machine.PinConfig{Mode: machine.PinOutput})
ENV.High()
R := machine.P1_00
R.Configure(machine.PinConfig{Mode: machine.PinOutput})
R.High()
time.Sleep(time.Millisecond * 10)
return Device{bus: bus, Address: ADPS9960_ADDRESS, mode: MODE_NONE}
}