Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFT_eSprite drawString is crash #83

Open
nnn112358 opened this issue Jan 5, 2020 · 5 comments
Open

TFT_eSprite drawString is crash #83

nnn112358 opened this issue Jan 5, 2020 · 5 comments

Comments

@nnn112358
Copy link

Kernel panic occurs when the size of drawString is set to 1 in TFT_eSprite.

moji2 = "Test";
TFT_eSprite * Spr->drawString(moji2, 80, 0, 1);

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

There is no problem if the character size is 2 or more.

moji2 = "Test";
TFT_eSprite * Spr->drawString(moji2, 80, 0, 2);

I use
・arduino-esp ver 1.04
・m5stickc libs in adrduino ver 0.1.1

@EeeeBin
Copy link
Contributor

EeeeBin commented Jan 5, 2020

@nnn112358
Copy link
Author

nnn112358 commented Jan 6, 2020

This example is no problem by the character size is between 2 and 8 .

EX.
    stext2.drawString("Hello World", 6, 0, 2); // draw at 6,0 in sprite, font 2 size

If folloow modification is bad.

    stext2.drawString("Hello World", 6, 0, 1); // draw at 6,0 in sprite, font 1 size
    stext2.drawString("Hello World", 6, 0, 10); // draw at 6,0 in sprite, font 10 size

@nnn112358
Copy link
Author

nnn112358 commented Jan 7, 2020

I investigated.

*int16_t TFT_eSPI::drawString(const char string, int32_t poX, int32_t poY, uint8_t font)

When specifying the "uint8_t font" value, there is no problem between 2 and 8.
"uint8_t font" value is 1 or over 9will crash.

My Trouble Source Code

  //This is crash
  //Spr->drawString(moji, 0, 0, 1);

  //This is No problem
  Spr->drawString(moji, 0, 20, 2);
  Spr->drawString(moji, 0, 40, 3);
  Spr->drawString(moji, 0, 60, 4);
  
  //This is crash
  //Spr->drawString(moji, 0, 60, 10);

https://gist.github.com/anoken/8ef9355e6945080b37fed12d6edb1e94

Crash Point
drawString() goes into textWidth() processing

TFT_eSPI::textWidth(const char *string, uint8_t font)
https://github.com/m5stack/M5StickC/blob/master/src/utility/In_eSPI.cpp#L2354

If "uint8_t font" value between 2 and 8 is follow process. This is No problem.
int16_t TFT_eSPI::textWidth(const char *string, uint8_t font)
https://github.com/m5stack/M5StickC/blob/master/src/utility/In_eSPI.cpp#L2387

But, If "uint8_t font" value1 or 9 is follow process. This is crash point.
gfxFont is invaid value, so crashed when accessed.
https://github.com/m5stack/M5StickC/blob/master/src/utility/In_eSPI.cpp#L2409

And, M5Stack is No problem.
the same code within M5StickC is crash.

@ciniml
Copy link

ciniml commented Jan 7, 2020

Hi,

I found that the root cause of this issue is just initialization code of TFT_eSPI::gfxFont is missing in its constructor.

Adding gfxFont = NULL; before the line 269 of In_eSPI.cpp is enough to solve this issue.

@mancini0
Copy link

mancini0 commented Jul 20, 2020

@ciniml your workaround worked for me - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants