-
Notifications
You must be signed in to change notification settings - Fork 6
/
MagicImageWand.h
1358 lines (1308 loc) · 62.3 KB
/
MagicImageWand.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include <ArtnetnodeWifi.h>
#include <NodeReportCodes.h>
#include <OpCodes.h>
#include <PollReply.h>
#include <PriorityCodes.h>
#include <ProtocolSettings.h>
#include <StyleCodes.h>
const char* MIW_Version = "3.27";
const char* StartFileName = "START.MIW";
#include "MIWconfig.h"
#include <ArduinoJson.h>
const int JSON_DOC_SIZE = 5000;
const char* MACRO_JSON_FILE = "/macro.json";
//#include <BLEDevice.h>
//#include <BLEUtils.h>
//#include <BLEServer.h>
//#include <BLE2902.h>
#include <Update.h>
#include <time.h>
#if USE_STANDARD_SD
#include "SD.h"
#else
#include <SdFatConfig.h>
#include <sdfat.h>
#endif
#include "SPI.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include <WebServer.h>
#include "WebServerX.h"
String wifiMacs = "MIW-" + WiFi.macAddress();
const char *ssid = wifiMacs.c_str();
const char *password = "12345678"; // not critical stuff, therefore simple password is enough
// we need to change the file handling for exFat, the name function is different than standard SD lib
#if USE_STANDARD_SD
WebServer server(80);
#else
WebServerX server(80);
#endif
String webpage = "";
char localIpAddress[16];
String file_size(int bytes){
String fsize = "";
if (bytes < 1024) fsize = String(bytes)+" B";
else if(bytes < (1024*1024)) fsize = String(bytes/1024.0,3)+" KB";
else if(bytes < (1024*1024*1024)) fsize = String(bytes/1024.0/1024.0,3)+" MB";
else fsize = String(bytes/1024.0/1024.0/1024.0,3)+" GB";
return fsize;
}
#include <FastLED.h>
#include <Preferences.h>
#include "RotaryDialButton.h"
#if TTGO_T == 1 || TTGO_T == 3
#include <TFT_eSPI.h>
#elif TTGO_T == 4
#include <TFT_eSPI.h>
#endif
#include <vector>
#include <stack>
//#include <fonts/GFXFF/FreeMono18pt7b.h>
// definitions for preferences
const char* prefsName = "MIW";
const char* prefsVars = "vars";
const char* prefsVersion = "version";
const char* prefsBuiltInInfo = "builtininfo";
const char* prefsImgInfo = "imginfo";
const char* prefsLedInfo = "ledinfo";
const char* prefsBuiltinInfo = "builtininfo";
const char* prefsSystemInfo = "systeminfo";
const char* prefsAutoload = "autoload";
// rotary dial values
const char* prefsLongPressTimer = "longpress";
const char* prefsDialSensitivity = "dialsense";
const char* prefsDialSpeed = "dialspeed";
const char* prefsDialReverse = "dialreverse";
#if USE_STANDARD_SD
SPIClass spiSDCard;
#else
//SPIClass spi1(VSPI);
SdFs SD; // fat16/32 and exFAT
#endif
// the display
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
#define BTN_SELECT CRotaryDialButton::BTN_CLICK
#define BTN_NONE CRotaryDialButton::BTN_NONE
#define BTN_LEFT CRotaryDialButton::BTN_LEFT
#define BTN_LEFT_LONG CRotaryDialButton::BTN_LEFT_LONG
#define BTN_RIGHT CRotaryDialButton::BTN_RIGHT
#define BTN_RIGHT_LONG CRotaryDialButton::BTN_RIGHT_LONG
#define BTN_LONG CRotaryDialButton::BTN_LONGPRESS
#define BTN_B0_CLICK CRotaryDialButton::BTN0_CLICK
#define BTN_B0_LONG CRotaryDialButton::BTN0_LONGPRESS
#define BTN_B1_CLICK CRotaryDialButton::BTN1_CLICK
#define BTN_B1_LONG CRotaryDialButton::BTN1_LONGPRESS
#define BTN_B2_LONG CRotaryDialButton::BTN2_LONGPRESS
#define BTN_LEFT_RIGHT_LONG CRotaryDialButton::BTN_LEFT_RIGHT_LONG
#define BTN1DIAL_LONGPRESS CRotaryDialButton::BTN1DIAL_LONGPRESS
// functions
void ShowLeds(int mode = 0, CRGB colorval = TFT_BLACK, int imgHeight = 144);
void SetDisplayBrightness(int val);
void DisplayCurrentFile(bool bShowPath = true, bool bFirstOnly = false);
void DisplayLine(int line, String text, uint16_t color = TFT_WHITE, uint16_t backColor = TFT_BLACK);
void DisplayMenuLine(int line, int displine, String text);
void fixRGBwithGamma(byte* rp, byte* gp, byte* bp);
void WriteMessage(String txt, bool error = false, int wait = 2000, bool process = false);
void BarberPole();
void TestBouncingBalls();
void CheckerBoard();
void RandomBars();
void RunningDot();
void RandomDot();
void OppositeRunningDots();
void TestTwinkle();
void TestMeteor();
void TestCylon();
void TestCircles();
void TestRainbow();
void TestJuggle();
void TestSine();
void TestBpm();
void TestConfetti();
void DisplayLedLightBar();
void TestStripes();
void TestLines();
void RainbowPulse();
void TestWedge();
void ReportCouldNotCreateFile(String target);
void handleFileUpload();
void append_page_header();
void append_page_footer();
void HomePage();
void File_Download();
void SD_file_download(String filename);
void File_Upload();
void SendHTML_Header();
void SendHTML_Content();
void SendHTML_Stop();
void SelectInput(String heading1, String command, String arg_calling_name);
void ReportFileNotPresent(String target);
void ReportSDNotPresent();
void IncreaseRepeatButton();
void DecreaseRepeatButton();
bool SaveLoadSettings(bool save = false, bool autoloadonly = false, bool ledonly = false, bool nodisplay = false);
CRotaryDialButton::Button ReadButton();
bool CheckCancel(bool bLeaveButton = false);
bool bAutoLoadSettings = false;
// The array of leds, up to 512
CRGB* leds;
// temporary array for various uses
CRGB* tmpLeds;
// 0 feed from center, 1 serial from end, 2 from outsides
enum LED_STRIPS_WIRING_MODE { STRIPS_MIDDLE_WIRED = 0, STRIPS_CHAINED, STRIPS_OUTSIDE_WIRED };
const char* StripsWiringText[] = { "Middle","Serial","Outside" };
const char* DisplayRotationText[] = { "90","180","270","0" };
typedef struct LED_INFO {
bool bSecondController = false; // enable the second controller
bool bSwapControllers = false; // swap the 1st and 2nd LED controller output pins
int nLEDBrightness = 25;
int nTotalLeds = 144;
bool bGammaCorrection = true;
int stripsMode = STRIPS_MIDDLE_WIRED;
// white balance values, really only 8 bits, but menus need ints
struct {
int r;
int g;
int b;
} whiteBalance = { 255,255,255 };
//int nPixelMaxCurrent = 48; // maximum milliamps to allow on any pixel
};
LED_INFO LedInfo;
enum DIAL_IMG_FUNCTIONS { DIAL_IMG_NONE = 0, DIAL_IMG_BRIGHTNESS, DIAL_IMB_SPEED };
const char* DialImgText[] = { "None","Brightness","Speed" };
// image settings
typedef struct IMG_INFO {
int nFrameHold = 10; // default for the frame delay,mS
bool bFixedTime = false; // set to use imagetime instead of framehold, the frame time will be calculated
int nFixedImageTime = 5; // time to display image when fixedtime is used, in seconds
int nFramePulseCount = 0; // advance frame when button pressed this many times, 0 means ignore
bool bManualFrameAdvance = false; // advance frame by clicking or rotating button
bool bReverseImage = false; // read the file lines in reverse
bool bUpsideDown = false; // play the image upside down
bool bRotate180 = false; // the image is rotated 180 degrees, example: MagiLight images
bool bDoublePixels = false; // double the image line, to go from 144 to 288
bool bMirrorPlayImage = false; // play the file twice, 2nd time reversed
int nMirrorDelay = 0; // pause between the two halves of the image
bool bChainFiles = false; // set to run all the files from current to the last one in the current folder
int nChainRepeats = 1; // how many times to repeat the chain
int nChainDelay = 0; // number of 1/10 seconds to delay between chained files
bool bChainWaitKey = false; // wait for keypress to advance to next chained file
bool bScaleHeight = false; // scale the Y values to fit the number of pixels
int nFadeInOutFrames = 0; // number of frames to use for fading in and out
int startDelay = 0; // Variable for delay between button press and start of light sequence, in seconds
//bool bRepeatForever = false; // Variable to select auto repeat (until select button is pressed again)
int repeatDelay = 0; // Variable for delay between repeats, 0.1 seconds
int repeatCount = 1; // Variable to keep track of number of repeats
int nCurrentMacro = 0; // the number of the macro to select or run
int nRepeatWaitMacro = 0; // time between macro repeats, in 1/10 seconds
int nRepeatCountMacro = 1; // repeat count for macros
bool bMacroWaitKey = false; // wait for keypress after each macro file display
bool bShowBuiltInTests = false; // list the internal file instead of the SD card
int nDialDuringImgAction = DIAL_IMG_NONE; // dial action during image display
int nDialDuringImgInc = 1; // how much to change by during image display
int nLeftCrop = 0; // starting column to display
int nRightCrop = 0; // ending column to display, ignored if 0 or same as start
bool bAutoColumnReset = true; // reset the start and end columns when the file is changed
int nStutterTime = 0; // black/white band between columns time in mS
bool bStutterWhite = false; // stutter column black or white
};
RTC_DATA_ATTR IMG_INFO ImgInfo;
// a stack to hold the file indexes as we navigate folders, put it in RTC memory for waking from sleep
typedef struct FILEINDEXINFO {
int nFileIndex; // current file index
int nFileCursor; // used when scrolling cursor, IE current file not always on top
};
#define FILEINDEXSTACKSIZE 10
RTC_DATA_ATTR FILEINDEXINFO FileIndexStack[FILEINDEXSTACKSIZE];
RTC_DATA_ATTR int FileIndexStackSize = 0;
// hold the current information
RTC_DATA_ATTR FILEINDEXINFO currentFileIndex = { 0,0 };
// functions that btn0 long press can map to
enum BTN_LONG_FUNCTIONS { BTN_LONG_ROTATION = 0, BTN_LONG_LIGHTBAR };
const char* BtnLongText[] = { "DisplayRotate","LightBar" };
// display dim modes, make sure sensor mode is last
enum DISPLAY_DIM_MODES { DISPLAY_DIM_MODE_NONE = 0, DISPLAY_DIM_MODE_TIME, DISPLAY_DIM_MODE_SENSOR };
const char* DisplayDimModeText[] = { "None","Timer","Sensor" };
enum PREVIEW_FILE_MODE { PREVIEW_MODE_SCROLL = 0, PREVIEW_MODE_FILE, PREVIEW_MODE_CROP_SELECT };
const char* PreviewFileModeText[] = { "Sideways Scroll","Browse Images","Set Cropping" };
typedef struct SYSTEM_INFO {
uint16_t menuTextColor = TFT_BLUE;
bool bMenuStar = false;
bool bHiLiteCurrentFile = true;
int nPreviewScrollCols = 20; // now many columns to scroll with dial during preview
bool bShowProgress = true; // show the progress bar
bool bShowFolder = false; // show the path in front of the file
#if TTGO_T == 1 || TTGO_T == 3
int nDisplayBrightness = 50; // this is in %
#elif TTGO_T == 4
int nDisplayBrightness = 75; // this is in %
#endif
bool bAllowMenuWrap = false; // allows menus to wrap around from end and start instead of pinning
bool bShowNextFiles = true; // show the next files in the main display
bool bShowLEDsOnLcdWhileRunning = false; // set this to display the bmp on the LCD and the LED during BMP display
int nSidewayScrollSpeed = 25; // mSec for pixel scroll
int nSidewaysScrollPause = 20; // how long to wait at each end
int nSidewaysScrollReverse = 3; // reverse speed multiplier
bool bMacroUseCurrentSettings = false; // ignore settings in macro files when this is true
#if TTGO_T == 3
int nBatteryFullLevel = 2534; // 100% battery
int nBatteryEmptyLevel = 1660; // 0% battery, should cause a shutdown to save the batteries
int nBatteries = 1; // how many batteries
#else
int nBatteryFullLevel = 1760; // 100% battery
int nBatteryEmptyLevel = 1230; // 0% battery, should cause a shutdown to save the batteries
int nBatteries = 2; // how many batteries
#endif
bool bShowBatteryLevel = HAS_BATTERY_LEVEL; // display the battery level on the bottom line
bool bShowFilePosition = true; // display the current selected file position and count
bool bSleepOnLowBattery = false; // sleep on low battery
bool bCriticalBatteryLevel = false; // set true if battery too low
CRotaryDialButton::ROTARY_DIAL_SETTINGS DialSettings;
int nSleepTime = 0; // value in minutes before going to sleep, 0 means never
int eDisplayDimMode = DISPLAY_DIM_MODE_NONE;// 0 is none, 1 is dimtime, 2 is light sensor
int nDisplayDimTime = 0; // seconds before lcd is dimmed
int nDisplayDimValue = 10; // the value to dim to
#if TTGO_T == 1 || TTGO_T == 3
int nDisplayRotation = 1; // rotates display 0, 180, 90, 270
#elif TTGO_T == 4
int nDisplayRotation = 0; // rotates display 0, 180, 90, 270
#endif
int nBtn0LongFunction = BTN_LONG_ROTATION; // function that long btn0 performs
int nBtn1LongFunction = BTN_LONG_LIGHTBAR; // function that long btn1 performs
bool bSimpleMenu = false; // full or simple menu
int nLightSensorDim = 4000; // value for the dimmest setting
int nLightSensorBright = 100; // value for the brightest setting
bool bHasLightSensor = false; // set to true if the light sensor is detected
int nPreviewAutoScroll = 0; // mSec for preview autoscroll, 0 means no scroll
int nPreviewAutoScrollAmount = 1; // now many pixels to auto scroll
int nPreviewMode = PREVIEW_MODE_SCROLL; // default to sideways scroll, choose file browse or column limits setting
#if TTGO_T == 1
int nPreviewStartOffset = 5; // how many pixels to offset the start, the display is only 135, not 144
#else
int nPreviewStartOffset = 0; // how many pixels to offset the start, the display is only 135, not 144
#endif
bool bKeepFileOnTopLine = false; // keep the active file on the top line
bool bInitTest = true; // test the LED's on boot
// ArtNet DMX variables
bool bRunArtNetDMX = false; // set to run the ArtNet WiFi DMX protocol
char cArtNetName[20] = "MIW_ARTNET_DMX"; // ArtNet name
char cNetworkName[33] = ""; // the network to connect to
char cNetworkPassword[65] = ""; // network password
bool bStartUniverseOne = true; // some controllers need 1, others 0 (false)
bool bRunWebServer = false; // run the web server
bool bAutoLoadFileOnRun = true; // load the associated file when an image is run
int nB0B1SetColumnsTimer = 3; // seconds to wait after B0/B1 to do single column moving of column with the dial
int nRunningDisplayBrightness = -1; // display brightness while running, -1 is default, 0 to 100%
//bool bShowCroppedView = true; // show the cropped view in scroll view or browse mode
//
};
RTC_DATA_ATTR SYSTEM_INFO SystemInfo;
// Art-Net variables
ArtnetnodeWifi artnet;
// Art-Net settings
String ArtNetLocalIP;
bool bArtNetActive = false;
enum LIGHT_BAR_MODES { LBMODE_HSV = 0, LBMODE_RGB, LBMODE_KELVIN };
const char* LightBarModeText[] = { "HSV","RGB","Kelvin" };
uint32_t LightBarColorList[] = {
Candle,
Tungsten40W,
Tungsten100W,
Halogen,
CarbonArc,
HighNoonSun,
DirectSunlight,
OvercastSky,
ClearBlueSky,
WarmFluorescent,
StandardFluorescent,
CoolWhiteFluorescent,
FullSpectrumFluorescent,
GrowLightFluorescent,
BlackLightFluorescent,
MercuryVapor,
SodiumVapor,
MetalHalide,
HighPressureSodium,
};
const char* LightBarColorKelvinText[] = {
"Candle 1900K",
"Tungsten 40W 2600K",
"Tungsten 100W 2850K",
"Halogen 3200K",
"Carbon Arc 5200K",
"High Noon Sun 5400K",
"Direct Sunlight 6000K",
"Overcast Sky 7000K",
"Clear Blue Sky 20000K",
"Warm Fluorescent",
"Standard Fluorescent",
"Cool White Fluorescent",
"Full Spectrum Fluorescent",
"Grow Light Fluorescent",
"Black Light Fluorescent",
"Mercury Vapor",
"Sodium Vapor",
"Metal Halide",
"High Pressure Sodium",
};
typedef struct BUILTIN_INFO {
// adjustment values for builtins
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
// bouncing balls
int nBouncingBallsCount = 4;
int nBouncingBallsDecay = 1000;
int nBouncingBallsFirstColor = 0; // first color, wraps to get all 32
int nBouncingBallsChangeColors = 0; // how many 100 count cycles to wait for change
// cylon eye
int nCylonEyeSize = 10;
int nCylonEyeRed = 255;
int nCylonEyeGreen = 0;
int nCylonEyeBlue = 0;
// random bars
bool bRandomBarsBlacks = true;
int nRandomBarsHoldframes = 10;
// meteor
int nMeteorSize = 10;
int nMeteorRed = 255;
int nMeteorGreen = 255;
int nMeteorBlue = 255;
// display all color, AKA lightbar
bool bAllowRollover = true; // lets 255->0 and 0->255
int nLightBarMode = LBMODE_HSV;
int nDisplayAllRed = 255;
int nDisplayAllGreen = 255;
int nDisplayAllBlue = 255;
int nDisplayAllHue = 0;
int nDisplayAllSaturation = 255;
int nDisplayAllBrightness = 255;
int nColorTemperature = 0;
int nDisplayAllPixelCount = 288;
bool bDisplayAllFromMiddle = true;
int nDisplayAllChangeTime = 0; // mS when changing steps between HUE, etc
int nDisplayAllIncrement = 10;
// rainbow
int nRainbowHueDelta = 4;
int nRainbowInitialHue = 0;
int nRainbowFadeTime = 10; // fade in out 0.1 Sec
bool bRainbowAddGlitter = false;
bool bRainbowCycleHue = false;
// twinkle
bool bTwinkleOnlyOne = false;
// confetti
bool bConfettiCycleHue = false;
// juggle
// sine
int nSineStartingHue = 0;
bool bSineCycleHue = false;
int nSineSpeed = 13;
// bpm
int nBpmBeatsPerMinute = 62;
bool bBpmCycleHue = false;
// checkerboard/bars
int nCheckerboardHoldframes = 10;
int nCheckboardBlackWidth = 12;
int nCheckboardWhiteWidth = 12;
bool bCheckerBoardAlternate = true;
int nCheckerboardAddPixels = 0;
// stripes
// black and white lines
int nLinesWhite = 5;
int nLinesBlack = 5;
// rainbow pulse settings
int nRainbowPulseColorScale = 10;
int nRainbowPulsePause = 5;
int nRainbowPulseSaturation = 255;
int nRainbowPulseStartColor = 0;
// wedge data
bool bWedgeFill = false;
int nWedgeRed = 255;
int nWedgeGreen = 255;
int nWedgeBlue = 255;
// circles data
int nCirclesDiameter = 144;
int nCirclesHue = 0;
int nCirclesSaturation = 255;
int nCirclesCount = 1;
int nCirclesGap = 0; // space after each circle
bool bCirclesFill = true; // fill the circle
};
RTC_DATA_ATTR BUILTIN_INFO BuiltinInfo;
// settings
bool bSdCardValid = false; // set to true when card is found
bool bControllerReboot = false; // set this when controllers or led count changed
int AdjustStripIndex(int ix);
// get the real LED strip index from the desired index
void SetPixel(int ix, CRGB pixel, int column = 0, int totalColumns = 1);
int nRepeatsLeft; // countdown while repeating, used for BLE also
int g = 0; // Variable for the Green Value
int b = 0; // Variable for the Blue Value
int r = 0; // Variable for the Red Value
// settings
constexpr auto NEXT_FOLDER_CHAR = '>';
constexpr auto PREVIOUS_FOLDER_CHAR = '<';
String currentFolder = "/";
RTC_DATA_ATTR char sleepFolder[50]; // a place to save the folder during sleeping
FILEINDEXINFO lastFileIndex = { 0,0 }; // save between switching of internal and SD
String lastFolder = "/";
std::vector<String> FileNames;
String nameFilter;
bool bnameFilter = false; // set this true to enable the filters set in nameFilter
bool bSettingsMode = false; // set true when settings are displayed
bool bCancelRun = false; // set to cancel a running job
bool bCancelMacro = false; // set to cancel a running macro
bool bWebRunning = false; // set while running from web
bool bRecordingMacro = false; // set while recording
char FileToShow[100];
unsigned long recordingTime; // shows the time for each part
bool bRunningMacro = false; // set while running
unsigned long nMacroColumnsDone = 0; // how many pixel columns in the macro
int nMacroRepeatsLeft = 1; // set during macro running
volatile int nTimerSeconds;
// esp timers
// set this to the delay time while we get the next frame, also used for delay timers
volatile bool g_bStripWaiting = false;
esp_timer_handle_t oneshot_LED_timer;
esp_timer_create_args_t oneshot_LED_timer_args;
// use this timer for seconds countdown
volatile int sleepTimer = 0;
// seconds before dimming the display
volatile int displayDimTimer = 30;
volatile bool displayDimNow = false;
volatile int g_nB0Pressed = 0;
volatile int g_nB1Pressed = 0;
volatile bool g_bB0B1Cleared = false;
esp_timer_handle_t periodic_Second_timer;
esp_timer_create_args_t periodic_Second_timer_args;
#if USE_STANDARD_SD
SDFile dataFile;
#else
FsFile dataFile;
#endif
// system state, idle or running
bool bIsRunning = false;
enum eDisplayOperation {
eTerminate = 0, // must be last in a menu, (or use {})
eText, // handle text with optional %s value
eTextInt, // handle text with optional %d value
eTextCurrentFile, // adds current basefilename for %s in string
eBool, // handle bool using %s and on/off values
eMenu, // load another menu
eExit, // closes this menu, handles optional %d or %s in string
eIfEqual, // start skipping menu entries if match with boolean data value
eIfIntEqual, // start skipping menu entries if match with int data value
eElse, // toggles the skipping
eEndif, // ends an if block
eBuiltinOptions, // use an internal settings menu if available, see the internal name,function list below (BuiltInFiles[])
eReboot, // reboot the system
eMacroList, // used to make a selection from the macro list
eList, // used to rotate selection from a list of choices
};
// we need to have a pointer reference to this in the MenuItem, the full declaration follows later
struct BuiltInItem;
std::vector<bool> bMenuValid; // set to indicate menu item is valid
typedef struct MenuItem {
enum eDisplayOperation op;
const char* text; // text to display
union {
void(*function)(MenuItem*); // called on click
MenuItem* menu; // jump to another menu
BuiltInItem* builtin; // builtin items
};
const void* value; // associated variable
long min; // the minimum value, also used for ifequal, min length for string
long max; // the maximum value, also size to compare for if, max length for string
int decimals; // 0 for int, 1 for 0.1
const char* on; // text for boolean true
const char* off; // text for boolean false
// flag is 1 for first time, 0 for changes, and -1 for last call, bools only call this with -1
void(*change)(MenuItem*, int flag); // call for each change, example: brightness change show effect, can be NULL
const char** nameList; // used for multichoice of items, example wiring mode, .max should be count-1 and .min=0
const char* cHelpText; // a place to put some menu help
};
// builtins
// built-in "files"
typedef struct BuiltInItem {
const char* text;
void(*function)();
MenuItem* menu;
};
extern BuiltInItem BuiltInFiles[];
// some menu functions using menus
void CheckUpdateBin(MenuItem* menu);
void FactorySettings(MenuItem* menu);
void EraseFlash(MenuItem* menu);
void EraseStartFile(MenuItem* menu);
void SaveStartFile(MenuItem* menu);
void EraseAssociatedFile(MenuItem* menu);
void SaveAssociatedFile(MenuItem* menu);
void LoadAssociatedFile(MenuItem* menu);
void LoadStartFile(MenuItem* menu);
void SaveEepromSettings(MenuItem* menu);
void LoadEepromSettings(MenuItem* menu);
void ShowWhiteBalance(MenuItem* menu);
void GetIntegerValue(MenuItem* menu);
void GetIntegerValueHue(MenuItem* menu);
void GetSelectChoice(MenuItem* menu);
void ToggleBool(MenuItem* menu);
void ToggleArtNet(MenuItem* menu);
void ToggleWebServer(MenuItem* menu);
void ToggleFilesBuiltin(MenuItem* menu);
void UpdateDisplayBrightness(MenuItem* menu, int flag);
void UpdateBatteries(MenuItem* menu, int flag);
void UpdateDisplayRotation(MenuItem* menu, int flag);
void UpdateDisplayDimMode(MenuItem* menu, int flag);
void SetMenuColor(MenuItem* menu);
void UpdateKeepOnTop(MenuItem* menu, int flag);
void UpdateTotalLeds(MenuItem* menu, int flag);
void UpdateControllers(MenuItem* menu, int flag);
void UpdateWiringMode(MenuItem* menu, int flag);
void UpdateStripBrightness(MenuItem* menu, int flag);
void UpdateStripHue(MenuItem* menu, int flag);
//void UpdatePixelMaxCurrent(MenuItem* menu, int flag);
void UpdateStripWhiteBalanceR(MenuItem* menu, int flag);
void UpdateStripWhiteBalanceG(MenuItem* menu, int flag);
void UpdateStripWhiteBalanceB(MenuItem* menu, int flag);
bool WriteOrDeleteConfigFile(String filename, bool remove, bool startfile, bool bMacro);
void RunMacro(MenuItem* menu);
void LoadMacro(MenuItem* menu);
void InfoMacro(MenuItem* menu);
void SaveMacro(MenuItem* menu);
void DeleteMacro(MenuItem* menu);
void DeleteMacroJson(MenuItem* menu);
void LightBar(MenuItem* menu);
void Sleep(MenuItem* menu);
//void ReadBattery(MenuItem* menu);
void ShowBmp(MenuItem* menu);
void ShowBattery(MenuItem* menu);
void SetHighLowBattery(MenuItem*);
void SetFilter(MenuItem* menu);
void ShowLightSensor(MenuItem* menu);
//void UpdateFilter(MenuItem* menu, int flag);
void GetStringName(MenuItem* menu);
void GetNetworkName(MenuItem* menu);
void ChangeNetCredentials(MenuItem* menu);
struct saveValues {
void* val;
int size;
};
// these values are saved during macro runs
const saveValues saveValueList[] = {
{&LedInfo,sizeof(LedInfo)},
{&ImgInfo,sizeof(ImgInfo)},
{&BuiltinInfo,sizeof(BuiltinInfo)},
{&SystemInfo,sizeof(SystemInfo)},
{¤tFileIndex.nFileIndex,sizeof(currentFileIndex.nFileIndex)},
};
// Gramma Correction (Defalt Gamma = 2.8)
const uint8_t gammaR[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5,
5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9,
9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14,
15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33,
33, 34, 35, 36, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 46,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 78, 79, 80,
81, 83, 84, 85, 87, 88, 89, 91, 92, 94, 95, 97, 98, 99,101,102,
104,105,107,109,110,112,113,115,116,118,120,121,123,125,127,128,
130,132,134,135,137,139,141,143,145,146,148,150,152,154,156,158,
160,162,164,166,168,170,172,174,177,179,181,183,185,187,190,192,
194,196,199,201,203,206,208,210,213,215,218,220,223,225,227,230 };
const uint8_t gammaG[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
const uint8_t gammaB[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 8,
8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 13,
13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 19,
20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28,
29, 30, 30, 31, 32, 32, 33, 34, 34, 35, 36, 37, 37, 38, 39, 40,
40, 41, 42, 43, 44, 44, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70,
71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 83, 84, 85, 86, 88, 89,
90, 92, 93, 94, 96, 97, 98,100,101,103,104,106,107,109,110,112,
113,115,116,118,119,121,122,124,126,127,129,131,132,134,136,137,
139,141,143,144,146,148,150,152,153,155,157,159,161,163,165,167,
169,171,173,175,177,179,181,183,185,187,189,191,193,196,198,200 };
const char* PreviousMenu = "Back";
MenuItem BouncingBallsMenu[] = {
{eExit,"Bouncing Balls"},
{eTextInt,"Ball Count: %d",GetIntegerValue,&BuiltinInfo.nBouncingBallsCount,1,32},
{eTextInt,"Decay: %d",GetIntegerValue,&BuiltinInfo.nBouncingBallsDecay,100,10000},
{eTextInt,"First Color: %d",GetIntegerValue,&BuiltinInfo.nBouncingBallsFirstColor,0,31},
{eTextInt,"Change Color Rate: %d",GetIntegerValue,&BuiltinInfo.nBouncingBallsChangeColors,0,10,0},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem CheckerBoardMenu[] = {
{eExit,"Checker Board"},
{eTextInt,"Hold Frames: %d",GetIntegerValue,&BuiltinInfo.nCheckerboardHoldframes,1,100},
{eTextInt,"Black Width: %d pixels",GetIntegerValue,&BuiltinInfo.nCheckboardBlackWidth,1,288},
{eTextInt,"White Width: %d pixels",GetIntegerValue,&BuiltinInfo.nCheckboardWhiteWidth,1,288},
{eTextInt,"Add Pixels per Cycle: %d",GetIntegerValue,&BuiltinInfo.nCheckerboardAddPixels,0,144},
{eBool,"Alternate per Cycle: %s",ToggleBool,&BuiltinInfo.bCheckerBoardAlternate,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem RainbowMenu[] = {
{eExit,"Rainbow"},
{eTextInt,"Fade Time: %d.%d S",GetIntegerValue,&BuiltinInfo.nRainbowFadeTime,0,100,1},
{eTextInt,"Starting Hue: %d",GetIntegerValueHue,&BuiltinInfo.nRainbowInitialHue,0,255,0,NULL,NULL,UpdateStripHue},
{eBool,"Cycle Hue: %s",ToggleBool,&BuiltinInfo.bRainbowCycleHue,0,0,0,"Yes","No"},
{eTextInt,"Hue Delta Size: %d",GetIntegerValue,&BuiltinInfo.nRainbowHueDelta,1,255},
{eBool,"Add Glitter: %s",ToggleBool,&BuiltinInfo.bRainbowAddGlitter,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem RainbowPulseMenu[] = {
{eExit,"Rainbow Pulse"},
{eTextInt,"Step Pause: %d",GetIntegerValue,&BuiltinInfo.nRainbowPulsePause,0,1000},
{eTextInt,"Color Rate Scale: %d",GetIntegerValue,&BuiltinInfo.nRainbowPulseColorScale,0,256},
{eTextInt,"Start Color: %d",GetIntegerValue,&BuiltinInfo.nRainbowPulseStartColor,0,255},
{eTextInt,"Color Saturation: %d",GetIntegerValue,&BuiltinInfo.nRainbowPulseSaturation,0,255},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem ConfettiMenu[] = {
{eExit,"Confetti"},
{eBool,"Cycle Hue: %s",ToggleBool,&BuiltinInfo.bConfettiCycleHue,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem TwinkleMenu[] = {
{eExit,"Twinkle"},
{eBool,"One or Many: %s",ToggleBool,&BuiltinInfo.bTwinkleOnlyOne,0,0,0,"One","Many"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem WedgeMenu[] = {
{eExit,"Wedge"},
{eBool,"Fill Wedge: %s",ToggleBool,&BuiltinInfo.bWedgeFill,0,0,0,"Solid","<"},
{eTextInt,"Red: %d",GetIntegerValue,&BuiltinInfo.nWedgeRed,0,255},
{eTextInt,"Green: %d",GetIntegerValue,&BuiltinInfo.nWedgeGreen,0,255},
{eTextInt,"Blue: %d",GetIntegerValue,&BuiltinInfo.nWedgeBlue,0,255},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem SineMenu[] = {
{eExit,"Sine"},
{eTextInt,"Starting Hue: %d",GetIntegerValueHue,&BuiltinInfo.nSineStartingHue,0,255,0,NULL,NULL,UpdateStripHue},
{eBool,"Cycle Hue: %s",ToggleBool,&BuiltinInfo.bSineCycleHue,0,0,0,"Yes","No"},
{eTextInt,"Speed: %d",GetIntegerValue,&BuiltinInfo.nSineSpeed,1,500},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem BpmMenu[] = {
{eExit,"Beats"},
{eTextInt,"Beats per minute: %d",GetIntegerValue,&BuiltinInfo.nBpmBeatsPerMinute,1,300},
{eBool,"Cycle Hue: %s",ToggleBool,&BuiltinInfo.bBpmCycleHue,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem CirclesMenu[] = {
{eExit,"Circles"},
{eTextInt,"Diameter: %d",GetIntegerValue,&BuiltinInfo.nCirclesDiameter,0,LedInfo.nTotalLeds},
{eTextInt,"Hue: %d",GetIntegerValueHue,&BuiltinInfo.nCirclesHue,0,255,0,NULL,NULL,UpdateStripHue},
{eTextInt,"Saturation: %d",GetIntegerValue,&BuiltinInfo.nCirclesSaturation,0,255},
{eTextInt,"Count: %d",GetIntegerValue,&BuiltinInfo.nCirclesCount,1,255},
{eTextInt,"Gap Columns: %d",GetIntegerValue,&BuiltinInfo.nCirclesGap,0,100},
{eBool,"Fill Circle: %s",ToggleBool,&BuiltinInfo.bCirclesFill,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem LinesMenu[] = {
{eExit,"Lines"},
{eTextInt,"White Pixels: %d",GetIntegerValue,&BuiltinInfo.nLinesWhite,0,LedInfo.nTotalLeds},
{eTextInt,"Black Pixels: %d",GetIntegerValue,&BuiltinInfo.nLinesBlack,0,LedInfo.nTotalLeds},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem CylonEyeMenu[] = {
{eExit,"Cylon Eye"},
{eTextInt,"Eye Size: %d",GetIntegerValue,&BuiltinInfo.nCylonEyeSize,1,100},
{eTextInt,"Eye Red: %d",GetIntegerValue,&BuiltinInfo.nCylonEyeRed,0,255},
{eTextInt,"Eye Green: %d",GetIntegerValue,&BuiltinInfo.nCylonEyeGreen,0,255},
{eTextInt,"Eye Blue: %d",GetIntegerValue,&BuiltinInfo.nCylonEyeBlue,0,255},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem MeteorMenu[] = {
{eExit,"Meteor"},
{eTextInt,"Meteor Size: %d",GetIntegerValue,&BuiltinInfo.nMeteorSize,1,100},
{eTextInt,"Meteor Red: %d",GetIntegerValue,&BuiltinInfo.nMeteorRed,0,255},
{eTextInt,"Meteor Green: %d",GetIntegerValue,&BuiltinInfo.nMeteorGreen,0,255},
{eTextInt,"Meteor Blue: %d",GetIntegerValue,&BuiltinInfo.nMeteorBlue,0,255},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem LedLightBarMenu[] = {
{eExit,"Light Bar Settings"},
{eBool,"Allow rollover: %s",ToggleBool,&BuiltinInfo.bAllowRollover,0,0,0,"Yes","No"},
{eTextInt,"Change Delay: %d mS",GetIntegerValue,&BuiltinInfo.nDisplayAllChangeTime,0,1000},
{eList,"Color Mode: %s",GetSelectChoice,&BuiltinInfo.nLightBarMode,0,sizeof(LightBarModeText) / sizeof(*LightBarModeText) - 1,0,NULL,NULL,NULL,LightBarModeText},
{eIfIntEqual,"",NULL,&BuiltinInfo.nLightBarMode,LBMODE_HSV},
{eTextInt,"Hue: %d",GetIntegerValueHue,&BuiltinInfo.nDisplayAllHue,0,255,0,NULL,NULL,UpdateStripHue},
{eTextInt,"Saturation: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllSaturation,0,255},
{eTextInt,"Brightness: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllBrightness,0,255,0,NULL,NULL,UpdateStripBrightness},
{eEndif},
{eIfIntEqual,"",NULL,&BuiltinInfo.nLightBarMode,LBMODE_RGB},
{eTextInt,"Red: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllRed,0,255},
{eTextInt,"Green: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllGreen,0,255},
{eTextInt,"Blue: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllBlue,0,255},
{eEndif},
{eIfIntEqual,"",NULL,&BuiltinInfo.nLightBarMode,LBMODE_KELVIN},
{eList,"Temp: %s",GetSelectChoice,&BuiltinInfo.nColorTemperature,0,sizeof(LightBarColorKelvinText) / sizeof(*LightBarColorKelvinText) - 1,0,NULL,NULL,NULL,LightBarColorKelvinText},
{eEndif},
{eTextInt,"Pixels: %d",GetIntegerValue,&BuiltinInfo.nDisplayAllPixelCount,1,288},
{eBool,"From: %s",ToggleBool,&BuiltinInfo.bDisplayAllFromMiddle,0,0,0,"Middle","End"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem RandomBarsMenu[] = {
{eExit,"Random Color Bars"},
{eTextInt,"Hold Frames: %d",GetIntegerValue,&BuiltinInfo.nRandomBarsHoldframes,1,100},
{eBool,"Alternating Black: %s",ToggleBool,&BuiltinInfo.bRandomBarsBlacks,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem BatteryMenu[] = {
{eExit,"Battery"},
{eBool,"Low Battery Sleep: %s",ToggleBool,&SystemInfo.bSleepOnLowBattery,0,0,0,"Yes","No"},
{eBool,"Show Battery: %s",ToggleBool,&SystemInfo.bShowBatteryLevel,0,0,0,"Yes","No"},
{eText,"Read Battery",ShowBattery},
{eTextInt,"100%% Battery: %d",GetIntegerValue,&SystemInfo.nBatteryFullLevel,900,4200},
{eTextInt,"0%% Battery: %d",GetIntegerValue,&SystemInfo.nBatteryEmptyLevel,500,3000},
#if TTGO_T == 3
{eText,"Set Battery From Full",SetHighLowBattery},
#endif
#if TTGO_T != 3
{ eTextInt,"Battery Count: %d",GetIntegerValue,&SystemInfo.nBatteries,1,4,0,NULL,NULL,UpdateBatteries },
#endif
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem LightSensorMenu[] = {
{eExit,"Light Sensor"},
{eText,"Read Light Sensor",ShowLightSensor},
{eTextInt,"Dim Value: %d",GetIntegerValue,&SystemInfo.nLightSensorDim,1000,5000},
{eTextInt,"Bright Value: %d",GetIntegerValue,&SystemInfo.nLightSensorBright,0,1000},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem SidewaysScrollMenu[] = {
{eExit,"Sideways Scrolling"},
{eTextInt,"Sideways Scroll Speed: %d mS",GetIntegerValue,&SystemInfo.nSidewayScrollSpeed,1,1000},
{eTextInt,"Sideways Scroll Pause: %d",GetIntegerValue,&SystemInfo.nSidewaysScrollPause,1,100},
{eTextInt,"Sideways Scroll Reverse: %dx",GetIntegerValue,&SystemInfo.nSidewaysScrollReverse,1,20},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem DialMenu[] = {
{eExit,"Rotary Dial Settings"},
{eBool,"Direction: %s",ToggleBool,&SystemInfo.DialSettings.m_bReverseDial,0,0,0,"Reverse","Normal"},
{eTextInt,"Pulse Count: %d",GetIntegerValue,&SystemInfo.DialSettings.m_nDialPulseCount,1,5},
{eTextInt,"Pulse Timer: %d mS",GetIntegerValue,&SystemInfo.DialSettings.m_nDialPulseTimer,100,1000},
{eTextInt,"Long Press count: %d",GetIntegerValue,&SystemInfo.DialSettings.m_nLongPressTimerValue,2,200},
{eList,"Btn0 Long: %s",GetSelectChoice,&SystemInfo.nBtn0LongFunction,0,sizeof(BtnLongText) / sizeof(*BtnLongText) - 1,0,NULL,NULL,NULL,BtnLongText},
{eList,"Btn1 Long: %s",GetSelectChoice,&SystemInfo.nBtn1LongFunction,0,sizeof(BtnLongText) / sizeof(*BtnLongText) - 1,0,NULL,NULL,NULL,BtnLongText},
{eBool,"Rotate Dial Type: %s",ToggleBool,&SystemInfo.DialSettings.m_bToggleDial,0,0,0,"Toggle","Pulse"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem HomeScreenMenu[] = {
{eExit,"Home Screen Settings"},
{eBool,"Show LEDs on LCD: %s",ToggleBool,&SystemInfo.bShowLEDsOnLcdWhileRunning,0,0,0,"Yes","No"},
{eBool,"Current File: %s",ToggleBool,&SystemInfo.bHiLiteCurrentFile,0,0,0,"Color","*"},
{eBool,"Show More Files: %s",ToggleBool,&SystemInfo.bShowNextFiles,0,0,0,"Yes","No"},
{eBool,"File on Top Line: %s",ToggleBool,&SystemInfo.bKeepFileOnTopLine,0,0,0,"Yes","No",UpdateKeepOnTop},
{eBool,"Show Folder: %s",ToggleBool,&SystemInfo.bShowFolder,0,0,0,"Yes","No"},
{eBool,"Show File Index/Total: %s",ToggleBool,&SystemInfo.bShowFilePosition,0,0,0,"Yes","No"},
{eBool,"Progress Bar: %s",ToggleBool,&SystemInfo.bShowProgress,0,0,0,"On","Off"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
#define MAX_DIM_MODE (sizeof(DisplayDimModeText) / sizeof(*DisplayDimModeText) - 1)
const char* HelpDisplayRunningBrightness = "Display brightness while running. -1 to use default, 0 for off, 100 for max";
MenuItem DisplayMenu[] = {
{eExit,"Display Settings"},
{eList, "Display Rotation: %s", GetSelectChoice, &SystemInfo.nDisplayRotation, 0, sizeof(DisplayRotationText) / sizeof(*DisplayRotationText) - 1, 0, NULL, NULL, UpdateDisplayRotation, DisplayRotationText},
{eTextInt,"Run Brightness: %d%%",GetIntegerValue,&SystemInfo.nRunningDisplayBrightness,-1,100,0,NULL,NULL,NULL,NULL,HelpDisplayRunningBrightness},
{eTextInt,"Main Brightness: %d%%",GetIntegerValue,&SystemInfo.nDisplayBrightness,1,100,0,NULL,NULL,UpdateDisplayBrightness},
{eList, "Dimming Mode: %s", GetSelectChoice, &SystemInfo.eDisplayDimMode, 0, MAX_DIM_MODE, 0, NULL, NULL, UpdateDisplayDimMode, DisplayDimModeText},
{eIfIntEqual,"",NULL,&SystemInfo.eDisplayDimMode,DISPLAY_DIM_MODE_TIME},
{eTextInt,"Dim Brightness: %d%%",GetIntegerValue,&SystemInfo.nDisplayDimValue,1,100},
{eTextInt,"Dim Timer: %d S",GetIntegerValue,&SystemInfo.nDisplayDimTime,0,120},
{eEndif},
{eIfIntEqual,"",NULL,&SystemInfo.eDisplayDimMode,DISPLAY_DIM_MODE_SENSOR},
{eMenu,"Light Sensor",{.menu = LightSensorMenu}},
{eEndif},
{eMenu,"Sideways Scrolling",{.menu = SidewaysScrollMenu}},
{eBool,"Menu Choice: %s",ToggleBool,&SystemInfo.bMenuStar,0,0,0,"*","Color"},
{eText,"Text Color",SetMenuColor},
{eBool,"Menu Wrap: %s",ToggleBool,&SystemInfo.bAllowMenuWrap,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem PreviewMenu[] = {
{eExit,"Preview Settings"},
{eList,"Dial: %s",GetSelectChoice,&SystemInfo.nPreviewMode,0,sizeof(PreviewFileModeText) / sizeof(*PreviewFileModeText) - 1,0,NULL,NULL,NULL,PreviewFileModeText},
//{eBool,"Scroll Mode: %s",ToggleBool,&SystemInfo.bPreviewScrollFiles,0,0,0,"Files","Sideways"},
{eTextInt,"Top Start Offset: %d px",GetIntegerValue,&SystemInfo.nPreviewStartOffset,0,10},
{eTextInt,"Dial Scroll Pixels: %d px",GetIntegerValue,&SystemInfo.nPreviewScrollCols,1,240},
{eTextInt,"Auto Scroll Time: %d mS",GetIntegerValue,&SystemInfo.nPreviewAutoScroll,0,1000},
{eTextInt,"Auto Scroll Pixels: %d px",GetIntegerValue,&SystemInfo.nPreviewAutoScrollAmount,1,240},
{eBool,"Reset Crop on Change: %s",ToggleBool,&ImgInfo.bAutoColumnReset,0,0,0,"Yes","No"},
{eTextInt,"Crop Adjust B0B1 Timer: %d S",GetIntegerValue,&SystemInfo.nB0B1SetColumnsTimer,0,10},
//{eBool,"Cropped View: %s",ToggleBool,&SystemInfo.bShowCroppedView,0,0,0,"Yes","No"},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem WiFiMenu[] = {
{eExit,"WiFi Settings"},
{eBool,"MIW Web Server: %s",ToggleWebServer,&SystemInfo.bRunWebServer,0,0,0,"On","Off"},
{eIfEqual,"",NULL,&SystemInfo.bRunWebServer,true},
{eText,"MIW Net: %s",NULL,ssid},
{eText,"Homepage: %s",NULL,localIpAddress},
{eEndif},
{eBool,"Art-Net DMX: %s",ToggleArtNet,&SystemInfo.bRunArtNetDMX,0,0,0,"On","Off"},
{eIfEqual,"",NULL,&SystemInfo.bRunArtNetDMX,true},
{eBool,"DMX Status: %s",NULL,&bArtNetActive,0,0,0,"Running","Stopped"},
{eText,"DMX IP: %s",NULL,ArtNetLocalIP.c_str()},
{eText,"Name: %s",ChangeNetCredentials,SystemInfo.cArtNetName,0,sizeof(SystemInfo.cArtNetName)},
{eText,"Network: %s",ChangeNetCredentials,SystemInfo.cNetworkName,0,sizeof(SystemInfo.cNetworkName)},
{eText,"Choose Network",GetNetworkName,SystemInfo.cNetworkName,0,sizeof(SystemInfo.cNetworkName)},
{eText,"Password: %s",ChangeNetCredentials,SystemInfo.cNetworkPassword,0,sizeof(SystemInfo.cNetworkPassword)},
{eBool,"Universe Start: %s",ToggleBool,&SystemInfo.bStartUniverseOne,0,0,0,"1","0"},
{eEndif},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
MenuItem SystemMenu[] = {
{eExit,"System Settings"},
{eMenu,"Display Settings",{.menu = DisplayMenu}},
{eMenu,"Home Screen Settings",{.menu = HomeScreenMenu}},
{eMenu,"Dial & Button Settings",{.menu = DialMenu}},
{eMenu,"Preview Settings",{.menu = PreviewMenu}},
#if HAS_BATTERY_LEVEL
{eMenu,"Battery Settings",{.menu = BatteryMenu}},
#endif
{eTextInt,"Sleep Time: %d Min",GetIntegerValue,&SystemInfo.nSleepTime,0,120},
{eBool,"Startup LED Test: %s",ToggleBool,&SystemInfo.bInitTest,0,0,0,"On","Off"},
{eMenu,"WiFi Settings",{.menu = WiFiMenu}},
{eText,"New Version BIN file",CheckUpdateBin},
{eText,"Reset All Settings",FactorySettings},
{eExit,PreviousMenu},
// make sure this one is last
{eTerminate}
};
const char* HelpImageColumnTime = "How many mSeconds to display each column on the LEDS";
const char* HelpImageTime = "How many seconds to display the entire image on the LEDS";
const char* HelpImageFade = "Columns that fade up at start and down at end";
const char* HelpStartCol = "Starting column index, 0 is first";
const char* HelpEndCol = "Ending column index, make 0 to disable";
MenuItem ImageMenu[] = {
{eExit,"Image Settings"},
{eBool,"Timing Type: %s",ToggleBool,&ImgInfo.bFixedTime,0,0,0,"Image","Column"},
{eIfEqual,"",NULL,&ImgInfo.bFixedTime,false},
{eTextInt,"Column Time: %d mS",GetIntegerValue,&ImgInfo.nFrameHold,0,500,0,NULL,NULL,NULL,NULL,HelpImageColumnTime},
{eElse},
{eTextInt,"Image Time: %d S",GetIntegerValue,&ImgInfo.nFixedImageTime,1,120,0,NULL,NULL,NULL,NULL,HelpImageTime},
{eEndif},
{eTextInt,"Stutter Time: %d mS",GetIntegerValue,&ImgInfo.nStutterTime,0,500,0,NULL,NULL,NULL,NULL,HelpImageColumnTime},
{eBool,"Stutter B/W: %s",ToggleBool,&ImgInfo.bStutterWhite,0,0,0,"White","Black"},
{eTextInt,"Start Delay: %d.%d S",GetIntegerValue,&ImgInfo.startDelay,0,100,1},