Subversion Repositories group.electronics

Rev

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

Rev 187 Rev 189
Line 27... Line 27...
27
 
27
 
28
            ushort upperval = this.max;
28
            ushort upperval = this.max;
29
            if (this.prev <= upperval - this.thres)
29
            if (this.prev <= upperval - this.thres)
30
                upperval = (ushort)(this.prev + this.thres);
30
                upperval = (ushort)(this.prev + this.thres);
31
 
31
 
32
            //Console.WriteLine("JS " + ":" + this.prev + "," + this.value + "," + this.max + "," + lowerval + "," + upperval);
-
 
33
 
-
 
34
            if ((this.value < lowerval) || (this.value > upperval)) {
32
            if ((this.value < lowerval) || (this.value > upperval)) {
35
                // Cover our min/max ranges within threshold
33
                // Cover our min/max ranges within threshold
36
                if (this.value < this.thres)
34
                if (this.value < this.thres)
37
                    this.value = 0;
35
                    this.value = 0;
38
                if (this.value > this.max - this.thres)
36
                if (this.value > this.max - this.thres)
39
                    this.value = this.max;
37
                    this.value = this.max;
40
 
38
 
41
 
-
 
-
 
39
                // Only update the prev value once we've moved out of the
-
 
40
                //  threshold and triggered an update
42
                this.prev = this.value;
41
                this.prev = this.value;
43
 
42
 
44
                position = Globals.map_uint16(this.value, 0, this.max, 0, this.mapsize);
43
                position = Globals.map_uint16(this.value, 0, this.max, 0, this.mapsize);
45
 
44
 
46
                return true;
45
                return true;
Line 240... Line 239...
240
        }
239
        }
241
 
240
 
242
        public override void Tick() {
241
        public override void Tick() {
243
            UInt16 tmpval = 0;
242
            UInt16 tmpval = 0;
244
            bool changed = data.axis[channel].getPosition(ref tmpval);
243
            bool changed = data.axis[channel].getPosition(ref tmpval);
245
            
-
 
246
 
244
 
247
            
-
 
248
            if (changed) {
245
            if (changed) {
249
                this.value = tmpval;
246
                this.value = tmpval;
250
                foreach (Command cmd in this.commands) {
247
                foreach (Command cmd in this.commands) {
251
                    cmd.data = this.data;
248
                    cmd.data = this.data;
252
                    if (cmd.Send(this.value) == 0)
249
                    if (cmd.Send(this.value) == 0)