Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SITL: add ENABLED defines for remaining simulated I2C devices #28848

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

srmainwaring
Copy link
Contributor

@srmainwaring srmainwaring commented Dec 12, 2024

Adds conditional compilation defines for the remainder of the I2C sensors included in SIM_I2C.cpp.

Motivation

Aside from consistency, this reduces DRAM use for SIM on HW (esp. esp32empty and esp32s3empty where RAM limits are causing WiFi to not initialise correctly).

cd ./build/esp32s3empty/esp-idf_build
ninja -v -v size-files | grep SIM_I2C.cpp

Before:

Object File DRAM .data .bss IRAM .text RAM Total Flash .text .rodata Flash Total
SIM_I2C.cpp.0.o 116 20620 0 20736 867 184 1167

After:

Object File DRAM .data .bss IRAM .text RAM Total Flash .text .rodata Flash Total
SIM_I2C.cpp.0.o 36 3984 0 4020 71 24 131

See also:

@@ -2,6 +2,14 @@

#include "SIM_I2CDevice.h"

#include <AP_HAL/AP_HAL_Boards.h>

#ifndef AP_SIM_AIRSPEEDDLVR_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should go in SIM_config.h

Also, please add underscores in each of them:

Suggested change
#ifndef AP_SIM_AIRSPEEDDLVR_ENABLED
#ifndef AP_SIM_AIRSPEED_DLVR_ENABLED

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Updated in 92b8e86

@srmainwaring srmainwaring force-pushed the prs/prs-sitl-i2c-defines branch 2 times, most recently from a758871 to 035d4e4 Compare December 14, 2024 14:29
@srmainwaring srmainwaring force-pushed the prs/prs-sitl-i2c-defines branch from 035d4e4 to 92b8e86 Compare December 14, 2024 14:32
@@ -1,5 +1,7 @@
#include "SIM_Temperature_TSYS01.h"

#if AP_SIM_TEMPERATURE_TSYS01_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our pattern is to include SIM_config.h and then check this, including the .h corresponding to the .cpp after that check has passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in follow up here: #28871

@peterbarker peterbarker merged commit 70fe304 into ArduPilot:master Dec 14, 2024
99 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants