Subversion Repositories group.electronics

Rev

Rev 107 | Rev 109 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 107 Rev 108
Line 23... Line 23...
23
#include "hiddesc.h"
23
#include "hiddesc.h"
24
 
24
 
25
#define BUTTONS	 		1
25
#define BUTTONS	 		1
26
 
26
 
27
#define LCD_UPDATE		11
27
#define LCD_UPDATE		11
-
 
28
 
28
#define ROTARY_TIME		50
29
#define ROTARY_ON_TIME		30
-
 
30
#define ROTARY_OFF_TIME		15
29
 
31
 
30
void pcInterrupt(uint8_t);
32
void pcInterrupt(uint8_t);
31
uint8_t getKey(void);
33
uint8_t getKey(void);
32
void updateLcd();
34
void updateLcd();
33
void checkRotarys();
35
void checkRotarys();
Line 197... Line 199...
197
	}
199
	}
198
	return key;
200
	return key;
199
}
201
}
200
 
202
 
201
void checkRotarys() {
203
void checkRotarys() {
202
	if (rotary.direction && rotary.timer == 0)
204
	if (rotary.direction && rotary.timer == 0) {
203
		rotary.direction = 0x00;
205
		rotary.direction = 0x00;
-
 
206
		rotary.timer = ROTARY_OFF_TIME;
-
 
207
	}
204
 
208
	
-
 
209
	if (rotary.timer == 0) {
205
	if (rotary.direction == 1) {
210
		if (rotary.direction == 1) {
206
		reportJoystick.rot1a = 1; 
211
			reportJoystick.rot1a = 1; 
207
	} else if (rotary.direction == 2) {
212
		} else if (rotary.direction == 2) {
208
		reportJoystick.rot1b = 1; 
213
			reportJoystick.rot1b = 1; 
-
 
214
		}
209
	}
215
	}
210
 
216
 
211
}
217
}
212
 
218
 
213
void checkButtons() {
219
void checkButtons() {
Line 284... Line 290...
284
 * Process the Pin Change Interrupt.
290
 * Process the Pin Change Interrupt.
285
 * pcint provides what bank caused the interrupt
291
 * pcint provides what bank caused the interrupt
286
 *
292
 *
287
 */
293
 */
288
void pcInterrupt(uint8_t pcint) {
294
void pcInterrupt(uint8_t pcint) {
289
		pcint = 1;
295
		
290
        /*switch (pcint) {
296
        switch (pcint) {
291
                case 0: pcInt[pcint].current = PINB; break;
297
                case 0: pcInt[pcint].current = PINB; break;
292
                case 1: pcInt[pcint].current = PIND; break;
298
                case 1: pcInt[pcint].current = PIND; break;
293
                case 2: pcInt[pcint].current = PINC; break;
299
                case 2: pcInt[pcint].current = PINC; break;
294
        }*/
300
        }
295
        pcInt[pcint].current = PIND;
301
        
296
        pcInt[pcint].mask = pcInt[pcint].current ^ pcInt[pcint].last;
302
        pcInt[pcint].mask = pcInt[pcint].current ^ pcInt[pcint].last;
297
        pcInt[pcint].last = pcInt[pcint].current;
303
        pcInt[pcint].last = pcInt[pcint].current;
298
 
304
 
299
 
305
 
300
        // If rot stat is not 0, we havn't sent
306
        // If rot stat is not 0, we havn't sent
Line 309... Line 315...
309
                && rbi(pcInt[pcint].current, PCINT17) == 0 
315
                && rbi(pcInt[pcint].current, PCINT17) == 0 
310
                && rbi(pcInt[pcint].mask, PCINT16) ) {
316
                && rbi(pcInt[pcint].mask, PCINT16) ) {
311
				
317
				
312
					if (rotary.timer == 0) {
318
					if (rotary.timer == 0) {
313
                        rotary.direction = 1;
319
                        rotary.direction = 1;
314
						rotary.timer = ROTARY_TIME;
320
						rotary.timer = ROTARY_ON_TIME;
315
					}
321
					}
316
 
322
 
317
        } else if (rbi(pcInt[pcint].current, PCINT16) == 0 
323
        } else if (rbi(pcInt[pcint].current, PCINT16) == 0 
318
                && rbi(pcInt[pcint].current, PCINT17) == 0 
324
                && rbi(pcInt[pcint].current, PCINT17) == 0 
319
                && rbi(pcInt[pcint].mask, PCINT17) ) {
325
                && rbi(pcInt[pcint].mask, PCINT17) ) {
320
					
326
					
321
					if (rotary.timer == 0) {
327
					if (rotary.timer == 0) {
322
                        rotary.direction = 2;
328
                        rotary.direction = 2;
323
						rotary.timer = ROTARY_TIME;
329
						rotary.timer = ROTARY_ON_TIME;
324
					}
330
					}
325
 
331
 
326
        }
332
        }
327
 
333
 
328
        // Clear the mask so we know we've delth with it
334
        // Clear the mask so we know we've delth with it