Skip to content

Commit de80e64

Browse files
committed
example
1 parent 849df23 commit de80e64

File tree

3 files changed

+81
-25
lines changed

3 files changed

+81
-25
lines changed

Diff for: examples/ScienceJournal/ScienceJournal.ino

+38-13
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ rtos::Thread thread_update_sensors;
2828
bool ble_is_connected = false;
2929

3030

31-
void setup() {
32-
31+
void setup(){
3332
science_kit.begin(NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
3433

3534
if (!BLE.begin()){
@@ -81,7 +80,7 @@ void setup() {
8180
void update(void){
8281
while(1){
8382
science_kit.update(ROUND_ROBIN_ENABLED);
84-
rtos::ThisThread::sleep_for(20);
83+
rtos::ThisThread::sleep_for(25);
8584
}
8685
}
8786

@@ -125,8 +124,16 @@ void updateSubscribedCharacteristics(){
125124
lightCharacteristic.writeValue((byte*)light, sizeof(light));
126125
}
127126

128-
if (proximityCharacteristic.subscribed()){
127+
if (proximityCharacteristic.subscribed()){ // need to be fixed
128+
/*
129129
proximityCharacteristic.writeValue(science_kit.getProximity());
130+
*/
131+
if (science_kit.getUltrasonicIsConnected()){
132+
proximityCharacteristic.writeValue(science_kit.getDistance()*100.0);
133+
}
134+
else{
135+
proximityCharacteristic.writeValue(-1.0);
136+
}
130137
}
131138

132139
if (accelerationCharacteristic.subscribed()){
@@ -165,26 +172,44 @@ void updateSubscribedCharacteristics(){
165172
humidityCharacteristic.writeValue(science_kit.getHumidity());
166173
}
167174

168-
// need to be fix
175+
// need to be fixed
169176
if(sndIntensityCharacteristic.subscribed()){
170-
if (science_kit.getUltrasonicIsConnected()){
171-
sndIntensityCharacteristic.writeValue(science_kit.getDistance()*100.0);
172-
}
173-
else{
174-
sndIntensityCharacteristic.writeValue(-1.0);
175-
}
177+
sndIntensityCharacteristic.writeValue(science_kit.getMicrophoneRMS());
176178
}
177179

178-
// need to be fix
180+
// need to be fixed
179181
if(sndPitchCharacteristic.subscribed()){
180182
sndPitchCharacteristic.writeValue(science_kit.getExternalTemperature());
181183
}
182184

183185
if (inputACharacteristic.subscribed()){
186+
/*
184187
inputACharacteristic.writeValue(science_kit.getInputA());
188+
*/
189+
inputACharacteristic.writeValue(science_kit.getFrequency1());
185190
}
186191

187192
if (inputBCharacteristic.subscribed()){
188193
inputBCharacteristic.writeValue(science_kit.getInputB());
189194
}
190-
}
195+
}
196+
197+
198+
199+
200+
201+
/***
202+
* _ _
203+
* /\ | | (_)
204+
* / \ _ __ __| |_ _ _ _ __ ___
205+
* / /\ \ | '__/ _` | | | | | '_ \ / _ \
206+
* / ____ \| | | (_| | |_| | | | | | (_) |
207+
* /_/____\_\_| _\__,_|\__,_|_|_| |_|\___/ ___ _ _____ ____
208+
* / ____| (_) | |/ (_) | | __ \|___ \
209+
* | (___ ___ _ ___ _ __ ___ ___ | ' / _| |_ | |__) | __) |
210+
* \___ \ / __| |/ _ \ '_ \ / __/ _ \ | < | | __| | _ / |__ <
211+
* ____) | (__| | __/ | | | (_| __/ | . \| | |_ | | \ \ ___) |
212+
* |_____/ \___|_|\___|_| |_|\___\___| |_|\_\_|\__| |_| \_\____/
213+
*
214+
*
215+
*/

Diff for: src/Arduino_ScienceKitCarrier.cpp

+25-6
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ int ScienceKitCarrier::begin(const uint8_t auxiliary_threads){
142142
return ERR_BEGIN_FUNCTION_GENERATOR_CONTROLLER;
143143
}
144144

145-
// let's start ultrasonic and check if it is connected
146-
if (beginUltrasonic()!=0){
147-
return ERR_BEGIN_ULTRASONIC;
148-
}
149-
150145
// let's start microphone (PDM on Arduino Nano RP2040 Connect)
151146
if (beginMicrophone()!=0){
152147
return ERR_BEGIN_MICROPHONE;
153148
}
154149

150+
// let's start ultrasonic and check if it is connected
151+
if (beginUltrasonic()!=0){
152+
return ERR_BEGIN_ULTRASONIC;
153+
}
154+
155155
// let's start bme688 and external ds18b20 probe
156156
startAuxiliaryThreads(auxiliary_threads);
157157
}
@@ -815,4 +815,23 @@ void ScienceKitCarrier::startAuxiliaryThreads(const uint8_t auxiliary_threads){
815815
}
816816
thread_ext_temperature_is_running=true;
817817
}
818-
}
818+
}
819+
820+
821+
822+
823+
/***
824+
* _ _
825+
* /\ | | (_)
826+
* / \ _ __ __| |_ _ _ _ __ ___
827+
* / /\ \ | '__/ _` | | | | | '_ \ / _ \
828+
* / ____ \| | | (_| | |_| | | | | | (_) |
829+
* /_/____\_\_| _\__,_|\__,_|_|_| |_|\___/ ___ _ _____ ____
830+
* / ____| (_) | |/ (_) | | __ \|___ \
831+
* | (___ ___ _ ___ _ __ ___ ___ | ' / _| |_ | |__) | __) |
832+
* \___ \ / __| |/ _ \ '_ \ / __/ _ \ | < | | __| | _ / |__ <
833+
* ____) | (__| | __/ | | | (_| __/ | . \| | |_ | | \ \ ___) |
834+
* |_____/ \___|_|\___|_| |_|\___\___| |_|\_\_|\__| |_| \_\____/
835+
*
836+
*
837+
*/

Diff for: src/Arduino_ScienceKitCarrier.h

+18-6
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,25 @@ class ScienceKitCarrier{
227227

228228
};
229229

230-
/*
231-
// static members must be initialized externally the class definition
232-
short ScienceKitCarrier::sampleBuffer[MICROPHONE_BUFFER_SIZE];
233-
volatile int ScienceKitCarrier::samplesRead;
234-
*/
235230

236231

237232

233+
#endif
234+
235+
238236

239-
#endif
237+
/***
238+
* _ _
239+
* /\ | | (_)
240+
* / \ _ __ __| |_ _ _ _ __ ___
241+
* / /\ \ | '__/ _` | | | | | '_ \ / _ \
242+
* / ____ \| | | (_| | |_| | | | | | (_) |
243+
* /_/____\_\_| _\__,_|\__,_|_|_| |_|\___/ ___ _ _____ ____
244+
* / ____| (_) | |/ (_) | | __ \|___ \
245+
* | (___ ___ _ ___ _ __ ___ ___ | ' / _| |_ | |__) | __) |
246+
* \___ \ / __| |/ _ \ '_ \ / __/ _ \ | < | | __| | _ / |__ <
247+
* ____) | (__| | __/ | | | (_| __/ | . \| | |_ | | \ \ ___) |
248+
* |_____/ \___|_|\___|_| |_|\___\___| |_|\_\_|\__| |_| \_\____/
249+
*
250+
*
251+
*/

0 commit comments

Comments
 (0)