neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
933 stars 189 forks source link

Problem using U8x8 display as output on Heltec WiFi Kit 32 #327

Closed cwoolum closed 3 years ago

cwoolum commented 3 years ago

Hello, I've been trying to use a U8x8 display as an output for the menu and am having an issue with kernel panic. I am using an Heltec WiFi Kit ESP32 and the display works on its own. Additionally, the menu works if only a serial output is used so it definitely seems to be a problem specifically with U8x8Out but I'm having trouble diagnosing. Here is the code I'm using.

#ifdef ARDUINO_HELTEC_WIFI_KIT_32
#include <U8x8lib.h>
#endif

U8X8_SSD1306_128X64_NONAME_SW_I2C oled(/* clock=*/15, /* data=*/4, /* reset=*/16);

OLEDController oledController(wifiManager, oled);
#pragma region Menu

#define LEDPIN LED_BUILTIN
#define MAX_DEPTH 1

// Encoder /////////////////////////////////////
#define encA 35
#define encB 32
//this encoder has a button here
#define encBtn 5

ClickEncoder clickEncoder(encA, encB, encBtn, 2);
ClickEncoderStream encStream(clickEncoder, 1);

unsigned int timeOn = 10;
unsigned int timeOff = 90;

const char *constMEM hexDigit MEMMODE = "0123456789ABCDEF";
const char *constMEM hexNr[] MEMMODE = {"0", "x", hexDigit, hexDigit};
char buf1[] = "0x11";

int chooseTest = -1;

CHOOSE(chooseTest, chooseMenu, "Choose", doNothing, noEvent, noStyle, VALUE("First", 1, doNothing, noEvent), VALUE("Second", 2, doNothing, noEvent), VALUE("Third", 3, doNothing, noEvent), VALUE("Last", -1, doNothing, noEvent));

MENU(mainMenu, "Main menu", doNothing, noEvent, wrapStyle, OP("Op1", doNothing, noEvent), EDIT("Hex", buf1, hexNr, doNothing, noEvent, noStyle), SUBMENU(chooseMenu), EXIT("<Back"));

MENU_OUTPUTS(out, MAX_DEPTH, U8X8_OUT(oled, {0, 0, 10, 6}), SERIAL_OUT(Serial));

serialIn serial(Serial);
MENU_INPUTS(in, &serial, &encStream);

NAVROOT(nav, mainMenu, MAX_DEPTH, in, out);

#pragma endregion

void setup()
{
    oled.begin();
    oled.setFont(u8x8_font_chroma48medium8_r);
}

void loop()
{   
        try
        {           
            nav.poll();
        }
        catch (...)
        {
        }   
}

It blows up at nav.poll(). The error I get is

rst:0x3 (SW_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
Guru Meditation Error: Core  1 panic'ed (Cache disabled but cached memory region accessed)
Core 1 register dump:
PC      : 0x400dcd74  PS      : 0x00060034  A0      : 0x800816d8  A1      : 0x3ffbe790  
A2      : 0x3ffbee0c  A3      : 0x20000000  A4      : 0x00000400  A5      : 0x3ffb1c40
A6      : 0x00000001  A7      : 0x3ffb8058  A8      : 0x80080fd4  A9      : 0x00000001
A10     : 0x3ffc1628  A11     : 0x00000000  A12     : 0x00060023  A13     : 0x00000001
A14     : 0x00060021  A15     : 0x00000000  SAR     : 0x0000001b  EXCCAUSE: 0x00000007  
EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0xffffffff
Core 1 was running in ISR context:
EPC1    : 0x40082dfb  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x400dcd74

Backtrace: 0x400dcd74:0x3ffbe790 0x400816d5:0x3ffbe7b0 0x40084be9:0x3ffbe7d0 0x40082df8:0x3ffb1c80 0x40086ee7:0x3ffb1ca0 0x40087022:0x3ffb1cc0 0x400874fa:0x3ffb1ce0 0x4014b3cf:0x3ffb1d50 0x400ee19d:0x3ffb1d80 0x400ee36d:0x3ffb1db0 0x400efbee:0x3ffb1de0 0x400ed662:0x3ffb1e20 0x400ec570:0x3ffb1e50 0x400ed008:0x3ffb1e90 0x400de5df:0x3ffb1f50 0x400d3a74:0x3ffb1f80 0x400e13bf:0x3ffb1fb0 0x40088ff5:0x3ffb1fd0

Rebooting...
ets Jun  8 2016 00:22:57

From what I read, this seems to be related to interrupts not having a IRAM_ATTR data type. Any idea what this problem could be or how to further debug it?

bellum128 commented 2 years ago

What was the solution here? I seem to be having a similar issue...