diff --git a/wled00/FX.cpp b/wled00/FX.cpp index d4566976d9..ca18881a51 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -4861,6 +4861,59 @@ static const char _data_FX_MODE_FLOWSTRIPE[] PROGMEM = "Flow Stripe@Hue speed,Ef #define XY(x,y) SEGMENT.XY(x,y) +///////////////////////////// +// 2D Analog Clock // +///////////////////////////// +uint16_t mode_2DAnalogClock(void) { // By Andras Fekete (bandi13) + if (!strip.isMatrix || !SEGMENT.is2D()) return mode_static(); // not a 2D set-up + + const int cols = SEGMENT.virtualWidth(); + const int rows = SEGMENT.virtualHeight(); + const int centerX = (cols-!(cols%2)) >> 1; // use odd sized circle + const int centerY = (rows-!(rows%2)) >> 1; // use odd sized circle + const int radius = min(centerX, centerY); + const bool soft = radius > 6 && SEGMENT.check2; + + if (SEGENV.call == 0) { // set up defaults + if (SEGMENT.colors[0] == DEFAULT_COLOR) SEGMENT.colors[0] = RED; + if (SEGMENT.colors[1] == BLACK) SEGMENT.colors[1] = GREEN; + if (SEGMENT.colors[2] == BLACK) SEGMENT.colors[2] = BLUE; + } + + SEGMENT.fadeToBlackBy(240); + SEGMENT.drawCircle(centerX, centerY, radius, DARKGREY, soft); + if (radius > 8) SEGMENT.drawCircle(centerX, centerY, radius-1, DARKGREY, soft); // thicker circle + + time_t hours_in_day = (localTime / (60 * 60)) % 12; + time_t minutes_in_day = (localTime / (60)) % 60; + time_t seconds_in_day = (localTime) % 60; + + float hour_angle = radians(30.0f * (hours_in_day + minutes_in_day / 60.0f) - 90.0f); + int hour_len = radius / 2; + int hour_x = centerX + hour_len * cos_t(hour_angle); + int hour_y = centerY + hour_len * sin_t(hour_angle); + + float minute_angle = radians(6.0f * (minutes_in_day + seconds_in_day / 60.0f) - 90.0f); + int minute_len = (radius * 7) / 10; + int minute_x = centerX + minute_len * cos_t(minute_angle); + int minute_y = centerY + minute_len * sin_t(minute_angle); + + if (SEGMENT.check1) { + float second_angle = radians(6.0f * seconds_in_day - 90.0f); + int second_len = (radius * 9) / 10; + int second_x = centerX + second_len * cos_t(second_angle); + int second_y = centerY + second_len * sin_t(second_angle); + SEGMENT.drawLine(centerX, centerY, second_x, second_y, SEGCOLOR(2), soft); + } + + SEGMENT.drawLine(centerX, centerY, minute_x, minute_y, SEGCOLOR(1), soft); + SEGMENT.drawLine(centerX, centerY, hour_x, hour_y, SEGCOLOR(0), soft); + + return FRAMETIME; +} // mode_2DAnalogClock() +static const char _data_FX_MODE_2DANALOGCLOCK[] PROGMEM = "Analog Clock@,,,,,Seconds,Soft;Hour,Minute,Second;;2;o1=1,o2=1"; + + // Black hole uint16_t mode_2DBlackHole(void) { // By: Stepko https://editor.soulmatelights.com/gallery/1012 , Modified by: Andrew Tuline if (!strip.isMatrix || !SEGMENT.is2D()) return mode_static(); // not a 2D set-up @@ -8096,6 +8149,7 @@ void WS2812FX::setupEffectData() { addEffect(FX_MODE_2DGEQ, &mode_2DGEQ, _data_FX_MODE_2DGEQ); // audio + addEffect(FX_MODE_2DANALOGCLOCK, &mode_2DAnalogClock, _data_FX_MODE_2DANALOGCLOCK); addEffect(FX_MODE_2DNOISE, &mode_2Dnoise, _data_FX_MODE_2DNOISE); addEffect(FX_MODE_2DFIRENOISE, &mode_2Dfirenoise, _data_FX_MODE_2DFIRENOISE); diff --git a/wled00/FX.h b/wled00/FX.h index 6e458fceaf..2f95291a31 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -179,7 +179,7 @@ #define FX_MODE_TWO_DOTS 50 #define FX_MODE_FAIRYTWINKLE 51 //was Two Areas prior to 0.13.0-b6 (use "Two Dots" with full intensity) #define FX_MODE_RUNNING_DUAL 52 -// #define FX_MODE_HALLOWEEN 53 // removed in 0.14! +#define FX_MODE_2DANALOGCLOCK 53 // was HALLOWEEN, removed in 0.14! #define FX_MODE_TRICOLOR_CHASE 54 #define FX_MODE_TRICOLOR_WIPE 55 #define FX_MODE_TRICOLOR_FADE 56