Subversion Repositories group.electronics

Rev

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

Rev 169 Rev 170
Line 28... Line 28...
28
 
28
 
29
            ushort upperval = this.max;
29
            ushort upperval = this.max;
30
            if (this.prev <= upperval - this.thres)
30
            if (this.prev <= upperval - this.thres)
31
                upperval = (ushort)(this.prev + this.thres);
31
                upperval = (ushort)(this.prev + this.thres);
32
 
32
 
-
 
33
            //Console.WriteLine("JS " + ":" + this.prev + "," + this.value + "," + this.max + "," + lowerval + "," + upperval);
-
 
34
 
33
            if ((this.value < lowerval) || (this.value >= upperval)) {
35
            if ((this.value < lowerval) || (this.value > upperval)) {
34
                // Cover our min/max ranges within threshold
36
                // Cover our min/max ranges within threshold
35
                if (this.value < this.thres)
37
                if (this.value < this.thres)
36
                    this.value = 0;
38
                    this.value = 0;
37
                if (this.value > this.max - this.thres)
39
                if (this.value > this.max - this.thres)
38
                    this.value = this.max;
40
                    this.value = this.max;
39
 
41
 
-
 
42
                
40
                this.prev = this.value;
43
                this.prev = this.value;
41
 
44
 
42
                position = Globals.map_uint16(this.value, 0, this.max, 0, this.mapsize);
45
                position = Globals.map_uint16(this.value, 0, this.max, 0, this.mapsize);
43
                return true;
-
 
44
                //Globals.bios.SendData("ALCP_RCVR_LTS " + refuellight.ToString() + "\n");
-
 
45
                //Console.WriteLine("ALCP_RCVR_LTS " + ":" + refuellight.ToString() + "(" + devices[devid].cur_adc + ")");
-
 
46
            } else {
46
                
47
                return false;
47
                return true;               
48
            }
48
            }
-
 
49
            
-
 
50
            return false;
49
        }
51
        }
50
 
52
 
51
 
53
 
52
    }
54
    }
53
 
55
 
54
    public struct jsdata {
56
    public class jsdata {
55
        public bool changed;
57
        public bool changed { get; set; }
56
        public UInt64 buttons;
58
        public UInt64 buttons { get; set; }
57
        public UInt64 prev;
59
        public UInt64 prev { get; set; }
-
 
60
 
-
 
61
        public jsaxis[] axis = new jsaxis[6];
58
 
62
 
59
        public jsaxis[] axis;
63
        public jsdata() {
-
 
64
            changed = false;
-
 
65
            prev = buttons = 0;
-
 
66
 
-
 
67
            for (int i = 0; i < 6; i++) {
-
 
68
                axis[i] = new jsaxis();
-
 
69
                axis[i].thres = Globals.ADC_THRESHOLD;
-
 
70
                axis[i].max = Globals.ADC_DEFMAX;
-
 
71
                axis[i].prev = axis[i].value = 0;
-
 
72
                axis[i].mapsize = 0xffff;
-
 
73
            }            
-
 
74
        }
60
    }
75
    }
61
 
76
 
62
 
77
 
63
    public interface IPanel {
78
    public interface IPanel {
64
        int Init();
79
        int Init();
Line 89... Line 104...
89
            this.mcp = mcp;
104
            this.mcp = mcp;
90
            this.mcp.usbi2c.Settings.GetConnectionStatus();
105
            this.mcp.usbi2c.Settings.GetConnectionStatus();
91
            this.id = this.mcp.usbi2c.Management.GetSelectedDevNum();
106
            this.id = this.mcp.usbi2c.Management.GetSelectedDevNum();
92
            this.name = this.mcp.usbi2c.Settings.GetUsbStringDescriptor();
107
            this.name = this.mcp.usbi2c.Settings.GetUsbStringDescriptor();
93
 
108
 
94
            this.data.axis[0] = new jsaxis();
-
 
95
            this.data.axis[1] = new jsaxis();
-
 
96
 
-
 
97
 
-
 
98
            data.changed = false;
-
 
99
        }
109
        }
100
 
110
 
101
        public virtual int Init() {
111
        public virtual int Init() {
102
            
112
            
103
 
113
 
Line 116... Line 126...
116
 
126
 
117
        private mcp23017[] chips;
127
        private mcp23017[] chips;
118
 
128
 
119
        public Panel_AHFS(mcp2221 mcp) : base(mcp) {
129
        public Panel_AHFS(mcp2221 mcp) : base(mcp) {
120
            chips = new mcp23017[2] { new mcp23017(mcp, 0x20), new mcp23017(mcp, 0x21) };
130
            chips = new mcp23017[2] { new mcp23017(mcp, 0x20), new mcp23017(mcp, 0x21) };
121
 
-
 
122
            data.buttons = 0;
-
 
123
            data.prev = 0;
-
 
124
 
-
 
125
            data.axis[0].prev = data.axis[0].value = 0;
-
 
126
            data.axis[0].thres = 15;
-
 
127
            data.axis[0].max = 930;
-
 
128
            data.axis[0].mapsize = 0xffff;
-
 
129
 
-
 
130
            this.Init();
131
            this.Init();
131
        }
132
        }
132
 
133
 
133
        public override int Init() {
134
        public override int Init() {
134
            //AHCP
135
            //AHCP