Exemple #1
0
        public async Task <bool> Init(int address, int cols, int rows, int charSize = LCDConstants.LCD_5x8DOTS,
                                      int en           = 6, int rw = 5,
                                      int rs           = 4, int d4 = 0,
                                      int d5           = 1, int d6 = 2,
                                      int d7           = 3,
                                      int?backlightPin = null, BacklightPolarity?polarity = null)
        {
            _address = address;

            if (_lcdHitachiI2Cio == null)
            {
                _lcdHitachiI2Cio = new LCD_Hitachi_I2CIO(_i2CDevice);
                if (await _lcdHitachiI2Cio.Init(_address))
                {
                    _lcdHitachiI2Cio.PortMode(LCDConstants.OUTPUT); // Set the entire IO extender to OUTPUT
                    _displayFunction = LCDConstants.LCD_4BITMODE | LCDConstants.LCD_1LINE | LCDConstants.LCD_5x8DOTS;
                    _lcdHitachiI2Cio.Write(0);                      // Set the entire port to LOW
                }
            }

            await Begin(cols, rows, charSize);

            _backlightPinMask = 0;
            _backlightStsMask = LCD_NOBACKLIGHT;
            _polarity         = BacklightPolarity.Positive;

            _en = (1 << en);
            _rw = (1 << rw);
            _rs = (1 << rs);

            // Initialise pin mapping
            _dataPins[0] = (1 << d4);
            _dataPins[1] = (1 << d5);
            _dataPins[2] = (1 << d6);
            _dataPins[3] = (1 << d7);

            if (backlightPin != null && polarity != null)
            {
                SetBacklightPin(backlightPin.Value, polarity.Value);
            }

            return(true);
        }
        public  async Task<bool> Init(int address, int cols, int rows, int charSize = LCDConstants.LCD_5x8DOTS,
            int en = 6, int rw = 5, 
            int rs = 4, int d4 = 0, 
            int d5 = 1, int d6 = 2, 
            int d7 = 3,
            int? backlightPin = null, BacklightPolarity? polarity = null)
        {
            _address = address;

            if (_lcdHitachiI2Cio == null)
            {
                _lcdHitachiI2Cio = new LCD_Hitachi_I2CIO(_i2CDevice);
                if (await _lcdHitachiI2Cio.Init(_address))
                {
                    _lcdHitachiI2Cio.PortMode(LCDConstants.OUTPUT);  // Set the entire IO extender to OUTPUT
                    _displayFunction = LCDConstants.LCD_4BITMODE | LCDConstants.LCD_1LINE | LCDConstants.LCD_5x8DOTS;
                    _lcdHitachiI2Cio.Write(0);  // Set the entire port to LOW
                }
            }

            await Begin(cols, rows, charSize);

            _backlightPinMask = 0;
            _backlightStsMask = LCD_NOBACKLIGHT;
            _polarity = BacklightPolarity.Positive;

            _en = (1 << en);
            _rw = (1 << rw);
            _rs = (1 << rs);

            // Initialise pin mapping
            _dataPins[0] = (1 << d4);
            _dataPins[1] = (1 << d5);
            _dataPins[2] = (1 << d6);
            _dataPins[3] = (1 << d7);

            if (backlightPin != null && polarity != null)
            {
                SetBacklightPin(backlightPin.Value, polarity.Value);
            }

            return true;
        }