Skip to content

Commit da841fa

Browse files
committed
accel works
1 parent d16b63d commit da841fa

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ BLEAdafruitAddressablePixel blePixel;
4848

4949
#elif defined ARDUINO_NRF52840_CLUE
5050
#include <Adafruit_APDS9960.h>
51+
#include <Adafruit_LSM6DS33.h>
52+
5153
#define DEVICE_NAME "CLUE"
5254
#define NEOPIXEL_COUNT 1
5355

5456
Adafruit_APDS9960 apds9960;
57+
Adafruit_LSM6DS33 lsm6ds33;
5558
#else
5659
#error "Board is not supported"
5760
#endif
@@ -107,16 +110,25 @@ uint16_t measure_light_sensor(uint8_t* buf, uint16_t bufsize)
107110

108111
uint16_t measure_accel(uint8_t* buf, uint16_t bufsize)
109112
{
110-
float accel[3];
113+
float* accel_buf = (float*) buf;
111114

112115
#if defined ARDUINO_NRF52840_CIRCUITPLAY
113-
accel[0] = CircuitPlayground.motionX();
114-
accel[1] = CircuitPlayground.motionY();
115-
accel[2] = CircuitPlayground.motionZ();
116+
accel_buf[0] = CircuitPlayground.motionX();
117+
accel_buf[1] = CircuitPlayground.motionY();
118+
accel_buf[2] = CircuitPlayground.motionZ();
119+
#else
120+
121+
sensors_event_t accel, gyro, temp;
122+
(void) gyro; (void) temp;
123+
124+
lsm6ds33.getEvent(&accel, &gyro, &temp);
125+
126+
accel_buf[0] = accel.acceleration.x;
127+
accel_buf[1] = accel.acceleration.y;
128+
accel_buf[2] = accel.acceleration.z;
116129
#endif
117130

118-
memcpy(buf, accel, sizeof(accel));
119-
return sizeof(accel);
131+
return 3*sizeof(float); // 12
120132
}
121133

122134
void setup()
@@ -138,8 +150,12 @@ void setup()
138150
// Buzzer Speaker
139151
pinMode(PIN_BUZZER, OUTPUT);
140152

153+
// Light sensor
141154
apds9960.begin();
142155
apds9960.enableColor(true);
156+
157+
// Accelerometer
158+
lsm6ds33.begin_I2C();
143159
#endif
144160

145161

0 commit comments

Comments
 (0)