Subversion Repositories group.electronics

Rev

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

Rev 24 Rev 26
Line 23... Line 23...
23
 
23
 
24
volatile uint8_t rot_stat = 0;
24
volatile uint8_t rot_stat = 0;
25
volatile uint8_t rot_sent = 0;
25
volatile uint8_t rot_sent = 0;
26
 
26
 
27
struct{
27
struct{
28
  int data1;	// X axis
-
 
29
  int data2;	// Y axis
-
 
30
  union {
28
  union {
31
    uint8_t data3;	// Rotaries
29
    uint8_t data[5];	// Rotaries
32
    struct {
30
    struct {
33
	uint8_t rot1a:1;
31
	uint8_t rx:8;
34
	uint8_t rot1b:1;
32
	uint8_t ry:8;
35
	uint8_t rot2a:1;
33
	uint8_t b00:1;
36
	uint8_t rot2b:1;
34
	uint8_t b01:1;
37
    };
-
 
38
  };
-
 
39
  union {
-
 
40
    uint16_t data4;	// 16 buttons
-
 
41
    struct {
-
 
42
      uint8_t b00:1;
-
 
43
      uint8_t b01:1;
-
 
44
      uint8_t b02:1;
35
	uint8_t b02:1;
45
      uint8_t b03:1;
36
	uint8_t b03:1;
46
      uint8_t b04:1;
37
	uint8_t b04:1;
47
      uint8_t b05:1;
38
	uint8_t b05:1;
48
      uint8_t b06:1;
39
	uint8_t b06:1;
49
      uint8_t b07:1;
40
	uint8_t b07:1;
50
      uint8_t b08:1;
41
	uint8_t b08:1;
51
      uint8_t b09:1;
42
	uint8_t b09:1;
52
      uint8_t b10:1;
43
	uint8_t b10:1;
53
      uint8_t b11:1;
44
	uint8_t b11:1;
54
      uint8_t b12:1;
45
	uint8_t b12:1;
55
      uint8_t b13:1;
46
	uint8_t b13:1;
56
      uint8_t b14:1;
47
	uint8_t b14:1;
57
      uint8_t b15:1;
48
	uint8_t b15:1;
58
    };
49
    };
59
  };
50
  };
60
} report;
51
} report;
61
 
52
 
62
usbMsgLen_t usbFunctionSetup(uchar data[8]) {
53
usbMsgLen_t usbFunctionSetup(uchar data[8]) {
Line 130... Line 121...
130
  for(;;) {
121
  for(;;) {
131
    wdt_reset();
122
    wdt_reset();
132
    usbPoll();
123
    usbPoll();
133
 
124
 
134
    if(usbInterruptIsReady()){
125
    if(usbInterruptIsReady()){
135
        report.data1 = 0; // Center X
-
 
136
        report.data2 = 0; // Center Y
-
 
137
 
-
 
138
 
126
 
139
	report.data4 |= (1 << getKey());
127
	report.data[2] |= (1 << getKey());
140
 
128
 
141
	// Now work out what rotary to send, if any
129
	// Now work out what rotary to send, if any
142
	// Also record if we sent a positive response, 
130
	// Also record if we sent a positive response, 
143
	//  so we can send a '0' next time (if selected on PD4)
131
	//  so we can send a '0' next time (if selected on PD4)
-
 
132
	/*
144
	if (rot_stat == 0x01 && rot_sent == 0) {
133
	if (rot_stat == 0x01 && rot_sent == 0) {
145
		report.rot1a = 1;
134
		report.rot1a = 1;
146
		rot_sent = 1;
135
		rot_sent = 1;
147
	} else if (rot_stat == 0x02 && rot_sent == 0) {
136
	} else if (rot_stat == 0x02 && rot_sent == 0) {
148
		report.rot1b = 1;
137
		report.rot1b = 1;
149
		rot_sent = 1;
138
		rot_sent = 1;
150
	} else {
139
	} else {
151
		rot_sent = 0;
140
		rot_sent = 0;
152
	}
141
	}*/
153
 
142
 
154
	// Reset our stat so ready for next turn
143
	// Reset our stat so ready for next turn
155
	rot_stat = 0;
144
	rot_stat = 0;
156
 
145
 
157
	// If our function select is set, dont bother
146
	// If our function select is set, dont bother