| 133 | } |
| 134 | |
| 135 | static inline void _PulseWidthModulation(void) |
| 136 | { |
| 137 | static uint8_t s_pwmIndex = 0; // index of current PWM level |
| 138 | |
| 139 | if (s_pwmIndex == g_Settings.maxPwmValue) |
| 140 | { |
| 141 | s_pwmIndex = 0; |
| 142 | |
| 143 | _StartConstantTime(); |
| 144 | |
| 145 | // Switch OFF LEDs on time sets in g_Settings.brightness |
| 146 | LedDriver_OffLeds(); |
| 147 | |
| 148 | // Also eval current image |
| 149 | if (g_Settings.isSmoothEnabled) |
| 150 | { |
| 151 | EvalCurrentImage_SmoothlyAlg(); |
| 152 | } |
| 153 | |
| 154 | _EndConstantTime(g_Settings.brightness); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | if (g_Settings.isSmoothEnabled) |
| 159 | { |
| 160 | LedDriver_UpdatePWM(g_Images.current, s_pwmIndex); |
| 161 | } else { |
| 162 | LedDriver_UpdatePWM(g_Images.end, s_pwmIndex); |
| 163 | } |
| 164 | |
| 165 | s_pwmIndex++; |
| 166 | |
| 167 | // Clear timer counter |
| 168 | TCNT1 = 0x0000; |
| 169 | } |
| 170 | |
| 171 | void LedManager_UpdateColors(void) |
| 172 | { |
no test coverage detected