-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Analog clock 2d branch0 15 #3943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
154da94
7e8a667
5d93543
8930a6e
3473794
2ee702e
fd16120
1b799f7
aab45af
9dcad8d
7960805
d5faa26
c9c0d7d
93d5ba4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4850,6 +4850,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 | ||||||||||
bandi13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| 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); | ||||||||||
bandi13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| if (radius > 8) SEGMENT.drawCircle(centerX, centerY, radius-1, DARKGREY, soft); // thicker circle | ||||||||||
|
Comment on lines
+4873
to
+4874
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify DARKGREY is defined The code uses Consider using a defined color constant or an explicit color value: - SEGMENT.drawCircle(centerX, centerY, radius, DARKGREY, soft);
- if (radius > 8) SEGMENT.drawCircle(centerX, centerY, radius-1, DARKGREY, soft); // thicker circle
+ SEGMENT.drawCircle(centerX, centerY, radius, RGBW32(64, 64, 64, 0), soft);
+ if (radius > 8) SEGMENT.drawCircle(centerX, centerY, radius-1, RGBW32(64, 64, 64, 0), soft); // thicker circle📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| 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); | ||||||||||
blazoncek marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| 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; | ||||||||||
bandi13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| } // mode_2DAnalogClock() | ||||||||||
| static const char _data_FX_MODE_2DANALOGCLOCK[] PROGMEM = "Analog Clock@,,,,,Seconds,Soft;Hour,Minute,Second;;2;o1=1,o2=1"; | ||||||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any way to make the default colors actually correct? On startup, Hour=white, Minute=black, Second=black for me.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately you can't but I guess you are not using every effect using default values. Or are you?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Effect metadata format is documented here: It looks like you can define default colors in metadata, too. Edit: you can only specify the names of the 3 colors that appear below the color wheel, sorry.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default values should be ones that work for most cases out of the box. When you buy a car/phone/computer/anything it should work out of the box without you having to edit parameters to make it functional. Note that I didn't say customized, just functional out of the gate. Maybe you could have a special case, that if the Hour=White and Minute=Second=Black that it would set the colors to Red, Green, Blue respectively?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you buy it, yes. If you get it for free, it is just a nice touch.
You can do that in effect initialisation code that starts as: if (SEGENV.call == 0) {
SEGMENT.colors[0] = <hour_color>;
...
}But I would only change those if they a black. The other option is to enhance metadata. That will be a lot more work IMO. |
||||||||||
|
|
||||||||||
|
|
||||||||||
| // 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 | ||||||||||
|
|
@@ -8080,6 +8133,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); | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.