Merged Thomas' comments.

This commit is contained in:
2006-09-29 22:30:03 +00:00
parent e4b8aa91e7
commit 9a5b35168d
3 changed files with 35 additions and 16 deletions

View File

@ -2,7 +2,7 @@
* \file pwm_channels.c
* \brief Manages the values of the displayed channels.
* \author Thomas Stegemann
* \version $Id: pwm_channels.c,v 1.1 2006/09/26 18:18:27 rschaten Exp $
* \version $Id: pwm_channels.c,v 1.2 2006/09/29 22:30:03 rschaten Exp $
*
* License: See documentation.
*/
@ -41,9 +41,10 @@ void pwm_Channels_cleanup(void) {
* \return Current message.
*/
static pwm_Channels_Message pwm_Channels_Message_get(pwm_Channels_ChannelBrightness channels[CHANNELS]) {
int j;
pwm_Channels_StepCounter i= 0;
int j; /* index of the current channel */
pwm_Channels_StepCounter i= 0; /* index of the current step */
pwm_Channels_Message message;
/* first step: switch on all channels at cycle 0 */
message.step[i].field = 0;
for (j = 0; j < CHANNELS; j++) {
message.step[i].field |= channels[j].field;
@ -52,14 +53,22 @@ static pwm_Channels_Message pwm_Channels_Message_get(pwm_Channels_ChannelBrightn
for (j = 0; j < CHANNELS; j++) {
if(channels[j].cycle == message.step[i].cycle) {
/* if cycle for this channel is reached
switch off channel in current step */
message.step[i].field&= ~channels[j].field;
} else {
/* need another step for this channel:
set end of the current step
use copy of current step for next step
and switch off this channel
*/
message.step[i].cycle= channels[j].cycle;
i++;
message.step[i]= message.step[i-1];
message.step[i].field&= ~channels[j].field;
}
}
/* last step ends at pwm_Timer_Cycles_Max */
message.step[i].cycle= pwm_Timer_Cycles_Max;
return message;
}
@ -95,7 +104,7 @@ void pwm_Channels_show(pwm_Channels channels) {
pwm_Channels_Message message;
pwm_Channels_ChannelBrightness channel_brightness[CHANNELS];
for (i = 0; i < CHANNELS; i++) {
channel_brightness[i].field = 1 << i; // 1 << i equals 2^i
channel_brightness[i].field = 1 << i; // 1 << i equals 2^i: the channel i, uses the bit i
channel_brightness[i].cycle = pwm_Channels_BrightnessToCycles(channels.channel[i]);
}