@@ -48,10 +48,13 @@ BLEAdafruitAddressablePixel blePixel;
48
48
49
49
#elif defined ARDUINO_NRF52840_CLUE
50
50
#include < Adafruit_APDS9960.h>
51
+ #include < Adafruit_LSM6DS33.h>
52
+
51
53
#define DEVICE_NAME " CLUE"
52
54
#define NEOPIXEL_COUNT 1
53
55
54
56
Adafruit_APDS9960 apds9960;
57
+ Adafruit_LSM6DS33 lsm6ds33;
55
58
#else
56
59
#error "Board is not supported"
57
60
#endif
@@ -107,16 +110,25 @@ uint16_t measure_light_sensor(uint8_t* buf, uint16_t bufsize)
107
110
108
111
uint16_t measure_accel (uint8_t * buf, uint16_t bufsize)
109
112
{
110
- float accel[ 3 ] ;
113
+ float * accel_buf = ( float *) buf ;
111
114
112
115
#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 ;
116
129
#endif
117
130
118
- memcpy (buf, accel, sizeof (accel));
119
- return sizeof (accel);
131
+ return 3 *sizeof (float ); // 12
120
132
}
121
133
122
134
void setup ()
@@ -138,8 +150,12 @@ void setup()
138
150
// Buzzer Speaker
139
151
pinMode (PIN_BUZZER, OUTPUT);
140
152
153
+ // Light sensor
141
154
apds9960.begin ();
142
155
apds9960.enableColor (true );
156
+
157
+ // Accelerometer
158
+ lsm6ds33.begin_I2C ();
143
159
#endif
144
160
145
161
0 commit comments