Skip to content

Commit 9cd8b78

Browse files
committed
refinements
1 parent c1f786d commit 9cd8b78

File tree

7 files changed

+43
-26
lines changed

7 files changed

+43
-26
lines changed

examples/ScienceJournal/ScienceJournal.ino

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ unsigned long lastNotify = 0;
2424

2525
ScienceKitCarrier science_kit;
2626

27-
rtos::Thread _t(osPriorityHigh);
28-
rtos::Thread _tu;
29-
27+
//rtos::Thread _thread_check_connection(osPriorityHigh);
28+
rtos::Thread _thread_update_sensors;
3029

30+
bool _is_connected = false;
3131

3232

3333
void setup() {
34-
pinMode(8,OUTPUT);
35-
pinMode(7,OUTPUT);
34+
//pinMode(8,OUTPUT);
35+
//pinMode(7,OUTPUT);
3636

37-
science_kit.begin(NO_AUXILIARY_THREADS); // Doesn't start the BME688 thread for the moment
37+
science_kit.begin(NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
3838

3939
if (!BLE.begin()) {
4040
while(1);
@@ -75,13 +75,14 @@ void setup() {
7575

7676
BLE.addService(service);
7777
BLE.advertise();
78+
7879
science_kit.startAuxiliaryThreads(); // start the BME688 and External Temperature Probe threads
79-
//_t.start(loop_data);
80-
_tu.start(update);
81-
}
8280

83-
bool _is_connected = false;
81+
//_thread_check_connection.start(loop_data);
82+
_thread_update_sensors.start(update); // this thread updates sensors
83+
}
8484

85+
/*
8586
void loop_data() {
8687
bool last_connected_status = _is_connected;
8788
while (1) {
@@ -91,18 +92,18 @@ void loop_data() {
9192
}
9293
}
9394
}
95+
*/
9496

9597
void update(void){
9698
while(1){
97-
digitalWrite(8,HIGH);
99+
//digitalWrite(8,HIGH);
98100
science_kit.update(ROUND_ROBIN_ENABLED);
99-
digitalWrite(8,LOW);
101+
//digitalWrite(8,LOW);
100102
rtos::ThisThread::sleep_for(20);
101103
}
102104
}
103105

104-
void loop() {
105-
106+
void loop(){
106107
BLEDevice central = BLE.central();
107108
if (central) {
108109
_is_connected = true;
@@ -113,7 +114,8 @@ void loop() {
113114
lastNotify=millis();
114115
}
115116
}
116-
} else {
117+
}
118+
else {
117119
delay(100);
118120
_is_connected = false;
119121
}
@@ -182,7 +184,12 @@ void updateSubscribedCharacteristics() {
182184
}
183185

184186
if(sndIntensityCharacteristic.subscribed()) {
185-
sndIntensityCharacteristic.writeValue(science_kit.getFrequency1());
187+
if (science_kit.getUltrasonicIsConnected()){
188+
sndIntensityCharacteristic.writeValue(science_kit.getDistance()*100.0);
189+
}
190+
else{
191+
sndIntensityCharacteristic.writeValue(-1.0);
192+
}
186193
}
187194

188195
if(sndPitchCharacteristic.subscribed()) {

examples/simple_temperature/simple_temperature.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or

keywords.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ getDistance KEYWORD2
7575
getTravelTime KEYWORD2
7676
getUltrasonicIsConnected KEYWORD2
7777

78+
beginExternalTemperature KEYWORD2
79+
updateExternalTemperature KEYWORD2
80+
getExternalTemperature KEYWORD2
81+
getExternalTemperatureIsConnected KEYWORD2
82+
threadExternalTemperature KEYWORD2
83+
7884
#######################################
7985
# Constants
8086
#######################################
@@ -97,16 +103,22 @@ G_EARTH LITERAL1
97103

98104
BME688_CS LITERAL1
99105

106+
OW_PIN LITERAL1
107+
EXTERNAL_TEMPERATURE_DISABLED LITERAL1
108+
100109
ERR_BEGIN_APDS LITERAL1
101110
ERR_BEGIN_INA LITERAL1
102111
ERR_BEGIN_IMU LITERAL1
103112
ERR_BEGIN_BME LITERAL1
104113
ERR_BEGIN_RESISTANCE LITERAL1
105114
ERR_BEGIN_FUNCTION_GENERATOR_CONTROLLER LITERAL1
106115
ERR_BEGIN_ULTRASONIC LITERAL1
116+
ERR_BEGIN_EXTERNAL_TEMPERATURE LITERAL1
107117

108118
ROUND_ROBIN_DISABLED LITERAL1
109119
ROUND_ROBIN_ENABLED LITERAL1
110120

111-
START_AUXILIARY_THREADS LITERAL1
112121
NO_AUXILIARY_THREADS LITERAL1
122+
START_AUXILIARY_THREADS LITERAL1
123+
START_INTERNAL_AMBIENT_SENSOR LITERAL1
124+
START_EXTERNAL_AMBIENT_SENSOR LITERAL1

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Arduino_ScienceKitCarrier
2-
version=0.1.0
2+
version=0.1.8
33
author=Arduino, Giovanni di Dio Bruno
44
maintainer=Arduino <info@arduino.cc>
55
sentence=Library and firmware for Arduino Science Kit R3
@@ -8,4 +8,4 @@ category=Communication
88
url=https://github.com/gbr1/Arduino_ScienceKitCarrier
99
architectures=mbed,mbed_nano
1010
includes=Arduino_ScienceKitCarrier.h
11-
depends=Arduino_APDS9960,ArduinoBLE,WiFiNINA,INA2xx,Arduino_BMI270_BMM150,BSEC Software Library,Arduino_GroveI2C_Ultrasonic
11+
depends=Arduino_APDS9960,ArduinoBLE,WiFiNINA,INA2xx,Arduino_BMI270_BMM150,BSEC Software Library,Arduino_GroveI2C_Ultrasonic,OneWireNg

src/Arduino_ScienceKitCarrier.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or
@@ -727,9 +727,7 @@ void ScienceKitCarrier::threadExternalTemperature(){
727727
beginExternalTemperature();
728728
while(1){
729729
updateAnalogInput(UPDATE_INPUT_A);
730-
digitalWrite(2,HIGH);
731730
updateExternalTemperature();
732-
digitalWrite(2,LOW);
733731
rtos::ThisThread::sleep_for(1000);
734732
}
735733
}

src/utils/Arduino_ScienceKitCarrier_definitions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or
@@ -49,7 +49,7 @@ const uint16_t MAXIMUM_AMPS{1}; // 1A
4949
#define BME688_CS 10
5050

5151
// External temperature connected on input A
52-
#define OW_PIN p26 //digitalPinToPinName(INPUTA_PIN)
52+
#define OW_PIN digitalPinToPinName(INPUTA_PIN)
5353
#define EXTERNAL_TEMPERATURE_DISABLED -273.0; // absolute zero xD
5454

5555

src/utils/function_generator_controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or

0 commit comments

Comments
 (0)