Skip to content

Commit a69199b

Browse files
committed
clang
1 parent ff6594c commit a69199b

File tree

1 file changed

+61
-29
lines changed

1 file changed

+61
-29
lines changed

Adafruit_Feather_Sense/feather_sense_sensor_demo/feather_sense_sensor_demo.ino

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#include <Adafruit_Sensor.h>
21
#include <Adafruit_APDS9960.h>
32
#include <Adafruit_BMP280.h>
43
#include <Adafruit_LIS3MDL.h>
54
#include <Adafruit_LSM6DS33.h>
65
#include <Adafruit_SHT31.h>
6+
#include <Adafruit_Sensor.h>
77
#include <PDM.h>
88

9-
Adafruit_APDS9960 apds9960; // proximity, light, color, gesture
10-
Adafruit_BMP280 bmp280; // temperautre, barometric pressure
11-
Adafruit_LIS3MDL lis3mdl; // magnetometer
12-
Adafruit_LSM6DS33 lsm6ds33; // accelerometer, gyroscope
13-
Adafruit_SHT31 sht30; // humidity
9+
Adafruit_APDS9960 apds9960; // proximity, light, color, gesture
10+
Adafruit_BMP280 bmp280; // temperautre, barometric pressure
11+
Adafruit_LIS3MDL lis3mdl; // magnetometer
12+
Adafruit_LSM6DS33 lsm6ds33; // accelerometer, gyroscope
13+
Adafruit_SHT31 sht30; // humidity
1414

1515
uint8_t proximity;
1616
uint16_t r, g, b, c;
@@ -25,14 +25,15 @@ extern PDMClass PDM;
2525
short sampleBuffer[256]; // buffer to read samples into, each sample is 16-bits
2626
volatile int samplesRead; // number of samples read
2727

28-
void setup(void)
29-
{
28+
void setup(void) {
3029
Serial.begin(115200);
31-
//while (!Serial) delay(10);
30+
// while (!Serial) delay(10);
3231
Serial.println("Feather Sense Sensor Demo");
33-
32+
3433
// initialize the sensors
35-
apds9960.begin(); apds9960.enableProximity(true); apds9960.enableColor(true);
34+
apds9960.begin();
35+
apds9960.enableProximity(true);
36+
apds9960.enableColor(true);
3637
bmp280.begin();
3738
lis3mdl.begin_I2C();
3839
lsm6ds33.begin_I2C();
@@ -41,11 +42,9 @@ void setup(void)
4142
PDM.begin(1, 16000);
4243
}
4344

44-
45-
void loop(void)
46-
{
45+
void loop(void) {
4746
proximity = apds9960.readProximity();
48-
while(!apds9960.colorDataReady()){
47+
while (!apds9960.colorDataReady()) {
4948
delay(5);
5049
}
5150
apds9960.getColorData(&r, &g, &b, &c);
@@ -74,28 +73,61 @@ void loop(void)
7473

7574
samplesRead = 0;
7675
mic = getPDMwave(4000);
77-
76+
7877
Serial.println("\nFeather Sense Sensor Demo");
7978
Serial.println("---------------------------------------------");
80-
Serial.print("Proximity: "); Serial.println(apds9960.readProximity());
81-
Serial.print("Red: "); Serial.print(r); Serial.print(" Green: "); Serial.print(g); Serial.print(" Blue :"); Serial.print(b); Serial.print(" Clear: "); Serial.println(c);
82-
Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C");
83-
Serial.print("Barometric pressure: "); Serial.println(pressure);
84-
Serial.print("Altitude: "); Serial.print(altitude); Serial.println(" m");
85-
Serial.print("Magnetic: "); Serial.print(magnetic_x); Serial.print(" "); Serial.print(magnetic_y); Serial.print(" "); Serial.print(magnetic_z); Serial.println(" uTesla");
86-
Serial.print("Acceleration: "); Serial.print(accel_x); Serial.print(" "); Serial.print(accel_y); Serial.print(" "); Serial.print(accel_z); Serial.println(" m/s^2");
87-
Serial.print("Gyro: "); Serial.print(gyro_x); Serial.print(" "); Serial.print(gyro_y); Serial.print(" "); Serial.print(gyro_z); Serial.println(" dps");
88-
Serial.print("Humidity: "); Serial.print(humidity); Serial.println(" %");
89-
Serial.print("Mic: "); Serial.println(mic);
79+
Serial.print("Proximity: ");
80+
Serial.println(apds9960.readProximity());
81+
Serial.print("Red: ");
82+
Serial.print(r);
83+
Serial.print(" Green: ");
84+
Serial.print(g);
85+
Serial.print(" Blue :");
86+
Serial.print(b);
87+
Serial.print(" Clear: ");
88+
Serial.println(c);
89+
Serial.print("Temperature: ");
90+
Serial.print(temperature);
91+
Serial.println(" C");
92+
Serial.print("Barometric pressure: ");
93+
Serial.println(pressure);
94+
Serial.print("Altitude: ");
95+
Serial.print(altitude);
96+
Serial.println(" m");
97+
Serial.print("Magnetic: ");
98+
Serial.print(magnetic_x);
99+
Serial.print(" ");
100+
Serial.print(magnetic_y);
101+
Serial.print(" ");
102+
Serial.print(magnetic_z);
103+
Serial.println(" uTesla");
104+
Serial.print("Acceleration: ");
105+
Serial.print(accel_x);
106+
Serial.print(" ");
107+
Serial.print(accel_y);
108+
Serial.print(" ");
109+
Serial.print(accel_z);
110+
Serial.println(" m/s^2");
111+
Serial.print("Gyro: ");
112+
Serial.print(gyro_x);
113+
Serial.print(" ");
114+
Serial.print(gyro_y);
115+
Serial.print(" ");
116+
Serial.print(gyro_z);
117+
Serial.println(" dps");
118+
Serial.print("Humidity: ");
119+
Serial.print(humidity);
120+
Serial.println(" %");
121+
Serial.print("Mic: ");
122+
Serial.println(mic);
90123
delay(300);
91124
}
92125

93-
94126
/*****************************************************************/
95127
int32_t getPDMwave(int32_t samples) {
96128
short minwave = 30000;
97129
short maxwave = -30000;
98-
130+
99131
while (samples > 0) {
100132
if (!samplesRead) {
101133
yield();
@@ -109,7 +141,7 @@ int32_t getPDMwave(int32_t samples) {
109141
// clear the read count
110142
samplesRead = 0;
111143
}
112-
return maxwave-minwave;
144+
return maxwave - minwave;
113145
}
114146

115147
void onPDMdata() {

0 commit comments

Comments
 (0)