Skip to content

Commit 1046b4c

Browse files
committed
SdFat file picker example
1 parent 7ee87ad commit 1046b4c

File tree

8 files changed

+371
-10
lines changed

8 files changed

+371
-10
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,20 @@ void loop() {
8989
- can be confined to a display area (numeric fields can still overflow the area, user should take account for them)
9090
- Tested on Arduino AVR's & ARM, Teensy, ESP8266, Esp32, nRF52, STM32
9191
92-
## Version 2.x videos
92+
## Videos
9393
[![IMAGE ALT TEXT](https://img.youtube.com/vi/wHv5sU-HXVI/2.jpg)](https://youtu.be/wHv5sU-HXVI "Arduino menu 2.0 fields video") [![IMAGE ALT TEXT](https://img.youtube.com/vi/W-TRCziF67g/2.jpg)](https://youtu.be/W-TRCziF67g "Arduino menu basic features video")[![IMAGE ALT TEXT](https://img.youtube.com/vi/27KEUTpCHfg/2.jpg)](https://youtu.be/27KEUTpCHfg "Arduino menu 4.x")
9494
95+
## Plugins
96+
97+
Plugins are particular menu combinations or item customized behaviors and/or drawing.
98+
99+
Some plugins might be platform specific or require some hardware.
100+
101+
- barField - displays a bar for numeric field on LCD
102+
- cancelField - allows to restore previous numeric value on escape.
103+
- SDMenu - full automated SD Card file picker, using standard Arduino SD lib.
104+
- SdFatMenu - full automated SD Card file picker, using standard SdFat (https://github.com/greiman/SdFat).
105+
95106
## Applications
96107
97108
Some applications using ArduinoMenu, (current and older versions).
@@ -261,7 +272,7 @@ https://github.com/neu-rah/AnsiStream
261272
262273
- ESP8266 (builtin)
263274
264-
**note:** esp8266 will require a streaming library even if not using web interface
275+
**note:** esp8266 will require a streaming library even if not using web interface, along with `#include <menuIO/esp8266Out.h>`
265276
266277
depending on your output driver it may be one of (can install both)
267278
- https://github.com/neu-rah/streamFlow
@@ -336,6 +347,8 @@ multiple stream packing for input to mix encoder stream with encoder keyboard (u
336347
## History
337348
338349
### 4.0
350+
- SdFat plugin and example
351+
- EscControl examle
339352
- support Bodmer/TFT_eSPI
340353
- SDCard file picker plugin
341354
- Allow virtual/dynamic data custom menus

examples/SDCard/SDCard/SDCard.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <menu.h>
44
#include <menuIO/serialIO.h>
55
#include <plugin/SDMenu.h>
6+
//enable this include if using esp8266
7+
// #include <menuIO/esp8266Out.h>
68

79
using namespace Menu;
810

examples/SSD1306Ascii/SSD1306Ascii/SSD1306Ascii.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ constexpr int OLED_SDC=5;
4545
#include <menu.h>
4646
#include <menuIO/SSD1306AsciiOut.h>
4747
#include <menuIO/serialIO.h>
48+
//enable this include if using esp8266
49+
// #include <menuIO/esp8266Out.h>
4850
using namespace Menu;
4951

5052
//Define your font here. Default font: lcd5x7

examples/SdFat/SdFat/SdFat.ino

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include <SPI.h>
2+
#include <SdFat.h>
3+
#include <menu.h>
4+
#include <menuIO/serialIO.h>
5+
#include <plugin/SdFatMenu.h>
6+
//enable this include if using esp8266
7+
// #include <menuIO/esp8266Out.h>
8+
9+
using namespace Menu;
10+
11+
//esp8266 SS
12+
#define SDCARD_SS 15
13+
SdFat sd;
14+
15+
//function to handle file select
16+
// declared here and implemented bellow because we need
17+
// to give it as event handler for `filePickMenu`
18+
// and we also need to refer to `filePickMenu` inside the function
19+
result filePick(eventMask event, navNode& nav, prompt &item);
20+
21+
22+
SDMenuT<CachedFSO<SdFat,32>> filePickMenu(sd,"SD Card","/",filePick,enterEvent);
23+
24+
//implementing the handler here after filePick is defined...
25+
result filePick(eventMask event, navNode& nav, prompt &item) {
26+
// switch(event) {//for now events are filtered only for enter, so we dont need this checking
27+
// case enterCmd:
28+
if (nav.root->navFocus==(navTarget*)&filePickMenu) {
29+
Serial.println();
30+
Serial.print("selected file:");
31+
Serial.println(filePickMenu.selectedFile);
32+
Serial.print("from folder:");
33+
Serial.println(filePickMenu.selectedFolder);
34+
}
35+
// break;
36+
// }
37+
return proceed;
38+
}
39+
40+
#define MAX_DEPTH 2
41+
42+
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
43+
,SUBMENU(filePickMenu)
44+
,OP("Something else...",doNothing,noEvent)
45+
,EXIT("<Back")
46+
);
47+
48+
MENU_OUTPUTS(out,MAX_DEPTH
49+
,SERIAL_OUT(Serial)
50+
,NONE//must have 2 items at least
51+
);
52+
53+
serialIn serial(Serial);
54+
NAVROOT(nav,mainMenu,MAX_DEPTH,serial,out);
55+
56+
void setup() {
57+
Serial.begin(115200);
58+
while (!Serial);
59+
Serial.print("Initializing SD card...");
60+
if (!sd.begin(SDCARD_SS, SD_SCK_MHZ(50))) {
61+
sd.initErrorHalt();
62+
}
63+
filePickMenu.begin();//need this after sd begin
64+
Serial.println("initialization done.");
65+
}
66+
67+
constexpr int menuFPS=25;
68+
unsigned long nextPool=0;
69+
void loop() {
70+
unsigned long now=millis();
71+
if(now>=nextPool) {
72+
nav.poll();
73+
nextPool=now+1000/menuFPS;
74+
}
75+
}

examples/codeCtrl/codeCtrl/codeCtrl.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ MENU(subMenu,"Sub-Menu",doNothing,anyEvent,wrapStyle
107107
);
108108

109109
constText* constMEM textFilter MEMMODE=" .0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTWXYZ";
110-
constText* constMEM textMask[] MEMMODE={textFilter};//this mask will repear till the end of the field
110+
constText* constMEM textMask[] MEMMODE={textFilter};//this mask will repeat till the end of the field
111111
char name[]=" ";//<-- menu will edit this text
112112

113113
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle

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.17.10
2+
version=4.17.11
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/menuDefs.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ using namespace Menu;
2121
#endif
2222

2323
#if defined(MENU_DEBUG) || defined(MENU_ASYNC)
24-
#ifndef ARDUINO_STREAMING
25-
//https://github.com/neu-rah/streamFlow
26-
#include <streamFlow.h>
27-
#else
28-
//https://github.com/scottdky/Streaming
29-
#include <Streaming.h>
24+
#ifndef ios_h
25+
#ifndef ARDUINO_STREAMING
26+
//https://github.com/neu-rah/streamFlow
27+
#include <streamFlow.h>
28+
#else
29+
//https://github.com/scottdky/Streaming
30+
#include <Streaming.h>
31+
#endif
3032
#endif
3133
#endif
3234

0 commit comments

Comments
 (0)