-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtltvhead.ino
2120 lines (1818 loc) · 59.9 KB
/
Atltvhead.ino
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
/* Atltvhead.ino - Arduino code of how atltvhead helmet runs
* Created by Nate Damen, 2015
* Apache License Version 2.0
* Updated to use MQTT
* Updated 10-6-2021
*/
#include <FastLED.h>
//#include <LEDMatrix.h>
//#include <LEDText.h>
//#include <FontMatrise.h>
#include "EspMQTTClient.h"
#include "cred.h"
#include <Arduino.h>
#include <ArduinoJson.h>
#include <Math.h>
#include <driver/i2s.h>
const int capacity = JSON_OBJECT_SIZE(15);
StaticJsonDocument<capacity> doc;
const char* ssid1 = SSID1;
const char* password1 = PASSWORD1;
const char* ssid2 = SSID2;
const char* password2 = PASSWORD2;
const char* ssid3 = SSID3;
const char* password3 = PASSWORD3;
const char* mqttServerIp = MQTTBROKER;
const short mqttServerPort = PORT;
const char* mqttUser= MQTTUSER;
const char* mqttPassword= MQTTPASSWORD;
// Pubsub
EspMQTTClient client(
ssid1,
password1,
mqttServerIp, // MQTT Broker server ip
MQTTUSER, // Can be omitted if not needed
MQTTPASSWORD,
mqttClientName, // Client name that uniquely identify your device
mqttServerPort
);
//-----------------------------------------------------------------------
#define I2S_WS 15
#define I2S_SD 13
#define I2S_SCK 2
#define I2S_PORT I2S_NUM_0
//----------------------------------------------------------------------------------------------------//
int posin = 0;
int posinold = 0;
//----------------------------------------------------------------------------------------------------//
#define CHIPSET WS2812B
#define PIN 27
#define COLOR_ORDER GRB
int bright=255;
// Params for width and height
const uint8_t kMatrixWidth = 30;
const uint8_t kMatrixHeight = 18;
static uint16_t U;
static uint16_t O;
static uint16_t P;
uint16_t speed = 20;
uint16_t scale = 30; // scale is set dynamically once we've started up
#define NUM_LEDS ((kMatrixWidth * kMatrixHeight))
#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
CRGB leds[NUM_LEDS];
CRGB ledsbuff[NUM_LEDS];
uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
// these are for storing the max min and random users
String maxuser;
String minuser;
String selCheck;
String randuser;
// These are for storing the number of times the max and min people have chatted
String maxUseNum;
String minUseNum;
int minValue=0;
int maxValue=0;
// Param for serpentine led layout
const bool kMatrixSerpentineLayout = true;
// Use the "XY" function to generate the led number
uint16_t XY( uint8_t x, uint8_t y)
{
uint16_t i;
if( kMatrixSerpentineLayout == false) {
i = (y * kMatrixWidth) + x;
}
if( kMatrixSerpentineLayout == true) {
if( y & 0x01) {
// Odd rows run backwards
uint8_t reverseX = (kMatrixWidth - 1) - x;
i = (y * kMatrixWidth) + reverseX;
} else {
// Even rows run forwards
i = (y * kMatrixWidth) + x;
}
}
return i;
}
//------------------------
#define MATRIX_WIDTH 30
#define MATRIX_HEIGHT 18
#define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX
//cLEDMatrix<MATRIX_WIDTH, -MATRIX_HEIGHT, MATRIX_TYPE> LEDs;
//cLEDText ScrollingMsg;
int CurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t chanel = 1;
uint8_t oldChanel = 1;
uint32_t ms = 0;
uint32_t yHueDelta32 = 0;
uint32_t xHueDelta32 = 0;
uint32_t hue = 0;
uint8_t angle = 0;
uint8_t mode = 1;
bool HFM = false;
double STime=0;
double FTime = 0;
double BTime=0;
bool BLMB = false;
char pasnum = 'B';
//-------------------------
//const unsigned char txt[] = {EFFECT_SCROLL_LEFT " B L A C K L I V E S M A T T E R "};
//const unsigned char txt[] = {"what up"};
char inChar;
int in = 0;
bool TW = false;
bool mh = false;
bool mv = false;
bool mq = false;
bool mqr = false;
int Hue = 0;
int hHue = 211;
int hSat = 255;
int hVal = 255;
int bHue = 135;
int bSat = 255;
int bVal = 255;
int cHue = 211;
int cSat = 255;
int cVal = 255;
int cbHue = 135;
int cbSat = 255;
int cbVal = 255;
int hue5=254;
int hue6=hue5+160;
byte eyeCount=0;
boolean fullrainbow = false;
unsigned int flick =0;
boolean flickoverRide = false;
unsigned int raincount = 0;
uint8_t sprand=0;
//--------------------------------------------
bool tv[18][30]={
{0,0,0,0,0,0,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------------------------------------------------------------------------------------------//
bool blm[9][39]={
{0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0}};
//----------------------------------------------------------------------------------------------------//
int wificount = 0;
int heartcount = 0; //for the count on getting the animation to play
const int invheartc =2;
int hcind = 0;
bool flicker = false;
//hsv color values for hear animation
uint8_t color = 211; //CHSV(211,255,255) Pink //CHSV(211,100,255) Light Pink //CHSV(135,255,255) Blue
uint8_t oldColor = 135;
uint8_t colorHolder = 0;
//saturation values for heart animation
uint8_t sat = 255; //CHSV(211,255,255) Pink //CHSV(211,100,255) Light Pink //CHSV(135,255,255) Blue
uint8_t oldSat = 150;
uint8_t satHolder = 0;
// for demonDelay function
long totalTime = 0;
boolean MLF = false;
boolean MUD = false;
boolean MUP = false;
boolean MRF = false;
int cur = 0;
int last = 0;
int diff = 50;
CRGBPalette16 currentPalette( PartyColors_p);
TBlendType currentBlending;
uint8_t colorLoop = 1;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
#define HOLD_PALETTES_X_TIMES_AS_LONG 1
void setup() {
// From the FASTLED CODE
//---------------------------------------------
FastLED.addLeds<CHIPSET, PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
FastLED.setBrightness( bright );
//FastLED.clear(true);
gradHeart();
displayScreen();
delay(100);
U = random16();
O = random16();
P = random16();
i2s_install();
i2s_setpin();
i2s_start(I2S_PORT);
delay(100);
Serial.begin(115200);
//---------------------
//ScrollingMsg.SetFont(MatriseFontData);
//ScrollingMsg.Init(&LEDs, LEDs.Width(), ScrollingMsg.FontHeight()+1, 0, 0);
//ScrollingMsg.SetText((unsigned char *)txt, sizeof(txt) - 1);
//ScrollingMsg.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 0xff, 0x00, 0xff);
// FROM THE IRC TWITCHBOT CODE
//-----------------------------------------------------------------------
// pinMode(LED_BUILTIN, OUTPUT);
delay(100);
currentBlending = LINEARBLEND;
// add way to autochange wifi networks
// Optionnal functionnalities of EspMQTTClient :
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
client.enableLastWillMessage("TestClient/lastwill", "I am going offline"); // You can activate the retain flag by setting the third parameter to true
client.setMaxPacketSize(256);
}
void loop() {
// getting the MQTT going and reading
//---------------------------------------------------------
client.loop();
int32_t sample = 0;
int bytes = i2s_pop_sample(I2S_PORT, (char*)&sample, portMAX_DELAY);
if(bytes >0){
// This indicates if audio has occured. can be used as a switch.
yield();
}
ms = millis();
yHueDelta32 = ((int32_t)sin16( ms * (27/1) ) * (350 / kMatrixWidth));
xHueDelta32 = ((int32_t)cos16( ms * (39/1) ) * (310 / kMatrixHeight));
// Periodically choose a new palette, speed, and scale
ChangePaletteAndSettingsPeriodically();
// generate noise data
fillnoise8();
switch(mode){
case 0:
switch(chanel)
{
case 0:
tvOutlineDisp();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 1:
gradHeart();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 2:
DrawOneFrame( ms / 131072, xHueDelta32 / 65536, yHueDelta32 / 65536);
if(!fullrainbow){
superRainbowHeart();
}
else if(fullrainbow){
if(raincount <3000){
raincount++;
}
else{
raincount = 0;
fullrainbow = false;
}
}
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 3:
atlunited();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
}
break;
case 1:
switch(chanel)
{
case 0:
tvColorCycle();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 1:
seawave2();
glitch_side_stutter();
//gradHeartsp();
//FastLED.delay(50);
mirrorHandler();
displayScreen();
break;
case 2:
SectionGlitchesHeart();
glitch_side_stutter();
mirrorHandler();
delay(random(250,1000));
displayScreen();
break;
case 3:
mahearta();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
}
break;
case 2:
switch(chanel)
{
case 0:
gradHeartspcycle(cHue, cbHue);
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 1:
randomNoiseHeart();
glitch_side_stutter();
mirrorHandler();
delay(random(12,125));
displayScreen();
break;
case 2:
currentPalette = RainbowStripeColors_p;
SetupBlackAndWhiteStripedPalette();
static uint8_t startIndex = 0;
startIndex = startIndex + 3; /* motion speed */
FillLEDsFromPaletteColors1( startIndex);
mirrorHandler();
glitch_side_stutter();
displayScreen();
break;
case 3:
BlackLivesMatterHeart();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
}
break;
case 3:
switch(chanel)
{
case 0:
mapNoiseToHeartWithOutline();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 1:
mapNoiseToHeart();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 2:
NoiseToScreen();
glitch_side_stutter();
mirrorHandler();
displayScreen();
break;
case 3:
color = 211;
for(int ppgLooper =0; ppgLooper <= 3; ppgLooper++){
for(int indPPG =0; indPPG<=5;indPPG++){
ppg(indPPG);
}
}
break;
}
break;
case 4:
eyeTvU(eyeCount);
glitch_side_stutter();
delay(500);
displayScreen();
}
posinold = posin;
}
//------------------------------------------------------------------------------------------------------
// this is where the commands for chat are located
void onConnectionEstablished()
{
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("stream_live", [](const String & payload) {
Serial.println(payload);
});
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("tvhead_bright", [](const String & payload) {
Serial.println(payload);
});
// gESTURE HANDLER
client.subscribe("glove/gesture", [](const String & payload) {
if(payload=="wave_mode"){
mode=1;
}
else if(payload=="speed_mode"){
mode=3;
}
else if(payload=="random_motion_mode"){
mode=0;
}
else if(payload=="fist_pump_mode"){
mode=2;
}
Serial.println(payload);
});
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("viewer_click", [](const String & payload) {
chanel++;
if(chanel>=4){
chanel=0;
}
Serial.println(payload);
});
// Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
//client.subscribe("mytopic/wildcardtest/#", [](const String & topic, const String & payload) {
// Serial.println("(From wildcard) topic: " + topic + ", payload: " + payload);
//});
// Publish a message to "mytopic/test"
client.publish("tvhead", "alive"); // You can activate the retain flag by setting the third parameter to true
// Execute delayed instructions
//client.executeDelayed(5 * 1000, []() {
// client.publish("mytopic/wildcardtest/test123", "This is a message sent 5 seconds later");
//});
}
/*
void callback(IRCMessage ircMessage) {
//Serial.println("In CallBack");
// PRIVMSG ignoring CTCP messages
if (ircMessage.command == "PRIVMSG" && ircMessage.text[0] != '\001') {
//Serial.println("Passed private message.");
String message("<" + ircMessage.nick + "> " + ircMessage.text);
Serial.println(message);
selCheck = ircMessage.text[0];
//Serial.println(selCheck);
///////////////////////////////////////////////////////////////////////////////////////////
if((ircMessage.text == "!ch0" && ircMessage.nick == "atltvhead") || (ircMessage.text =="0" && ircMessage.nick == "atltvhead") || ircMessage.text=="LUL"){
chanel = 0;
client.sendMessage(IRC_CHAN, ircMessage.nick + " set atltvhead to the secret 0!");
//Serial.println(chanel);
}
else if(ircMessage.text == "<3" || ircMessage.text =="atltvhSph" || ircMessage.text =="1" || ircMessage.text =="!ch1" || ircMessage.text=="TwitchLit" || ircMessage.text =="TwitchUnity"){
chanel = 1;
if(heartcount >= 2){
client.sendMessage(IRC_CHAN, ircMessage.nick + " shows their heart! Thank you! Chat, you've shown your heart! YOU ARE AWESOME! THANK YOU!!!!!!!!!!");
for(int ppgLooper =0; ppgLooper <= 3; ppgLooper++){
for(int indPPG =0; indPPG<=5;indPPG++){
ppg(indPPG);
}
}
heartcount = 0;
}
else{
hcind = invheartc - heartcount;
client.sendMessage(IRC_CHAN, ircMessage.nick + " shows their heart! Thank you! Chat, we need " + hcind + " more people to show their '!heart'. LET'S DO THIS!");
heartcount++;
}
}
else if(ircMessage.text=="TheIlluminati"){
mode = 4;
}
else if(ircMessage.text == "1" && ircMessage.nick == "atltvhead"){
//client.sendMessage(IRC_CHAN, ircMessage.nick + " It's PowerPuff Girl's Heart Time!");
for(int ppgLooper =0; ppgLooper <= 3; ppgLooper++){
for(int indPPG =0; indPPG<=5;indPPG++){
ppg(indPPG);
}
}
}
else if(ircMessage.text == "!flicker"){
flicker = true;
}
else if(ircMessage.text == "!flickerOff"){
flickoverRide = true;
}
else if(ircMessage.text == "!brighter"){
bright = bright +10;
FastLED.setBrightness(bright);
}
else if(ircMessage.text == "!dimmer"){
bright = bright -10;
FastLED.setBrightness(bright);
}
else if(ircMessage.text =="!heartColor"){
changeHeartHue();
}
else if(ircMessage.text =="!heartSat"){
changeHeartSat();
}
else if(ircMessage.text =="!heartBright"){
changeHeartVal();
}
else if(ircMessage.text =="!backgroundColor"){
changeBackHue();
}
else if(ircMessage.text =="!backgroundSat"){
changeBackSat();
}
else if(ircMessage.text =="!backgroundBright"){
changeBackVal();
}
else if(ircMessage.text =="!reset"){
resetHeart();
}
else if(ircMessage.text =="!fullRainbow"){
fullrainbow = true;
}
else if(ircMessage.text =="!mirrorRight"){
MLF = true;
}
else if(ircMessage.text =="!mirrorOff"){
MLF = false;
MUD = false;
MUP = false;
}
else if(ircMessage.text =="!mirrorUp"){
MUP = true;
MUD = false;
}
else if(ircMessage.text =="!mirrorDown"){
MUD = true;
MUP = false;
}
else if(ircMessage.text =="atltvhRb" || ircMessage.text == "!ch2" || ircMessage.text =="2" || ircMessage.text =="!rainbowHeart" || ircMessage.text=="KappaPride" || ircMessage.text=="VirtualHug" || ircMessage.text =="PridePaint"){
chanel = 2;
fullrainbow = true;
}
else if(ircMessage.text =="!ch3" || ircMessage.text =="3" || ircMessage.text =="!United" || ircMessage.text =="!Mahearta" || ircMessage.text =="!unite" || ircMessage.text=="bleedPurple"){
chanel=3;
}
else if(selCheck == "~" && ircMessage.nick == "tvheadbot"){
//do nothing for compile check
minuser = ircMessage.text;
minuser.remove(0,1);
}
else if(selCheck == "+" && ircMessage.nick == "tvheadbot"){
//do nothing for compile check
maxuser = ircMessage.text;
maxuser.remove(0,1);
}
else if(selCheck == "~" && ircMessage.nick == "atltvhead"){
//do nothing for compile check
minuser = ircMessage.text;
minuser.remove(0,1);
}
else if(selCheck == "+" && ircMessage.nick == "atltvhead"){
//do nothing for compile check
maxuser = ircMessage.text;
maxuser.remove(0,1);
}
else if(selCheck == ">" && ircMessage.nick == "atltvhead"){
maxUseNum = ircMessage.text;
maxUseNum.remove(0,1);
maxValue = atoi(maxUseNum.c_str());
}
else if(selCheck == "<" && ircMessage.nick == "atltvhead"){
minUseNum == ircMessage.text;
minUseNum.remove(0,1);
minValue = atoi(minUseNum.c_str());
}
else if(selCheck == ">" && ircMessage.nick == "tvheadbot"){
maxUseNum = ircMessage.text;
maxUseNum.remove(0,1);
maxValue = atoi(maxUseNum.c_str());
}
else if(selCheck == "<" && ircMessage.nick == "tvheadbot"){
minUseNum == ircMessage.text;
minUseNum.remove(0,1);
minValue = atoi(minUseNum.c_str());
}
else if(ircMessage.text == "!maxtvhead" && ircMessage.nick == maxuser){
chanel = 0;
// do nothing for right now
}
else if(ircMessage.text == "!mintvhead" && ircMessage.nick == minuser){
chanel = 0;
//do nothing for right now
}
else if(selCheck =="-" && ircMessage.nick == "tvheadbot"){
randuser = ircMessage.text;
randuser.remove(0,1);
}
else if(selCheck =="-" && ircMessage.nick == "atltvhead"){
randuser = ircMessage.text;
randuser.remove(0,1);
}
else if(ircMessage.text == "!randtvhead" && ircMessage.nick == randuser){
chanel = 0;
}
else if(ircMessage.text == "!random_motion_mode"){
mode = 0;
}
else if(ircMessage.text == "!fist_pump_mode"){
mode = 2;
}
else if(ircMessage.text == "!wave_mode"){
mode = 1;
}
else if(ircMessage.text == "!speed_mode"){
mode = 3;
}
return;
}
}
*/
void mirrorHandler(){
if(MLF==true){
mirrorLeftToRight();
}
if(MUD == true){
mirrorUptoDown();
}
if(MUP == true){
mirrorDowntoUp();
}
}
//--------------------------------------------------------------------------------------------------
// these are the tvhead helper functions.
//-----------------------------------------------------------------------------------------------------------------------------------
void i2s_install(){
const i2s_config_t i2s_config = {
.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 44100,
.bits_per_sample = i2s_bits_per_sample_t(16),
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}
void i2s_setpin(){
const i2s_pin_config_t pin_config = {
.bck_io_num = I2S_SCK,
.ws_io_num = I2S_WS,
.data_out_num = -1,
.data_in_num = I2S_SD
};
i2s_set_pin(I2S_PORT, &pin_config);
}
//_________________________________________________________________________________________
// heart effect
void heart(){
for( byte y = 0; y < kMatrixHeight; y++) {
for( byte x = 0; x < kMatrixWidth; x++) {
if(tv[y][x]){
leds[ XY(x, y)] = CHSV( cHue, cSat, cVal);
}
else{
leds[XY(x,y)]=CHSV(cbHue,cbSat,cbVal);
}
}
}
}
void colorFillScreen(int hue12, int hue34){
for( byte y = 0; y < kMatrixHeight; y++) {
for( byte x = 0; x < kMatrixWidth; x++) {
if(tv[y][x]){
leds[ XY(x, y)] = CHSV( hue12, cSat, cVal);
}
else{
leds[XY(x,y)]=CHSV(hue34,cbSat,cbVal);
}
}
}
}
void changeHeartHue(){
cHue = cHue + 30;
if(cHue >= 255){
cHue = 10;
}
}
void changeHeartSat(){
cSat = cSat + 25;
if(cSat>= 255){
cSat = 25;
}
}
void changeHeartVal(){
cVal = cVal + 25;
if(cVal>= 255){
cVal = 25;
}
}
void changeBackHue(){
cbHue = cbHue + 35;
if(cbHue >= 255){
cbHue = 25;
}
}
void changeBackSat(){
cbSat = cbSat + 25;
if(cbSat>= 255){
cbSat = 25;
}
}
void changeBackVal(){
cbVal = cbVal + 25;
if(cbVal>= 255){
cbVal = 25;
}
}
void resetHeart(){
cHue = hHue;
cVal = hVal;
cSat = hSat;
cbHue = bHue;
cbVal = bVal;
cbSat = bSat;
}
void ppg(byte frame){
if(frame ==0){
fill_solid(leds,NUM_LEDS, CHSV(oldColor,oldSat,255)); // change this to a solid fill
FastLED.show();
delay(75);