Subversion Repositories group.electronics

Rev

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

Rev 187 Rev 189
Line 171... Line 171...
171
            data.buttons |= (UInt64)bytes[1];
171
            data.buttons |= (UInt64)bytes[1];
172
 
172
 
173
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
173
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
174
            data.axis[1].value = mcp.ReadADC(1); // X Axis
174
            data.axis[1].value = mcp.ReadADC(1); // X Axis
175
 
175
 
176
 
-
 
177
            if (data.buttons != data.prev
176
            if (data.buttons != data.prev
178
                || (data.axis[0].prev != data.axis[0].value)
177
                || (data.axis[0].prev != data.axis[0].value)
179
                || (data.axis[1].prev != data.axis[1].value))
178
                || (data.axis[1].prev != data.axis[1].value)) {
-
 
179
                    foreach (Control control in this.controls) {
-
 
180
                        control.data = this.data;
180
                data.changed = true;
181
                        control.Tick();
181
            else
182
                    }
182
                data.changed = false;
183
                    data.prev = data.buttons;
-
 
184
            }
183
 
185
            
184
            byte tmpShadow = this.ledShadow;
186
            byte tmpShadow = this.ledShadow;
185
            foreach (Led led in this.leds) {
187
            foreach (Led led in this.leds) {
186
                led.Tick(ref ledShadow);
188
                led.Tick(ref ledShadow);
187
            }
189
            }
188
 
190
 
189
            // Only update if leds have changed
191
            // Only update if leds have changed
190
            if (tmpShadow != this.ledShadow)
192
            if (tmpShadow != this.ledShadow)
191
                chips[1].SetBank(0, ledShadow);
193
                chips[1].SetBank(0, ledShadow);
192
 
194
 
193
 
-
 
194
            return rslt;
195
            return rslt;
195
        }
196
        }
196
 
197
 
197
        public override int Input() {
198
        public override int Input() {
198
            //Console.WriteLine(data.buttons.ToString("X"));
-
 
199
            foreach (Control control in this.controls) {
-
 
200
                control.data = this.data;
-
 
201
                control.Tick();
-
 
202
            }
-
 
203
            
-
 
204
            data.axis[0].prev = data.axis[0].value;
-
 
205
            data.axis[1].prev = data.axis[1].value;
-
 
206
            data.prev = data.buttons;
-
 
207
            data.changed = false;
199
            data.changed = false;
208
            return 1;
200
            return 1;
209
        }
201
        }
210
    }
202
    }
211
}
203
}