Skip to content

Commit 021072b

Browse files
committed
Merge branch 'dev'
2 parents 8e064bf + 2676138 commit 021072b

File tree

9 files changed

+97
-45
lines changed

9 files changed

+97
-45
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ multiple stream packing for input to mix encoder stream with encoder keyboard (u
255255
- More examples
256256
- Text edit fields with validation *
257257
- Pad style menus (horizontal list)
258-
- inline pad menus can input custom formats like IP/Date/Time
258+
- inline pad menus can input custom formats like IP/Date/Time, experimental and just for devices that can position a cursor
259259
- Plugins, alternative menu items potentially device specific
260260
- Allow multiple concurrent menus
261261
- Support UCGLib displays

TODO.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Arduino Menu Library
22

3-
- implement attribute hidden
3+
- pad menu should exit at left (the least)
4+
=> can have edit blocks (non-preview)
5+
- implement dynamic attribute hidden and edit (only appears on edit)
46
- central menu init
57
=> check's ex: if numeric input available then output numeric indexes
68
+1 padMenu: printMenu needs to return idx_t instead of void

examples/Serial/serialio/platformio.ini

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
src_dir=serialio
1212
lib_dir=~/Arduino/Libraries
1313

14-
; [env:nanoatmega328]
15-
; platform = atmelavr
16-
; board = nanoatmega328
17-
; framework = arduino
18-
; upload_port=/dev/ttyUSB*
19-
; upload_flags=-V
20-
; build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -DNODEBUG
14+
[env:nanoatmega328]
15+
platform = atmelavr
16+
board = nanoatmega328
17+
framework = arduino
18+
upload_port=/dev/ttyUSB*
19+
upload_flags=-V
20+
build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -DNODEBUG
2121

2222
; [env:teensy31]
2323
; platform = teensy
2424
; board = teensy31
2525
; framework = arduino
2626
; build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -lstdc++
2727

28-
[env:due]
29-
platform = atmelsam
30-
board = due
31-
framework = arduino
32-
build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -DNODEBUG -DNOTRACE
28+
; [env:due]
29+
; platform = atmelsam
30+
; board = due
31+
; framework = arduino
32+
; build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -DNODEBUG -DNOTRACE
3333

3434
; [env:esp01_1m]
3535
; platform = espressif8266

examples/Serial/serialio/serialio/serialio.ino

+13
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ MENU(subMenu,"Sub-Menu",showEvent,anyEvent,noStyle
8787
,EXIT("<Back")
8888
);
8989

90+
uint16_t year=2017;
91+
uint16_t month=10;
92+
uint16_t day=7;
93+
94+
//define a pad style menu (single line menu)
95+
//here with a set of fields to enter a date in YYYY/MM/DD format
96+
altMENU(menu,birthDate,"Birth",doNothing,noEvent,noStyle,_asPad
97+
,FIELD(year,"","/",1900,3000,20,1,doNothing,noEvent,noStyle)
98+
,FIELD(month,"","/",1,12,1,0,doNothing,noEvent,wrapStyle)
99+
,FIELD(day,"","",1,31,1,0,doNothing,noEvent,wrapStyle)
100+
);
101+
90102
char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
91103
char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
92104
char buf1[]="0x11";
@@ -103,6 +115,7 @@ MENU(mainMenu,"Main menu",zZz,noEvent,wrapStyle
103115
,SUBMENU(chooseMenu)
104116
,OP("Alert test",doAlert,enterEvent)
105117
,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
118+
//,SUBMENU(birthDate)
106119
,EXIT("<Back")
107120
);
108121

examples/esp8266/WebMenu/WebMenu/WebMenu.ino

+55-25
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ extern "C" {
3636

3737
using namespace Menu;
3838

39-
const char* ssid = "r-site.net";
40-
const char* password = "rsite.2011";
39+
#define ANALOG_PIN 4
40+
41+
#ifndef MENU_SSID
42+
#error "need to define WiFi SSID here"
43+
#define MENU_SSID "r-site.net"
44+
#endif
45+
#ifndef MENU_PASS
46+
#error "need to define WiFi password here"
47+
#define MENU_PASS ""
48+
#endif
49+
50+
const char* ssid = MENU_SSID;
51+
const char* password = MENU_PASS;
52+
const char* serverName="192.168.1.79";
4153
#ifdef DEBUG
4254
// on debug mode I put aux files on external server to allow changes without SPIFF update
4355
// on this mode the browser MUST be instructed to accept cross domain files
@@ -76,8 +88,12 @@ result action2(eventMask event, navNode& nav, prompt &item) {
7688
}
7789

7890
int ledCtrl=LOW;
91+
#define LEDPIN LED_BUILTIN
92+
void updLed() {
93+
digitalWrite(LEDPIN,!ledCtrl);
94+
}
7995

80-
TOGGLE(ledCtrl,setLed,"Led: ",doNothing,noEvent,noStyle//,doExit,enterEvent,noStyle
96+
TOGGLE(ledCtrl,setLed,"Led: ",updLed,enterEvent,noStyle//,doExit,enterEvent,noStyle
8197
,VALUE("On",HIGH,doNothing,noEvent)
8298
,VALUE("Off",LOW,doNothing,noEvent)
8399
);
@@ -97,13 +113,17 @@ CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
97113
,VALUE("Last",-1,doNothing,noEvent)
98114
);
99115

116+
int timeOn=50;
117+
void updAnalog() {
118+
analogWrite(ANALOG_PIN,map(timeOn,0,100,0,PWMRANGE));
119+
}
120+
100121
//the menu
101-
int timeOn;
102122
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
103123
,SUBMENU(setLed)
104124
,OP("Action A",action1,enterEvent)
105125
,OP("Action B",action2,enterEvent)
106-
,FIELD(timeOn,"On","ms",0,500,100,10, doNothing, noEvent, noStyle)
126+
,FIELD(timeOn,"On","ms",0,100,10,1, updAnalog, anyEvent, noStyle)
107127
,SUBMENU(selMenu)
108128
,SUBMENU(chooseMenu)
109129
);
@@ -124,37 +144,39 @@ NAVROOT(nav,mainMenu,MAX_DEPTH,serial,out);
124144
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
125145
switch(type) {
126146
case WStype_DISCONNECTED:
127-
USE_SERIAL.printf("[%u] Disconnected!\n", num);
147+
//USE_SERIAL.printf("[%u] Disconnected!\n", num);
128148
break;
129149
case WStype_CONNECTED: {
130150
IPAddress ip = webSocket.remoteIP(num);
131-
USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
151+
//USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
132152
webSocket.sendTXT(num, "console.log('ArduinoMenu Connected')");
133153
}
134154
break;
135155
case WStype_TEXT:
136-
USE_SERIAL.printf("[%u] get Text: %s\n", num, payload);
156+
//USE_SERIAL.printf("[%u] get Text: %s\n", num, payload);
137157
nav.async((const char*)payload);//this is slow!!!!!!!!
138158
break;
139159
case WStype_BIN: {
140-
USE_SERIAL.printf("[WSc] get binary length: %u", length);
141-
Serial<<endl;
142-
/*for(int c=0;c<length;c++)
143-
USE_SERIAL<<*(char*)(payload+c);*/
160+
USE_SERIAL<<"[WSc] get binary length:"<<length<<"[";
161+
for(int c=0;c<length;c++) {
162+
USE_SERIAL.print(*(char*)(payload+c),HEX);
163+
USE_SERIAL.write(',');
164+
}
165+
Serial<<"]"<<endl;
144166
uint16_t id=*(uint16_t*) payload++;
145167
idx_t len=*((idx_t*)++payload);
146168
idx_t* pathBin=(idx_t*)++payload;
147169
const char* inp=(const char*)(payload+len);
148-
Serial<<"id:"<<id<<endl;
170+
//Serial<<"id:"<<id<<endl;
149171
if (id==nav.active().hash()) {
150-
Serial<<"id ok."<<endl;Serial.flush();
151-
Serial<<"input:"<<inp<<endl;
172+
//Serial<<"id ok."<<endl;Serial.flush();
173+
//Serial<<"input:"<<inp<<endl;
152174
//StringStream inStr(inp);
153175
//while(inStr.available())
154176
nav.doInput(inp);
155177
webSocket.sendTXT(num, "binBusy=false;");//send javascript to unlock the state
156-
} else Serial<<"id not ok!"<<endl;
157-
Serial<<endl;
178+
} //else Serial<<"id not ok!"<<endl;
179+
//Serial<<endl;
158180
}
159181
break;
160182
}
@@ -164,12 +186,14 @@ void pageStart() {
164186
server.sendHeader("Cache-Control","no-cache, no-store, must-revalidate");
165187
server.sendHeader("Pragma","no-cache");
166188
server.sendHeader("Expires","0");
167-
serverOut<<
168-
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n"
169-
"<?xml-stylesheet type=\"text/xsl\" href=\""
170-
xslt
171-
"\"?>\r\n<menuLib>\r\n";
172-
"<menuLib>\r\n";
189+
serverOut
190+
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n"
191+
"<?xml-stylesheet type=\"text/xsl\" href=\""
192+
xslt
193+
"\"?>\r\n<menuLib>\r\n"
194+
"<sourceURL>"
195+
<<serverName
196+
<<"</sourceURL>";
173197
}
174198

