Skip to content

Commit d16b63d

Browse files
committed
light works
1 parent c340043 commit d16b63d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/.cluenrf52840.test.only

Whitespace-only changes.

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ BLEAdafruitAddressablePixel blePixel;
4747

4848

4949
#elif defined ARDUINO_NRF52840_CLUE
50-
50+
#include <Adafruit_APDS9960.h>
5151
#define DEVICE_NAME "CLUE"
5252
#define NEOPIXEL_COUNT 1
5353

54-
54+
Adafruit_APDS9960 apds9960;
5555
#else
5656
#error "Board is not supported"
5757
#endif
@@ -73,7 +73,6 @@ uint16_t measure_button(uint8_t* buf, uint16_t bufsize)
7373
// No slide switch
7474
button |= ( digitalRead(PIN_BUTTON1) ? 0x00 : 0x02 );
7575
button |= ( digitalRead(PIN_BUTTON2) ? 0x00 : 0x04 );
76-
7776
#endif
7877

7978
memcpy(buf, &button, 4);
@@ -91,10 +90,18 @@ uint16_t measure_temperature(uint8_t* buf, uint16_t bufsize)
9190

9291
uint16_t measure_light_sensor(uint8_t* buf, uint16_t bufsize)
9392
{
93+
float lux;
94+
9495
#if defined ARDUINO_NRF52840_CIRCUITPLAY
95-
float lux = CircuitPlayground.lightSensor();
96-
memcpy(buf, &lux, 4);
96+
lux = CircuitPlayground.lightSensor();
97+
#else
98+
uint16_t r, g, b, c;
99+
apds9960.getColorData(&r, &g, &b, &c);
100+
101+
lux = c;
97102
#endif
103+
104+
memcpy(buf, &lux, 4);
98105
return 4;
99106
}
100107

@@ -130,6 +137,9 @@ void setup()
130137

131138
// Buzzer Speaker
132139
pinMode(PIN_BUZZER, OUTPUT);
140+
141+
apds9960.begin();
142+
apds9960.enableColor(true);
133143
#endif
134144

135145

0 commit comments

Comments
 (0)