Rev 177 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using WindowsInput.Native;namespace nitdcscore {public class Panel_AAP : Panel {private mcp23017 chip0;public Panel_AAP(mcp2221 mcp) : base(mcp) {chip0 = new mcp23017(mcp, 0x20);this.Init();}public override int Init() {this.addControl(new Switch2Pos(new CommandTrackIRKey(VirtualKeyCode.F9), 16));this.addControl(new Switch2Pos(new CommandTrackIRKey(VirtualKeyCode.F11), 17));this.addControl(new Switch2Pos(new CommandTrackIRKey(VirtualKeyCode.F7), 12));this.addControl(new Switch2Pos(new CommandVKey(VirtualKeyCode.SPACE), 13));this.addControl(new Switch2Pos(new CommandVKey(VirtualKeyCode.RETURN), 14));this.addControl(new Switch2Pos(new CommandVKey(VirtualKeyCode.VOLUME_MUTE), 15));this.addControl(new Switch2Pos(new CommandDCS("AAP_CDUPWR"), 11));this.addControl(new Switch2Pos(new CommandDCS("AAP_EGIPWR"), 10));this.addControl(new Switch3Pos(new CommandDCS("AAP_STEER"), 9, 8));this.addControl(new Selector(new CommandDCS("AAP_STEERPT"), new int[] { 4, 5, 6 }));this.addControl(new Selector(new CommandDCS("AAP_PAGE"), new int[] { 0, 1, 2, 3 }));// Enable the mcp23017mcp.WriteGpio(3, 0);Utils.delayms(10);mcp.WriteGpio(3, 1);// Set io dir, pullups and rev polaritychip0.SetIODirection(0xff, 0xff);chip0.SetIOPolarity(0xff, 0xff);chip0.SetIOPullups(0xff, 0xff);this.Refresh();data.prev = data.buttons;data.changed = false;return 1;}public override int Refresh() {byte[] bytes;int rslt = 0;rslt = chip0.GetIO(out bytes);// Join all our buttons into a single inputsuint gpio = (uint)((1 - mcp.ReadGpio(0)) | ((1 - mcp.ReadGpio(1)) << 1));data.buttons = (uint)gpio << 16;data.buttons |= (uint)bytes[0] << 8;data.buttons |= (uint)bytes[1];if (data.buttons != data.prev)data.changed = true;elsedata.changed = false;return rslt;}public override int Input() {//Console.WriteLine(input.curr.ToString("X"));foreach (Control control in this.controls) {control.data = this.data;control.Tick();}data.prev = data.buttons;data.changed = false;return 1;}}}