public void CreateChar(int location, int[] charMap) { location &= 0x7; // we only have 8 locations 0-7 _command(Constants.SetCGRAMAddr | (location << 3)); StopwatchDelay.DelayMicroSeconds(30); for (int i = 0; i < 8; i++) { Write(charMap[i]); // call the virtual write method StopwatchDelay.DelayMicroSeconds(40); } }
public void Home() { _command(Constants.ReturnHome); StopwatchDelay.DelayMicroSeconds(Constants.HomeClearExec); }
public void Clear() { _command(Constants.ClearDisplay); StopwatchDelay.DelayMicroSeconds(Constants.HomeClearExec); }
public virtual void Begin(int cols, int rows, int charSize = Constants.LCD_5x8DOTS) { if (rows > 1) { _displayFunction |= Constants.LCD_2LINE; } _numlines = rows; _cols = cols; StopwatchDelay.Delay(100); if ((_displayFunction & Constants.LCD_8BITMODE) == 0) { // this is according to the hitachi HD44780 datasheet // figure 24, pg 46 // we start in 8bit mode, try to set 4 bit mode Send(0x03, Constants.FOUR_BITS); StopwatchDelay.DelayMicroSeconds(4500); // wait min 4.1ms // second try Send(0x03, Constants.FOUR_BITS); StopwatchDelay.DelayMicroSeconds(4500); // wait min 4.1ms // third go! Send(0x03, Constants.FOUR_BITS); StopwatchDelay.DelayMicroSeconds(150); // finally, set to 4-bit interface Send(0x02, Constants.FOUR_BITS); } else { // this is according to the hitachi HD44780 datasheet // page 45 figure 23 // Send function set command sequence _command(Constants.FunctionSet | _displayFunction); StopwatchDelay.DelayMicroSeconds(4500); // wait more than 4.1ms // second try _command(Constants.FunctionSet | _displayFunction); StopwatchDelay.DelayMicroSeconds(150); // third go _command(Constants.FunctionSet | _displayFunction); } // finally, set # lines, font size, etc. _command(Constants.FunctionSet | _displayFunction); // turn the display on with no cursor or blinking default _displaycontrol = Constants.DisplayOn | Constants.CursorOff | Constants.BlinkOff; Display(); // clear the LCD Clear(); // Initialize to default text direction (for romance languages) _displaymode = Constants.EntryLeft | Constants.ShiftDecrement; // set the entry mode _command(Constants.EntryModeSet | _displaymode); BackLight(); }