瀏覽代碼

Enabled variable fade duration

Kevin Lee 6 年之前
父節點
當前提交
89e7a0a2c9
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      Nixie_Firmware_Mbed/main.cpp

+ 5 - 3
Nixie_Firmware_Mbed/main.cpp

@@ -126,6 +126,8 @@ void RngTickerCallback(void) {
 Timeout RngUpdateTimeout;
 int RngUpdateIteration;
 void RngUpdateCallback(void) {
+    int newfadeDuration = DIGIT_RNG_FADE_DURATION_US + RngUpdateIteration * DIGIT_RNG_FADE_DURATION_US;
+    if (newfadeDuration >= DIGIT_FADE_DURATION_US) newfadeDuration = DIGIT_FADE_DURATION_US;
     for (int i = 0; i < NUM_TUBES; i++) {
         if (Tubes[i].Refresh) {
             if (RngUpdateIteration) {
@@ -135,15 +137,15 @@ void RngUpdateCallback(void) {
                 } while (nextDigit == Tubes[i].LastActiveDigit || 
                     (RngUpdateIteration == 1 && nextDigit == Tubes[i].RefreshLastDigit));
 
-                FadeInOutDigit(i, nextDigit, DIGIT_RNG_FADE_DURATION_US);
+                FadeInOutDigit(i, nextDigit, newfadeDuration);
             } else {
-                FadeInOutDigit(i, Tubes[i].RefreshLastDigit, DIGIT_RNG_FADE_DURATION_US);
+                FadeInOutDigit(i, Tubes[i].RefreshLastDigit, newfadeDuration);
                 Tubes[i].Refresh = false;
             }
         }
     }
     if (RngUpdateIteration-- != 0) {
-        RngUpdateTimeout.attach_us(RngUpdateCallback, DIGIT_RNG_FADE_DURATION_US);
+        RngUpdateTimeout.attach_us(RngUpdateCallback, newfadeDuration);
     }
 }