File tree Expand file tree Collapse file tree 4 files changed +54
-13
lines changed
Expand file tree Collapse file tree 4 files changed +54
-13
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,8 @@ Library to use the Science Kit Carrier rev3 sensors and make possible the connec
99
1010## NOTE
1111This library requires at least firmware 1.5.0 on your NINA module.
12+
13+ # WARNING - WIP
14+
15+ this branch works only with Modulino Distance and ESP32.
16+ When building this branch, please choose "pin numbering: by GPIO number (legacy)" from the tool tab in Arduino IDE.
Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ ScienceKitCarrier::ScienceKitCarrier(){
112112 enable_led_green = false ;
113113 enable_led_blue = false ;
114114 led_time_base = 20 ;
115+
116+ // Modulino.begin(Wire);
117+ tof = new ModulinoDistance ();
118+
115119}
116120
117121
@@ -133,7 +137,7 @@ int ScienceKitCarrier::begin(const uint8_t auxiliary_threads){
133137 digitalWrite (LED_BLUE,HIGH);
134138 #endif
135139
136-
140+ Modulino. begin ();
137141 Wire.begin ();
138142
139143 // most of begin functions return always 0, it is a code-style or future implementation
@@ -170,6 +174,15 @@ int ScienceKitCarrier::begin(const uint8_t auxiliary_threads){
170174 }
171175 #endif
172176
177+
178+ if (!tof->begin ()){
179+ tof_connected = false ;
180+ }
181+ else {
182+ tof_connected = true ;
183+ ultrasonic_is_connected = true ;
184+ }
185+
173186 // let's start bme688, external ds18b20 probe and ultrasonic sensor
174187 startAuxiliaryThreads (auxiliary_threads);
175188 return 1 ;
@@ -791,6 +804,7 @@ void ScienceKitCarrier::updateUltrasonic(){
791804 distance = -1.0 ;
792805 travel_time = -1.0 ;
793806 }
807+
794808}
795809
796810void ScienceKitCarrier::requestUltrasonicUpdate (){
@@ -826,8 +840,10 @@ bool ScienceKitCarrier::getUltrasonicIsConnected(){
826840
827841void ScienceKitCarrier::threadUltrasonic (){
828842 while (1 ){
829- updateUltrasonic ();
830- delay (200 );
843+ // updateUltrasonic();
844+ updateTOF ();
845+ // delay(200);
846+ delay (100 );
831847 }
832848}
833849
@@ -1017,7 +1033,19 @@ void ScienceKitCarrier::startAuxiliaryThreads(const uint8_t auxiliary_threads){
10171033 #endif
10181034}
10191035
1020-
1036+ // WIP
1037+ void ScienceKitCarrier::updateTOF (){
1038+ if (tof_connected){
1039+ if (tof->available ()){
1040+ distance = tof->get ();
1041+ travel_time = distance*2.0 /0.343 ;
1042+ }
1043+ }
1044+ else {
1045+ distance = -1.0 ;
1046+ travel_time = -1.0 ;
1047+ }
1048+ }
10211049
10221050
10231051
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ static Placeholder<OneWireNg_CurrentPlatform> ow;
6969#define wire_unlock xSemaphoreGive (wire_semaphore)
7070#endif
7171
72+ #include < Arduino_Modulino.h>
7273
7374class ScienceKitCarrier {
7475 private:
@@ -143,6 +144,12 @@ class ScienceKitCarrier{
143144 void requestUltrasonicUpdate ();
144145 void retriveUltrasonicUpdate ();
145146
147+ // WIP
148+
149+ ModulinoDistance * tof;
150+ bool tof_connected;
151+
152+
146153 public:
147154 ScienceKitCarrier ();
148155
@@ -254,7 +261,8 @@ class ScienceKitCarrier{
254261 static void freeRTOSUltrasonic (void * pvParameters);
255262 #endif
256263
257-
264+ // WIP
265+ void updateTOF ();
258266
259267 /* External temperature probe - Dallas DS18B20 */
260268 int beginExternalTemperature ();
Original file line number Diff line number Diff line change 2121#define __ARDUINO_SCIENCEKITCARRIER_DEFINITIONS_H__
2222
2323// Grove pads
24- #define INPUTA_PIN A0
25- #define INPUTB_PIN A1
24+ #define INPUTA_PIN 1
25+ #define INPUTB_PIN 2
2626#define ANALOGIN_DISABLED 0
2727#define UPDATE_ALL 0
2828#define UPDATE_INPUT_A 1
3636#endif
3737
3838// APDS9960
39- #define INT_APDS9960 9
39+ #define INT_APDS9960 18
4040#define APDS9960_VERSION 0
4141#define APDS9999_VERSION 1
4242
@@ -45,7 +45,7 @@ const uint32_t SHUNT_MICRO_OHM{100000}; // check schematic R20
4545const uint16_t MAXIMUM_AMPS {1 }; // 1A
4646
4747// Resistance
48- #define RESISTANCE_PIN A2
48+ #define RESISTANCE_PIN 3
4949#define RESISTOR_AUX 1000.0
5050#ifdef ARDUINO_NANO_RP2040_CONNECT
5151#define REF_VOLTAGE 3.3
@@ -66,14 +66,14 @@ const uint16_t MAXIMUM_AMPS{1}; // 1A
6666#define G_EARTH 9.807
6767
6868// Bme688
69- #define BME688_CS 10
69+ #define BME688_CS 21
7070
7171// External temperature connected on input A
7272#ifdef ARDUINO_NANO_RP2040_CONNECT
7373#define OW_PIN digitalPinToPinName(INPUTA_PIN)
7474#endif
7575#ifdef ARDUINO_NANO_ESP32
76- #define OW_PIN digitalPinToGPIONumber( INPUTA_PIN)
76+ #define OW_PIN INPUTA_PIN
7777#endif
7878#define EXTERNAL_TEMPERATURE_DISABLED -273.15; // absolute zero xD
7979
@@ -134,8 +134,8 @@ const uint16_t MAXIMUM_AMPS{1}; // 1A
134134
135135
136136// Servos
137- #define SERVO_A_PIN 3
138- #define SERVO_B_PIN 2
137+ #define SERVO_A_PIN 6
138+ #define SERVO_B_PIN 5
139139
140140
141141
You can’t perform that action at this time.
0 commit comments