Skip to content

Usermods that need fixing for compatibility with 16bit effect IDs #274

@coderabbitai

Description

@coderabbitai

Overview

This issue tracks usermods that require updates to support 16-bit effect IDs (PR #270). The migration from 8-bit to 16-bit effect IDs affects usermods that store, compare, or iterate over effect/mode IDs.

Critical Issues

1. usermod_v2_rotary_encoder_ui_ALT - Incomplete 16-bit support

Location: usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h

While effectCurrentIndex and knownMode were updated to uint16_t in PR #270, several critical issues remain:

  • Line 141: byte *modes_alpha_indexes - Array uses byte (uint8_t) to store mode indexes, limiting values to 0-255.
  • Line 354-358: re_initIndexArray() allocates and initializes a byte array with byte loop counter
  • Line 633: Loop counter is uint8_t i but iterates up to strip.getModeCount() which now returns uint16_t
  • sorting of effects list (re_sortModes(), re_qstringCmp(), re_initIndexArray()) cannot handle 16bit IDs, and may crash or produce other random side-effects.

Fix: Change modes_alpha_indexes from byte* to uint16_t* and update all related loops to use uint16_t counters.

Usermods with uint8_t knownMode Variables

The following usermods still use uint8_t for storing mode IDs and need to be updated to uint16_t:

2. usermod_v2_four_line_display_ALT

Location: usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h:161

  • uint8_t knownMode needs to be uint16_t

3. Wemos_D1_mini+Wemos32_mini_shield

Locations:

  • usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod.cpp:87
  • usermods/Wemos_D1_mini+Wemos32_mini_shield/usermod_bme280.cpp:88
  • Both have uint8_t knownMode that needs to be uint16_t

4. Enclosure_with_OLED_temp_ESP07

Locations:

  • usermods/Enclosure_with_OLED_temp_ESP07/usermod.cpp:53
  • usermods/Enclosure_with_OLED_temp_ESP07/usermod_bme280.cpp:92
  • Both have uint8_t knownMode that needs to be uint16_t

5. TTGO-T-Display

Location: usermods/TTGO-T-Display/usermod.cpp:82

  • uint8_t knownMode needs to be uint16_t

Elegant Fix Approach

For all affected usermods, the fix is straightforward:

  1. Change uint8_t knownMode declarations to uint16_t knownMode
  2. For usermod_v2_rotary_encoder_ui_ALT specifically:
    • Change byte *modes_alpha_indexes to uint16_t *modes_alpha_indexes
    • Update re_initIndexArray() signature and implementation to use uint16_t
    • Change loop counters from uint8_t to uint16_t when iterating over modes

MQTT Protocol

No issues found with MQTT serialization of effect IDs in usermods. MQTT typically uses JSON or string-based protocols which handle larger integers naturally.

Testing Recommendations

After fixes:

  • Test with builds containing >255 effects
  • Verify display usermods correctly show effect names for high-numbered effects
  • Confirm rotary encoder usermod can navigate through all effects

Related


Priority: Medium - These usermods will malfunction when effect IDs exceed 255.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions