I'm trying to manipulate a variable with either a CHOOSE menu or manual increments through a FIELD menu
It works though various choose options, but editing it though a field crashes and resets my program
Variable in question is rnds
Am I doing something wrong?
#include<Wire.h>
#include<menu.h>
#include<menuIO/U8g2Out.h>
#include<menuIO/clickEncoderIn.h>
#include<menuIO/chainStream.h>
#include<EEPROM.h>
#defineencA7
#defineencB5
#defineencBtn3
#defineencStep4
#defineMAX_DEPTH2
#definefontName u8g2_font_7x13_mf
#definefontX4
#definefontY15
#defineoffsetX3
#defineoffsetY3
#defineU8_Width128
#defineU8_Height64usingnamespaceMenu;U8G2_SH1106_128X64_NONAME_F_HW_I2Cu8g2(U8G2_R0, U8X8_PIN_NONE);
ClickEncoder rotaryEncoder = ClickEncoder(encA, encB, encBtn, encStep);
ClickEncoderStream encStream(rotaryEncoder, 1);
MENU_INPUTS(in,&encStream);
voidIRAM_ATTRonTimer();
const colorDef<uint8_t> colors[6] MEMMODE={
{{0,0},{0,1,1}},//bgColor
{{1,1},{1,0,0}},//fgColor
{{1,1},{1,0,0}},//valColor
{{1,1},{1,0,0}},//unitColor
{{0,1},{0,0,1}},//cursorColor
{{1,1},{1,0,0}},//titleColor
};
int rnds=0;
result loadBBs(eventMask e,navNode& nav, prompt &item) {
Serial.println(rnds);
Serial.flush();
return proceed;
}
CHOOSE(rnds,presetMenu,"Preset",doNothing,noEvent,noStyle
,VALUE("None",0,doNothing,noEvent)
,VALUE("Low Cap",30,doNothing,noEvent)
,VALUE("MP5 Mid Short",65,doNothing,noEvent)
,VALUE("M16 Polymer Mid",120,doNothing,noEvent)
,VALUE("M4 Mid",200,doNothing,noEvent)
,VALUE("PTS EPM1 Mid",250,doNothing,noEvent)
);
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
,SUBMENU(presetMenu)
,FIELD(rnds,"Rounds"," Rnds",0,300,10,1,doNothing,noEvent,noStyle)
,OP("Load",loadBBs,enterEvent)
,OP("Manual",doNothing,enterEvent)
);
MENU_OUTPUTS(out,MAX_DEPTH
,U8G2_OUT(u8g2,colors,fontX,fontY,offsetX,offsetY,{0,0,U8_Width/fontX,U8_Height/fontY})
,NONE
);
NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);
hw_timer_t *timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
voidsetup() {
Serial.begin(115200);
Wire.begin();
u8g2.begin();
u8g2.setFont(fontName);
//nav.idleTask=idle;
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000, true);
timerAlarmEnable(timer);
pinMode(encA, INPUT_PULLUP);
pinMode(encB, INPUT_PULLUP);
rotaryEncoder.setAccelerationEnabled(true);
rotaryEncoder.setDoubleClickEnabled(false);
}
voidloop() {
nav.doInput();
if (nav.changed(0)) {
u8g2.firstPage();
do nav.doOutput(); while(u8g2.nextPage());
}
}
voidIRAM_ATTRonTimer()
{
rotaryEncoder.service();
}
I'm trying to manipulate a variable with either a CHOOSE menu or manual increments through a FIELD menu
It works though various choose options, but editing it though a field crashes and resets my program
Variable in question is
rndsAm I doing something wrong?
Hardware: