witnessmenow / WiFi-Tetris-Clock

A WiFi clock made of falling tetris blocks. For the ESP8266 or ESP32
MIT License
186 stars 52 forks source link

esp8266 gfx support #1

Closed tablatronix closed 5 years ago

tablatronix commented 5 years ago
Exception Cause: Not found

0x40000f68: ?? ??:0
0x40208da9: __yield at ??:?
0x40205cd0: TetrisMatrixDraw::drawText(int, int) at ??:?
0x402303d2: esf_buf_recycle at ??:?
0x4022dbb0: ppRecycleRxPkt at ??:?
0x402036a9: animationHandler() at ??:?
0x4020b2ca: std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) at ??:?
0x40233c10: ets_timer_handler_isr at ??:?
0x4020ba0e: Ticker::_static_callback(void*) at ??:?
0x40233c1d: ets_timer_handler_isr at ??:?
0x40233c62: ets_timer_handler_isr at ??:?
0x40208c73: loop_task(ETSEventTag*) at core_esp8266_main.cpp:?
0x40000f49: ?? ??:0
0x40000f49: ?? ??:0
0x40000f49: ?? ??:0
0x40000e19: ?? ??:0
0x40001878: ?? ??:0
0x40104f68: call_user_start_local at ??:?
0x40104f6e: call_user_start_local at ??:?
0x4010000d: call_user_start at ??:?
0x40101108: cont_ret at cont.S.o:?
0x401010a9: cont_continue at cont.S.o:?
0x4022e937: pp_attach at ??:?
0x4022e986: pp_attach at ??:?
0x4022ea92: pp_attach at ??:?
0x40101a5e: pp_post at ??:?
0x4022da43: ppTxPkt at ??:?
0x40220e17: ieee80211_output_pbuf at ??:?
0x401054e7: wdt_feed at ??:?
0x40213719: glue2esp_linkoutput at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:748
0x4020a94c: malloc at ??:?
0x4021399b: new_linkoutput at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-lwip/lwip-git.c:424
0x40213d8c: ethernet_output at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/netif/ethernet.c:312
0x4021c59c: mem_malloc at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/core/mem.c:210
0x4020a94c: malloc at ??:?
0x4021c59c: mem_malloc at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/core/mem.c:210
0x4022e937: pp_attach at ??:?
0x4022e986: pp_attach at ??:?
0x4022ea92: pp_attach at ??:?
0x40101a5e: pp_post at ??:?
0x4022da43: ppTxPkt at ??:?
0x40220e17: ieee80211_output_pbuf at ??:?
0x4021b0d8: etharp_output_LWIP2 at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/core/ipv4/etharp.c:890
0x40213719: glue2esp_linkoutput at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:748
0x40211bf6: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:233
0x402089f1: String::equals(char const*) const at ??:?
0x4020d8f0: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c:194 (discriminator 1)
0x40211bf6: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:233
0x40211b28: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:180
0x4020d9f8: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c:244
0x40243af0: sleep_reset_analog_rtcreg_8266 at ??:?
0x40101a5e: pp_post at ??:?
0x40104e5f: lmacRxDone at ??:?
0x4021200b: _svfprintf_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:660
0x40102775: trc_NeedRTS at ??:?
0x4010294e: trc_NeedRTS at ??:?
0x40208432: String::copy(char const*, unsigned int) at ??:?
0x40102d8e: wDev_ProcessFiq at ??:?
0x40201ff6: Timezone::tzTime(long, ezLocalOrUTC_t) at ??:?
0x4000050c: ?? ??:0
0x40102b28: wDev_ProcessFiq at ??:?
0x40209f56: uart_tx_fifo_available at ??:?
0x40105741: ets_timer_disarm at ??:?
0x4000050c: ?? ??:0
0x402092ff: twi_write_bit at core_esp8266_si2c.cpp:?
0x402092e8: twi_write_bit at core_esp8266_si2c.cpp:?
0x4020b438: Adafruit_GFX::writePixel(short, short, unsigned short) at ??:?
0x4020a02a: uart_write at ??:?
0x40207c90: HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
0x40207f29: Print::write(char const*) at ??:?
0x402088ac: String::concat(String const&) at ??:?
0x402080c7: Print::printNumber(unsigned long, unsigned char) at ??:?
0x402093dd: twi_write_byte at core_esp8266_si2c.cpp:?
0x402093dd: twi_write_byte at core_esp8266_si2c.cpp:?
0x402095c5: twi_writeTo at ??:?
0x4020a02a: uart_write at ??:?
0x401055f6: wdt_feed at ??:?
0x401056b2: ets_timer_setfn at ??:?
0x40105884: ets_timer_arm_new at ??:?
0x40208cb8: esp_yield at ??:?
0x402097ab: delay at ??:?
0x40203cbb: setup at ??:?
0x4020367c: animationHandler() at ??:?
0x4020b2d4: std::_Function_base::_Base_manager<void (*)()>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at ??:?
0x4020b2c0: std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) at ??:?
0x4020367c: animationHandler() at ??:?
0x40208d60: loop_wrapper() at core_esp8266_main.cpp:?
0x4010f000: ?? ??:0
tablatronix commented 5 years ago

