private void DrawCrossBar(bool[] digitToBarPresence, LCDState nextState) { Write(digitToBarPresence[_digits[_charIndex]] ? _crossBar : _crossBarBlank); _charIndex++; _state = _charIndex == _digits.Length ? LCDState.EOL : LCDState.Between; _nextState = nextState; }
private void DrawVBar(bool[] digitToBarPresence, LCDState nextState) { var onLeft = (_state == LCDState.BL || _state == LCDState.TL); Write(digitToBarPresence[_digits[_charIndex]] ? "|" : Space); _state = onLeft ? LCDState.Blank : (++_charIndex == _digits.Length ? LCDState.EOL : LCDState.Between); _nextState = nextState; }
internal void AppendLCD() { while (_state != LCDState.Ended) { switch (_state) { case LCDState.Starting: _state = LCDState.Top; break; case LCDState.Top: DrawCrossBar(_topBars, LCDState.Top); break; case LCDState.Middle: DrawCrossBar(_midBars, LCDState.Middle); break; case LCDState.Bottom: DrawCrossBar(_botBars, LCDState.Bottom); break; case LCDState.Between: Write(Space); _state = _nextState; break; case LCDState.Blank: Write(_internalBlank); _state = _nextState; break; case LCDState.TL: DrawVBar(_tlBars, LCDState.TR); break; case LCDState.TR: DrawVBar(_trBars, LCDState.TL); break; case LCDState.BL: DrawVBar(_blBars, LCDState.BR); break; case LCDState.BR: DrawVBar(_brBars, LCDState.BL); break; case LCDState.EOL: WriteLine(); if (_row == 0) { _state = LCDState.TL; } else if (_row == _size) { _state = LCDState.Middle; } else if (_row == _size + 1) { _state = LCDState.BL; } else if (_row == 2 * _size + 1) { _state = LCDState.Bottom; } else if (_row == 2 * _size + 2) { _state = LCDState.Ended; } else { _state = _nextState; } _row++; _charIndex = 0; break; } } }