Small fixes and tweaks to blur2d, clock and firework.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Schlenz 2019-09-25 20:05:18 +02:00
parent c1024b3423
commit 075f434997
3 changed files with 24 additions and 24 deletions

View File

@ -5,18 +5,18 @@ boolean Blur2DEffect::can_be_shown_with_clock() {
} }
void Blur2DEffect::loop() { void Blur2DEffect::loop() {
uint8_t blur_amount = dim8_raw(beatsin8(3, 64, 192)); uint8_t blur_amount = dim8_raw(beatsin8(3, 128, 224));
window->blur(blur_amount); window->blur(blur_amount);
uint8_t x1 = beatsin8(5, 0, window->width-1); uint8_t x1 = beatsin8(7, 0, window->width-1);
uint8_t y1 = beatsin8(8, 0, window->height-1); uint8_t y1 = beatsin8(11, 0, window->height-1);
uint8_t x2 = beatsin8(8, 0, window->width-1); uint8_t x2 = beatsin8(13, 0, window->width-1);
uint8_t y2 = beatsin8(3, 0, window->height-1); uint8_t y2 = beatsin8(8, 0, window->height-1);
uint8_t x3 = beatsin8(4, 0, window->width-1); uint8_t x3 = beatsin8(11, 0, window->width-1);
uint8_t y3 = beatsin8(7, 0, window->height-1); uint8_t y3 = beatsin8(13, 0, window->height-1);
uint16_t ms = millis(); uint16_t ms = millis();
CRGB c1 = CHSV(ms / 29, 200, 255); CRGB c1 = CHSV(ms / 29, 200, 255);
CRGB c2 = CHSV(ms / 41, 200, 255); CRGB c2 = CHSV(ms / 41, 200, 255);

View File

@ -13,7 +13,7 @@ void NightClockEffect::loop() {
//uint8_t y = minutes % ((window->height - 5) * 2 - 2); //uint8_t y = minutes % ((window->height - 5) * 2 - 2);
//if (y > window->height - 5) y = 2*window->height - 2*y; //if (y > window->height - 5) y = 2*window->height - 2*y;
uint8_t y = minutes % 10; uint8_t y = minutes % 10;
ClockEffect::loop(false, CRGB(0x880000), CRGB(0x000000), y); ClockEffect::loop(false, CRGB(0x200000), CRGB(0x000000), y);
} }
void ClockEffect::loop() { void ClockEffect::loop() {
@ -34,7 +34,7 @@ void ClockEffect::loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t yPo
// Manually clear the needed parts // Manually clear the needed parts
for(int y=0; y<6; y++) { for(int y=0; y<6; y++) {
window->setPixel(3, yPos+y, &bg_color); window->setPixel(3, yPos+y, &bg_color);
if (y!=2 && y!=4) { if (y!=1 && y!=3) {
window->setPixel(7, yPos+y, &bg_color); window->setPixel(7, yPos+y, &bg_color);
} }
window->setPixel(8, yPos+y, &bg_color); window->setPixel(8, yPos+y, &bg_color);

View File

@ -7,7 +7,7 @@ FireworkEffectDot::FireworkEffectDot(Window* w, FireworkEffect* e) {
show = 0; show = 0;
type = FIREWORK_DOT_NONE; type = FIREWORK_DOT_NONE;
_x = 0; _x = 0;
_y = 0; _y = _window->height - 1;
_xv = 0; _xv = 0;
_yv = 0; _yv = 0;
_r = 0; _r = 0;
@ -35,7 +35,7 @@ void FireworkEffectDot::draw() {
_screenscale(_y, _window->height, iy, ye); _screenscale(_y, _window->height, iy, ye);
xc = 255 - xe; xc = 255 - xe;
yc = 255 - ye; yc = 255 - ye;
CRGB c00 = CRGB(dim8_video( scale8( scale8( _color.r, yc), xc)), CRGB c00 = CRGB(dim8_video( scale8( scale8( _color.r, yc), xc)),
dim8_video( scale8( scale8( _color.g, yc), xc)), dim8_video( scale8( scale8( _color.g, yc), xc)),
dim8_video( scale8( scale8( _color.b, yc), xc))); dim8_video( scale8( scale8( _color.b, yc), xc)));
@ -59,8 +59,8 @@ void FireworkEffectDot::move() {
_yv -= EFFECT_FIREWORK_GRAVITY; _yv -= EFFECT_FIREWORK_GRAVITY;
_xv = _scale15by8_local(_xv, EFFECT_FIREWORK_DRAG); _xv = _scale15by8_local(_xv, EFFECT_FIREWORK_DRAG);
_yv = _scale15by8_local(_yv, EFFECT_FIREWORK_DRAG); _yv = _scale15by8_local(_yv, EFFECT_FIREWORK_DRAG);
if (type == FIREWORK_DOT_SPARK) { if (type == FIREWORK_DOT_SPARK) {
_xv = _scale15by8_local(_xv, EFFECT_FIREWORK_DRAG); _xv = _scale15by8_local(_xv, EFFECT_FIREWORK_DRAG);
_yv = _scale15by8_local(_yv, EFFECT_FIREWORK_DRAG); _yv = _scale15by8_local(_yv, EFFECT_FIREWORK_DRAG);
_color.nscale8(255); _color.nscale8(255);
@ -68,9 +68,9 @@ void FireworkEffectDot::move() {
show = 0; show = 0;
} }
} }
// Bounce if we hit the ground // Bounce if we hit the ground
if (_xv < 0 && _y < (-_yv)) { if (_xv < 0 && _y - _window->height < (-_yv)) {
if (type == FIREWORK_DOT_SPARK) { if (type == FIREWORK_DOT_SPARK) {
show = 0; show = 0;
} else { } else {
@ -81,10 +81,10 @@ void FireworkEffectDot::move() {
} }
} }
} }
if (_yv < 300) { if (_yv < 300) {
if (type == FIREWORK_DOT_SHELL) { if (type == FIREWORK_DOT_SHELL) {
if (_y > (uint16_t)0x8000) { if (_y < (uint16_t)0x8000) {
// boom // boom
CRGB white(0xFFFFFF); CRGB white(0xFFFFFF);
_window->clear(&white); _window->clear(&white);
@ -93,7 +93,7 @@ void FireworkEffectDot::move() {
_main->skyburst(_x, _y, _xv, _yv, _color); _main->skyburst(_x, _y, _xv, _yv, _color);
} }
} }
if (type == FIREWORK_DOT_SPARK) { if (type == FIREWORK_DOT_SPARK) {
if ((_xv > 0 && _x>_xv) || (_xv < 0 && _x<(0xFFFF+_xv))) { if ((_xv > 0 && _x>_xv) || (_xv < 0 && _x<(0xFFFF+_xv))) {
_x += _xv; _x += _xv;
@ -103,7 +103,7 @@ void FireworkEffectDot::move() {
} else { } else {
_x += _xv; _x += _xv;
} }
_y += _yv; _y -= _yv;
} }
void FireworkEffectDot::ground_launch() { void FireworkEffectDot::ground_launch() {
@ -157,7 +157,7 @@ void FireworkEffect::loop() {
launch_countdown--; launch_countdown--;
} }
} }
if (_skyburst) { if (_skyburst) {
int nsparks = random8(EFFECT_FIREWORK_SPARKS / 2, EFFECT_FIREWORK_SPARKS + 1); int nsparks = random8(EFFECT_FIREWORK_SPARKS / 2, EFFECT_FIREWORK_SPARKS + 1);
for (int i=0; i<nsparks; i++) { for (int i=0; i<nsparks; i++) {