Skip to content

Commit 9790db7

Browse files
committed
1. Fix the M5PM1_REG_NEO_CFG register
1 parent 3f84249 commit 9790db7

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/M5PM1.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,10 +4392,10 @@ m5pm1_err_t M5PM1::setLeds(const m5pm1_rgb_t* colors, uint8_t arraySize, uint8_t
43924392

43934393
m5pm1_err_t M5PM1::setLedCount(uint8_t count)
43944394
{
4395-
// 验证参数:count 必须在 1-31 范围内(5位寄存器限制
4396-
// Validate parameter: count must be in range 1-31 (5-bit register limit)
4397-
if (count == 0 || count > 31) {
4398-
M5PM1_LOG_E(TAG_LED, "LED count %d out of valid range (1-31)", count);
4395+
// 验证参数:count 必须在 1-32 范围内(固件最大支持32
4396+
// Validate parameter: count must be in range 1-32 (firmware max 32)
4397+
if (count == 0 || count > M5PM1_MAX_LED_COUNT) {
4398+
M5PM1_LOG_E(TAG_LED, "LED count %d out of valid range (1-%d)", count, M5PM1_MAX_LED_COUNT);
43994399
return M5PM1_ERR_INVALID_ARG;
44004400
}
44014401
if (!_initialized) {

src/M5PM1.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ typedef enum {
331331
// ---- NeoPixel Registers ----
332332
#define M5PM1_REG_NEO_CFG \
333333
0x50 // R/W NeoPixel配置 / NeoPixel configuration
334-
// [7-6] 保留 / Reserved
335-
// [5] REFRESH - 写1刷新LED / REFRESH - write 1 to refresh LEDs
336-
// [4:0] LED_CNT - LED数量 (1-31,5位寄存器限制) / LED count (1-31, 5-bit register limit)
334+
// [7] 保留 / Reserved
335+
// [6] REFRESH - 写1刷新LED / REFRESH - write 1 to refresh LEDs
336+
// [5:0] LED_CNT - LED数量 (1-32,固件最大支持32) / LED count (1-32, firmware max 32)
337337
#define M5PM1_REG_AW8737A_PULSE \
338338
0x53 // R/W AW8737A脉冲控制 / AW8737A pulse control
339339
// 用于控制AW8737A音频放大器增益 / Used to control AW8737A audio amplifier gain
@@ -384,8 +384,8 @@ typedef enum {
384384

385385
// ---- NeoPixel配置寄存器位 ----
386386
// ---- NEO_CFG Register Bits ----
387-
#define M5PM1_NEO_CFG_REFRESH (1 << 5) // 刷新标志 / Refresh flag (write 1 to update LEDs)
388-
#define M5PM1_NEO_CFG_COUNT_MASK 0x1F // LED数量掩码 / LED count mask (0-31)
387+
#define M5PM1_NEO_CFG_REFRESH (1 << 6) // 刷新标志 / Refresh flag (write 1 to update LEDs)
388+
#define M5PM1_NEO_CFG_COUNT_MASK 0x3F // LED数量掩码 / LED count mask (0-63, firmware max 32)
389389

390390
// ============================
391391
// 枚举类型
@@ -2411,12 +2411,12 @@ class M5PM1 {
24112411
/**
24122412
* @brief 设置 NeoPixel LED 数量
24132413
* Set NeoPixel LED count
2414-
* @param count LED 数量 (1-31,受5位寄存器限制)
2415-
* LED count (1-31, limited by 5-bit register)
2414+
* @param count LED 数量 (1-32)
2415+
* LED count (1-32)
24162416
* @return 成功返回 M5PM1_OK,否则返回错误码
24172417
* Return M5PM1_OK on success, error code otherwise
2418-
* @note 寄存器为5位宽度,最大值为31。设置为32会溢出为0
2419-
* Register is 5-bit wide, maximum value is 31. Setting to 32 will overflow to 0
2418+
* @note 寄存器为6位宽度[5:0],固件最大支持32个LED
2419+
* Register is 6-bit wide [5:0], firmware supports max 32 LEDs
24202420
*/
24212421
m5pm1_err_t setLedCount(uint8_t count);
24222422

0 commit comments

Comments
 (0)