-
Notifications
You must be signed in to change notification settings - Fork 7
/
config_fs.cpp
2721 lines (2072 loc) · 97.5 KB
/
config_fs.cpp
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
/*
This is part of the Tinypixelmapper.
Here we store the functions for writing and reading the configuration.
either from SD card (Olimex POE Board) or in SPIFFS
*/
#include <FS.h>
#include "config_TPM.h"
#include "config_fs.h"
#include "tools.h"
#include "tpm_artnet.h"
#include "osc.h"
#ifdef USE_SD
#include "SD_MMC.h"
fs::SDMMCFS &selectedFS = SD_MMC;
#else
#include<SPIFFS.h>
fs::SPIFFSFS &selectedFS = SPIFFS;
#endif
// ***************** External Structures
#include "wifi-ota.h"
extern wifi_Struct wifi_cfg;
#include "leds.h"
#include "leds_def_values.h" // include the default values for led settings
#ifndef ARTNET_DISABLED
extern artnet_struct artnet_cfg;
extern artnet_node_struct artnetNode[ARTNET_NR_NODES_TPM];
#endif
extern deck_struct deck[2] ; // The 2 main decks config
extern deck_struct mem_confs[2] ; // The 16 memory confs
extern fft_ip_cfg_struct fft_ip_cfg;
extern led_cfg_struct led_cfg;
extern uint16_t play_conf_time_min[MAX_NR_SAVES];
#include "mmqt.h"
extern mqtt_Struct mqtt_cfg;
//**************** Functions
SaveStruct SaveConf = { {0,0,0,0,0,0,0,0} ,
{64,65,66,67,68,69,70,71,71,73,74,75,76,78,79},
{0,0}
};
//uint8_t savelooppos = 255; // Wher are we in the Fade animation when loading ans saving
//uint8_t saveloopConfNr = 255; // What conf Nr are we loading or saving
unsigned int FS_get_UsedKBytes()
{
return (selectedFS.usedBytes() /1024);
}
unsigned int FS_get_TotalKBytes()
{
return (selectedFS.totalBytes() /1024 );
}
unsigned int FS_get_leftKBytes()
{
//debugMe("TotalB :" + String ((selectedFS.totalBytes())));
//debugMe("usedB :" + String ((selectedFS.usedBytes())));
//debugMe("LeftB :" + String ((selectedFS.totalBytes()-selectedFS.usedBytes() )));
//debugMe("LeftKB :" + String ((selectedFS.totalBytes()-selectedFS.usedBytes() )/1024));
return ((selectedFS.totalBytes()-selectedFS.usedBytes() ) /1024);
}
boolean FS_get_PalyConfSatatus(uint8_t play_NR)
{
String addr = String("/conf/" + String(play_NR) + ".playConf.txt");
File conf_file = selectedFS.open(addr,"r");
if(conf_file && conf_file.isDirectory() == false)
{ //exists and its a file
conf_file.close();
return true;
}
conf_file.close();
return false;
}
void FS_load_PlayConf_status()
{
for(uint8_t bit_nr = 0; bit_nr < sizeof(SaveConf.confStatus); bit_nr++)
{
for(uint8_t conf_nr = 0; conf_nr < 8; conf_nr++)
{
bitWrite(SaveConf.confStatus[bit_nr], conf_nr, FS_get_PalyConfSatatus( (8*bit_nr) + conf_nr ) );
}
}
}
boolean FS_check_Conf_Available(uint8_t play_NR)
{
boolean return_bool = 0;
uint8_t byte_nr = 0;
uint8_t bit_nr = play_NR;
while (bit_nr > 7)
{
byte_nr++;
bit_nr = bit_nr - 8;
}
return_bool = bitRead(SaveConf.confStatus[byte_nr], bit_nr);
return return_bool;
}
void FS_write_Conf_status(uint8_t play_NR, boolean value)
{
if (play_NR >= MAX_NR_SAVES) return;
uint8_t byte_nr = 0;
uint8_t bit_nr = play_NR;
while (bit_nr > 7)
{
byte_nr++;
bit_nr = bit_nr - 8;
}
bitWrite(SaveConf.confStatus[byte_nr], bit_nr, value);
}
void FS_write_Custom_Conf_status(uint8_t play_NR, boolean value)
{
if (play_NR >= Nr_CustomConfs) return;
uint8_t byte_nr = 0;
uint8_t bit_nr = play_NR;
while (bit_nr > 7)
{
byte_nr++;
bit_nr = bit_nr - 8;
}
bitWrite(SaveConf.confCustomStatus[byte_nr], bit_nr, value);
}
// Reading Conf values from file.
bool get_bool_byte(uint8_t in_byte, uint8_t in_bit)
{
// gives back the value of in_bit, the in bit is wrapped into a value from 0-7
//
while (in_bit > 7) in_bit = in_bit - 8;
if (bitRead(in_byte, in_bit) == true)
return true;
else return false;
}
// Check if thers another seiing in the config string to load
boolean AnotherSetting(char *character)
{
if (*character != ']')
return true;
else return false;
}
int get_int_conf_value(File myFile, char *character, int def_value = 0 )
{
// When reading from a file give back a INT value
//char character;
String settingName;
String settingValue;
if (*character != ']')
{
*character = myFile.read();
while ((myFile.available()) && (*character != ':') && (*character != '.') && *character != ']') {
settingValue = settingValue + *character;
*character = myFile.read();
}
if (settingValue != NULL)
{
int outval = settingValue.toInt();
yield();
return outval;
}
else {
return def_value;
}
}
else
return def_value;
}
bool get_bool_conf_value(File myFile, char *character)
{
// Read a bool value from a file
String settingValue;
if (*character != ']') {
*character = myFile.read();
while ((myFile.available()) && (*character != ':') && *character != ']')
{
settingValue = settingValue + *character;
*character = myFile.read();
}
}
yield();
if (settingValue[0] == '1')
return true;
else
return false;
}
String get_string_conf_value(File myFile, char *character)
{
String settingValue;
if (*character != ']') {
*character = myFile.read();
while ((myFile.available()) && (*character != ':') && *character != ']') {
settingValue = settingValue + *character;
*character = myFile.read();
}
yield();
return settingValue;
}
else
return String("none");
}
int get_IP_conf_value(File myFile, char *character)
{
// When reading from a file give back a INT value but accept . as a value seperator makes reading the config easyser for IP addresses
//char character;
String settingName;
String settingValue;
if (*character != ']') {
*character = myFile.read();
while ((myFile.available()) && (*character != ':') && *character != '.' && *character != ']') {
settingValue = settingValue + *character;
*character = myFile.read();
}
if (settingValue != NULL)
{
int outval = settingValue.toInt();
yield();
return outval;
}
else {
return 0;
}
}
else
return 0;
}
// fft settings
boolean FS_FFT_read(uint8_t conf_nr)
{
// read the FFT settings from file.
// int conf_nr = what file NR to read
String addr = String("/conf/" + String(conf_nr) + ".fft.txt");
File conf_file = selectedFS.open(addr, "r");
//delay(100);
if (conf_file && !conf_file.isDirectory()) {
char character;
String settingName;
String settingValue;
char type;
//int bin_no = 0;
debugMe("FFT_File-opened");
while (conf_file.available())
{
character = conf_file.read();
while ((conf_file.available()) && (character != '[')) { // Go to first setting
character = conf_file.read();
}
type = conf_file.read();
character = conf_file.read(); // go past the first ":"
if (type == 'I')
{
write_bool(FFT_ENABLE, get_bool_conf_value(conf_file, &character));
write_bool(FFT_MASTER, get_bool_conf_value(conf_file, &character)) ;
for (uint8_t i = 0; i < 4; i++) fft_ip_cfg.IP_multi[i] = get_int_conf_value(conf_file, &character);
fft_ip_cfg.port_master = get_int_conf_value(conf_file, &character);
fft_ip_cfg.port_slave = get_int_conf_value(conf_file, &character);
}
while ((conf_file.available()) && (character != ']')) // go to end
character = conf_file.read();
}
// close the file:
conf_file.close();
debugMe("fft File-Closed");
return true;
}
else {
// if the file didn't open, print an error:
Serial.println("error opening fft config " + addr);
}
return false;
}
void FS_FFT_write(uint8_t conf_nr)
{
// write a FFT conf file NR = conf_nr
String title = "FFT";
String addr = String("/conf/" + String(conf_nr) + ".fft.txt");
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory())
{
Serial.println("fft file creation failed");
}
else
{ // yeah its open
conf_file.println(title);
conf_file.print(String("FFT Settings I: FFT Send enable =1 : FFT Master Mode = 1 : Multicast IP : Master Port : slave Port "));
conf_file.print(String("[I:" + String(get_bool(FFT_MASTER_SEND))));
conf_file.print(String(":" + String(get_bool(FFT_MASTER))));
conf_file.print(String(":" + String(fft_ip_cfg.IP_multi[0])));
conf_file.print(String(":" + String(fft_ip_cfg.IP_multi[1])));
conf_file.print(String(":" + String(fft_ip_cfg.IP_multi[2])));
conf_file.print(String(":" + String(fft_ip_cfg.IP_multi[3])));
conf_file.print(String(":" + String(fft_ip_cfg.port_master)));
conf_file.print(String(":" + String(fft_ip_cfg.port_slave)));
conf_file.println("] ");
conf_file.close();
}
} // end FS_FFT_write()
// wifi
void FS_wifi_write()
{ //also save the bools
FS_Bools_write(0);
// write out the wifi config
String addr = String("/conf/wifi.txt");
//String title = "Main Config for ESP.";
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory())
{
debugMe("Cant write Main Conf file");
}
else // it opens
{
conf_file.println("Main Wifi Config for ESP.");
conf_file.println("b = Wifi-booleans: Wifi Power 0=0ff, 1=on: Mode 0= Client 1 = Access point : 0= DHCP 1= static IP: OTA Update 1=on : HTTP Server 1=on: ");
conf_file.print(String("[b:" + String(get_bool(WIFI_POWER))));
conf_file.print(String(":" + String(get_bool(WIFI_MODE_TPM)))); // Wifi
conf_file.print(String(":" + String(get_bool(STATIC_IP_ENABLED))));
conf_file.print(String(":" + String(get_bool(OTA_SERVER))));
conf_file.print(String(":" + String(get_bool(HTTP_ENABLED))));
conf_file.println("] ");
conf_file.println("w = Wifi : name and APname: AP Password : SSID : Password : wifi-channe (1-12): ip1-4: IP subnet 1-4 : IP DGW 1-4: IP DNS 1-4: NTP-FQDN l ");
conf_file.print(String("[w:" + String(wifi_cfg.APname)));
conf_file.print(String(":" + String(wifi_cfg.APpassword)));
conf_file.print(String(":" + String(wifi_cfg.ssid)));
conf_file.print(String(":" + String(wifi_cfg.pwd)));
conf_file.print(String(":" + String(wifi_cfg.wifiChannel)));
conf_file.print(String(":" + String(wifi_cfg.ipStaticLocal[0])));
conf_file.print(String("." + String(wifi_cfg.ipStaticLocal[1])));
conf_file.print(String("." + String(wifi_cfg.ipStaticLocal[2])));
conf_file.print(String("." + String(wifi_cfg.ipStaticLocal[3])));
conf_file.print(String(":" + String(wifi_cfg.ipSubnet[0])));
conf_file.print(String("." + String(wifi_cfg.ipSubnet[1])));
conf_file.print(String("." + String(wifi_cfg.ipSubnet[2])));
conf_file.print(String("." + String(wifi_cfg.ipSubnet[3])));
conf_file.print(String(":" + String(wifi_cfg.ipDGW[0])));
conf_file.print(String("." + String(wifi_cfg.ipDGW[1])));
conf_file.print(String("." + String(wifi_cfg.ipDGW[2])));
conf_file.print(String("." + String(wifi_cfg.ipDGW[3])));
conf_file.print(String(":" + String(wifi_cfg.ipDNS[0])));
conf_file.print(String("." + String(wifi_cfg.ipDNS[1])));
conf_file.print(String("." + String(wifi_cfg.ipDNS[2])));
conf_file.print(String("." + String(wifi_cfg.ipDNS[3])));
conf_file.print(String(":" + String(wifi_cfg.ntp_fqdn)));
conf_file.println("] ");
conf_file.close();
debugMe("Wifi wrote conf");
} // end open conf file
} // end FS_wifi_write()
boolean FS_wifi_read()
{
// read the wifi config
String addr = String("/conf/wifi.txt");
File conf_file = selectedFS.open(addr, "r");
if (!conf_file) {
debugMe("There was an error opening the file for writing");
}
else debugMe("conf file here ?");
//delay(100);
if (conf_file && !conf_file.isDirectory())
{
debugMe("Loading Wifi conf " + addr);
char character;
String settingValue;
char type;
debugMe("File-opened");
memset(wifi_cfg.APname, 0, sizeof(wifi_cfg.APname)); // reset them to 0
memset(wifi_cfg.APpassword, 0, sizeof(wifi_cfg.APpassword));
memset(wifi_cfg.ssid, 0, sizeof(wifi_cfg.ssid));
memset(wifi_cfg.pwd, 0, sizeof(wifi_cfg.pwd));
memset(wifi_cfg.ntp_fqdn, 0, sizeof(wifi_cfg.ntp_fqdn));
while (conf_file.available())
{
character = conf_file.read();
//delay(100);
while ((conf_file.available()) && (character != '[')) { // Go to first setting
character = conf_file.read();
}
type = conf_file.read();
character = conf_file.read(); // go past the first ":" after the type
if (type == 'b') // wifi booleans
{
write_bool(WIFI_POWER, get_bool_conf_value(conf_file, &character));
write_bool(WIFI_MODE_TPM, get_bool_conf_value(conf_file, &character));
write_bool(STATIC_IP_ENABLED, get_bool_conf_value(conf_file, &character));
write_bool(OTA_SERVER, get_bool_conf_value(conf_file, &character));
write_bool(HTTP_ENABLED, get_bool_conf_value(conf_file, &character));
}
else if (type == 'w') // Changed to 'w' from W' beacuse of new bools settings
{
settingValue = get_string_conf_value(conf_file, &character);
settingValue.toCharArray(wifi_cfg.APname, settingValue.length() + 1);
settingValue = get_string_conf_value(conf_file, &character);
settingValue.toCharArray(wifi_cfg.APpassword, settingValue.length() + 1);
settingValue = get_string_conf_value(conf_file, &character);
settingValue.toCharArray(wifi_cfg.ssid, settingValue.length() + 1);
settingValue = get_string_conf_value(conf_file, &character);
settingValue.toCharArray(wifi_cfg.pwd, settingValue.length() + 1);
uint8_t in_int = get_int_conf_value(conf_file, &character); wifi_cfg.wifiChannel = uint8_t(constrain(in_int, 1, 12));
for (uint8_t i = 0; i < 4; i++) wifi_cfg.ipStaticLocal[i] = get_IP_conf_value(conf_file, &character);
for (uint8_t i = 0; i < 4; i++) wifi_cfg.ipSubnet[i] = get_IP_conf_value(conf_file, &character);
for (uint8_t i = 0; i < 4; i++) wifi_cfg.ipDGW[i] = get_IP_conf_value(conf_file, &character);
for (uint8_t i = 0; i < 4; i++) wifi_cfg.ipDNS[i] = get_IP_conf_value(conf_file, &character);
settingValue = get_string_conf_value(conf_file, &character);
settingValue.toCharArray(wifi_cfg.ntp_fqdn, settingValue.length() + 1);
}
while ((conf_file.available()) && (character != ']')) character = conf_file.read(); // goto End
}
conf_file.close();
debugMe("done wifi load " + addr);
return true;
} // end open conf file
else debugMe("error opening " + addr);
conf_file.close();
return false;
} // end FS_wifi_read()
//Artnet
#ifndef ARTNET_DISABLED
void FS_artnet_write()
{
// write the artnet config to disk
String addr = String("/conf/artnet.txt");
//String title = "Main Config for ESP.";
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory())
{
debugMe("Cant write artnet Conf file");
}
else // it opens
{
conf_file.println("Artnet Config for ESP.");
conf_file.print(String("[A:" + String(get_bool(ARTNET_SEND))));
conf_file.print(String(":" + String(artnet_cfg.startU)));
conf_file.print(String(":" + String(artnet_cfg.numU)));
conf_file.print(String(":" + String(get_bool(ARTNET_RECIVE))));
conf_file.println("] ");
conf_file.println("Artnet node Config for , Node Nr:StartU: Number Universe: IP.");
for (uint8_t node = 0 ; node < ARTNET_NR_NODES_TPM; node++)
{
conf_file.print(String("[N:" + String(node)));
conf_file.print(String(":" + String(artnetNode[node].startU)));
conf_file.print(String(":" + String(artnetNode[node].numU)));
conf_file.print(String(":" + String(artnetNode[node].IP[0])));
conf_file.print(String("." + String(artnetNode[node].IP[1])));
conf_file.print(String("." + String(artnetNode[node].IP[2])));
conf_file.print(String("." + String(artnetNode[node].IP[3])));
conf_file.println("] ");
}
conf_file.close();
debugMe("artnet conf wrote");
} // end open conf file
}
boolean FS_artnet_read()
{
// read the artnet config from disk
String addr = String("/conf/artnet.txt");
File conf_file = selectedFS.open(addr, "r");
//delay(100);
if (!conf_file && !conf_file.isDirectory()) {
debugMe("artnet file read failed");
}
else
{
debugMe("Opening " + addr);
char character;
//String settingName;
//String settingValue;
char type;
while (conf_file.available())
{
character = conf_file.read();
while ((conf_file.available()) && (character != '[')) { // Go to first setting
character = conf_file.read();
}
type = conf_file.read();
character = conf_file.read(); // go past the first ":" after the type
if (type == 'A')
{
write_bool(ARTNET_SEND, get_bool_conf_value(conf_file, &character));
artnet_cfg.startU = get_int_conf_value(conf_file, &character);
artnet_cfg.numU = get_int_conf_value(conf_file, &character);
write_bool(ARTNET_RECIVE, get_bool_conf_value(conf_file, &character));
}
if (type == 'N')
{
uint8_t nodeNr = get_int_conf_value(conf_file, &character);
artnetNode[nodeNr].startU = get_int_conf_value(conf_file, &character);
artnetNode[nodeNr].numU = get_int_conf_value(conf_file, &character);
for (uint8_t i = 0; i < 4; i++) artnetNode[nodeNr].IP[i] = get_IP_conf_value(conf_file, &character);
}
while ((conf_file.available()) && (character != ']')) character = conf_file.read();
}
conf_file.close();
return true;
} // end open conf file
return false;
}
#endif
void FS_play_conf_clear(uint8_t conf_nr)
{
String addr = String("/conf/"+ String(conf_nr) + ".playConf.txt");
debugMe("deleted save " + addr);
{ if( selectedFS.remove(addr.c_str())) debugMe("deleted save ok"); else debugMe("haha delete did not work"); }
uint8_t byte_nr = 0;
uint8_t bit_nr = conf_nr;
while (bit_nr > 7)
{
byte_nr++;
bit_nr = bit_nr - 8;
}
bitWrite(SaveConf.confStatus[byte_nr], bit_nr, false);
osc_queu_MSG_rgb(String("/ostc/master/conf/l/"+String(conf_nr)), 255,0,0);
osc_queu_MSG_VAL_STRING("/ostc/master/savename/" + String(conf_nr) , "-" ) ;
}
void FS_pal_save(uint8_t save_no, uint8_t pal_no)
{
String addr = String("/conf/" + String(save_no) + ".pal.txt");
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory()) {
debugMe("pallete file creation failed");
}
conf_file.println("Pallete Config.");
conf_file.println("holds the 16 colors for a pallete");
conf_file.println("p = pallete Config : R . G . B : R . G . B ... ");
conf_file.print(String("[p:" + String(LEDS_pal_read( pal_no, 0, 0))));
conf_file.print(String("." + String(LEDS_pal_read(pal_no, 0, 1))));
conf_file.print(String("." + String(LEDS_pal_read(pal_no, 0, 2))));
for (uint8_t color = 1; color < 16; color++)
{
conf_file.print(String(":" + String(LEDS_pal_read( pal_no, color, 0))));
conf_file.print(String("." + String(LEDS_pal_read(pal_no, color, 1))));
conf_file.print(String("." + String(LEDS_pal_read(pal_no, color, 2))));
}
conf_file.println("] ");
}
void FS_pal_load(uint8_t load_nr,uint8_t pal_no)
{
String addr = String("/conf/" + String(load_nr) + ".pal.txt");
debugMe("READ Conf " + addr);
File conf_file = selectedFS.open(addr, "r");
//delay(100);
if (conf_file && !conf_file.isDirectory())
{
char character;
char type;
while (conf_file.available())
{
character = conf_file.read();
while ((conf_file.available()) && (character != '['))
{ // Go to first setting
character = conf_file.read();
}
type = conf_file.read();
character = conf_file.read(); // go past the first ":"
int in_int = 0;
if (type == 'p')
{
for (uint8_t color = 0; color < 16; color++) {
in_int = get_int_conf_value(conf_file, &character); LEDS_pal_write(pal_no, color, 0, in_int) ; // targetPalette[pal_no][color].r =
in_int = get_int_conf_value(conf_file, &character); LEDS_pal_write(pal_no, color, 1, in_int);
in_int = get_int_conf_value(conf_file, &character); LEDS_pal_write(pal_no, color, 2, in_int);
}
}
}
conf_file.close();
}
}
void FS_write_Strip_Config(uint8_t val)
{
uint8_t selectedDeckNo = 0;
String addr = String("/conf/" + String(val) + ".LampConf.txt");
//String title = "Main Config for ESP.";
yield();
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory()) {
debugMe("play file creation failed");
}
else
{ // yeah its open
debugMe("Write Conf File");
conf_file.print(String("[NM:"+ String(led_cfg.Led_Setup_confname)));
conf_file.println("] ");
for (uint8_t form = 0; form < NR_FORM_PARTS; form++)
{
conf_file.print(String("[FC:" + String(form)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_cfg[form].start_led)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_cfg[form].nr_leds)));
conf_file.println("] ");
}
conf_file.close();
}
}
bool FS_play_conf_write1(uint8_t val)
{
// write the artnet config to disk
uint8_t selectedDeckNo = 0;
String addr = String("/conf/" + String(val) + ".playConf.txt");
//String title = "Main Config for ESP.";
yield();
File conf_file = selectedFS.open(addr, "w");
if (!conf_file && !conf_file.isDirectory()) {
debugMe("play file creation failed");
return false;
}
else { // yeah its open
debugMe("Write Conf File");
conf_file.print(String("[NM:"+ String(deck[0].cfg.confname)));
conf_file.println("] ");
//conf_file.println("Play Config.");
//conf_file.println("LS = LED DEVICE Settings : Fire Cooling : Fire Sparking : Red : Green : Blue : Pallete Bri: Pallete FPS: Blend Invert : SPARE : fft scale : Global Bri");
conf_file.print(String("[LS:" + String(deck[selectedDeckNo].cfg.led_master_cfg.r)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.led_master_cfg.g)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.led_master_cfg.b)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.led_master_cfg.pal_bri)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.led_master_cfg.pal_fps)));
conf_file.print(String(":" + String( map(deck[0].cfg.led_master_cfg.bri, 0 , led_cfg.max_bri , 0 ,255) )));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.layer.clear_start_led)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.layer.clear_Nr_leds)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.fft_config.Scale)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.fft_config.fftAutoMin)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.fft_config.fftAutoMax)));
conf_file.println("] ");
//conf_file.println("ly = Layers 0 to 47, ");
conf_file.print("[ly:" + String(deck[selectedDeckNo].cfg.layer.select[0]) ) ;
for (uint8_t layer = 1 ; layer < MAX_LAYERS_SELECT ; layer++)
{
conf_file.print(":" + String(deck[selectedDeckNo].cfg.layer.select[layer]) ) ;
}
conf_file.println("] ");
for (uint8_t layer = 0 ; layer < NO_OF_SAVE_LAYERS ; layer++)
{
conf_file.print("[LC:" + String(layer) ) ;
conf_file.print(":" + String(deck[selectedDeckNo].cfg.layer.save_startLed[layer]) ) ;
conf_file.print(":" + String(deck[selectedDeckNo].cfg.layer.save_NrLeds[layer]) ) ;
conf_file.print(":" + String(deck[selectedDeckNo].cfg.layer.save_lvl[layer]) ) ;
conf_file.print(":" + String(deck[selectedDeckNo].cfg.layer.save_mix[layer]) ) ;
conf_file.println("] ");
}
//conf_file.println("PF - Pallete FX Form ");
for (uint8_t form = 0; form < NR_FORM_PARTS; form++)
{
if (deck[selectedDeckNo].cfg.form_cfg[form].nr_leds > 0
&& ( ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_00_PAL)
&& form < 16 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_16_PAL)
&& form >= 16
&& form < 32 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_32_PAL)
&& form >= 32
&& form < 48 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_48_PAL)
&& form >= 48)
)
)
{
conf_file.print(String("[PF:" + String(form)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal[form].level)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal[form].index_start)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal[form].index_add_led)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal[form].index_add_frame)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal[form].autoPalMode)));
conf_file.println("] ");
}
}
for (uint8_t form = 0; form < _M_NR_FORM_BYTES_; form++)
{
if (
( ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_00_PAL)
&& form < 2 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_16_PAL)
&& form >= 2
&& form < 4 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_32_PAL)
&& form >= 4
&& form < 6 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_48_PAL)
&& form >= 6)
)
)
{
conf_file.print(String("[PS:" + String(form)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].pal)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].mix_mode)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].palSpeedBin)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].triggerBin)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].lvl_bin)));
for (uint8_t setting = 0; setting < _M_NR_FORM_PAL_OPTIONS_; setting++) conf_file.print((String(":" + String(deck[selectedDeckNo].cfg.form_menu_pal[form][setting]))));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_pal_singles[form].master_lvl)));
conf_file.println("] ");
}
}
//conf_file.println("TF form fft ");
for (uint8_t form = 0; form < NR_FORM_PARTS; form++)
{
if (deck[selectedDeckNo].cfg.form_cfg[form].nr_leds > 0)
{
if ( deck[selectedDeckNo].cfg.form_cfg[form].nr_leds > 0
&& (
( ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_00_FFT)
&& form < 16 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_16_FFT)
&& form >= 16
&& form < 32 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_32_FFT)
&& form >= 32
&& form < 48 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_48_FFT)
&& form >= 48)
)
)
)
{
conf_file.print(String("[TF:" + String(form)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_fft[form].level)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_fft[form].offset)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_fft[form].extend)));
conf_file.println("] ");
}
}
}
for (uint8_t form = 0; form < _M_NR_FORM_BYTES_; form++)
{
if (
( ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_00_FFT)
&& form < 2 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_16_FFT)
&& form >= 2
&& form < 4 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_32_FFT)
&& form >= 4
&& form < 6 )
|| ( LEDS_check_if_layer_selected(selectedDeckNo, _M_LAYER_48_FFT)
&& form >= 6)
)
)
{
conf_file.print(String("[TC:" + String(form)));
conf_file.print(String(":" + String(deck[selectedDeckNo].cfg.form_fx_fft_signles[form].mix_mode)));