Skip to content

Commit 49f5d2d

Browse files
committed
lolin32 example
1 parent 6e65ebd commit 49f5d2d

File tree

5 files changed

+254
-5
lines changed

5 files changed

+254
-5
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ platformio.ini
1414
!/.gitignore
1515
*.odg
1616
examples/clickEncoder
17-
examples/lolin32
1817
examples/screenNav

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,51 @@ void loop() {
9494
9595
## Applications
9696
97-
**Fielduino** hardware PWM generator using menu to select frequency and dutty.
97+
Some applications using ArduinoMenu, some using older versions.
98+
Do you have another? please let me know on gitter or email me.
9899
100+
**teensy-midi-looper** Microcontroller-based midi performance sequencer
101+
https://github.com/newdigate/teensy-midi-looper
102+
103+
**AmplifierControl** Automate procedure to switch on/off amplifier and band decode of Kenwood
104+
https://github.com/petrlab/AmplifierControl
105+
106+
**spna** An Arduino Single Port Network Analyzer (SPNA)
107+
https://github.com/tczerwonka/spna
108+
109+
**LRDuino** In car multi gauge system - STM32, SSD1306, MAX31856, ADXL345, ELM327
110+
https://github.com/BennehBoy/LRDuino
111+
112+
**LRDuinoTD5** In car multi gauge system - STM32, SSD1306, MAX31856, ADXL345, L9637D, TD5 ECU
113+
https://github.com/BennehBoy/LRDuinoTD5
114+
115+
**PANOBOT** A Panorama robot
116+
https://github.com/RobertFach/panobot
117+
118+
**thom-radio** Internet radio build
119+
https://github.com/evfool/thom-radio
120+
121+
**MIDI_drums** 7 chanel piezo MIDI drum box with menu on LCD
122+
https://github.com/Sobollion/MIDI_drums
123+
124+
**BalancingRobot**
125+
https://github.com/SLBarker/BalancingRobot
126+
127+
**swatili** 50l water meter with valve control, lcd, buttons, rtc and hall effect pulse reader
128+
https://github.com/daniel-leonard-robinson/swatili
129+
130+
**Fielduino** hardware PWM generator using menu to select frequency and dutty.
99131
https://github.com/neu-rah/Fielduino
100132
133+
**ArduinoMultiDesktop** MultiDesktop concept for hardware devices
134+
https://github.com/dontsovcmc/ArduinoMultiDesktop
135+
136+
**SmartGreenHouse**
137+
https://github.com/dontsovcmc/SmartGreenHouse/tree/master/src
138+
139+
**console.arduino** Portable serial debug console project using ILI9341
140+
https://github.com/malachib/console.arduino
141+
101142
## Platforms
102143
Atmel AVR, Atmel SAM, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Teensy, TI MSP430
103144

examples/U8G2/U8G2/U8G2.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ using namespace Menu;
6565
#define U8_Width 128
6666
#define U8_Height 64
6767
#define USE_HWI2C
68-
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);//, SCL, SDA);
69-
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, U8X8_PIN_NONE, 2, 0);
68+
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);//, SCL, SDA);
69+
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, U8X8_PIN_NONE, 4, 5);
70+
// U8G2_SSD1306_128X64_VCOMH0_F_HW_I2C u8g2(U8G2_R2, U8X8_PIN_NONE, 4, 5);
71+
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 4, 5);
7072
#else
7173
#error DEFINE YOUR OUTPUT HERE.
7274
#endif
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#include <Arduino.h>
2+
3+
/********************
4+
Arduino generic menu system
5+
lolin32 menu example
6+
7+
output: onboard oled (i2c ssd1306 u8g2)
8+
input: Serial
9+
mcu: esp32 lolin with builtin oled
10+
11+
*/
12+
13+
#include <menu.h>
14+
#include <menuIO/u8g2Out.h>
15+
// #include <menuIO/encoderIn.h>
16+
// #include <menuIO/keyIn.h>
17+
#include <menuIO/chainStream.h>
18+
#include <menuIO/serialOut.h>
19+
#include <menuIO/serialIn.h>
20+
21+
using namespace Menu;
22+
23+
// #define LEDPIN LED_BUILTIN
24+
25+
#include <Wire.h>
26+
#define fontName u8g2_font_7x13_mf
27+
#define fontX 7
28+
#define fontY 16
29+
#define offsetX 0
30+
#define offsetY 3
31+
#define U8_Width 128
32+
#define U8_Height 64
33+
#define USE_HWI2C
34+
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 4, 5);
35+
U8G2_SSD1306_128X64_VCOMH0_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 4, 5);//allow contrast change
36+
// U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 4, 5);
37+
38+
39+
// define menu colors --------------------------------------------------------
40+
//each color is in the format:
41+
// {{disabled normal,disabled selected},{enabled normal,enabled selected, enabled editing}}
42+
// this is a monochromatic color table
43+
const colorDef<uint8_t> colors[]={
44+
{{0,0},{0,1,1}},//bgColor
45+
{{1,1},{1,0,0}},//fgColor
46+
{{1,1},{1,0,0}},//valColor
47+
{{1,1},{1,0,0}},//unitColor
48+
{{0,1},{0,0,1}},//cursorColor
49+
{{1,1},{1,0,0}},//titleColor
50+
};
51+
52+
result doAlert(eventMask e, prompt &item);
53+
54+
int test=55;
55+
56+
int ledCtrl=HIGH;
57+
58+
result myLedOn() {
59+
ledCtrl=HIGH;
60+
return proceed;
61+
}
62+
result myLedOff() {
63+
ledCtrl=LOW;
64+
return proceed;
65+
}
66+
67+
TOGGLE(ledCtrl,setLed,"Led: ",doNothing,noEvent,noStyle//,doExit,enterEvent,noStyle
68+
,VALUE("On",HIGH,doNothing,noEvent)
69+
,VALUE("Off",LOW,doNothing,noEvent)
70+
);
71+
72+
int selTest=0;
73+
SELECT(selTest,selMenu,"Select",doNothing,noEvent,noStyle
74+
,VALUE("Zero",0,doNothing,noEvent)
75+
,VALUE("One",1,doNothing,noEvent)
76+
,VALUE("Two",2,doNothing,noEvent)
77+
);
78+
79+
int chooseTest=-1;
80+
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
81+
,VALUE("First",1,doNothing,noEvent)
82+
,VALUE("Second",2,doNothing,noEvent)
83+
,VALUE("Third",3,doNothing,noEvent)
84+
,VALUE("Last",-1,doNothing,noEvent)
85+
);
86+
87+
// //customizing a prompt look!
88+
// //by extending the prompt class
89+
// class altPrompt:public prompt {
90+
// public:
91+
// altPrompt(constMEM promptShadow& p):prompt(p) {}
92+
// Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) override {
93+
// return out.printRaw("special prompt!",len);;
94+
// }
95+
// };
96+
97+
MENU(subMenu,"Sub-Menu",doNothing,noEvent,noStyle
98+
,OP("Sub1",doNothing,noEvent)
99+
// ,altOP(altPrompt,"",doNothing,noEvent)
100+
,EXIT("<Back")
101+
);
102+
103+
uint16_t hrs=0;
104+
uint16_t mins=0;
105+
106+
//define a pad style menu (single line menu)
107+
//here with a set of fields to enter a date in YYYY/MM/DD format
108+
altMENU(menu,time,"Time",doNothing,noEvent,noStyle,(systemStyles)(_asPad|Menu::_menuData|Menu::_canNav|_parentDraw)
109+
,FIELD(hrs,"",":",0,11,1,0,doNothing,noEvent,noStyle)
110+
,FIELD(mins,"","",0,59,10,1,doNothing,noEvent,wrapStyle)
111+
);
112+
113+
char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
114+
char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
115+
char buf1[]="0x11";
116+
117+
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
118+
,OP("Op1",doNothing,noEvent)
119+
,OP("Op2",doNothing,noEvent)
120+
//,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
121+
,SUBMENU(time)
122+
,SUBMENU(subMenu)
123+
,SUBMENU(setLed)
124+
,OP("LED On",myLedOn,enterEvent)
125+
,OP("LED Off",myLedOff,enterEvent)
126+
,SUBMENU(selMenu)
127+
,SUBMENU(chooseMenu)
128+
,OP("Alert test",doAlert,enterEvent)
129+
,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
130+
,EXIT("<Exit")
131+
);
132+
133+
#define MAX_DEPTH 2
134+
135+
serialIn serial(Serial);
136+
MENU_INPUTS(in,&serial);
137+
138+
MENU_OUTPUTS(out,MAX_DEPTH
139+
,U8G2_OUT(u8g2,colors,fontX,fontY,offsetX,offsetY,{0,0,U8_Width/fontX,U8_Height/fontY})
140+
,SERIAL_OUT(Serial)
141+
);
142+
143+
NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);
144+
145+
result alert(menuOut& o,idleEvent e) {
146+
if (e==idling) {
147+
o.setCursor(0,0);
148+
o.print("alert test");
149+
o.setCursor(0,1);
150+
o.print("press [select]");
151+
o.setCursor(0,2);
152+
o.print("to continue...");
153+
}
154+
return proceed;
155+
}
156+
157+
result doAlert(eventMask e, prompt &item) {
158+
nav.idleOn(alert);
159+
return proceed;
160+
}
161+
162+
//when menu is suspended
163+
result idle(menuOut& o,idleEvent e) {
164+
o.clear();
165+
switch(e) {
166+
case idleStart:o.println("suspending menu!");break;
167+
case idling:o.println("suspended...");break;
168+
case idleEnd:o.println("resuming menu.");break;
169+
}
170+
return proceed;
171+
}
172+
173+
void setup() {
174+
// pinMode(LEDPIN,OUTPUT);
175+
Serial.begin(115200);
176+
while(!Serial);
177+
Serial.println("menu 4.x test");Serial.flush();
178+
Wire.begin(5,4);
179+
u8g2.begin();
180+
u8g2.setFont(fontName);
181+
// disable second option
182+
mainMenu[1].enabled=disabledStatus;
183+
nav.idleTask=idle;//point a function to be used when menu is suspended
184+
Serial.println("setup done.");Serial.flush();
185+
u8g2.firstPage();
186+
do {
187+
u8g2.drawStr(0,fontY,"ArduinoMenu 4.x");
188+
u8g2.drawStr(0,fontY<<1,"on lolin32");
189+
u8g2.drawStr(0,fontY+(fontY<<1),"with buitin oled");
190+
} while(u8g2.nextPage());
191+
for(int c=256;c>0;c--) {
192+
u8g2.setContrast(255-255.0*log(c)/log(255));
193+
delay(8);
194+
}
195+
u8g2.setContrast(255);
196+
delay(500);
197+
}
198+
199+
void loop() {
200+
nav.doInput();
201+
// digitalWrite(LEDPIN, !ledCtrl);//no led on this board
202+
if (nav.changed(0)) {//only draw if menu changed for gfx device
203+
u8g2.firstPage();
204+
do nav.doOutput(); while(u8g2.nextPage());
205+
}
206+
delay(100);//simulate other tasks delay
207+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.6.0
2+
version=4.6.1
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

0 commit comments

Comments
 (0)