FastLED 3.9.15
Loading...
Searching...
No Matches

◆ loop()

void loop ( )

Definition at line 98 of file curr.h.

98 {
99 uint32_t now = millis();
100 // fl::clear(lesdds);
102
103 static float pos = 0;
104
105 // Update the corkscrew mapping every second
106 // w = (w + 1) % CORKSCREW_WIDTH;
107 // frameBuffer.
108 pos += speed.value();
109 if (pos > corkscrew.size() - 1) {
110 pos = 0; // Reset to the beginning
111 }
112 if (allWhite) {
113 for (size_t i = 0; i < frameBuffer.size(); ++i) {
114 frameBuffer.data()[i] = CRGB(8, 8, 8);
115 }
116 }
117
118 if (splatRendering) {
119 Tile2x2_u8_wrap pos_tile = corkscrew.at_wrap(pos);
120 const CRGB color = CRGB::Blue;
121 // Draw each pixel in the 2x2 tile using the new wrapping API
122 for (int dx = 0; dx < 2; ++dx) {
123 for (int dy = 0; dy < 2; ++dy) {
124 auto data = pos_tile.at(dx, dy);
125 vec2i16 wrapped_pos = data.first; // Already wrapped position
126 uint8_t alpha = data.second; // Alpha value
127
128 if (alpha > 0) { // Only draw if there's some alpha
129 CRGB c = color;
130 c.nscale8(alpha); // Scale the color by the alpha value
131 frameBuffer.at(wrapped_pos.x, wrapped_pos.y) = c;
132 }
133 }
134 }
135 } else {
136 // None splat rendering, looks aweful.
137 vec2f pos_vec2f = corkscrew.at_exact(pos);
138 vec2i16 pos_i16 = vec2i16(round(pos_vec2f.x), round(pos_vec2f.y));
139 // Now map the cork screw position to the cylindrical buffer that we
140 // will draw.
141 frameBuffer.at(pos_i16.x, pos_i16.y) =
142 CRGB::Blue; // Draw a blue pixel at (w, h)
143 }
144 FastLED.show();
145}
uint8_t pos
Definition Blur.ino:11
UICheckbox allWhite("All White", false)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
Data & at(uint16_t x, uint16_t y)
Definition tile2x2.cpp:57
Corkscrew corkscrew(corkscrewInput)
UICheckbox splatRendering("Splat Rendering", true)
fl::Grid< CRGB > frameBuffer
Definition Corkscrew.h:71
uint16_t speed
Definition funky.cpp:82
void clear(CRGB(&arr)[N])
Definition clear.h:13
vec2< float > vec2f
Definition geometry.h:318
vec2< int16_t > vec2i16
Definition geometry.h:320
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:88
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:506
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55
#define round(x)
Definition util.h:10

References allWhite, fl::Tile2x2_u8_wrap::at(), CRGB::Blue, fl::clear(), corkscrew(), FastLED, frameBuffer, CRGB::nscale8(), pos, round, speed, splatRendering(), fl::vec2< T >::x, and fl::vec2< T >::y.

+ Here is the call graph for this function: