Rev 22 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 22 | Rev 29 | ||
---|---|---|---|
Line 112... | Line 112... | ||
112 | TCNT0 -= 101; |
112 | TCNT0 -= 101; |
Line 113... | Line 113... | ||
113 | 113 | ||
114 | // disable PWM when bad compass heading value |
114 | // disable PWM when bad compass heading value |
115 | if(Heading < 0) |
115 | if(Heading < 0) |
116 | { |
116 | { |
117 | PORTB &= ~(PORTB2); |
117 | PORTB &= ~(1<<PORTB2); |
118 | cmps_cnt = 0; |
118 | cmps_cnt = 0; |
119 | } |
119 | } |
120 | else |
120 | else |
121 | { |
121 | { |
122 | // if a periode of 38.0 ms is over |
122 | // if a periode of 38.0 ms is over |
123 | if(++cmps_cnt >= 380) |
123 | if(++cmps_cnt >= 380) |
124 | { |
124 | { |
125 | // set PWM out to high |
125 | // set PWM out to high |
126 | PORTB |= PORTB2; |
126 | PORTB |= (1<<PORTB2); |
127 | // reset periode counter |
127 | // reset periode counter |
128 | cmps_cnt = 0; |
128 | cmps_cnt = 0; |
129 | } |
129 | } |
130 | // if the delay in 0.1 ms is equal to Heading + 10 |
130 | // if the delay in 0.1 ms is equal to Heading + 10 |
131 | else if(cmps_cnt >= (Heading + 10)) |
131 | else if(cmps_cnt >= (Heading + 10)) |
132 | { |
132 | { |
133 | // set PWM out to low |
133 | // set PWM out to low |
134 | PORTB &= ~(PORTB2); |
134 | PORTB &= ~(1<<PORTB2); |
135 | } |
135 | } |
Line 136... | Line 136... | ||
136 | } |
136 | } |
137 | 137 |