MCPcopy Create free account
hub / github.com/Atarity/Lightpack / _PulseWidthModulation

Function _PulseWidthModulation

Firmware/LedManager.c:135–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135static 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
171void LedManager_UpdateColors(void)
172{

Callers 1

LedManager_UpdateColorsFunction · 0.85

Calls 5

_StartConstantTimeFunction · 0.85
LedDriver_OffLedsFunction · 0.85
_EndConstantTimeFunction · 0.85
LedDriver_UpdatePWMFunction · 0.85

Tested by

no test coverage detected