@@ -78,20 +78,17 @@ void andPixelAR(uint8_t angle, uint8_t dAngle, uint8_t startRadius, uint8_t endR
78
78
79
79
void antialiasPixelAR (uint8_t angle , uint8_t dAngle , uint8_t startRadius , uint8_t endRadius , CRGB color )
80
80
{
81
- uint16_t amax = qadd8 (angle , dAngle );
82
- uint8_t amin = qsub8 (angle , dAngle );
83
-
84
81
for (uint16_t i = 0 ; i < NUM_LEDS ; i ++ ) {
85
82
uint8_t o = i ;
86
83
87
84
uint8_t ao = angles [o ];
88
85
89
- uint8_t adiff = qsub8 ( max (ao , angle ), min ( ao , angle ));
90
- uint8_t fade = qmul8 (adiff , 32 );
86
+ uint8_t adiff = min ( sub8 (ao ,angle ), sub8 ( angle , ao ));
87
+ uint8_t fade = map (adiff , 0 , dAngle , 0 , 255 );
91
88
CRGB faded = color ;
92
89
faded .fadeToBlackBy (fade );
93
90
94
- if (ao <= amax && ao >= amin ) {
91
+ if (adiff <= dAngle ) {
95
92
uint8_t ro = physicalToFibonacci [o ];
96
93
97
94
if (ro <= endRadius && ro >= startRadius ) {
@@ -208,20 +205,22 @@ void drawAnalogClock() {
208
205
float minute = timeClient .getMinutes () + (second / 60.0 );
209
206
float hour = timeClient .getHours () + (minute / 60.0 );
210
207
211
- static uint8_t hourAngle = 0 ;
212
- static uint8_t minuteAngle = 0 ;
213
- static uint8_t secondAngle = 0 ;
214
-
215
208
const uint8_t hourRadius = 96 ;
216
209
const uint8_t minuteRadius = 192 ;
217
210
const uint8_t secondRadius = 255 ;
218
211
219
- const uint8_t handWidth = 32 ;
212
+ const uint8_t hourHandWidth = 8 ;
213
+ const uint8_t minuteHandWidth = 7 ;
214
+ const uint8_t secondHandWidth = 6 ;
220
215
221
216
const float degreesPerSecond = 255.0 / 60.0 ;
222
217
const float degreesPerMinute = 255.0 / 60.0 ;
223
218
const float degreesPerHour = 255.0 / 12.0 ;
224
219
220
+ static uint8_t hourAngle = 255 - hour * degreesPerHour ;
221
+ static uint8_t minuteAngle = 255 - minute * degreesPerMinute ;
222
+ static uint8_t secondAngle = 255 - second * degreesPerSecond ;
223
+
225
224
EVERY_N_MILLIS (100 ) {
226
225
hourAngle = 255 - hour * degreesPerHour ;
227
226
minuteAngle = 255 - minute * degreesPerMinute ;
@@ -230,9 +229,9 @@ void drawAnalogClock() {
230
229
231
230
fadeToBlackBy (leds , NUM_LEDS , clockBackgroundFade );
232
231
233
- antialiasPixelAR (secondAngle , handWidth , 0 , secondRadius , CRGB ::Blue );
234
- antialiasPixelAR (minuteAngle , handWidth , 0 , minuteRadius , CRGB ::Green );
235
- antialiasPixelAR (hourAngle , handWidth , 0 , hourRadius , CRGB ::Red );
232
+ antialiasPixelAR (secondAngle , secondHandWidth , 0 , secondRadius , CRGB ::Blue );
233
+ antialiasPixelAR (minuteAngle , minuteHandWidth , 0 , minuteRadius , CRGB ::Green );
234
+ antialiasPixelAR (hourAngle , hourHandWidth , 0 , hourRadius , CRGB ::Red );
236
235
leds [0 ] = CRGB ::Red ;
237
236
}
238
237
0 commit comments