@@ -28,9 +28,14 @@ ScienceKitCarrier science_kit;
28
28
rtos::Thread thread_update_sensors;
29
29
#endif
30
30
31
+ #ifdef ESP32
32
+ TaskHandle_t update_task;
33
+ #endif
34
+
31
35
bool ble_is_connected = false ;
32
36
33
37
38
+
34
39
void setup (){
35
40
science_kit.begin (NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
36
41
@@ -108,22 +113,38 @@ void setup(){
108
113
109
114
BLE.addService (service);
110
115
BLE.advertise ();
111
-
112
- // science_kit.startAuxiliaryThreads(); // start the BME688 and External Temperature Probe threads
116
+
113
117
#ifdef ARDUINO_NANO_RP2040_CONNECT
118
+ science_kit.startAuxiliaryThreads (); // start the BME688 and External Temperature Probe threads
114
119
thread_update_sensors.start (update); // this thread updates sensors
115
120
#endif
116
- }
117
121
122
+ // xTaskCreatePinnedToCore(&update, "update", 10000, NULL, 1, &update_task, 1); // starts the update sensors thread on core 1 (user)
123
+
124
+ }
118
125
126
+ /*
119
127
void update(void){
120
128
while(1){
121
129
science_kit.update(ROUND_ROBIN_ENABLED);
122
- // rtos::ThisThread::sleep_for(25);
130
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
131
+ rtos::ThisThread::sleep_for(25);
132
+ #endif
133
+ #ifdef ESP32
134
+ delay(25);
135
+ #endif
136
+ }
137
+ }
138
+ */
139
+
140
+ static void update (void * pvParameters){
141
+ while (1 ){
142
+ science_kit.update (ROUND_ROBIN_ENABLED);
123
143
delay (25 );
124
144
}
125
145
}
126
146
147
+
127
148
void loop (){
128
149
BLEDevice central = BLE.central ();
129
150
if (central) {
@@ -208,7 +229,6 @@ void updateSubscribedCharacteristics(){
208
229
/*
209
230
* BME688
210
231
*/
211
-
212
232
/* _____________________________________________________________TEMPERATURE */
213
233
if (temperatureCharacteristic.subscribed ()){
214
234
temperatureCharacteristic.writeValue (science_kit.getTemperature ());
@@ -228,7 +248,7 @@ void updateSubscribedCharacteristics(){
228
248
if (airQualityCharacteristic.subscribed ()){
229
249
airQualityCharacteristic.writeValue (science_kit.getAirQuality ());
230
250
}
231
-
251
+
232
252
/*
233
253
* MICROPHONE
234
254
*/
@@ -237,12 +257,14 @@ void updateSubscribedCharacteristics(){
237
257
/* _________________________________________________________SOUND_INTENSITY */
238
258
/* NOTE: raw value - value not in Db */
239
259
if (sndIntensityCharacteristic.subscribed ()){
240
- sndIntensityCharacteristic.writeValue (science_kit.getMicrophoneRMS ());
260
+ // sndIntensityCharacteristic.writeValue(science_kit.getMicrophoneRMS());
261
+ sndIntensityCharacteristic.writeValue (0.0 );
241
262
}
242
263
243
264
/* _____________________________________________________________SOUND_PITCH */
244
265
if (sndPitchCharacteristic.subscribed ()){
245
- sndPitchCharacteristic.writeValue (science_kit.getExternalTemperature ());
266
+ // sndPitchCharacteristic.writeValue(science_kit.getExternalTemperature());
267
+ sndPitchCharacteristic.writeValue (0.0 );
246
268
}
247
269
#endif
248
270
0 commit comments