Rev 54 | Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 54 | Rev 55 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | 12 | ||
13 | #include "main.h" |
13 | #include "main.h" |
14 | #include "uart.h" |
14 | #include "uart.h" |
Line 15... | Line 15... | ||
15 | #include "twislave.h" |
15 | #include "twislave.h" |
16 | 16 | ||
17 | volatile unsigned int ppm_signal = 1500; |
17 | volatile unsigned int PPM_SIGNAL = 1500; |
18 | volatile unsigned char ppm_new = 0; |
18 | volatile unsigned char PPM_NEW = 0; |
19 | volatile unsigned char TMR1OvF = 0; |
19 | volatile unsigned char TMR1OvF = 0; |
20 | volatile unsigned int TMR1MS; |
20 | volatile unsigned int TMR1MS; |
21 | volatile unsigned char ch0; |
21 | volatile unsigned char CH0; |
22 | volatile unsigned char ch1; |
22 | volatile unsigned char CH1; |
23 | volatile unsigned char ch2; |
23 | volatile unsigned char CH2; |
24 | volatile unsigned char ch3; |
24 | volatile unsigned char CH3; |
25 | volatile unsigned char ch4; |
- | |
26 | volatile unsigned char ch5; |
- | |
27 | volatile unsigned char ch0_tmp; |
- | |
28 | volatile unsigned char ch1_tmp; |
- | |
29 | volatile unsigned char ch2_tmp; |
- | |
30 | volatile unsigned char ch3_tmp; |
- | |
Line 31... | Line 25... | ||
31 | volatile unsigned char ch4_tmp; |
25 | volatile unsigned char CH4; |
32 | volatile unsigned char ch5_tmp; |
- | |
33 | 26 | volatile unsigned char CH5; |
|
34 | 27 | ||
35 | unsigned int timer; |
28 | |
36 | 29 | /*##############################################################################*/ |
|
Line 57... | Line 50... | ||
57 | ppm = (ICR1 - pos_ICR + (int) TMR1OvF * 65536); |
50 | ppm = (ICR1 - pos_ICR + (int) TMR1OvF * 65536); |
58 | if ((ppm > 600) && (ppm < 2400)) |
51 | if ((ppm > 600) && (ppm < 2400)) |
59 | { |
52 | { |
60 | if (ppm > 2100) ppm = 2100; |
53 | if (ppm > 2100) ppm = 2100; |
61 | if (ppm < 900) ppm = 900; |
54 | if (ppm < 900) ppm = 900; |
62 | ppm = (ppm_signal * 3 + ppm) / 4; |
55 | ppm = (PPM_SIGNAL * 3 + ppm) / 4; |
63 | ppm_signal = ppm; |
56 | PPM_SIGNAL = ppm; |
64 | if (ppm_new < 50) ppm_new++; |
57 | if (PPM_NEW < 50) PPM_NEW++; |
65 | } |
58 | } |
Line 66... | Line 59... | ||
66 | 59 | ||
Line 67... | Line 60... | ||
67 | } |
60 | } |
Line 68... | Line -... | ||
68 | - | ||
69 | } |
- | |
70 | - | ||
71 | - | ||
- | 61 | ||
72 | 62 | } |
|
73 | 63 | ||
74 | 64 | /*##############################################################################*/ |
|
75 | SIGNAL(SIG_OVERFLOW0) |
65 | SIGNAL(SIG_OVERFLOW0) |
76 | { |
66 | { |
Line 77... | Line 67... | ||
77 | // this function is called every 32us, |
67 | // this function is called every 32us, |
78 | // it is very important that it's execution time is as short as possible |
68 | // it is very important that it's execution time is as short as possible |
- | 69 | // currently it's about 20us |
|
- | 70 | ||
- | 71 | static unsigned char counter = 254; |
|
- | 72 | static unsigned char ms1 = 0; |
|
- | 73 | static unsigned char ch0_tmp = 0; |
|
- | 74 | static unsigned char ch1_tmp = 0; |
|
79 | // currently it's about 20us |
75 | static unsigned char ch2_tmp = 0; |
80 | 76 | static unsigned char ch3_tmp = 0; |
|
Line 81... | Line 77... | ||
81 | static unsigned char counter = 254; |
77 | static unsigned char ch4_tmp = 0; |
82 | static unsigned char ms1 = 0; |
78 | static unsigned char ch5_tmp = 0; |
Line 83... | Line 79... | ||
83 | unsigned char PORTB_BAK; |
79 | unsigned char PORTB_BAK; |
84 | unsigned char PORTD_BAK; |
80 | unsigned char PORTD_BAK; |
85 | 81 | ||
86 | PORTB_BAK = PORTB; |
82 | PORTB_BAK = PORTB; |
87 | PORTD_BAK = PORTD; |
83 | PORTD_BAK = PORTD; |
88 | 84 | ||
89 | if (counter++ == 254) |
85 | if (counter++ == 254) |
90 | { |
86 | { |
91 | PORTB_BAK LEDON (CH0_B | CH1_B | CH2_B); |
87 | PORTB_BAK LEDON (CH0_B | CH1_B | CH2_B); //new cycle, output on |
92 | PORTD_BAK LEDON (CH3_D | CH4_D | CH5_D); |
88 | PORTD_BAK LEDON (CH3_D | CH4_D | CH5_D); // |
93 | ch0_tmp = ch0; |
89 | ch0_tmp = CH0; |
94 | ch1_tmp = ch1; |
90 | ch1_tmp = CH1; |
Line 95... | Line 91... | ||
95 | ch2_tmp = ch2; |
91 | ch2_tmp = CH2; |
96 | ch3_tmp = ch3; |
92 | ch3_tmp = CH3; |
97 | ch4_tmp = ch4; |
93 | ch4_tmp = CH4; |
98 | ch5_tmp = ch5; |
94 | ch5_tmp = CH5; |
99 | counter = 0; |
95 | counter = 0; |
100 | } |
96 | } |
Line 101... | Line 97... | ||
101 | 97 | ||
102 | if (ch0_tmp == counter) PORTB_BAK LEDOFF CH0_B; |
98 | if (ch0_tmp == counter) PORTB_BAK LEDOFF CH0_B; //channel value reached, output off |
103 | if (ch1_tmp == counter) PORTB_BAK LEDOFF CH1_B; |
- | |
Line 104... | Line 99... | ||
104 | if (ch2_tmp == counter) PORTB_BAK LEDOFF CH2_B; |
99 | if (ch1_tmp == counter) PORTB_BAK LEDOFF CH1_B; // |
105 | if (ch3_tmp == counter) PORTD_BAK LEDOFF CH3_D; |
100 | if (ch2_tmp == counter) PORTB_BAK LEDOFF CH2_B; // |
106 | if (ch4_tmp == counter) PORTD_BAK LEDOFF CH4_D; |
101 | if (ch3_tmp == counter) PORTD_BAK LEDOFF CH3_D; // |
107 | if (ch5_tmp == counter) PORTD_BAK LEDOFF CH5_D; |
102 | if (ch4_tmp == counter) PORTD_BAK LEDOFF CH4_D; // |
Line 120... | Line 115... | ||
120 | 115 | ||
Line 121... | Line -... | ||
121 | - | ||
- | 116 | ||
122 | } |
117 | } |
123 | 118 | ||
124 | 119 | ||
125 | 120 | /*##############################################################################*/ |
|
Line 126... | Line 121... | ||
126 | unsigned int SetDelay (unsigned int t) |
121 | unsigned int SetDelay (unsigned int t) |
127 | { |
122 | { |
128 | unsigned char temp_hi; |
123 | unsigned char hi_byte; |
129 | unsigned char temp_lo; |
- | |
130 | - | ||
Line -... | Line 124... | ||
- | 124 | unsigned char lo_byte; |
|
131 | temp_hi = (TMR1MS >> 8); |
125 | |
Line 132... | Line -... | ||
132 | temp_lo = (TMR1MS & 0xff); |
- | |
- | 126 | hi_byte = (TMR1MS >> 8); |
|
133 | if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8); |
127 | lo_byte = (TMR1MS & 0xff); |
134 | 128 | if (hi_byte != (TMR1MS >> 8)) hi_byte = (TMR1MS >> 8); |
|
135 | return(((temp_hi << 8) | temp_lo) + t + 1); |
129 | |
136 | 130 | return(((hi_byte << 8) | lo_byte) + t + 1); |
|
137 | } |
- | |
138 | - | ||
139 | - | ||
140 | - | ||
Line -... | Line 131... | ||
- | 131 | } |
|
- | 132 | ||
141 | char CheckDelay(unsigned int t) |
133 | |
Line -... | Line 134... | ||
- | 134 | /*##############################################################################*/ |
|
142 | { |
135 | char CheckDelay(unsigned int t) |
Line 143... | Line -... | ||
143 | unsigned char temp_hi; |
- | |
144 | unsigned char temp_lo; |
136 | { |
145 | 137 | unsigned char hi_byte; |
|
146 | temp_hi = (TMR1MS >> 8); |
138 | unsigned char lo_byte; |
147 | temp_lo = (TMR1MS & 0xff); |
139 | |
148 | if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8); |
140 | hi_byte = (TMR1MS >> 8); |
149 | 141 | lo_byte = (TMR1MS & 0xff); |
|
Line 150... | Line 142... | ||
150 | return(((t - ((temp_hi << 8) | temp_lo)) & 0x8000) >> 9); |
142 | if (hi_byte != (TMR1MS >> 8)) hi_byte = (TMR1MS >> 8); |
Line 151... | Line -... | ||
151 | - | ||
152 | } |
143 | |
153 | 144 | return(((t - ((hi_byte << 8) | lo_byte)) & 0x8000) >> 9); |
|
154 | 145 | } |
|
Line 155... | Line 146... | ||
155 | 146 | ||
156 | 147 | ||
157 | /*##############################################################################*/ |
148 | |
158 | void StartPWM(void) |
149 | /*##############################################################################*/ |
159 | { |
150 | void StartPWM(void) |
Line 179... | Line 170... | ||
179 | TIMSK |= (1<<TICIE1)|(1<<TOIE1); //ICP_INT_ENABLE and TIMER1_INT_ENABLE |
170 | TIMSK |= (1<<TICIE1)|(1<<TOIE1); //ICP_INT_ENABLE and TIMER1_INT_ENABLE |
Line 180... | Line 171... | ||
180 | 171 | ||
Line 181... | Line -... | ||
181 | } |
- | |
182 | 172 | } |
|
183 | 173 | ||
184 | 174 | ||
185 | /*##############################################################################*/ |
175 | /*##############################################################################*/ |
186 | unsigned int GetPPM(void) |
176 | unsigned int GetPPM(void) |
187 | { |
177 | { |
Line 188... | Line 178... | ||
188 | //this routines seems to be nesseccary, as reading a 16 bit value |
178 | //this routines seems to be nesseccary, as reading a 16 bit value |
189 | //on a 8 bit machine is not atomic, so if an interrupt apears between reading |
179 | //on a 8 bit machine is not atomic, so if an interrupt apears between reading |
Line 190... | Line 180... | ||
190 | //low and high byte of the 16 bit value a wrong result is possible |
180 | //low and high byte of the 16 bit value a wrong result is possible |
191 | 181 | ||
192 | unsigned char temp_hi; |
182 | unsigned char temp_hi; |
193 | unsigned char temp_lo; |
183 | unsigned char temp_lo; |
Line 194... | Line 184... | ||
194 | 184 | ||
Line 204... | Line 194... | ||
204 | // MAIN |
194 | // MAIN |
205 | /*##############################################################################*/ |
195 | /*##############################################################################*/ |
206 | int main (void) |
196 | int main (void) |
207 | { |
197 | { |
Line 208... | Line 198... | ||
208 | 198 | ||
209 | #define step 128 |
199 | #define STEP 256 |
- | 200 | #define MUL 1 |
|
Line 210... | Line 201... | ||
210 | #define mul 2 |
201 | #define REDUCE 5 |
211 | 202 | ||
212 | #define sigeepadr 0x00 |
203 | #define EEPADRSIG 0x00 |
213 | #define mineepadr 0x20 |
204 | #define EEPADRMIN 0x20 |
214 | #define maxeepadr 0x22 |
- | |
215 | #define eepsig 0x55aa |
- | |
Line 216... | Line 205... | ||
216 | 205 | #define EEPADRMAX 0x22 |
|
- | 206 | #define EEPSIGATURE 0x55aa |
|
217 | 207 | ||
218 | 208 | unsigned int ppm; |
|
- | 209 | signed int color; |
|
- | 210 | unsigned int setupdly; |
|
219 | unsigned int ppm; |
211 | unsigned int ppmtodly; |
220 | unsigned int setupdly; |
212 | unsigned int flashdly; |
221 | unsigned int ppmtodly; |
213 | unsigned char setup; |
222 | unsigned int lmax; |
214 | unsigned int lmax; |
223 | unsigned int lmin; |
215 | unsigned int lmin; |
224 | unsigned int max; |
216 | unsigned int max; |
- | 217 | unsigned int min; |
|
Line 225... | Line 218... | ||
225 | unsigned int min; |
218 | unsigned long temp1; |
226 | unsigned int sig; |
219 | unsigned long temp2; |
Line 234... | Line 227... | ||
234 | PORTC = 0x00; |
227 | PORTC = 0x00; |
Line 235... | Line 228... | ||
235 | 228 | ||
236 | DDRD = (ledgreen|CH3_D|CH4_D|CH5_D); |
229 | DDRD = (ledgreen|CH3_D|CH4_D|CH5_D); |
Line 237... | Line 230... | ||
237 | PORTD = 0x00; |
230 | PORTD = 0x00; |
238 | 231 | ||
239 | ch0 = 0; |
232 | CH0 = 0; |
240 | ch1 = 0; |
233 | CH1 = 0; |
241 | ch2 = 0; |
234 | CH2 = 0; |
242 | ch3 = 0; |
235 | CH3 = 0; |
Line 243... | Line 236... | ||
243 | ch4 = 0; |
236 | CH4 = 0; |
244 | ch5 = 0; |
237 | CH5 = 0; |
Line 245... | Line 238... | ||
245 | 238 | ||
Line 251... | Line 244... | ||
251 | //StartI2C(); |
244 | //StartI2C(); |
252 | StartPWM(); |
245 | StartPWM(); |
253 | sei(); |
246 | sei(); |
Line 254... | Line -... | ||
254 | - | ||
255 | - | ||
Line 256... | Line 247... | ||
256 | min = 1100; |
247 | |
257 | max = 1900; |
248 | |
- | 249 | ||
- | 250 | if (eeprom_read_word(EEPADRSIG) != EEPSIGATURE) //check eep if signature is there |
|
258 | 251 | { |
|
259 | if (eeprom_read_word(sigeepadr) != eepsig) |
252 | min = 1100; //default min |
260 | { |
253 | max = 1900; //default max |
261 | eeprom_write_word(mineepadr, min); |
254 | eeprom_write_word(EEPADRMIN, min); //no, write initial min |
262 | eeprom_write_word(maxeepadr, max); |
255 | eeprom_write_word(EEPADRMAX, max); //and max values |
263 | eeprom_write_word(sigeepadr, eepsig); |
256 | eeprom_write_word(EEPADRSIG, EEPSIGATURE); //along with eep signature |
264 | } |
257 | } |
265 | else |
258 | else |
266 | { |
259 | { |
Line 267... | Line 260... | ||
267 | min = eeprom_read_word(mineepadr); |
260 | min = eeprom_read_word(EEPADRMIN); //signature ok |
268 | max = eeprom_read_word(maxeepadr); |
- | |
269 | } |
- | |
270 | - | ||
271 | printf("ppm: %d / min: %d / max: %d\n",ppm,min,max); |
261 | max = eeprom_read_word(EEPADRMAX); //read min and max |
272 | 262 | } |
|
- | 263 | ||
Line 273... | Line 264... | ||
273 | 264 | setup = 0; //reset setup toggle counter |
|
274 | setup = 0; |
265 | setupdly = SetDelay(3000); |
Line 275... | Line 266... | ||
275 | setupdly = SetDelay(3000); |
266 | ppmtodly = SetDelay(5000); |
276 | ppmtodly = SetDelay(5000); |
267 | flashdly = SetDelay(100); |
277 | 268 | ||
278 | while (1) |
269 | while (1) |
279 | { |
270 | { |
280 | 271 | ||
281 | if (ppm_new > 20) |
272 | if (PPM_NEW > 20) //ppm Signal ok |
282 | { |
273 | { |
283 | PORTC clrbit ledred; |
274 | PORTC clrbit ledred; |
284 | ppm = GetPPM(); |
275 | ppm = GetPPM(); |
285 | ppmtodly = SetDelay(500); |
276 | ppmtodly = SetDelay(500); //reset timeout |
286 | if (lmax < ppm) lmax=ppm; |
277 | if (lmax < ppm) lmax=ppm; //update impulse max |
287 | if (lmin > ppm) lmin=ppm; |
278 | if (lmin > ppm) lmin=ppm; //and min boundarys |
Line -... | Line 279... | ||
- | 279 | } |
|
288 | } |
280 | else |
289 | else |
281 | { |
290 | { |
282 | PORTC setbit ledred; //ppm signal not ok |
291 | PORTC setbit ledred; |
283 | ppm = min; //set ppm to minimum |
292 | ppm = min; |
284 | } |
- | 285 | ||
Line 293... | Line -... | ||
293 | } |
- | |
294 | - | ||
295 | if (CheckDelay(ppmtodly)) |
286 | |
296 | { |
287 | if (CheckDelay(ppmtodly)) //timeout |
- | 288 | { |
|
- | 289 | ppmtodly = SetDelay(5000); |
|
- | 290 | PPM_NEW = 0; //set ppm signal not ok |
|
- | 291 | } |
|
- | 292 | ||
- | 293 | ||
- | 294 | if (setup < 6) |
|
- | 295 | { |
|
- | 296 | if ((ppm > 1600) && ((setup&1)==0)) setup++; // |
|
- | 297 | if ((ppm < 1400) && ((setup&1)==1)) setup++; // |
|
- | 298 | ||
- | 299 | if (CheckDelay(flashdly)) //setup timeout reached |
|
- | 300 | { |
|
- | 301 | CH0 = CH0 ^ 0xff; |
|
- | 302 | CH1 = CH1 ^ 0xff; |
|
297 | ppmtodly = SetDelay(5000); |
303 | CH2 = CH2 ^ 0xff; |
298 | ppm_new = 0; |
304 | flashdly = SetDelay(250); |
299 | } |
305 | } |
300 | 306 | ||
301 | if ((ppm > 1600) && ((setup&1)==0)) setup++; |
307 | } |
302 | if ((ppm < 1400) && ((setup&1)==1)) setup++; |
308 | |
- | 309 | if (setup == 6) //if stick is toggled 6 times |
|
- | 310 | { //within setup timeout |
|
- | 311 | PORTD setbit ledgreen; //store ppm min and max |
|
- | 312 | eeprom_write_word(EEPADRMIN, lmin); //in eeprom |
|
- | 313 | eeprom_write_word(EEPADRMAX, lmax); |
|
- | 314 | min = lmin; |
|
- | 315 | max = lmax; |
|
- | 316 | setupdly = SetDelay(2000); |
|
- | 317 | ||
303 | if (setup == 6) |
318 | if (CheckDelay(flashdly)) //setup timeout reached |
- | 319 | { |
|
304 | { |
320 | CH0 = CH0 ^ 0xff; |
305 | PORTD setbit ledgreen; |
321 | CH1 = CH1 ^ 0xff; |
306 | eeprom_write_word(mineepadr, lmin); |
322 | CH2 = CH2 ^ 0xff; |
307 | eeprom_write_word(maxeepadr, lmax); |
323 | flashdly = SetDelay(25); |
308 | min = lmin; |
324 | } |
Line 309... | Line 325... | ||
309 | max = lmax; |
325 | |
310 | setupdly = SetDelay(2000); |
- | |
Line 311... | Line 326... | ||
311 | } |
326 | } |
312 | if (CheckDelay(setupdly)) |
- | |
313 | { |
- | |
314 | setup = 0; |
- | |
315 | PORTD clrbit ledgreen; |
- | |
316 | } |
- | |
317 | - | ||
318 | //printf("ppm: %d / min: %d / max: %d\n",ppm,lmin,lmax); |
- | |
319 | - | ||
320 | - | ||
321 | /* |
- | |
322 | // Farbablauf: rot > Violett > blau > tuerkis > gruen > gelb > |
- | |
323 | if ((ppm >= (step * 0)) && (ppm < (step * 1))) |
- | |
324 | { |
- | |
325 | ch0 = mul * ((ppm - (step * 0))); //fade in red > red (red only) |
- | |
326 | ch1 = 0; |
- | |
327 | ch2 = 0; |
- | |
328 | } |
- | |
329 | if ((ppm >= (step * 1)) && (ppm < (step * 2))) |
- | |
330 | { |
- | |
331 | ch0 = ((step-1) * mul); |
- | |
332 | ch2 = mul * ((ppm - (step * 1))); //fade in blue > purple (red + blue) |
- | |
333 | ch1 = 0; |
- | |
334 | } |
- | |
335 | if ((ppm >= (step * 2)) && (ppm < (step * 3))) |
- | |
336 | { |
- | |
337 | ch0 = mul * ((step - 1) - (ppm - (step * 2))); //fade out red > blue (blue only) |
- | |
338 | ch2 = ((step-1) * mul); |
- | |
339 | ch1 = 0; |
- | |
340 | } |
- | |
341 | if ((ppm >= (step * 3)) && (ppm < (step * 4))) |
- | |
342 | { |
- | |
343 | ch0 = 0; |
- | |
344 | ch2 = ((step-1) * mul); |
- | |
345 | ch1 = mul * ((ppm - (step * 3))); //fade in green > tuerkis (blue + green) |
- | |
346 | } |
- | |
347 | if ((ppm >= (step * 4)) && (ppm < (step * 5))) |
- | |
348 | { |
- | |
349 | ch0 = 0; |
- | |
350 | ch2 = mul * ((step - 1) - (ppm - (step * 4))); //fade out blue > green (green only) |
- | |
351 | ch1 = ((step-1) * mul); |
- | |
352 | } |
- | |
353 | if ((ppm >= (step * 5)) && (ppm < (step * 6))) |
- | |
354 | { |
327 | |
355 | ch0 = mul * ((ppm - (step * 5))); //fade in red > yellow (green + red) |
328 | if (CheckDelay(setupdly)) //setup timeout reached |
356 | ch2 = 0; |
329 | { |
357 | ch1 = ((step-1) * mul); |
- | |
358 | } |
- | |
359 | if ((ppm >= (step * 6)) && (ppm < (step * 7))) |
- | |
360 | { |
- | |
361 | ch0 = ((step-1) * mul); |
- | |
362 | ch2 = 0; |
- | |
Line -... | Line 330... | ||
- | 330 | setup = 7; //lockdown setup |
|
- | 331 | PORTD clrbit ledgreen; |
|
- | 332 | } |
|
Line -... | Line 333... | ||
- | 333 | ||
- | 334 | //printf("ppm: %d / min: %d / max: %d\n",ppm,lmin,lmax); |
|
363 | ch1 = mul * ((step - 1) - (ppm - (step * 6))); //fade out green > red (red only) |
335 | |
- | 336 | ||
- | 337 | ||
- | 338 | if (setup = 7) |
|
- | 339 | { |
|
- | 340 | ||
- | 341 | temp1 = (STEP * (long)40000 * (long)6) / ((max-REDUCE) - (min+REDUCE)); |
|
- | 342 | temp2 = ((ppm - (min+REDUCE)) * temp1); |
|
- | 343 | color = temp2 / 40000; |
|
- | 344 | ||
- | 345 | if (color < 0) color = 0; |
|
- | 346 | if (color > (STEP * 6)) color = (STEP * 6); |
|
- | 347 | ||
- | 348 | // Farbablauf: rot > Violett > blau > tuerkis > gruen > gelb > |
|
- | 349 | if ((color >= (STEP * 0)) && (color < (STEP * 1))) |
|
- | 350 | { |
|
- | 351 | CH0 = MUL * ((color - (STEP * 0))); //fade in red > red (red only) |
|
- | 352 | CH1 = 0; |
|
- | 353 | CH2 = 0; |
|
- | 354 | } |
|
- | 355 | if ((color >= (STEP * 1)) && (color < (STEP * 2))) |
|
- | 356 | { |
|
- | 357 | CH0 = ((STEP-1) * MUL); |
|
- | 358 | CH1 = 0; |
|
- | 359 | CH2 = MUL * ((color - (STEP * 1))); //fade in blue > purple (red + blue) |
|
- | 360 | } |
|
- | 361 | if ((color >= (STEP * 2)) && (color < (STEP * 3))) |
|
- | 362 | { |
|
- | 363 | CH0 = MUL * ((STEP - 1) - (color - (STEP * 2))); //fade out red > blue (blue only) |
|
- | 364 | CH1 = 0; |
|
- | 365 | CH2 = ((STEP-1) * MUL); |
|
- | 366 | } |
|
- | 367 | if ((color >= (STEP * 3)) && (color < (STEP * 4))) |
|
- | 368 | { |
|
- | 369 | CH0 = 0; |
|
- | 370 | CH1 = MUL * ((color - (STEP * 3))); //fade in green > cyan (blue + green) |
|
- | 371 | CH2 = ((STEP-1) * MUL); |
|
- | 372 | } |
|
- | 373 | if ((color >= (STEP * 4)) && (color < (STEP * 5))) |
|
- | 374 | { |
|
- | 375 | CH0 = 0; |
|
- | 376 | CH1 = ((STEP-1) * MUL); |
|
- | 377 | CH2 = MUL * ((STEP - 1) - (color - (STEP * 4))); //fade out blue > green (green only) |
|
- | 378 | } |
|
- | 379 | if ((color >= (STEP * 5)) && (color < (STEP * 6))) |
|
Line 364... | Line 380... | ||
364 | } |
380 | { |
Line 365... | Line -... | ||
365 | if ((ppm >= (step * 7)) ) |
- | |
366 | { |
381 | CH0 = MUL * ((color - (STEP * 5))); //fade in red > yellow (green + red) |