From 4cc41de3d8285714aa0897870268e8cfa3014c1e Mon Sep 17 00:00:00 2001 From: Thomas Day Date: Mon, 1 Dec 2025 14:45:11 -0500 Subject: [PATCH 1/6] Add LIS3MDL support Not fully tested, mainly wanted to commit to show current progress --- include/simulation/SERIAL_SIM_LIS2MDL.h | 25 +++++++++++++++++++++++++ include/simulation/Serial_Sim.h | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 include/simulation/SERIAL_SIM_LIS2MDL.h diff --git a/include/simulation/SERIAL_SIM_LIS2MDL.h b/include/simulation/SERIAL_SIM_LIS2MDL.h new file mode 100644 index 0000000..ac28223 --- /dev/null +++ b/include/simulation/SERIAL_SIM_LIS2MDL.h @@ -0,0 +1,25 @@ +#ifndef SERIAL_SIM_LIS2MDL_H +#define SERIAL_SIM_LIS2MDL_H + +#include "Serial_Sim.h" + +class Adafruit_LIS2MDL { +public: + Adafruit_LIS2MDL (){} + + bool begin_SPI(int cs) { return true; } // Mock successful initialization SPI + bool begin(int addr) { return true; } // Mock successful initialization I2C + + void setDataRate(int rate) {} + void enableInterrupts(bool a) {} + + int getDataRate() { return 155; } // Mock as 155 Hz + + void getEvent(sensors_event_t *mag) { + SerialSim::getInstance().updateMag(mag); + + } + +}; + +#endif // SERIAL_SIM_LIS3MDL_H diff --git a/include/simulation/Serial_Sim.h b/include/simulation/Serial_Sim.h index 8b257d7..0432091 100644 --- a/include/simulation/Serial_Sim.h +++ b/include/simulation/Serial_Sim.h @@ -9,11 +9,13 @@ #define LSM6DS_ACCEL_RANGE_16_G 0x03 #define LSM6DS_GYRO_RANGE_2000_DPS 0x03 #define LSM6DS_RATE_104_HZ 0x04 -// LIS3MDL (Magnetometer) Define +// LIS3MDL (Magnetometer 1.3) Define #define LIS3MDL_DATARATE_155_HZ 0x06 #define LIS3MDL_RANGE_4_GAUSS 0x01 #define LIS3MDL_CONTINUOUSMODE 0x00 #define LIS3MDL_MEDIUMMODE 0x01 +// LIS2MDL (Magnetometer 1.4) Define +#define LIS2MDL_DATARATE_155_HZ 0x06 // BMP3 (Barometric Pressure Sensor) Define #define BMP3_OVERSAMPLING_8X 0x03 #define BMP3_OVERSAMPLING_4X 0x02 From f19c37f29999371a7c4059aa8024924253b6b44d Mon Sep 17 00:00:00 2001 From: Thomas Day Date: Wed, 3 Dec 2025 18:50:48 -0500 Subject: [PATCH 2/6] LIS2MDL does not have a setting for 155 Hz --- include/simulation/Serial_Sim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/simulation/Serial_Sim.h b/include/simulation/Serial_Sim.h index 0432091..b00e965 100644 --- a/include/simulation/Serial_Sim.h +++ b/include/simulation/Serial_Sim.h @@ -15,7 +15,7 @@ #define LIS3MDL_CONTINUOUSMODE 0x00 #define LIS3MDL_MEDIUMMODE 0x01 // LIS2MDL (Magnetometer 1.4) Define -#define LIS2MDL_DATARATE_155_HZ 0x06 +#define LIS2MDL_RATE_100_HZ 0x06 // BMP3 (Barometric Pressure Sensor) Define #define BMP3_OVERSAMPLING_8X 0x03 #define BMP3_OVERSAMPLING_4X 0x02 From f1efc2ed69a987fa39e992d296cc65715ad89042 Mon Sep 17 00:00:00 2001 From: Thomas Day Date: Thu, 15 Jan 2026 20:31:20 -0300 Subject: [PATCH 3/6] Changed 155 Hz to 100 Hz --- include/simulation/SERIAL_SIM_LIS2MDL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/simulation/SERIAL_SIM_LIS2MDL.h b/include/simulation/SERIAL_SIM_LIS2MDL.h index ac28223..1f26ce5 100644 --- a/include/simulation/SERIAL_SIM_LIS2MDL.h +++ b/include/simulation/SERIAL_SIM_LIS2MDL.h @@ -13,7 +13,7 @@ class Adafruit_LIS2MDL { void setDataRate(int rate) {} void enableInterrupts(bool a) {} - int getDataRate() { return 155; } // Mock as 155 Hz + int getDataRate() { return 100; } // Mock as 155 Hz void getEvent(sensors_event_t *mag) { SerialSim::getInstance().updateMag(mag); From 5b27f225ac1bec55d127ba4fdc13504226b2b95d Mon Sep 17 00:00:00 2001 From: Thomas Day <122122322+Mayday-01@users.noreply.github.com> Date: Fri, 16 Jan 2026 13:08:14 -0300 Subject: [PATCH 4/6] Update and rename SERIAL_SIM_LIS2MDL.h to serial_sim_LIS2MDL.h --- .../simulation/{SERIAL_SIM_LIS2MDL.h => serial_sim_LIS2MDL.h} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename include/simulation/{SERIAL_SIM_LIS2MDL.h => serial_sim_LIS2MDL.h} (94%) diff --git a/include/simulation/SERIAL_SIM_LIS2MDL.h b/include/simulation/serial_sim_LIS2MDL.h similarity index 94% rename from include/simulation/SERIAL_SIM_LIS2MDL.h rename to include/simulation/serial_sim_LIS2MDL.h index 1f26ce5..0779836 100644 --- a/include/simulation/SERIAL_SIM_LIS2MDL.h +++ b/include/simulation/serial_sim_LIS2MDL.h @@ -22,4 +22,4 @@ class Adafruit_LIS2MDL { }; -#endif // SERIAL_SIM_LIS3MDL_H +#endif // SERIAL_SIM_LIS2MDL_H From 4fb2761962e3a19ad77007987439a2be01e07da6 Mon Sep 17 00:00:00 2001 From: Thomas Day <122122322+Mayday-01@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:28:11 -0300 Subject: [PATCH 5/6] Rename serial_sim_LIS2MDL.h to Serial_sim_LIS2MDL.h --- include/simulation/{serial_sim_LIS2MDL.h => Serial_sim_LIS2MDL.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename include/simulation/{serial_sim_LIS2MDL.h => Serial_sim_LIS2MDL.h} (100%) diff --git a/include/simulation/serial_sim_LIS2MDL.h b/include/simulation/Serial_sim_LIS2MDL.h similarity index 100% rename from include/simulation/serial_sim_LIS2MDL.h rename to include/simulation/Serial_sim_LIS2MDL.h From 3898b39a395016bc9f6902846dc1658f3669f183 Mon Sep 17 00:00:00 2001 From: Thomas Day <122122322+Mayday-01@users.noreply.github.com> Date: Tue, 20 Jan 2026 19:33:44 -0300 Subject: [PATCH 6/6] Rename Serial_sim_LIS2MDL.h to Serial_Sim_LIS2MDL.h I'm sorry. --- include/simulation/{Serial_sim_LIS2MDL.h => Serial_Sim_LIS2MDL.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename include/simulation/{Serial_sim_LIS2MDL.h => Serial_Sim_LIS2MDL.h} (100%) diff --git a/include/simulation/Serial_sim_LIS2MDL.h b/include/simulation/Serial_Sim_LIS2MDL.h similarity index 100% rename from include/simulation/Serial_sim_LIS2MDL.h rename to include/simulation/Serial_Sim_LIS2MDL.h