@@ -28,9 +28,14 @@ ScienceKitCarrier science_kit;
2828rtos::Thread thread_update_sensors;
2929#endif
3030
31+ #ifdef ESP32
32+ TaskHandle_t update_task;
33+ #endif
34+
3135bool ble_is_connected = false ;
3236
3337
38+
3439void setup (){
3540 science_kit.begin (NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
3641
@@ -108,22 +113,38 @@ void setup(){
108113
109114 BLE.addService (service);
110115 BLE.advertise ();
111-
112- // science_kit.startAuxiliaryThreads(); // start the BME688 and External Temperature Probe threads
116+
113117 #ifdef ARDUINO_NANO_RP2040_CONNECT
118+ science_kit.startAuxiliaryThreads (); // start the BME688 and External Temperature Probe threads
114119 thread_update_sensors.start (update); // this thread updates sensors
115120 #endif
116- }
117121
122+ // xTaskCreatePinnedToCore(&update, "update", 10000, NULL, 1, &update_task, 1); // starts the update sensors thread on core 1 (user)
123+
124+ }
118125
126+ /*
119127void update(void){
120128 while(1){
121129 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);
123143 delay (25 );
124144 }
125145}
126146
147+
127148void loop (){
128149 BLEDevice central = BLE.central ();
129150 if (central) {
@@ -208,7 +229,6 @@ void updateSubscribedCharacteristics(){
208229 /*
209230 * BME688
210231 */
211-
212232 /* _____________________________________________________________TEMPERATURE */
213233 if (temperatureCharacteristic.subscribed ()){
214234 temperatureCharacteristic.writeValue (science_kit.getTemperature ());
@@ -228,7 +248,7 @@ void updateSubscribedCharacteristics(){
228248 if (airQualityCharacteristic.subscribed ()){
229249 airQualityCharacteristic.writeValue (science_kit.getAirQuality ());
230250 }
231-
251+
232252 /*
233253 * MICROPHONE
234254 */
@@ -237,12 +257,14 @@ void updateSubscribedCharacteristics(){
237257 /* _________________________________________________________SOUND_INTENSITY */
238258 /* NOTE: raw value - value not in Db */
239259 if (sndIntensityCharacteristic.subscribed ()){
240- sndIntensityCharacteristic.writeValue (science_kit.getMicrophoneRMS ());
260+ // sndIntensityCharacteristic.writeValue(science_kit.getMicrophoneRMS());
261+ sndIntensityCharacteristic.writeValue (0.0 );
241262 }
242263
243264 /* _____________________________________________________________SOUND_PITCH */
244265 if (sndPitchCharacteristic.subscribed ()){
245- sndPitchCharacteristic.writeValue (science_kit.getExternalTemperature ());
266+ // sndPitchCharacteristic.writeValue(science_kit.getExternalTemperature());
267+ sndPitchCharacteristic.writeValue (0.0 );
246268 }
247269 #endif
248270
0 commit comments