Subversion Repositories group.electronics

Rev

Rev 110 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 110 Rev 111
Line 106... Line 106...
106
	*/
106
	*/
107
	DDRB	= 0B00001111;
107
	DDRB	= 0B00001111;
108
	PORTB 	= 0B00111111;
108
	PORTB 	= 0B00111111;
109
	
109
	
110
	/*
110
	/*
111
		PB2	- Input, Pullup, PCINT16	- Rotary 2a
111
		PC2	- Input, Pullup, PCINT16	- Rotary 2a
112
		PB3	- Input, Pullup, PCINT16	- Rotary 2b
112
		PC3	- Input, Pullup, PCINT16	- Rotary 2b
113
	*/
113
	*/
114
	DDRC	= 0B00000000;
114
	DDRC	= 0B00000000;
115
	PORTC 	= 0B00000011;	
115
	PORTC 	= 0B00001100;	
116
 
116
 
117
	/*
117
	/*
118
		PD0	- Input, Pullup, PCINT16	- Rotary 1a
118
		PD0	- Input, Pullup, PCINT16	- Rotary 1a
119
		PD1	- Input, Pullup, PCINT17	- Rotary 1b
119
		PD1	- Input, Pullup, PCINT17	- Rotary 1b
120
 
120
 
Line 323... Line 323...
323
        
323
        
324
        pcInt[pcint].mask = pcInt[pcint].current ^ pcInt[pcint].last;
324
        pcInt[pcint].mask = pcInt[pcint].current ^ pcInt[pcint].last;
325
        pcInt[pcint].last = pcInt[pcint].current;
325
        pcInt[pcint].last = pcInt[pcint].current;
326
 
326
 
327
 
327
 
328
        //  Dont continue if we already have a button press going out
-
 
329
        //if (rotary.direction != 0 && rotary.timer == 0) {
-
 
330
        //        pcInt[pcint].mask = 0;
-
 
331
        //        return;
-
 
332
        //}
-
 
333
		
-
 
334
		// For Each rotary:
328
		// For Each rotary:
335
        // 		Check which pin caused the interrupt. If they both
329
        // 		Check which pin caused the interrupt. If they both
336
        //  		equal 0, the pin that interrupted is the direction
330
        //  		equal 0, the pin that interrupted is the direction
337
		
331
		
338
		// Rotary 0
332
		// Rotary 0
339
        if (rbi(pcInt[pcint].current, PCINT10) == 0 
333
        if (rbi(pcInt[pcint].current, PCINT10) == 0 
340
                && rbi(pcInt[pcint].current, PCINT11) == 0 
334
                && rbi(pcInt[pcint].current, PCINT11) == 0 
341
                && rbi(pcInt[pcint].mask, PCINT10) ) {
335
                && rbi(pcInt[pcint].mask, PCINT11) ) {
342
				
336
				
343
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
337
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
344
                        rotary[0].direction = 1;
338
                        rotary[0].direction = 1;
345
						rotary[0].timer = ROTARY_ON_TIME;
339
						rotary[0].timer = ROTARY_ON_TIME;
346
					}
340
					}
347
        } else if (rbi(pcInt[pcint].current, PCINT10) == 0 
341
        } else if (rbi(pcInt[pcint].current, PCINT10) == 0 
348
                && rbi(pcInt[pcint].current, PCINT11) == 0 
342
                && rbi(pcInt[pcint].current, PCINT11) == 0 
349
                && rbi(pcInt[pcint].mask, PCINT11) ) {
343
                && rbi(pcInt[pcint].mask, PCINT10) ) {
350
					
344
					
351
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
345
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
352
                        rotary[0].direction = 2;
346
                        rotary[0].direction = 2;
353
						rotary[0].timer = ROTARY_ON_TIME;
347
						rotary[0].timer = ROTARY_ON_TIME;
354
					}
348
					}
Line 357... Line 351...
357
		// Rotary 1
351
		// Rotary 1
358
        if (rbi(pcInt[pcint].current, PCINT16) == 0 
352
        if (rbi(pcInt[pcint].current, PCINT16) == 0 
359
                && rbi(pcInt[pcint].current, PCINT17) == 0 
353
                && rbi(pcInt[pcint].current, PCINT17) == 0 
360
                && rbi(pcInt[pcint].mask, PCINT16) ) {
354
                && rbi(pcInt[pcint].mask, PCINT16) ) {
361
				
355
				
362
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
356
					if (rotary[1].timer == 0 && rotary[1].direction == 0) {
363
                        rotary[0].direction = 1;
357
                        rotary[1].direction = 1;
364
						rotary[0].timer = ROTARY_ON_TIME;
358
						rotary[1].timer = ROTARY_ON_TIME;
365
					}
359
					}
366
        } else if (rbi(pcInt[pcint].current, PCINT16) == 0 
360
        } else if (rbi(pcInt[pcint].current, PCINT16) == 0 
367
                && rbi(pcInt[pcint].current, PCINT17) == 0 
361
                && rbi(pcInt[pcint].current, PCINT17) == 0 
368
                && rbi(pcInt[pcint].mask, PCINT17) ) {
362
                && rbi(pcInt[pcint].mask, PCINT17) ) {
369
					
363
					
370
					if (rotary[0].timer == 0 && rotary[0].direction == 0) {
364
					if (rotary[1].timer == 0 && rotary[1].direction == 0) {
371
                        rotary[0].direction = 2;
365
                        rotary[1].direction = 2;
372
						rotary[0].timer = ROTARY_ON_TIME;
366
						rotary[1].timer = ROTARY_ON_TIME;
373
					}
367
					}
374
        }
368
        }
375
 
369
 
376
        // Clear the mask so we know we've delth with it
370
        // Clear the mask so we know we've delth with it
377
        pcInt[pcint].mask = 0;
371
        pcInt[pcint].mask = 0;