Rev 624 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 624 | Rev 683 | ||
---|---|---|---|
1 | #include "main.h" |
1 | #include "main.h" |
105 | 123 | } |
|
106 | } |
- | |
- | 124 | } |
|
- | 125 | ||
107 | 126 | ||
108 | // ----------------------------------------------------------------------- |
127 | |
109 | 128 | // ----------------------------------------------------------------------- |
|
110 | unsigned int SetDelay (unsigned int t) |
129 | uint16_t SetDelay (uint16_t t) |
111 | { |
130 | { |
112 | // TIMSK0 &= ~_BV(TOIE0); |
131 | // TIMSK0 &= ~(1<<TOIE0); |
113 | return(CountMilliseconds + t + 1); |
132 | return(CountMilliseconds + t + 1); |
114 | // TIMSK0 |= _BV(TOIE0); |
133 | // TIMSK0 |= (1<<TOIE0); |
115 | } |
134 | } |
116 | 135 | ||
117 | // ----------------------------------------------------------------------- |
136 | // ----------------------------------------------------------------------- |
118 | char CheckDelay(unsigned int t) |
137 | int8_t CheckDelay(uint16_t t) |
119 | { |
138 | { |
120 | // TIMSK0 &= ~_BV(TOIE0); |
139 | // TIMSK0 &= ~(1<<TOIE0); |
121 | return(((t - CountMilliseconds) & 0x8000) >> 9); |
140 | return(((t - CountMilliseconds) & 0x8000) >> 9); |
122 | // TIMSK0 |= _BV(TOIE0); |
141 | // TIMSK0 |= (1<<TOIE0); |
- | 142 | } |
|
- | 143 | ||
- | 144 | // ----------------------------------------------------------------------- |
|
- | 145 | void Delay_ms(uint16_t w) |
|
- | 146 | { |
|
- | 147 | unsigned int t_stop; |
|
- | 148 | t_stop = SetDelay(w); |
|
- | 149 | while (!CheckDelay(t_stop)); |
|
123 | } |
150 | } |
124 | 151 | ||
125 | // ----------------------------------------------------------------------- |
152 | // ----------------------------------------------------------------------- |
126 | void Delay_ms(unsigned int w) |
153 | void Delay_ms_Mess(uint16_t w) |
127 | { |
154 | { |
128 | unsigned int akt; |
155 | uint16_t t_stop; |
129 | akt = SetDelay(w); |
156 | t_stop = SetDelay(w); |
130 | while (!CheckDelay(akt)); |
- | |
131 | } |
- | |
132 | - | ||
133 | void Delay_ms_Mess(unsigned int w) |
- | |
134 | { |
- | |
135 | unsigned int akt; |
- | |
136 | akt = SetDelay(w); |
- | |
137 | while (!CheckDelay(akt)) ANALOG_ON; |
157 | while (!CheckDelay(t_stop)) ADC_Enable(); |
138 | } |
- | |
139 | - | ||
140 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
141 | // Servo ansteuern |
- | |
142 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
143 | SIGNAL(SIG_OUTPUT_COMPARE2A) |
- | |
144 | { |
- | |
145 | static unsigned char timer = 10; |
- | |
146 | - | ||
147 | if(!timer--) |
- | |
148 | { |
- | |
149 | TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3; |
- | |
150 | ServoValue = Parameter_ServoNickControl; |
- | |
151 | if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
- | |
152 | else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
- | |
153 | - | ||
154 | if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin; |
- | |
155 | else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax; |
- | |
156 | - | ||
157 | OCR2A = ServoValue;// + 75; |
- | |
158 | timer = EE_Parameter.ServoNickRefresh; |
- | |
159 | } |
- | |
160 | else |
- | |
161 | { |
- | |
162 | TCCR2A =3; |
- | |
163 | PORTD&=~0x80; |
- | |
164 | } |
- | |
165 | } |
158 | } |
- | 159 | ||
166 | 160 |