|
@@ -34,10 +34,12 @@ Digit Dot;
|
|
|
|
|
|
Timeout DotUpdateTimeout;
|
|
|
void DotUpdateCallback(void) {
|
|
|
+ int ticks = DOT_FADE_DURATION_US / REFRESH_RATE_US;
|
|
|
+ int step = ((DOT_MAX - DOT_MIN) + ticks - 1) / ticks;
|
|
|
if (Dot.CurrentState == Incrementing && Dot.Value < DOT_MAX) {
|
|
|
- Dot.Value = (Dot.Value + DOT_FADE_STEP >= DOT_MAX) ? DOT_MAX : Dot.Value + DOT_FADE_STEP;
|
|
|
+ Dot.Value = (Dot.Value + step >= DOT_MAX) ? DOT_MAX : Dot.Value + step;
|
|
|
} else if (Dot.CurrentState == Decrementing && Dot.Value > DOT_MIN) {
|
|
|
- Dot.Value = (Dot.Value - DOT_FADE_STEP <= DOT_MIN) ? DOT_MIN : Dot.Value - DOT_FADE_STEP;
|
|
|
+ Dot.Value = (Dot.Value - step <= DOT_MIN) ? DOT_MIN : Dot.Value - step;
|
|
|
}
|
|
|
Dot.Updated = true;
|
|
|
|
|
@@ -51,14 +53,14 @@ void DotUpdateCallback(void) {
|
|
|
#define TUBE_CALLBACK(x) \
|
|
|
void Tube##x##UpdateCallback(void) { \
|
|
|
int ticks = Tubes[x].FadeDuration / REFRESH_RATE_US; \
|
|
|
- int step = (DOT_MAX + ticks - 1) / ticks; \
|
|
|
+ int step = ((DIGIT_MAX - DIGIT_MIN) + ticks - 1) / ticks; \
|
|
|
bool activeTube = false; \
|
|
|
for (int i = 0; i < NUM_DIGITS; i++) { \
|
|
|
Digit *digit = &Tubes[x].Digits[i]; \
|
|
|
if (digit->CurrentState == Incrementing && digit->Value <= DIGIT_MAX) { \
|
|
|
digit->Value = (digit->Value + step >= DIGIT_MAX) ? DIGIT_MAX : digit->Value + step; \
|
|
|
digit->Updated = true; \
|
|
|
- } else if (digit->CurrentState == Decrementing && digit->Value >= DOT_MIN) { \
|
|
|
+ } else if (digit->CurrentState == Decrementing && digit->Value >= DIGIT_MIN) { \
|
|
|
digit->Value = (digit->Value - step <= DIGIT_MIN) ? DIGIT_MIN : digit->Value - step; \
|
|
|
digit->Updated = true; \
|
|
|
} \
|
|
@@ -166,7 +168,7 @@ int main() {
|
|
|
for (int i = 0; i < NUM_TUBES; i++) {
|
|
|
for (int j = 0; j < NUM_DIGITS; j++) {
|
|
|
Tubes[i].Digits[j].CurrentState = Decrementing;
|
|
|
- Tubes[i].Digits[j].Value = 0;
|
|
|
+ Tubes[i].Digits[j].Value = DIGIT_MIN;
|
|
|
Tubes[i].Digits[j].Updated = false;
|
|
|
}
|
|
|
Tubes[i].LastActiveDigit = -1;
|
|
@@ -176,7 +178,7 @@ int main() {
|
|
|
}
|
|
|
|
|
|
Dot.CurrentState = Decrementing;
|
|
|
- Dot.Value = 0;
|
|
|
+ Dot.Value = DOT_MIN;
|
|
|
Dot.Updated = false;
|
|
|
|
|
|
RtcTick = false;
|