@@ -172,7 +172,7 @@ int ScienceKitCarrier::begin(const uint8_t auxiliary_threads){
172
172
*/
173
173
174
174
// let's start bme688 and external ds18b20 probe
175
- // WIP startAuxiliaryThreads(auxiliary_threads);
175
+ startAuxiliaryThreads (auxiliary_threads);
176
176
}
177
177
178
178
@@ -248,14 +248,17 @@ int ScienceKitCarrier::beginAnalogInput(){
248
248
249
249
void ScienceKitCarrier::updateAnalogInput (const uint8_t input_to_update){
250
250
if ((input_to_update==UPDATE_INPUT_A)||(input_to_update==UPDATE_ALL)){
251
- /* WIP
251
+
252
252
if (!getExternalTemperatureIsConnected ()){
253
253
inputA=analogRead (inputA_pin);
254
+ #ifdef ESP32
255
+ beginExternalTemperature ();
256
+ #endif
254
257
}
255
258
else {
256
259
inputA=ANALOGIN_DISABLED;
257
260
}
258
- */
261
+
259
262
}
260
263
if ((input_to_update==UPDATE_INPUT_B)||(input_to_update==UPDATE_ALL)){
261
264
inputB=analogRead (inputB_pin);
@@ -472,14 +475,23 @@ float ScienceKitCarrier::getAirQuality(){
472
475
return airquality;
473
476
}
474
477
475
- #ifdef ARDUINO_NANO_RP2040_CONNECT
476
478
void ScienceKitCarrier::threadBME688 (){
477
479
beginBME688 ();
478
480
while (1 ){
479
481
updateBME688 ();
482
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
480
483
rtos::ThisThread::sleep_for (1000 );
484
+ #endif
485
+ #ifdef ESP32
486
+ delay (1000 );
487
+ #endif
481
488
}
482
489
}
490
+
491
+ #ifdef ESP32
492
+ void ScienceKitCarrier::freeRTOSInternalTemperature (void * pvParameters){
493
+ ((ScienceKitCarrier*) pvParameters)->threadBME688 ();
494
+ }
483
495
#endif
484
496
485
497
@@ -580,12 +592,11 @@ float ScienceKitCarrier::getMagneticFieldZ(){
580
592
581
593
#ifdef ARDUINO_NANO_RP2040_CONNECT
582
594
void ScienceKitCarrier::delay (unsigned long t){
583
- rtos::ThisThread::sleep_for (t);
595
+ rtos::ThisThread::sleep_for (t);
584
596
}
585
597
#endif
586
598
587
599
588
-
589
600
/* *******************************************************************/
590
601
/* LEDs: errors and activity */
591
602
/* *******************************************************************/
@@ -745,7 +756,6 @@ bool ScienceKitCarrier::getUltrasonicIsConnected(){
745
756
/* *******************************************************************/
746
757
// WIP
747
758
748
- #ifdef ARDUINO_NANO_RP2040_CONNECT
749
759
int ScienceKitCarrier::beginExternalTemperature (){
750
760
new (&ow) OneWireNg_CurrentPlatform (OW_PIN, false );
751
761
DSTherm drv (ow);
@@ -754,8 +764,14 @@ int ScienceKitCarrier::beginExternalTemperature(){
754
764
755
765
void ScienceKitCarrier::updateExternalTemperature (){
756
766
float temperature;
757
- pinMode (OW_PIN,INPUT);
758
767
768
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
769
+ pinMode (OW_PIN,INPUT);
770
+ #endif
771
+ #ifdef ESP32
772
+ pinMode (INPUTA_PIN,INPUT);
773
+ #endif
774
+
759
775
DSTherm drv (ow);
760
776
drv.convertTempAll (DSTherm::MAX_CONV_TIME, false );
761
777
@@ -795,11 +811,19 @@ void ScienceKitCarrier::threadExternalTemperature(){
795
811
while (1 ){
796
812
updateExternalTemperature ();
797
813
updateAnalogInput (UPDATE_INPUT_A);
798
- rtos::ThisThread::sleep_for (1000 );
814
+
815
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
816
+ rtos::ThisThread::sleep_for (1000 );
817
+ #endif
818
+ #ifdef ESP32
819
+ delay (1000 );
820
+ #endif
799
821
}
800
822
}
801
- #endif
802
823
824
+ void ScienceKitCarrier::freeRTOSExternalTemperature (void * pvParameters){
825
+ ((ScienceKitCarrier*) pvParameters)->threadExternalTemperature ();
826
+ }
803
827
804
828
805
829
/* *******************************************************************/
@@ -845,30 +869,35 @@ uint ScienceKitCarrier::getMicrophoneRMS(){
845
869
/* *******************************************************************/
846
870
/* Threads */
847
871
/* *******************************************************************/
848
- #ifdef ARDUINO_NANO_RP2040_CONNECT
849
872
850
873
void ScienceKitCarrier::startAuxiliaryThreads (const uint8_t auxiliary_threads){
851
874
// thread_activity_led->start(mbed::callback(this, &ScienceKitCarrier::threadActivityLed)); //left for legacy on prototypes and maybe future implementations
852
-
853
875
// start bme688 thread
854
876
if ((auxiliary_threads==START_AUXILIARY_THREADS)||(auxiliary_threads==START_INTERNAL_AMBIENT_SENSOR)){
855
877
if (!thread_bme_is_running){
856
- thread_update_bme->start (mbed::callback (this , &ScienceKitCarrier::threadBME688));
878
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
879
+ thread_update_bme->start (mbed::callback (this , &ScienceKitCarrier::threadBME688));
880
+ #endif
881
+ #ifdef ESP32
882
+ xTaskCreatePinnedToCore (this ->freeRTOSInternalTemperature , " update_internal_temperature" , 10000 , this , 1 , &thread_internal_temperature, INTERNAL_TEMPERATURE_CORE);
883
+ #endif
857
884
}
858
885
thread_bme_is_running=true ;
859
886
}
860
-
861
887
// start ds18b20 thread
862
888
if ((auxiliary_threads==START_AUXILIARY_THREADS)||(auxiliary_threads==START_EXTERNAL_AMBIENT_SENSOR)){
863
889
if (!thread_ext_temperature_is_running){
864
- thread_external_temperature->start (mbed::callback (this , &ScienceKitCarrier::threadExternalTemperature));
890
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
891
+ thread_external_temperature->start (mbed::callback (this , &ScienceKitCarrier::threadExternalTemperature));
892
+ #endif
893
+ #ifdef ESP32
894
+ xTaskCreatePinnedToCore (this ->freeRTOSExternalTemperature , " update_external_temperature" , 10000 , this , 1 , &thread_external_temperature, EXTERNAL_TEMPERATURE_CORE);
895
+ #endif
865
896
}
866
897
thread_ext_temperature_is_running=true ;
867
898
}
868
899
}
869
900
870
- #endif
871
-
872
901
873
902
/* **
874
903
* _ _
0 commit comments