public Mcp23017TextDriver(MCP23017 mcp, DisplayPins displayPins) : base(displayPins) { //pull out individual pins to control IDigitalOutput enable = mcp.Output.Bind(displayPins.Enable); IDigitalOutput backlight = mcp.Output.Bind(displayPins.BackLight); }
public static void Main() { MCP23017 mcp23017 = new MCP23017(); mcp23017.init("I2C1", Windows.Devices.I2c.I2cBusSpeed.FastMode, 1, 23, 22); led = mcp23017.OpenPin("A", 7); led.SetDriveMode(MCP23017.MCP23017PinDriveMode.Output); MCP23017Pin led1 = mcp23017.OpenPin("A", 6); led1.SetDriveMode(MCP23017.MCP23017PinDriveMode.Output); led1.Write(GpioPinValue.High); MCP23017Pin led2 = mcp23017.OpenPin("B", 3); led2.SetDriveMode(MCP23017.MCP23017PinDriveMode.Output); led2.Write(GpioPinValue.Low); MCP23017Pin button = mcp23017.OpenPin("B", 0); button.SetDriveMode(MCP23017.MCP23017PinDriveMode.InputPullUp); button.ValueChanged += Button_ValueChanged; while (true) { Thread.Sleep(250); led1.Toggle(); led2.Toggle(); } }
public async void Run(IBackgroundTaskInstance taskInstance) { var defferal = taskInstance.GetDeferral(); var mcp = new MCP23017(); await mcp.Init(); mcp.SetDriveMode(Pin.GPA0, PinMode.Ouput); mcp.SetDriveMode(Pin.GPA1, PinMode.Ouput); mcp.SetDriveMode(Pin.GPA2, PinMode.Ouput); mcp.SetDriveMode(Pin.GPA3, PinMode.Ouput); mcp.SetDriveMode(Pin.GPA4, PinMode.Ouput); mcp.SetDriveMode(Pin.GPA5, PinMode.Ouput); mcp.Write(0, 0x33); mcp.Write(0, 0x32); mcp.Write(0x08, (byte)(LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF)); mcp.Write(0x20, (byte)(LCD_4BITMODE | LCD_1LINE | LCD_2LINE | LCD_5x8DOTS)); mcp.Write(0x04, (byte)(LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT)); mcp.Write(0, 0x01); await Task.Delay(3000); mcp.Write(0x65, 0x00); await Task.Delay(3000); //mcp.Dispose(); defferal.Complete(); }
private static IDriveTextDisplays GetMcp8Driver() { II2CBus bus = new SpotI2CBus(); MCP23017 mcp = new MCP23017(bus, 0x021); DisplayPins displayPins = new DisplayPins((Pin)21, (Pin)22, (Pin)23, (Pin)24, (Pin)25, (Pin)26, (Pin)27, (Pin)28, (Pin)1, (Pin)3, Pin.None, (Pin)2); return(new Mcp23017TextDriver(mcp, displayPins)); }
static void Main(string[] args) { var exp1 = new MCP23017("COM7", 0x20); exp1.RegWrite(0x00, 0xff); exp1.RegWrite(0x01, 0x00); while (true) { var a = exp1.RegRead(0x12); exp1.RegWrite(0x13, a[0]); } }
public Menu(MCP23017 mcp23017) { lcdBoard = new RGBLCDShield(mcp23017); }
public static void Main() { try { mcp23017 = new MCP23017(); //the MCP is what allows us to talk with the RGB LCD panel. I need it in this class so I can read the button presses from the User... mMenu = new Menu(mcp23017); //Configure this one first so that errors can be written to the LCD Shield mMenu.MenuSelection = MenuSelection.PrintLabel; //Setup the interrupt port for button presses from the LCD Shield. //Here I have the Interrupt pin from the LCD Shield (configured in the MCP23017 class) going to the Netduino Digital Pin 5 btnShield = new InterruptPort(Pins.GPIO_PIN_D5, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow); // Bind the interrupt handler to the pin's interrupt event. btnShield.OnInterrupt += new NativeEventHandler(btnShield_OnInterrupt); //Configure the MUX which allows me to expand my serial ports. Here I am using digital pins 9 thru 10 to send the necessary signals to switch my MUX channels OutputPort DigitalPin9 = new OutputPort(Pins.GPIO_PIN_D9, false); //Goes to S0 OutputPort DigitalPin10 = new OutputPort(Pins.GPIO_PIN_D10, false); //Goes to S1 OutputPort DigitalPin11 = new OutputPort(Pins.GPIO_PIN_D11, false); //Goes to S2 OutputPort DigitalPin12 = new OutputPort(Pins.GPIO_PIN_D12, false); //Goes to S3 Mux = new CD74HC4067(DigitalPin9, DigitalPin10, DigitalPin11, DigitalPin12); Mux.SetPort(MuxChannel.C0); //default it to C0 which is data coming in from the Indicators Serial Port Settings = new Settings(); Settings.Increments = new double[] { .001, .01, .1, 1, 10, 100 }; Settings.IncrementSelection = 3; Settings.RetrieveSettingsFromSDCard(WORKINGDIRECTORY, "LabelFormat.txt", "Job.txt", "Operation.txt", "ShopTrakTransactionsURL.txt", "PieceWeight.txt", "NetWeightAdjustment.txt", "BackgroundColor.txt"); mMenu.SetBackLightColor(Settings.BacklightColor); // initialize the serial port for data being input via COM1 mIndicatorScannerSerialPort = new MySerialPort(SerialPorts.COM1, BaudRate.Baudrate9600, Parity.None, DataBits.Eight, StopBits.One); // initialize the serial port for data being output via COM3 mPrinterSerialPort = new MySerialPort(SerialPorts.COM3, BaudRate.Baudrate9600, Parity.None, DataBits.Eight, StopBits.One); // open the serial-ports, so we can send & receive data mIndicatorScannerSerialPort.Open(); mPrinterSerialPort.Open(); // add an event-handler for handling incoming data mIndicatorScannerSerialPort.DataReceived += new SerialDataReceivedEventHandler(IndicatorScannerSerialPort_DataReceived); //Setup the Onboard button; InterruptEdgeLevelLow only fires the event the first time that the button descends btnBoard = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); // Create an event handler for the button btnBoard.OnInterrupt += new NativeEventHandler(btnBoard_OnInterrupt); // write your code here var webServer = new WebServer(); webServer.AddRequestFilter(new RequestFilter()); var fileAndDirectoryService = new FileAndDirectoryService(); fileAndDirectoryService.SetSDCardManager(new SDCardManager(WORKINGDIRECTORY)); webServer.SetFileAndDirectoryService(fileAndDirectoryService); /*Setting a default controller removes the ability to browse the files and folder of the root web directory*/ //webServer.RouteTable.DefaultControllerName = "Scale"; webServer.StartServer(80);//If port is not specified, then default is port 8500 webServer.SetHostName("Cart Scale"); //Display appropriate information to the user... mMenu.DisplayInformation(Settings); } catch (Exception objEx) { Debug.Print("Exception caught in Main()\r\n"); Debug.Print(objEx.Message); mMenu.DisplayError(objEx); } //We are done. The thread must sleep or else the netduino turns off... Thread.Sleep(Timeout.Infinite); }
public MCP23017Tests() { _bus = new MockI2CBus(); _mcp = new MCP23017(_bus); //Defaults to address 0x20 }
public Lcd(MCP23017 mCP23017) { this.mCP23017 = mCP23017; }