Useless.. lol

tablatronix commented 5 years ago

I am debug tracing to find where we are at last since stack trace is not definitive..

This seems odd to me

drawShape:1073656364
drawShape:1073656364
drawShape:1073656364
drawShape:1073656364
drawShape:1
Soft WDT reset

>>>stack>>>

ctx: sys
sp: 3fffec10 end: 3fffffb0 offset: 01b0
3fffedc0:  3fff2700 00000000 3fff26f7 4020a032  
3fffedd0:  3fffee2c 00000014 3fffee20 4020a95d  
tablatronix commented 5 years ago

ok i am assuming something is getting all wacky and not being init or is set to memory space

fall_instr getFallinstrByNum() and others do not have defaults, and I am getting some weird values set for fall_instr current_fall = getFallinstrByNum(numstates[numpos].num_to_draw, numstates[numpos].blockindex);

also these for loops have no esp8266 safety delays

witnessmenow commented 5 years ago

Do you have a gist or something of what you have so far?

On Wed, 5 Jun 2019, 21:57 Shawn A, notifications@github.com wrote:

ok i am assuming something is getting all wacky and not being init or is set to memory space

fall_instr getFallinstrByNum() and others do not have defaults, and I am getting some weird values set for fall_instr current_fall = getFallinstrByNum(numstates[numpos].num_to_draw, numstates[numpos].blockindex);

also these for loops have no esp8266 safety delays

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/WiFi-Tetris-Clock/issues/1?email_source=notifications&email_token=AAL5PQR5GX5CN5KDEFXYEETPZASCVA5CNFSM4HUGVCYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXA72SQ#issuecomment-499252554, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5PQTF3UBOSXX7NX5JTEDPZASCVANCNFSM4HUGVCYA .

tablatronix commented 5 years ago

its mostly the example I guess I need to trim it down and remove the time, and just make a basic test, cause this is overly convoluted for debugging

tablatronix commented 5 years ago

I cannot even get the intro to work so something is wrong.. lol no clue at this point maybe ada gfx cannot handle a monochrome display with color data ?

tablatronix commented 5 years ago

probably going to give up I was hoping to fix this, sorry

witnessmenow commented 5 years ago

Could be alright, I was surprised that it worked at all on the nokia screen

I know it's unlikely to be your problem now (It was crashing for me the first time I was drawing the time) but I would defiantly start with one of the examples from the tetris animation library, I have my suspicions that ezTime is causing some problems. Alpha Test or number test would be a good place to start.

Does trying to draw the intro but passing in 0 instead of the colours work?

With regards the above stuff delays in loops etc, I think it would be good to raise them individually as issues against the tetris animation library so they can be picked up by people if they would like.

On Wed, 5 Jun 2019 at 22:06, Shawn A notifications@github.com wrote:

I cannot even get the intro to work so something is wrong.. lol no clue at this point maybe ada gfx cannot handle a monochrome display with color data ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/WiFi-Tetris-Clock/issues/1?email_source=notifications&email_token=AAL5PQVDRMJQOX2UCH5I4R3PZATELA5CNFSM4HUGVCYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXBASDA#issuecomment-499255564, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5PQTB37JUVRRP45CHSDTPZATELANCNFSM4HUGVCYA .

tablatronix commented 5 years ago

making progress, I will post something when I am done, and submit any PRs to the tetrisanimation library, thanks I might have an idea how to fix this, turns out to be more than 1 issue, those are always the hardest to figure out

witnessmenow commented 5 years ago

Awesome! Thank you!

On Wed, 5 Jun 2019, 22:42 Shawn A, notifications@github.com wrote:

