Subversion Repositories group.electronics

Rev

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

Rev 164 Rev 165
Line 7... Line 7...
7
 
7
 
8
namespace nitdcscore {
8
namespace nitdcscore {
9
    public class NitMultiPanel : Panel {
9
    public class NitMultiPanel : Panel {
10
 
10
 
11
        Utils.InputPair input;
11
        Utils.InputPair input;
-
 
12
 
-
 
13
        Utils.InputPair js_x;
-
 
14
        Utils.InputPair js_y;
-
 
15
 
12
        private mcp23017 chip0;
16
        private mcp23017 chip0;
13
 
17
 
14
        public NitMultiPanel(mcp2221 mcp)
18
        public NitMultiPanel(mcp2221 mcp)
15
            : base(mcp) {
19
            : base(mcp) {
16
            input.curr = 0;
20
            input.curr = 0;
17
            input.prev = 0;
21
            input.prev = 0;
18
 
22
 
-
 
23
            js_x.curr = js_x.prev = 0;
-
 
24
            js_y.curr = js_y.prev = 0;
-
 
25
 
19
            this.chip0 = new mcp23017(mcp, 0x20);
26
            this.chip0 = new mcp23017(mcp, 0x20);
20
 
27
 
21
            this.Init();
28
            this.Init();
22
        }
29
        }
23
 
30
 
Line 90... Line 97...
90
            Dictionary<uint, Command> pad12 = new Dictionary<uint, Command>();
97
            Dictionary<uint, Command> pad12 = new Dictionary<uint, Command>();
91
            pad12.Add(0, new CommandDCS("UFC_CLR"));
98
            pad12.Add(0, new CommandDCS("UFC_CLR"));
92
            pad12.Add(1, new CommandVKey(VirtualKeyCode.F12));
99
            pad12.Add(1, new CommandVKey(VirtualKeyCode.F12));
93
            this.addControl(new Switch2Pos(new CommandIf(selSwitch, pad12), 12));
100
            this.addControl(new Switch2Pos(new CommandIf(selSwitch, pad12), 12));
94
 
101
 
-
 
102
            // Joystick Press - Mapped to mouse button 1
-
 
103
            this.addControl(new Switch2Pos(new CommandMouseButton(CommandMouseButton.MB_LEFT), 16));
-
 
104
 
95
 
105
 
96
            // Enable the mcp23017
106
            // Enable the mcp23017
97
            mcp.WriteGpio(3, 0);
107
            mcp.WriteGpio(3, 0);
98
            Utils.delayms(50);
108
            Utils.delayms(50);
99
            mcp.WriteGpio(3, 1);
109
            mcp.WriteGpio(3, 1);
Line 116... Line 126...
116
            uint gpio = (uint)(1 - mcp.ReadGpio(0));
126
            uint gpio = (uint)(1 - mcp.ReadGpio(0));
117
            input.curr = (uint)gpio << 16;
127
            input.curr = (uint)gpio << 16;
118
            input.curr |= (uint)data[0] << 8;
128
            input.curr |= (uint)data[0] << 8;
119
            input.curr |= (uint)data[1];
129
            input.curr |= (uint)data[1];
120
 
130
 
-
 
131
            js_y.curr = mcp.ReadADC(0);
-
 
132
            js_x.curr = mcp.ReadADC(1);
-
 
133
            
-
 
134
 
-
 
135
            //Console.WriteLine(js_x.curr.ToString() + ":" + js_y.curr.ToString());
-
 
136
 
121
            if (input.curr != input.prev)
137
            if (input.curr != input.prev)
122
                this.inputChanged = true;
138
                this.inputChanged = true;
123
            else
139
            else
124
                this.inputChanged = false;
140
                this.inputChanged = false;
125
 
141
 
126
            return rslt;
142
            return rslt;
127
        }
143
        }
128
 
144
 
129
        public override int Input() {
145
        public override int Input() {
130
            //Console.WriteLine(input.curr.ToString("X"));
146
            Console.WriteLine(input.curr.ToString("X"));
131
            foreach (Control control in this.controls) {
147
            foreach (Control control in this.controls) {
132
                control.data = this.input;
148
                control.data = this.input;
133
                control.Tick();
149
                control.Tick();
134
            }
150
            }
135
            this.inputChanged = false;
151
            this.inputChanged = false;