Exemplo n.º 1
0
        //Sends an ASCII character to the LCD
        private void Putc(byte c)
        {
            shift[_LCDBit3] = (c & 0x80) != 0;
            shift[_LCDBit2] = (c & 0x40) != 0;
            shift[_LCDBit1] = (c & 0x20) != 0;
            shift[_LCDBit0] = (c & 0x10) != 0;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();

            shift[_LCDBit3] = (c & 0x08) != 0;
            shift[_LCDBit2] = (c & 0x04) != 0;
            shift[_LCDBit1] = (c & 0x02) != 0;
            shift[_LCDBit0] = (c & 0x01) != 0;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();
        }
Exemplo n.º 2
0
        public LCD(
            ShiftRegister shift,
            int bit0,
            int bit1,
            int bit2,
            int bit3,
            int enable,
            int registerSelect)
        {
            this.shift = shift;

            _LCDRegisterSelect = registerSelect;
            _LCDEnable         = enable;
            _LCDBit0           = bit0;
            _LCDBit1           = bit1;
            _LCDBit2           = bit2;
            _LCDBit3           = bit3;

            shift[_LCDRegisterSelect] = false;
            shift.OutBits();

            // 4 bit data communication
            shift[_LCDBit3] = false;
            shift[_LCDBit2] = false;
            shift[_LCDBit1] = true;
            shift[_LCDBit0] = true;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();

            shift[_LCDBit3] = false;
            shift[_LCDBit2] = false;
            shift[_LCDBit1] = true;
            shift[_LCDBit0] = true;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();

            shift[_LCDBit3] = false;
            shift[_LCDBit2] = false;
            shift[_LCDBit1] = true;
            shift[_LCDBit0] = true;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();

            shift[_LCDBit3] = false;
            shift[_LCDBit2] = false;
            shift[_LCDBit1] = true;
            shift[_LCDBit0] = false;
            shift.OutBits();

            shift[_LCDEnable] = true; //Toggle the Enable Pin
            shift.OutBits();
            shift[_LCDEnable] = false;
            shift.OutBits();

            SendCmd(DISP_ON);
            SendCmd(CLR_DISP);
        }