Subversion Repositories group.electronics

Rev

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

Rev 147 Rev 149
Line 16... Line 16...
16
            CMD_SET_DISPLAY0 = 21
16
            CMD_SET_DISPLAY0 = 21
17
        };
17
        };
18
 
18
 
19
        private byte[,] display { get; set; }
19
        private byte[,] display { get; set; }
20
        private byte[] buttons {get; set; }
20
        private byte[] buttons {get; set; }
21
        private byte[,] rotary;
21
        private sbyte[,] rotary;
22
 
22
 
23
        public NITNavCommDevice(NITDevice nitDevice) :
23
        public NITNavCommDevice(NITDevice nitDevice) :
24
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
24
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
25
            init();
25
            init();
26
        }
26
        }
Line 37... Line 37...
37
                for (byte i = 0; i < 10; i++)
37
                for (byte i = 0; i < 10; i++)
38
                    this.display[j, i] = 0x0a;
38
                    this.display[j, i] = 0x0a;
39
            this.buttons = new byte[2];
39
            this.buttons = new byte[2];
40
            this.buttons[0] = 0x00;
40
            this.buttons[0] = 0x00;
41
            this.buttons[1] = 0x00;
41
            this.buttons[1] = 0x00;
42
            this.rotary = new byte[2, 2];
42
            this.rotary = new sbyte[2, 2];
43
            this.rotary[0, 0] = 0x00;
43
            this.rotary[0, 0] = 0x00;
44
            this.rotary[0, 1] = 0x00;
44
            this.rotary[0, 1] = 0x00;
45
            this.rotary[1, 0] = 0x00;
45
            this.rotary[1, 0] = 0x00;
46
            this.rotary[1, 1] = 0x00;
46
            this.rotary[1, 1] = 0x00;
47
        }
47
        }
Line 110... Line 110...
110
        private void sendLatch(byte dis) {
110
        private void sendLatch(byte dis) {
111
            base.SendCommand(20, (short)dis, 0);
111
            base.SendCommand(20, (short)dis, 0);
112
        }
112
        }
113
 
113
 
114
        public void updateInput() {
114
        public void updateInput() {
115
            this.updateInput(0);
115
            //this.updateInput(0);
116
            this.updateInput(1);
116
            //this.updateInput(1);
117
        }
-
 
118
 
-
 
119
        public void updateInput(byte dis) {
-
 
120
            byte[] data = new byte[8];
117
            byte[] data = new byte[8];
121
            int transferred;
118
            int transferred;
122
            base.SendCommand(30, (short)dis, 0, data, out transferred);
119
            base.SendCommand(30, 0, 0, data, out transferred);
123
            this.buttons[dis] = data[0];
120
            this.buttons[0] = data[0];
124
            this.rotary[dis,0] = data[1];
121
            this.rotary[0, 0] += (sbyte)data[1];
125
            this.rotary[dis,1] = data[2];
122
            this.buttons[1] = data[2];
-
 
123
            this.rotary[1, 0] += (sbyte)data[3];
126
        }
124
        }
127
 
125
 
128
        public bool isSwapSet(byte dis) {
126
        public bool isSwapSet(byte dis) {
129
            if ((this.buttons[dis] & 0x01)>0)
127
            if ((this.buttons[dis] & 0x01)>0)
130
                return true;
128
                return true;
Line 135... Line 133...
135
            if ((this.buttons[dis] & 0x02) > 0)
133
            if ((this.buttons[dis] & 0x02) > 0)
136
                return true;
134
                return true;
137
            return false;
135
            return false;
138
        }
136
        }
139
 
137
 
140
        public byte getRotary(byte dis, byte rotary) {
138
        public sbyte getRotary(byte dis, byte rotary) {
141
            return this.rotary[dis, rotary];
139
            return this.rotary[dis, rotary];
142
        }
140
        }
143
 
141
 
-
 
142
        public void resetRotary(byte display, byte rotary) {
-
 
143
            this.rotary[display, rotary] = 0x00;
-
 
144
        }
-
 
145
 
144
        public void updateDisplay() {
146
        public void updateDisplay() {
145
            this.updateDisplay(0);
147
            this.updateDisplay(0);
146
            this.updateDisplay(1);
148
            this.updateDisplay(1);
147
        }
149
        }
148
 
150