Skip to content

Using projectMM as a Library

projectMM can be consumed as a PlatformIO library. Your project gets the full module runtime (Module, StatefulModule, ModuleManager, Scheduler, PAL, HTTP/WS server) plus all built-in modules (effects, layers, modifiers) without copying any source.


Add to your project

In your platformio.ini:

lib_deps =
    https://github.com/ewowi/projectMM
    bblanchon/ArduinoJson @ ^7
    ESP32Async/ESPAsyncWebServer#v3.10.3

PlatformIO fetches the repo, compiles src/ (excluding main.cpp), and links it into your firmware. The lib_compat_mode = strict flag is recommended to suppress the Raspberry Pi TCP backend on ESP32:

lib_compat_mode = strict

Provide your own entry point

The library omits src/main.cpp. Your project must provide a src/main.cpp (or equivalent) with the Arduino setup() and loop() functions. The simplest starting point:

#include "core/ModuleManager.h"
#include "core/Scheduler.h"

static ModuleManager mgr;
static Scheduler     sched;

void setup() {
    Serial.begin(115200);
    mgr.begin(sched);         // loads state/modulemanager.json or auto-creates defaults
}

void loop() {
    sched.loop();
}

The real src/main.cpp in this repo wires HTTP, WebSocket, WiFi and FreeRTOS tasks in addition to the above. Copy it as a starting point and strip what you do not need.


Register additional modules

All built-in modules are registered automatically via the library's ModuleRegistrations.cpp. To add your own:

// src/MyModuleRegistrations.cpp  (in your project, not the library)
#include "core/TypeRegistry.h"
#include "MyEffect.h"

REGISTER_MODULE(MyEffect)

REGISTER_MODULE must be called from a translation unit that is part of the executable, not a static library — placing it in your project's src/ satisfies that requirement.


Pin a specific release

To track a release tag rather than main:

lib_deps =
    https://github.com/ewowi/projectMM#v1.3.0

Check GitHub releases for available tags.


What the library exposes

Path Contents
src/core/ Module, StatefulModule, ModuleManager, Scheduler, TypeRegistry, HTTP/WS servers, KvStore, Logger
src/pal/ Pal.h, MemoryStats.h, FileSystem.h — platform abstraction layer
src/modules/ Effects, layers, modifiers, drivers, system modules + ModuleRegistrations.cpp
src/frontend/ frontend_bundle.h — inlined HTML/CSS/JS served over HTTP

src/main.cpp is excluded from the library build via library.json's srcFilter.


Exclude built-in modules (advanced)

If you need a smaller binary and do not want all built-in modules, you can point to a fork or a specific commit and modify ModuleRegistrations.cpp, or use PlatformIO's build_src_filter to override which files are compiled from the dependency. This is an advanced use case; the details depend on your PlatformIO version.