Blame | Last modification | View Log | RSS feed
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace nitdcscore {public class Panel_AHFS : Panel {private mcp23017[] chips;public Panel_AHFS(mcp2221 mcp) : base(mcp) {chips = new mcp23017[2] { new mcp23017(mcp, 0x20), new mcp23017(mcp, 0x21) };this.Init();}public override int Init() {//AHCPthis.addControl(new Switch3Pos(new CommandDCS("AHCP_MASTER_ARM"), 8, 9)); // Train - Safe - Armthis.addControl(new Switch3Pos(new CommandDCS("AHCP_GUNPAC"), 10, 11)); // Gunarm - Safe - Armthis.addControl(new Switch3Pos(new CommandDCS("AHCP_LASER_ARM"), 12, 13)); // Train - Safe - Armthis.addControl(new Switch2Pos(new CommandDCS("AHCP_TGP"), 14)); // Off - Onthis.addControl(new Switch3Pos(new CommandDCS("AHCP_ALT_SCE"), 0, 1)); // Radar - Delta - Barothis.addControl(new Switch2Pos(new CommandDCS("AHCP_HUD_DAYNIGHT"), 2)); // Night - Daythis.addControl(new Switch2Pos(new CommandDCS("AHCP_HUD_MODE"), 15)); // Stby - Normthis.addControl(new Switch2Pos(new CommandDCS("AHCP_CICU"), 3)); // Off - Onthis.addControl(new Switch2Pos(new CommandDCS("AHCP_JTRS"), 4)); // Off - Onthis.addControl(new Switch3Pos(new CommandDCS("AHCP_IFFCC"), 6, 5)); // Off - Test - Onthis.addControl(new Switch2Pos(new CommandDCS("HARS_FAST_ERECT"), 7)); // Off - Onthis.addControl(new Potentiometer(new CommandDCS("ALCP_RCVR_LTS"), 0)); // 0x00 - 0xFFFF// Fuel Systemthis.addControl(new Switch2Pos(new CommandDCS("FSCP_AMPL"), 16));this.addControl(new Switch2Pos(new CommandDCS("FSCP_BOOST_MAIN_L"), 24));this.addControl(new Switch2Pos(new CommandDCS("FSCP_BOOST_MAIN_R"), 25));this.addControl(new Switch2Pos(new CommandDCS("FSCP_BOOST_WING_L"), 26));this.addControl(new Switch2Pos(new CommandDCS("FSCP_BOOST_WING_R"), 27));this.addControl(new Switch2Pos(new CommandDCS("FSCP_CROSSFEED"), 28));this.addControl(new Switch2Pos(new CommandDCS("FSCP_EXT_TANKS_FUS"), 30));this.addControl(new Switch2Pos(new CommandDCS("FSCP_EXT_TANKS_WING"), 31));this.addControl(new Switch2Pos(new CommandDCS("FSCP_FD_MAIN_L"), 20, true));this.addControl(new Switch2Pos(new CommandDCS("FSCP_FD_MAIN_R"), 21, true));this.addControl(new Switch2Pos(new CommandDCS("FSCP_FD_WING_L"), 18, true));this.addControl(new Switch2Pos(new CommandDCS("FSCP_FD_WING_R"), 19, true));this.addControl(new Switch2Pos(new CommandDCS("FSCP_LINE_CHECK"), 17));this.addControl(new Switch2Pos(new CommandDCS("FSCP_RCVR_LEVER"), 23));this.addControl(new Switch2Pos(new CommandDCS("FSCP_TK_GATE"), 29));mcp.WriteGpio(3, 0);Utils.delayms(10);// Enable the mcp23017mcp.WriteGpio(3, 1);// Set io dir, pullups and rev polaritychips[0].SetIODirection(0xff, 0xff);chips[0].SetIOPolarity(0xf0, 0xff);chips[0].SetIOPullups(0xff, 0xff);chips[1].SetIODirection(0xff, 0xff);chips[1].SetIOPolarity(0xff, 0xff);chips[1].SetIOPullups(0xff, 0xff);// Get the initial valuesthis.Refresh();data.prev = data.buttons;data.axis[0].prev = data.axis[0].value;data.changed = false;return 0;}public override int Refresh() {byte[] bytes;int rslt = 0;rslt = chips[0].GetIO(out bytes);data.buttons = (uint)bytes[0] << 24;data.buttons |= (uint)bytes[1] << 16;rslt = chips[1].GetIO(out bytes);data.buttons |= (uint)bytes[0] << 8;data.buttons |= (uint)bytes[1];data.axis[0].value = mcp.ReadADC(1);if ((data.buttons != data.prev) || (data.axis[0].prev != data.axis[0].value))data.changed = true;elsedata.changed = false;return 1;}public override int Input() {foreach (Control control in this.controls) {control.data = this.data;control.Tick();}data.prev = data.buttons;data.axis[0].prev = data.axis[0].value;data.changed = false;return 1;}}}