175199
void pageEnd() {
@@ -242,6 +266,10 @@ bool handleMenu(){
242266
}
243267

244268
void setup(){
269+
pinMode(LEDPIN,OUTPUT);
270+
updLed();
271+
pinMode(ANALOG_PIN,OUTPUT);
272+
analogWriteRange(255);
245273
//options=&myOptions;//menu options
246274
Serial.begin(115200);
247275
while(!Serial)
@@ -260,16 +288,18 @@ void setup(){
260288
// Serial.setDebugOutput(0);
261289
// while(!Serial);
262290
// delay(10);
263-
wifi_station_set_hostname((char*)"ArduinoMenu");
291+
// wifi_station_set_hostname((char*)serverName);
264292
Serial.println("");
265293
Serial.println("Arduino menu webserver example");
266294

267295
SPIFFS.begin();
268296

297+
//WiFi.hostname(serverName);//not good
298+
269299
Serial.print("Connecting to ");
270300
Serial.println(ssid);
271301

272-
WiFiMulti.addAP("r-site.net", "rsite.2011");
302+
WiFiMulti.addAP(ssid, password);
273303
while(WiFiMulti.run() != WL_CONNECTED) delay(100);
274304
// WiFi.begin(ssid, password);
275305
// Wait for connection

examples/esp8266/WebMenu/WebMenu/data/menu.css

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ a:hover {
2929
border: 1px solid #fff;
3030
}
3131

32+
input[type=range] {
33+
display:inline-block !important;
34+
width:62% !important;
35+
background-color:#000800;
36+
}
3237

3338
/*
3439
* Base structure

examples/esp8266/WebMenu/WebMenu/data/menu.xslt

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
this is usefull for develop/debug
1111
to use external server the browser must be intructed to accept cross domain files
1212
-->
13-
<xsl:variable name="auxFilesSrc"></xsl:variable>
13+
<xsl:variable name="auxFilesSrc">http://neurux:8080</xsl:variable>
1414

1515
<xsl:template match="/">
1616
<html>
@@ -22,6 +22,10 @@
2222
<meta name="description" content="ArduinoMenu Example IOT/OTA for ESP8266"/>
2323
<meta name="author" content="Rui Azevedo ruihfazevedo@gmail.com (www.r-site.net)"/>
2424
<title>ArduinoMenu library OTA</title>
25+
<script>
26+
<xsl:text>var sourceURL="</xsl:text><xsl:value-of select="/menuLib/sourceURL"/><xsl:text>";</xsl:text>
27+
<xsl:text>console.log("sourceURL:",sourceURL);</xsl:text>
28+
</script>
2529
<link rel="icon" type="image/png" href="/logo.png"/>
2630
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha256-/SIrNqv8h6QGKDuNoLGA4iret+kyesCkHGzVUUV0shc=" crossorigin="anonymous"></script>
2731
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
@@ -118,15 +122,13 @@
118122
</xsl:template>
119123

120124
<xsl:template match="field">
121-
<li>
122125
<xsl:element name="input">
123126
<xsl:copy-of select="node/@*"/>
124127
<xsl:copy-of select="../../@data-idx"/>
125128
<xsl:attribute name="class">menu-range-field</xsl:attribute>
126129
<xsl:attribute name="type">range</xsl:attribute>
127130
<xsl:attribute name="value"><xsl:apply-templates/></xsl:attribute>
128131
</xsl:element>
129-
</li>
130132
</xsl:template>
131133

132134
<xsl:template match="*">

examples/esp8266/WebMenu/WebMenu/data/r-site.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function init() {
1313
s.change(updateSelect)
1414
}*/
1515

16-
wsSrc="192.168.1.64"
16+
wsSrc=sourceURL;//"192.168.1.79";
1717

18-
var connection = {}
18+
var connection = {};
1919
function menuIn(o) {connection.send(o.id.split('~').join('/')+"/"+o.value);}
2020

2121
function sendBinValue(nr,path,value) {

examples/esp8266/WebMenu/platformio.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ platform = espressif8266
2424
board = esp12e
2525
framework = arduino
2626
upload_speed=921600
27-
build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -lstdc++ -DDEBUG
27+
build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -lstdc++ -DNODEBUG -DMENU_SSID="\"r-site.net\"" -DMENU_PASS="\"rsite.2011\""

0 commit comments

Comments
 (0)