@@ -1007,3 +1007,50 @@ void applyCompensationGGA(char *nmeaSentence, int sentenceLength)
1007
1007
}
1008
1008
1009
1009
#endif // COMPILE_IM19_IMU
1010
+
1011
+ // Determine if a tilt sensor is available or not
1012
+ // Records outcome to NVM
1013
+ void tiltDetect ()
1014
+ {
1015
+ // Only test platforms that may have a tilt sensor on board
1016
+ if (present.tiltPossible == false )
1017
+ return ;
1018
+
1019
+ // Start test if not previously detected
1020
+ if (settings.detectedTilt == true )
1021
+ return ;
1022
+
1023
+ #ifdef COMPILE_IM19_IMU
1024
+ // Locally instantiate the library and hardware so it will release on exit
1025
+ IM19 *tiltSensor;
1026
+
1027
+ tiltSensor = new IM19 ();
1028
+
1029
+ // On Flex, ESP UART2 is connected to SW3, then UART3 of the GNSS (where a tilt module resides, if populated)
1030
+ HardwareSerial SerialTiltTest (2 ); // Use UART2 on the ESP32 to communicate with IMU
1031
+
1032
+ // Confirm SW3 is in the correct position
1033
+ gpioExpanderSelectImu ();
1034
+
1035
+ // We must start the serial port before handing it over to the library
1036
+ SerialTiltTest.begin (115200 , SERIAL_8N1, pin_IMU_RX, pin_IMU_TX);
1037
+
1038
+ if (settings.enableImuDebug == true )
1039
+ tiltSensor->enableDebugging (); // Print all debug to Serial
1040
+
1041
+ // Try multiple times to configure the IM19
1042
+ for (int x = 0 ; x < 3 ; x++)
1043
+ {
1044
+ if (tiltSensor->begin (SerialTiltTest) == true )
1045
+ {
1046
+ if (settings.enableImuDebug == true )
1047
+ systemPrintln (" Tilt sensor detected" );
1048
+
1049
+ present.imu_im19 = true ; // Allow tiltUpdate() to run
1050
+ settings.detectedTilt = true ;
1051
+ recordSystemSettings ();
1052
+ return ;
1053
+ }
1054
+ }
1055
+ #endif // COMPILE_IM19_IMU
1056
+ }
0 commit comments