🌈 rainbow supercomputaa
This commit is contained in:
		
							parent
							
								
									7b5701f2e9
								
							
						
					
					
						commit
						224f2beb23
					
				| @ -8,6 +8,7 @@ enum Mode { | ||||
| 
 | ||||
| enum DisplayStyle { | ||||
|   Rain, | ||||
|   Congress | ||||
|   Congress, | ||||
|   Supercomputer | ||||
| }; | ||||
| #endif | ||||
|  | ||||
| @ -6,6 +6,7 @@ | ||||
| #include "constants.h" | ||||
| #include "congress.h" | ||||
| #include "rain.h" | ||||
| #include "supercomputer.h" | ||||
| 
 | ||||
| #include "pillowlava8pt7b.h" | ||||
| 
 | ||||
| @ -65,6 +66,9 @@ void loop() { | ||||
|         style = Congress; | ||||
|         break; | ||||
|       case Congress: | ||||
|         style = Supercomputer; | ||||
|         break; | ||||
|       case Supercomputer: | ||||
|         style = Rain; | ||||
|         break; | ||||
|     } | ||||
| @ -78,6 +82,9 @@ void loop() { | ||||
|     case Congress: | ||||
|       draw_congress(matrix, mode); | ||||
|       break; | ||||
|     case Supercomputer: | ||||
|       draw_supercomputer(matrix); | ||||
|       break; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										40
									
								
								nametag/src/supercomputer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								nametag/src/supercomputer.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| #include <Arduino.h> | ||||
| #include <FastLED.h> | ||||
| #include "constants.h" | ||||
| #include "supercomputer.h" | ||||
| 
 | ||||
| struct Cell { | ||||
|   float state; | ||||
|   float factor; | ||||
| }; | ||||
| 
 | ||||
| float cell_value(Cell c) { | ||||
|   return (1.0 + sin(c.state * c.factor)) * 0.5; | ||||
| } | ||||
| 
 | ||||
| Cell cells[PANEL_WIDTH * PANEL_HEIGHT]; | ||||
| bool cells_setup = false; | ||||
| 
 | ||||
| void setup_cells() { | ||||
|   for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) { | ||||
|     cells[i].state = random(100, 1000) / 100.0; | ||||
|     cells[i].factor = random(90, 110) / 100.0; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void draw_supercomputer(MatrixPanel_I2S_DMA *matrix) { | ||||
|   if (!cells_setup) { | ||||
|     setup_cells(); | ||||
|     cells_setup = true; | ||||
|   } | ||||
|   for(int i = 0; i < PANEL_WIDTH * PANEL_HEIGHT; i++) { | ||||
|     cells[i].state += 0.3; | ||||
|     //matrix->drawPixel(i % PANEL_WIDTH, i / PANEL_WIDTH, matrix->color565((int)round(255.0 * cell_value(cells[i])), 0, 0));
 | ||||
|     int x = i % PANEL_WIDTH; | ||||
|     float progress = (255.0 / PANEL_WIDTH) * x; | ||||
|     CHSV hsv_color((int)round(progress), 255, 255 * cell_value(cells[i])); | ||||
|     CRGB rgb; | ||||
|     hsv2rgb_rainbow(hsv_color, rgb); | ||||
|     matrix->drawPixel(i % PANEL_WIDTH, i / PANEL_WIDTH, matrix->color565(rgb.r, rgb.g, rgb.b)); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										2
									
								
								nametag/src/supercomputer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								nametag/src/supercomputer.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h> | ||||
| void draw_supercomputer(MatrixPanel_I2S_DMA *matrix); | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user