Subversion Repositories group.electronics

Rev

Rev 161 | 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;

namespace nitdcscore {
    public interface IPanel {
        int Init();
        int Refresh();
        int Input();
    }

    public abstract class Panel : IPanel {
        protected mcp2221 mcp;
        public int id { get; set; }
        public String name { get; set; }
        public String serialno { get; set; }

        private Boolean enabled;
        public Boolean Enabled {
            get {
                return enabled;
            }
            set {
                this.enabled = true;
            }
        }

        public Panel(ref mcp2221 mcp) {
            this.mcp = mcp;
            this.mcp.usbi2c.Management.GetSelectedDevInfo();
            this.id = this.mcp.usbi2c.Management.GetSelectedDevNum();
            this.name = this.mcp.usbi2c.Settings.GetUsbStringDescriptor();
        }

        public virtual int Init() {
            

            return 1;
        }
        public abstract int Refresh();
        public abstract int Input();
    }

    public struct panel_input {
        public uint prev;
        public uint curr;
    }

    public class Panel_AAP : Panel {

        panel_input input;

        public Panel_AAP(ref mcp2221 mcp) : base(ref mcp) {
            input.curr = 0;
            input.prev = 0;

        }

        public override int Init() {
            // Enable the mcp23017
            mcp.WriteGpio(3, 0);
            Utils.delayms(500);
            mcp.WriteGpio(3, 1);
            //this.delayms();

            // Set io dir, pullups and rev polarity
            byte[] data;
            data = new byte[] { 0x00, 0xff, 0xff, 0xff, 0xff }; // All inputs & polarity
            mcp.WriteI2cData(0x40, data, 5);
            data = new byte[] { 0x0c, 0xff, 0xff }; // All pullups = on
            mcp.WriteI2cData(0x40, data, 3);

            //refresh_aap(devid);

            return 1;
        }
        public override int Refresh() {

            return 1;
        }

        public override int Input() {

            return 1;
        }
    }
}