public RGBLCDShield(MCP23017 mcp23017, byte cols = 16, byte rows = 2, byte dotsize = 0) { this.mcp23017 = mcp23017; this.displayFunction = 0x0; // initialize the MCP23017 for this board mcp23017.PinMode(8, MCP23017.Direction.Output); mcp23017.PinMode(6, MCP23017.Direction.Output); mcp23017.PinMode(7, MCP23017.Direction.Output); //SetBacklight(BacklightColor.White); mcp23017.PinMode(rsPin, MCP23017.Direction.Output); mcp23017.PinMode(rwPin, MCP23017.Direction.Output); mcp23017.PinMode(enablePin, MCP23017.Direction.Output); for (int i = 0; i < dataPins.Length; i++) { mcp23017.PinMode(dataPins[i], MCP23017.Direction.Output); } for (int i = 0; i < buttonPins.Length; i++) { mcp23017.PinMode(buttonPins[i], MCP23017.Direction.Input); mcp23017.PullUp(buttonPins[i], 0x01); } Thread.Sleep(50); mcp23017.DigitalWrite(rsPin, 0x00); mcp23017.DigitalWrite(enablePin, 0x00); mcp23017.DigitalWrite(rwPin, 0x00); // put the LCD screen into 4 bit mode Write4Bits(0x03); Thread.Sleep(5); Write4Bits(0x03); Thread.Sleep(1); Write4Bits(0x03); Write4Bits(0x02); this.displayFunction = DisplayFunction.LCD_2LINE | DisplayFunction.LCD_4BITMODE | DisplayFunction.LCD_5x8DOTS; command((byte)((byte)Commands.LCD_FUNCTIONSET | (byte)this.displayFunction)); this.displayControl = DisplayControl.LCD_DISPLAYON | DisplayControl.LCD_CURSOROFF | DisplayControl.LCD_BLINKOFF; Display(); Clear(); this.displayMode = DisplayMode.LCD_ENTRYLEFT | DisplayMode.LCD_ENTRYSHIFTDECREMENT; command((byte)((byte)Commands.LCD_ENTRYMODESET | (byte)this.displayMode)); }
public RGBLCDShield(MCP23017 mcp23017, byte cols = 16, byte rows = 2, byte dotsize = 0) { this.mcp23017 = mcp23017; this.displayFunction = 0x0; // initialize the MCP23017 for this board mcp23017.PinMode(8, MCP23017.Direction.Output); mcp23017.PinMode(6, MCP23017.Direction.Output); mcp23017.PinMode(7, MCP23017.Direction.Output); //SetBacklight(BacklightColor.White); mcp23017.PinMode(rsPin, MCP23017.Direction.Output); mcp23017.PinMode(rwPin, MCP23017.Direction.Output); mcp23017.PinMode(enablePin, MCP23017.Direction.Output); for (int i = 0; i < dataPins.Length; i++) mcp23017.PinMode(dataPins[i], MCP23017.Direction.Output); for (int i = 0; i < buttonPins.Length; i++) { mcp23017.PinMode(buttonPins[i], MCP23017.Direction.Input); mcp23017.PullUp(buttonPins[i], 0x01); } Thread.Sleep(50); mcp23017.DigitalWrite(rsPin, 0x00); mcp23017.DigitalWrite(enablePin, 0x00); mcp23017.DigitalWrite(rwPin, 0x00); // put the LCD screen into 4 bit mode Write4Bits(0x03); Thread.Sleep(5); Write4Bits(0x03); Thread.Sleep(1); Write4Bits(0x03); Write4Bits(0x02); this.displayFunction = DisplayFunction.LCD_2LINE | DisplayFunction.LCD_4BITMODE | DisplayFunction.LCD_5x8DOTS; command((byte)((byte)Commands.LCD_FUNCTIONSET | (byte)this.displayFunction)); this.displayControl = DisplayControl.LCD_DISPLAYON | DisplayControl.LCD_CURSOROFF | DisplayControl.LCD_BLINKOFF; Display(); Clear(); this.displayMode = DisplayMode.LCD_ENTRYLEFT | DisplayMode.LCD_ENTRYSHIFTDECREMENT; command((byte)((byte)Commands.LCD_ENTRYMODESET | (byte)this.displayMode)); }