/// <summary>Constructs a new instance.</summary> /// <param name="Pin9OnGSocket">Backlight pin.</param> /// <param name="Pin3OnISocket">Interrupt pin for capacitive touch panel (i2c).</param> public DisplayDriver43(int BacklightPin) { i2CController = I2cController.GetDefault(); gpioController = GpioController.GetDefault(); this.backlightPin = gpioController.OpenPin(BacklightPin); this.backlightPin.SetDriveMode(GpioPinDriveMode.Output); BacklightEnabled = true; SetupCapacitiveTouchController(); ConfigureDisplay(); //this.backlightPin = GpioPinFactory.Create(gSocket, Socket.Pin.Nine, true, this); }
public LcdRgbBacklight() { var settings = new I2cConnectionSettings((0x7c >> 1)); settings.SharingMode = I2cSharingMode.Shared; settings.BusSpeed = I2cBusSpeed.FastMode; //string aqs = I2cDevice.GetDeviceSelector("I2C1"); DisplayDevice = I2cController.GetDefault().GetDevice(settings); settings = new I2cConnectionSettings((0xc4 >> 1)); settings.SharingMode = I2cSharingMode.Shared; settings.BusSpeed = I2cBusSpeed.FastMode; BacklightDevice = I2cController.GetDefault().GetDevice(settings); //////////////////////////////////// // get the display going //byte cols = 6; byte lines = 2; byte dotsize = 0; if (lines > 1) { _displayfunction |= 0x08;// LCD_2LINE; } _numlines = lines; _currline = 0; // for some 1 line displays you can select a 10 pixel high font if ((dotsize != 0) && (lines == 1)) { _displayfunction |= 0x04;// LCD_5x10DOTS; } // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 //delayMicroseconds(50000); Thread.Sleep(50); // this is according to the hitachi HD44780 datasheet // page 45 figure 23 // Send function set command sequence command((byte)(LCD_FUNCTIONSET | _displayfunction)); //delayMicroseconds(4500); // wait more than 4.1ms Thread.Sleep(5); // second try command((byte)(LCD_FUNCTIONSET | _displayfunction)); //delayMicroseconds(150); Thread.Sleep(1); // third go command((byte)(LCD_FUNCTIONSET | _displayfunction)); // finally, set # lines, font size, etc. command((byte)(LCD_FUNCTIONSET | _displayfunction)); // turn the display on with no cursor or blinking default _displaycontrol = (byte)(LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF); EnableDisplay(true); // clear it off Clear(); // Initialize to default text direction (for romance languages) _displaymode = (byte)(LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT); // set the entry mode command((byte)(LCD_ENTRYMODESET | _displaymode)); // backlight init WriteBacklightReg(REG_MODE1, 0); // set LEDs controllable by both PWM and GRPPWM registers WriteBacklightReg(REG_OUTPUT, 0xFF); // set MODE2 values // 0010 0000 -> 0x20 (DMBLNK to 1, ie blinky mode) WriteBacklightReg(REG_MODE2, 0x20); //setColorWhite(); SetBacklightRGB(255, 0, 100); }