m5stack / M5Unified

Unified library for M5Stack series

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

M5Capsule cannot be detected corretly

peterchenyipu opened this issue · comments

commented

Library versions:

  • M5Unified 0.1.13
  • M5GFX 0.1.13
  • M5Capsule 1.0.0

Issue:
None of the examples in M5Capsule would work due to the fact that the board type is not detected correctly. I confirmed with M5.getBoard(), and the result is 137 (board_M5AtomS3Lite). The code that resulted this is here:

M5Unified/src/M5Unified.cpp

Lines 489 to 498 in 725c654

board = ((const board_t[])
{ // ↓StampS3 pattern↓
board_t::board_unknown, board_t::board_unknown, board_t::board_M5StampS3, board_t::board_unknown, // ← unknown
board_t::board_M5AtomS3Lite,board_t::board_M5AtomS3Lite,board_t::board_unknown , board_t::board_M5AtomS3Lite, // ← AtomS3Lite pattern
board_t::board_M5AtomS3U, board_t::board_M5AtomS3U, board_t::board_M5StampS3, board_t::board_M5AtomS3U, // ← AtomS3U pattern
board_t::board_unknown, board_t::board_unknown, board_t::board_M5StampS3, board_t::board_unknown, // ← unknown
})[result&15];
if (board == board_t::board_M5StampS3) {
if ((result >> 3) == 0b110) { board = board_t::board_M5Capsule; }
}

The result variable is 54 or 0b110110. Taking the lowest 4 bits gives 0b0110 or 6. This corresponds to board_unknown in row 2 column 3. As a hack I modified it to be board_M5StampS3 and the examples started working again.

Is this a bug in the library or is there something wrong with my device? I only have one M5Capsule so I cannot verify if the other devices also have this issue. Thank you!

Hello @peterchenyipu .

Thank you for reporting this issue.
I overlooked this issue when I did the last update.

I have now updated the develop branch and changed it so that if the lower 2 bits of the bit pattern are 2, it is considered a Capsule. I think this will solve the problem.

Distinguishing between AtomS3Lite and StampS3 is quite a difficult problem, and I'm not sure how to tell the difference exactly. I am choosing an implementation that seems to have a high probability based on the results of my experiments, but I would welcome any suggestions for other better methods.

commented

Thank you for the update!