module_base: remove CRTP template pattern to reduce flash bloat (#26476)

* module_base: claude rewrite to remove CRTP bloat

* module_base: apply to all drivers/modules

* format

* fix build errors

* fix missing syntax

* remove reference to module.h in files that need module_base.h

* remove old ModuleBase<T>

* add module_base.cpp to px4_protected_layers.cmake

* fix IridiumSBD can_stop()

* fix IridiumSBD.cpp

* clang-tidy: downcast static cast

* get_instance() template accessor, revert clang-tidy global

* rename module_base.h to module.h

* revert changes in zenoh/Kconfig.topics
This commit is contained in:
Jacob Dahl
2026-02-19 15:17:17 +13:00
committed by GitHub
parent 657854ae1b
commit ce3e62841f
227 changed files with 1741 additions and 1496 deletions
+10 -8
View File
@@ -66,6 +66,8 @@
#include "MspV1.hpp"
ModuleBase::Descriptor MspOsd::desc{task_spawn, custom_command, print_usage};
//OSD elements positions
//in betaflight configurator set OSD elements to your desired positions and in CLI type "set osd" to retreieve the numbers.
//234 -> not visible. Horizontally 2048-2074(spacing 1), vertically 2048-2528(spacing 32). 26 characters X 15 lines
@@ -246,7 +248,7 @@ void MspOsd::Run()
{
if (should_exit()) {
ScheduleClear();
exit_and_cleanup();
exit_and_cleanup(desc);
return;
}
@@ -588,8 +590,8 @@ int MspOsd::task_spawn(int argc, char *argv[])
MspOsd *instance = new MspOsd(device);
if (instance) {
_object.store(instance);
_task_id = task_id_is_work_queue;
desc.object.store(instance);
desc.task_id = task_id_is_work_queue;
if (instance->init()) {
return PX4_OK;
@@ -600,8 +602,8 @@ int MspOsd::task_spawn(int argc, char *argv[])
}
delete instance;
_object.store(nullptr);
_task_id = -1;
desc.object.store(nullptr);
desc.task_id = -1;
return PX4_ERROR;
}
@@ -700,8 +702,8 @@ int MspOsd::custom_command(int argc, char *argv[])
if (argc == 1) {
PX4_INFO("Please provide a channel");
} else if (is_running() && _object.load()) {
MspOsd *object = _object.load();
} else if (is_running(desc) && desc.object.load()) {
MspOsd *object = get_instance<MspOsd>(desc);
int ret = object->set_channel(argv[1]);
if (ret == -1) {
@@ -748,5 +750,5 @@ $ msp_osd
extern "C" __EXPORT int msp_osd_main(int argc, char *argv[])
{
return MspOsd::main(argc, argv);
return ModuleBase::main(MspOsd::desc, argc, argv);
}
+3 -1
View File
@@ -100,9 +100,11 @@ enum SymbolIndex : uint8_t {
POWER = 21
};
class MspOsd : public ModuleBase<MspOsd>, public ModuleParams, public px4::ScheduledWorkItem
class MspOsd : public ModuleBase, public ModuleParams, public px4::ScheduledWorkItem
{
public:
static Descriptor desc;
MspOsd(const char *device);
~MspOsd() override;