From 399972dd1649bcd936601be7ed561ce899982cb1 Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Tue, 12 Nov 2024 12:14:12 -0500 Subject: [PATCH] Delete bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar directory --- .../NmeaChecksum.h | 23 ---- .../NmeaXDR.h | 73 ------------- .../bbn_m5atomS3_lite_TFminiS_range_lidar.ino | 103 ------------------ 3 files changed, 199 deletions(-) delete mode 100644 bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaChecksum.h delete mode 100644 bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaXDR.h delete mode 100644 bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/bbn_m5atomS3_lite_TFminiS_range_lidar.ino diff --git a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaChecksum.h b/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaChecksum.h deleted file mode 100644 index 6db8331..0000000 --- a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaChecksum.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NmeaChecksum_h -#define NmeaChecksum_h - -#define NMEA_END_CHAR_1 '\r' - -/* - NMEA-0183 checksum - */ - -uint8_t nmea0183_checksum(const char *sentence); - -uint8_t nmea0183_checksum(const char *sentence) { - const char *n = sentence + 1; - uint8_t chk = 0; - /* While current char isn't '*' or sentence ending (newline) */ - while ('*' != *n && NMEA_END_CHAR_1 != *n && '\0' != *n) { - chk ^= (uint8_t) *n; - n++; - } - return chk; -} - -#endif diff --git a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaXDR.h b/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaXDR.h deleted file mode 100644 index b2efad9..0000000 --- a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/NmeaXDR.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef NmeaXDR_h -#define NmeaXDR_h - -/* - XDR - Transducer Measurement - https://gpsd.gitlab.io/gpsd/NMEA.html#_xdr_transducer_measurement - https://www.eye4software.com/hydromagic/documentation/articles-and-howtos/handling-nmea0183-xdr/ - - Format: $--XDR,a,x.x,a,c--c, ..... *hh - Example: - - $HCXDR,A,171,D,PITCH,A,-37,D,ROLL,G,367,,MAGX,G,2420,,MAGY,G,-8984,,MAGZ*41 - $SDXDR,C,23.15,C,WTHI*70 - - Transducer Types: - A - Angular displacement - C - Temperature - D - Depth - F - Frequency - H - Humidity - N - Force - P - Pressure - R - Flow - B - Absolute humidity - G - Generic - I - Current - L - Salinity - S - Switch, valve - T - Tachometer - U - Voltage - V - Volume - could be more - - Unit of measurement - "" - could be empty! - A - Amperes - B - Bars | Binary - C - Celsius - D - Degrees - H - Hertz - I - liters/second - K - Kelvin | Density, kg/m3 kilogram per cubic metre - M - Meters | Cubic Meters (m3) - N - Newton - P - Percent of full range | Pascal - R - RPM - S - Parts per thousand - V - Volts - could be more -*/ - -/* - Bareboat Necessities Sensors NMEA-0183 XDR Sentences: - - NMEA-0183 Sender - BB - - Range with Lidar - - $BBXDR,D,0.20,M,RANGE_TFminiS*xx - -*/ - -#include "NmeaChecksum.h" - -void gen_nmea0183_xdr(const char *nmea_fmt, float value) { - char nmea_part[82]; - snprintf(nmea_part, 76, nmea_fmt, value); - int checksum = nmea0183_checksum(nmea_part); - Serial.printf("%s*%02X\r\n", nmea_part, checksum); -} - -#endif diff --git a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/bbn_m5atomS3_lite_TFminiS_range_lidar.ino b/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/bbn_m5atomS3_lite_TFminiS_range_lidar.ino deleted file mode 100644 index f4e5f5a..0000000 --- a/bbn_m5atomS3_lite_dlight/bbn_m5atomS3_lite_TFminiS_range_lidar/bbn_m5atomS3_lite_TFminiS_range_lidar.ino +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include "NmeaXDR.h" - -/* - Benewake TFmini-S UART LiDAR to NMEA-0183 XDR -*/ - -// UART pins when Lidar is plugged into port C of ATOMIC PortABC Extension Base -#define RXD2 G6 // Green on the Lidar -#define TXD2 G5 // White on the Lidar - -// UART pins when Lidar is plugged directly into grove port of M5 AtomS3-lite -//#define RXD2 G1 // Green on the Lidar -//#define TXD2 G2 // White on the Lidar - -// Other esp32 Lidar wiring pins -//#define RXD2 G16 // Green on the Lidar -//#define TXD2 G17 // White on the Lidar - -unsigned char check; -int dist; // actual distance measurements of LiDAR -unsigned char uart[9]; // save data measured by LiDAR -const int HEADER = 0x59; // frame header of data package -int rec_debug_state = 0x01; // receive state for frame - -const long report_interval = 500; // interval at which to update (milliseconds) -unsigned long previousMillis = 0UL; - -void setup() { - auto cfg = M5.config(); - AtomS3.begin(cfg); - Serial.begin(4800); - Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2); -} - -void loop() { - unsigned long currentMillis = millis(); - if (currentMillis - previousMillis >= report_interval) { - previousMillis = currentMillis; - Get_Lidar_data(); - } -} - -void Get_Lidar_data() { - if (Serial2.available()) { - if (rec_debug_state == 0x01) { - uart[0] = Serial2.read(); - if (uart[0] == 0x59) { - check = uart[0]; - rec_debug_state = 0x02; - } - } else if (rec_debug_state == 0x02) { - uart[1] = Serial2.read(); - if (uart[1] == 0x59) { - check += uart[1]; - rec_debug_state = 0x03; - } else { - rec_debug_state = 0x01; - } - } else if (rec_debug_state == 0x03) { - uart[2] = Serial2.read(); - check += uart[2]; - rec_debug_state = 0x04; - } else if (rec_debug_state == 0x04) { - uart[3] = Serial2.read(); - check += uart[3]; - rec_debug_state = 0x05; - } else if (rec_debug_state == 0x05) { - uart[4] = Serial2.read(); - check += uart[4]; - rec_debug_state = 0x06; - } else if (rec_debug_state == 0x06) { - uart[5] = Serial2.read(); - check += uart[5]; - rec_debug_state = 0x07; - } else if (rec_debug_state == 0x07) { - uart[6] = Serial2.read(); - check += uart[6]; - rec_debug_state = 0x08; - } else if (rec_debug_state == 0x08) { - uart[7] = Serial2.read(); - check += uart[7]; - rec_debug_state = 0x09; - } else if (rec_debug_state == 0x09) { - uart[8] = Serial2.read(); - if (uart[8] == check) { - dist = uart[2] + uart[3] * 256; // the distance in cm - int percent = 0; - if (dist <= 200) { // dist in cm, so 200 cm = 2 meters - percent = (200 - dist) * 100 / 200; // calculate percentage - } - - gen_nmea0183_xdr("$BBXDR,D,%.2f,M,RANGE_TFminiS", dist / 100.0); - - while (Serial2.available()) { - Serial2.read(); - } // Clear serial buffer - delay(100); - } - rec_debug_state = 0x01; - } - } -}