Skip to content

Commit 5a16a67

Browse files
authored
Revise usermod documentation and rules
Updated usermod structure and guidelines in AGENTS.md. Added a guideline to prevent agents from overwriting PR descriptions (see https://github.com/orgs/community/discussions/187027).
1 parent 83368c3 commit 5a16a67

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,40 @@ docs/ # Coding convention docs
140140

141141
## Usermod Pattern
142142

143-
Usermods live in `usermods/<name>/` with a `.cpp`, optional `.h`, `library.json`, and `readme.md`.
143+
Usermods live in `usermods/<name>/` with a `.h` and `readme.md`.
144144

145145
```cpp
146+
#pragma once
147+
#include "wled.h"
148+
146149
class MyUsermod : public Usermod {
147150
private:
148-
bool enabled = false;
149-
static const char _name[];
151+
#if !defined(_MoonModules_WLED_)
152+
// WLEDMM: don't overload global attributes
153+
bool enabled = false;
154+
static const char _name[];
155+
#endif
150156
public:
157+
#if defined(_MoonModules_WLED_)
158+
MyUsermod(const char *name, bool enabled):Usermod(name, enabled) {} // WLEDMM: passthrough of constructor - Usermod is an abstract class
159+
#endif
160+
151161
void setup() override { /* ... */ }
152162
void loop() override { /* ... */ }
153163
void addToConfig(JsonObject& root) override { /* ... */ }
154164
bool readFromConfig(JsonObject& root) override { /* ... */ }
155165
uint16_t getId() override { return USERMOD_ID_MYMOD; }
156166
};
157-
const char MyUsermod::_name[] PROGMEM = "MyUsermod";
158-
static MyUsermod myUsermod;
159-
REGISTER_USERMOD(myUsermod);
167+
#if !defined(_MoonModules_WLED_)
168+
const char MyUsermod::_name[] PROGMEM = "MyUsermod"; // WLEDMM: don't double initialize _name[] and _enabled[]
169+
// WLEDMM: for compatibility with upstream WLED
170+
static MyUsermod myUsermod;
171+
REGISTER_USERMOD(myUsermod);
172+
#endif
160173
```
161174

162-
- Add usermod IDs to `wled00/const.h`
163-
- Activate via `custom_usermods` in platformio build config
164-
- Base new usermods on `usermods/EXAMPLE/` (never edit the example directly)
175+
- Add usermod IDs to `wled00/const.h`, integrate new usermods via `wled00/usermod_list.cpp`
176+
- Base new usermods on `usermods/EXAMPLE_v2/` (never edit the example directly)
165177
- Store repeated strings as `static const char[] PROGMEM`
166178

167179
## CI/CD
@@ -177,6 +189,7 @@ No automated linting is configured. Match existing code style in files you edit.
177189

178190
- Repository language is English
179191
- Never edit or commit auto-generated `wled00/html_*.h` / `wled00/js_*.h`
192+
- When updating an existing PR, retain the original description. Only modify it to ensure technical accuracy. Add change logs after the existing description.
180193
- No force-push on open PRs
181194
- Changes to `platformio.ini` require maintainer approval
182195
- Remove dead/unused code — justify or delete it

0 commit comments

Comments
 (0)