making progress, I will post something when I am done, and submit any PRs to the tetrisanimation library, thanks I might have an idea how to fix this, turns out to be more than 1 issue, those are always the hardest to figure out

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/WiFi-Tetris-Clock/issues/1?email_source=notifications&email_token=AAL5PQVQC3YTMCOAIZH2GMLPZAXKZA5CNFSM4HUGVCYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXBDGLQ#issuecomment-499266350, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5PQXIFUPZAGDA76CZSMLPZAXKZANCNFSM4HUGVCYA .

tablatronix commented 5 years ago

The problem is right in the libraries, eg. ssd1306

#if defined(ESP8266)
  // ESP8266 needs a periodic yield() call to avoid watchdog reset.
  // With the limited size of SSD1306 displays, and the fast bitrate
  // being used (1 MHz or more), I think one yield() immediately before
  // a screen write and one immediately after should cover it.  But if
  // not, if this becomes a problem, yields() might be added in the
  // 32-byte transfer condition below.
  yield();
#endif

So calling display inside an ISR and trying to yield or not yielding enough is probably the problem. The only solution I see is to not use ticker, and use some other loop process timer library

Also some adafruit libraries, eg, ssd1306 cannot handle color info and has no sanity check or fallback so it chokes, I will PR adafruits libraries to fix this, but if using a monochrome display never use a value outside of the available colors eg. WHITE,BLACK,INVERT

witnessmenow commented 5 years ago

Cool thanks for looking into this!

There is an intiliaseColours method in the library that could be overloaded to set up the monochrome colours too.

On Thu, 6 Jun 2019, 16:16 Shawn A, notifications@github.com wrote:

The problem is right in the libraries, eg. ssd1306

if defined(ESP8266)

// ESP8266 needs a periodic yield() call to avoid watchdog reset. // With the limited size of SSD1306 displays, and the fast bitrate // being used (1 MHz or more), I think one yield() immediately before // a screen write and one immediately after should cover it. But if // not, if this becomes a problem, yields() might be added in the // 32-byte transfer condition below. yield();

endif

So calling display inside an ISR and trying to yield or not yielding enough is probably the problem. The only solution I see is to not use ticker, and use some other loop process timer library

Also some adafruit libraries, eg, ssd1306 cannot handle color info and has no sanity check or fallback so it chokes, I will PR adafruits libraries to fix this, but if using a monochrome display never use a value outside of the available colors eg. WHITE,BLACK,INVERT

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/WiFi-Tetris-Clock/issues/1?email_source=notifications&email_token=AAL5PQUQ7W6DZEMT642ZMNTPZES3TA5CNFSM4HUGVCYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXDFY4A#issuecomment-499539056, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5PQWMS4SLTP5PHMXHG5DPZES3TANCNFSM4HUGVCYA .

tablatronix commented 5 years ago

I almost have it working, hunting down scale crash now.

Yeah I saw that, should be pretty easy to clean up and make a monochrome flag

tablatronix commented 5 years ago

