-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProtoRainbow.ino
109 lines (101 loc) · 2.94 KB
/
ProtoRainbow.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
/*********
By speck and jtingf MUhahaha
*********/
#include "ProtoRainbow.h"
#include "RainbowSettings.h"
#include "Frames.h"
#include <Arduino.h>
#include "Adafruit_GFX.h"
#include "Framebuffer_GFX.h"
#include "PxMatrix.h"
#include "FastLED.h"
#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 2
CRGB matrixleds[ledcount];
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
TaskHandle_t Task1;
TaskHandle_t Task2;
// Pins for LED MATRIX
#define matrix_width 128
#define matrix_height 32
// This defines the 'on' time of the display is us. The larger this number,
// the brighter the display. If too large the ESP will crash
uint8_t display_draw_time=10; //10-50 is usually fine
//rainbow scroll for WS2812B
void rainbow_wave(uint8_t thisSpeed, uint8_t deltaHue, int framedelay, int counts) {
// uint8_t thisHue = beatsin8(thisSpeed,0,255);
for (int i = 0; i < (counts + 1); i++){
uint8_t thisHue = beat8(thisSpeed,255);
fill_rainbow(matrixleds, ledcount, thisHue, deltaHue);
delay(framedelay);
FastLED.show();
}
}
void Task2code( void * pvParameters ){
for(;;){
delay(1);
display.display(50); //was60
}
}
void setup() {
Serial.begin(9600);
setCpuFrequencyMhz(160);
xTaskCreatePinnedToCore(
Task2code,
"Task2",
11000,
NULL,
24,
&Task2,
0);
display.begin(16);
display.setMuxDelay(1,1,1,1,1);
display.setPanelsWidth(2);
display.setFastUpdate(true);
FastLED.addLeds<WS2812,4>(matrixleds, ledcount); // "4" is the pin you connect your WS2812 matrix to !
display.setBrightness(MATRIX_BRIGHTNESS); //this is where you set your brightness for HUB75
FastLED.setBrightness(LED_BRIGHTNESS); //and for WS2812
}
void loop() {
//display.clearDisplay();
hueOffset += 1;
if (hueOffset == (72*loopEvent + 1)){ //insert event on the (loopEvent)th RGB cycle TODO: what is 72???
//your event goes here, here it blinks on every second cycle
for (int h = 0; h < 7; h++){
display.clearDisplay();
switch (h){
case 0:
case 6:
draw_face(blink1, h);
rainbow_wave(50, 10, animation_delay, 4); //this function serves as a delay but to include the scrolling of WS2812B's, since there aint async or maybe im stupid
break;
case 1:
case 5:
draw_face(blink2, h);
rainbow_wave(50, 10, animation_delay, 4);
break;
case 2:
case 4:
draw_face(blink3, h);
rainbow_wave(50, 10, animation_delay, 4);
break;
case 3:
draw_face(blink4, h);
rainbow_wave(50, 10, animation_delay, 8);
break;
}
}
hueOffset = 4; // 4 Represents how may frames have passed? shouldnt it be 7?
display.clearDisplay();
}
else{
draw_face(cheer, hueOffset);
rainbow_wave(50, 10, frame_delay, 1);
}
}