-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_setup.h
284 lines (244 loc) · 8.62 KB
/
menu_setup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#include <Arduino.h>
#include <menu.h>
//inputs
#include <menuIO/serialIn.h>
//outputs
#include <menuIO/liquidCrystalOut.h>
#include <menuIO/serialOut.h>
//include plugins
#include <plugin/cancelField.h>
#include <plugin/barField.h>
#include <IRremote.h>
IRrecv irrecv(PIN_IRREC); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
// LCD /////////////////////////////////////////
#define RS 8
#define RW 3
#define EN 9
LiquidCrystal lcd(RS, RW, EN, 4, 5, 6, 7);
#define LEDPIN 13
using namespace Menu;
int test=55;
int ledCtrl=LOW;
serialIn serial(Serial);
char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
char buf1[]="0x11";
result runFRAP(eventMask e, prompt &item);
result runPEEK(eventMask e, prompt &item);
// Custom menu item to choose parameter settings
class confirmParams:public menu {
public:
confirmParams(constMEM menuNodeShadow& shadow):menu(shadow) {}
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t p) override {
return idx<0?//idx will be -1 when printing a menu title or a valid index when printing as option
menu::printTo(root,sel,out,idx,len,p)://when printing title
out.printRaw((constText*)F("No"),len);//when printing as regular option
}
};
// Custom menu item to confirm FRAP start
class confirmFRAP:public menu {
public:
confirmFRAP(constMEM menuNodeShadow& shadow):menu(shadow) {}
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t p) override {
return idx<0?//idx will be -1 when printing a menu title or a valid index when printing as option
menu::printTo(root,sel,out,idx,len,p)://when printing title
out.printRaw((constText*)F("Start"),len);//when printing as regular option
}
};
// Paramater menu for Baseline LED (HI_LED)
MENU(paramsBaseline, "BaseLine Params.",doNothing,noEvent,wrapStyle
,altFIELD(cancelField, baselineWindow,"Period:","ms",0,1000,10,0,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,EXIT("<Exit")
);
// Paramater menu for High Power Led (HI_LED)
MENU(paramsHPLED, "HP-LED Params.",doNothing,noEvent,wrapStyle
,altFIELD(cancelField,HPcount,"#ofPulse:","",0,10000,100,10,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,EXIT("<Exit")
,altFIELD(cancelField, HPdutyCycle,"D.Cyc:","%",0,99,10,1,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,altFIELD(cancelField, HPpulseLength,"PulseLen:","us",100,6000,10,0,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,altFIELD(cancelField, HPcooldown,"Cooldwn:","us",100,100000,1000,100,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
);
// Paramater menu for Camera
MENU(paramsCamera, "Camera Params.",doNothing,noEvent,wrapStyle
,altFIELD(cancelField, CAMframesBase,"Bse Fr:","",0,200000,100,10,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,altFIELD(cancelField, CAMframesRecov,"Rcv Fr:","",0,200000,100,10,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,altFIELD(cancelField, CAMexposure,"Exp:","",0,10,0.1,0.01,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,EXIT("<Exit")
);
// altMenu for starting FRAP
altMENU(confirmFRAP, frapMenu," Start FRAP?",doNothing,noEvent,wrapStyle,(Menu::_menuData|Menu::_canNav)
,OP("Yes!", runFRAP,enterEvent)
,OP("PEEK!", runPEEK,enterEvent)
,EXIT("<Cancel surgery")
);
// altMenu for non-default parameter choices & FRAP starting
// TODO add camera params (delay after bleach, frame rate, etc.)
altMENU(confirmParams, paramMenu," Parameters",doNothing,noEvent,wrapStyle,(Menu::_menuData|Menu::_canNav)
,SUBMENU(paramsHPLED)
,EXIT("<Exit")
,SUBMENU(frapMenu)
,SUBMENU(paramsCamera)
,SUBMENU(paramsBaseline)
);
// A main menu for FRAPulse control
MENU(mainMenu1," Use Defaults?",doNothing,noEvent,wrapStyle
,SUBMENU(frapMenu)
,SUBMENU(paramMenu)
);
//a menu using a plugin field
MENU(mainMenu,"Main menUE",doNothing,noEvent,wrapStyle
,BARFIELD(test,"Bar field","%",0,100,10,1,doNothing,noEvent,wrapStyle)//numeric field with a bar
,FIELD(test,"Original","%",0,100,10,1,doNothing,noEvent,wrapStyle)//normal numeric field (2 edit levels)
,FIELD(test,"O. Simple","%",0,100,1,0,doNothing,noEvent,wrapStyle)//normal numeric field (1 edit level)
,altFIELD(cancelField,test,"Cancelable","%",0,100,10,1,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
,altFIELD(cancelField,test,"C. Simple","%",0,100,1,0,doNothing,enterEvent,wrapStyle)//cancelable field (1 edit level)
,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
,EXIT("<Exit")
);
#define MAX_DEPTH 3
MENU_OUTPUTS(out,MAX_DEPTH
,SERIAL_OUT(Serial)
,LIQUIDCRYSTAL_OUT(lcd,{0,0,16,2})
);
NAVROOT(nav,mainMenu1,MAX_DEPTH,serial,out);//the navigation root object
result runFRAP(eventMask e, prompt &item) {
// capture((1000*baselineWindow)/(int)CAMpulseLength);
// Frames based on 0.03219, or ~31 FPS
// 1864 frames -> 59.94 seconds
// 466 frames -> 14.99 seconds
// Run Baseline
baselineON();
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("Baseline...");
capture(CAMframesBase);
lcd.setCursor(0, 1);
lcd.print("Cooling...");
waitMicro(1000000); // wait 1 second...
// Run Bleach
baselineOFF();
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("Bleach!");
burst(HPcount);
digitalWrite(PIN_HPLED, LOW);
lcd.setCursor(0, 1);
lcd.print("Cooling...");
delayMicroseconds(200000); // wait 2 seconds...
// Run Recovery for 10 x 30 seconds
baselineON();
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery1...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery2...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery3...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery4...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery5...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery6...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery7...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery8...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery9...");
capture(CAMframesRecov);
lcd.clear();
lcd.print("FRAP STEP:");
lcd.setCursor(0, 1);
lcd.print("30s Recovery10...");
capture(CAMframesRecov);
baselineOFF();
nav.doNav(upCmd);
return proceed;
}
// turn on HP-LED for thrice as long as the photobleach burst
// NOTE: TURN DOWN POWER BEFORE PEEKING
result runPEEK(eventMask e, prompt &item) {
digitalWrite(LED_BUILTIN, HIGH);
// waitMicro(HPcooldown);
burst(HPcount);
// waitMicro(HPcooldown);
// nav.doNav(upCmd);
digitalWrite(LED_BUILTIN, LOW);
return proceed;
}
/* translateIR()
* Takes action based on IR code received
*/
void translateIR()
{
delay(100); // Do not get immediate repeat
switch(results.value){
case 0xFFA25D: Serial.println("POWER"); break;
case 0xFFE21D: Serial.println("FUNC/STOP");
nav.doNav(escCmd);
break;
case 0xFF629D:Serial.println("VOL+");
nav.doNav(upCmd);
break;
case 0xFF22DD: Serial.println("FAST BACK");
// nav.doNav(escCmd);
break;
case 0xFF02FD: Serial.println("PAUSE");
nav.doNav(enterCmd);
break;
case 0xFFC23D: Serial.println("FAST FORWARD"); break;
case 0xFFE01F: Serial.println("DOWN");
nav.doNav(downCmd);
break;
case 0xFFA857: Serial.println("VOL-");
nav.doNav(downCmd);
break;
case 0xFF906F: Serial.println("UP");
nav.doNav(upCmd);
break;
case 0xFF9867: Serial.println("EQ"); break;
case 0xFFB04F: Serial.println("ST/REPT"); break;
case 0xFF6897: Serial.println("0"); break;
case 0xFF30CF: Serial.println("1"); break;
case 0xFF18E7: Serial.println("2"); break;
case 0xFF7A85: Serial.println("3"); break;
case 0xFF10EF: Serial.println("4"); break;
case 0xFF38C7: Serial.println("5"); break;
case 0xFF5AA5: Serial.println("6"); break;
case 0xFF42BD: Serial.println("7"); break;
case 0xFF4AB5: Serial.println("8"); break;
case 0xFF52AD: Serial.println("9"); break;
case 0xFFFFFFFF: Serial.println("_REPEAT");break;
default:
Serial.println(" other button ");
}// End Case
}