Here is a stack trace from scale 2

    Exception Cause: 9  [LoadStoreAlignmentCause: Load or store to an unaligned address]

    0x40105658: ets_timer_setfn at ??:?
    0x40105884: ets_timer_arm_new at ??:?
    0x40208d18: free at ??:?
    0x40207988: delay at ??:?
    0x40206154: String::~String() at ??:?
    0x40203bd3: TetrisMatrixDraw::drawLargerBlock(int, int, int, unsigned short) at ??:?
    0x40102e2b: wDev_ProcessFiq at ??:?
    0x40203d6f: TetrisMatrixDraw::drawLargerShape(int, int, unsigned short, int, int, int) at ??:?
    0x40203408: getFallinstrByNum(int, int) at ??:?
    0x4000050c: ?? ??:0
    0x402200b3: ieee80211_send_probereq at ??:?
    0x402045b8: TetrisMatrixDraw::drawNumbers(int, int, bool) at ??:?
    0x40223aa3: chm_start_op at ??:?
    0x402026ec: animationHandler() at ??:?
    0x402094b6: std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) at ??:?
    0x4023245c: ets_timer_handler_isr at ??:?
    0x4020a3ae: Ticker::_static_callback(void*) at ??:?
    0x40232469: ets_timer_handler_isr at ??:?
    0x402324ae: ets_timer_handler_isr at ??:?
    0x40000f49: ?? ??:0
    0x40000f49: ?? ??:0
    0x40000f49: ?? ??:0
    0x40000e19: ?? ??:0
    0x40001878: ?? ??:0
    0x40104f68: call_user_start_local at ??:?
    0x40104f6e: call_user_start_local at ??:?
    0x4010000d: call_user_start at ??:?
    0x40101108: cont_ret at cont.S.o:?
    0x401010a9: cont_continue at cont.S.o:?
    0x40101a5e: pp_post at ??:?
    0x40104e5f: lmacRxDone at ??:?
    0x40102775: trc_NeedRTS at ??:?
    0x4010294e: trc_NeedRTS at ??:?
    0x40102d8e: wDev_ProcessFiq at ??:?
    0x4000050c: ?? ??:0
    0x40102b28: wDev_ProcessFiq at ??:?
    0x400043f0: ?? ??:0
    0x400044ab: ?? ??:0
    0x40241ea0: sleep_reset_analog_rtcreg_8266 at ??:?
    0x4022d183: pp_attach at ??:?
    0x4022d1d2: pp_attach at ??:?
    0x40101a5e: pp_post at ??:?
    0x40104e5f: lmacRxDone at ??:?
    0x40101a5e: pp_post at ??:?
    0x40101a5e: pp_post at ??:?
    0x40104e5f: lmacRxDone at ??:?
    0x40101a5e: pp_post at ??:?
    0x40102775: trc_NeedRTS at ??:?
    0x4010294e: trc_NeedRTS at ??:?
    0x40206256: String::reserve(unsigned int) at ??:?
    0x402062b6: String::copy(char const*, unsigned int) at ??:?
    0x402064d1: String::operator=(char const*) at ??:?
    0x402063a9: String::move(String&) at ??:?
    0x40206965: String::equals(char const*) const at ??:?
    0x40206154: String::~String() at ??:?
    0x40201c5a: Timezone::tzTime(long, ezLocalOrUTC_t, String&, bool&, short&) at ??:?
    0x402075bc: twi_write_byte at core_esp8266_si2c.cpp:?
    0x40105741: ets_timer_disarm at ??:?
    0x4000050c: ?? ??:0
    0x402074cd: twi_write_bit at core_esp8266_si2c.cpp:?
    0x40100118: twi_delay at core_esp8266_si2c.cpp:?
    0x40205f5b: Print::printNumber(unsigned long, unsigned char) at ??:?
    0x4023f704: sleep_reset_analog_rtcreg_8266 at ??:?
    0x402067e1: String::concat(__FlashStringHelper const*) at ??:?
    0x40208212: uart_write at ??:?
    0x40205b64: HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
    0x40205de5: Print::write(char const*) at ??:?
    0x40205fb4: Print::print(long, int) at ??:?
    0x402075c5: twi_write_byte at core_esp8266_si2c.cpp:?
    0x402075c5: twi_write_byte at core_esp8266_si2c.cpp:?
    0x402077ad: twi_writeTo at ??:?
    0x40204e1c: TwoWire::endTransmission(unsigned char) at ??:?
    0x4010557f: wdt_feed at ??:?
    0x40206ea0: esp_yield at ??:?
    0x40105884: ets_timer_arm_new at ??:?
    0x40206ea0: esp_yield at ??:?
    0x40207993: delay at ??:?
    0x40202c31: loop at ??:?
    0x40206f50: loop_wrapper() at core_esp8266_main.cpp:?
tablatronix commented 5 years ago

ok so ssd1306 works, I am cleaning up my example to PR then I will check the other displays I have.

I am having one issue still, it seems the display slows down really slow the longer it animates, almost seems like there is a bad loop somewhere or something is filling up and not clearing out memory maybe.

Ill have to test the lib examples and see if they do it also, I did not see any purposeful delay in the code.

tablatronix commented 5 years ago

https://github.com/toblum/TetrisAnimation/issues/3

tablatronix commented 5 years ago

I am going to close this out with this

tablatronix commented 4 years ago

I opened an issue in ada gfx ( as I have this issue in other projects/libs) https://github.com/adafruit/Adafruit-GFX-Library/issues/236

I could never figure out a solution or cause so I closed it

Martin-Laclaustra commented 4 years ago

I am going to close this out with this

* [ ]  Find decent timer library that uses loop process not an ISR

@tablatronix Maybe you could check this, and see if it fits your needs. https://github.com/Martin-Laclaustra/CronAlarms

tablatronix commented 4 years ago

Nice, It is a but overkill for a basic timer, it would be several lines of code to just to just add it to the sketch