Skip to content

Commit

Permalink
New handling of blinking cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
pichenettes committed Dec 28, 2013
1 parent b6e1319 commit 40ad1e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
15 changes: 5 additions & 10 deletions devices/buffered_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ class BufferedDisplay {
Lcd::WriteData(status_ - 1);
remote_[scan_position_] = status_ - 1;
}

static void BlinkCursor() {
++blink_;
}

static void Tick() {
// The following code is likely to write 4 bytes at most. If there are less
Expand All @@ -120,11 +124,6 @@ class BufferedDisplay {
// It is now safe to assume that all writes of 4 bytes to the display buffer
// will not block.

if (previous_blink_counter_ > Lcd::blink_counter()) {
++blink_;
}
previous_blink_counter_ = Lcd::status_counter();

if (previous_status_counter_ > Lcd::status_counter()) {
status_ = 0;
}
Expand All @@ -134,7 +133,7 @@ class BufferedDisplay {
// Determine which character to show at the current position.
// If the scan position is the cursor and it is shown (blinking), draw the
// cursor.
if (scan_position_ == cursor_position_ && (blink_ & 2)) {
if (scan_position_ == cursor_position_ && (blink_ & 128)) {
character = cursor_character_;
} else {
// Otherwise, check if there's a status indicator to display. It is
Expand Down Expand Up @@ -227,10 +226,6 @@ uint8_t BufferedDisplay<Lcd>::scan_position_last_write_;
template<typename Lcd>
uint8_t BufferedDisplay<Lcd>::blink_;

/* static */
template<typename Lcd>
uint8_t BufferedDisplay<Lcd>::previous_blink_counter_;

/* static */
template<typename Lcd>
uint8_t BufferedDisplay<Lcd>::previous_status_counter_;
Expand Down
9 changes: 0 additions & 9 deletions devices/hd44780_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class Hd44780Lcd {
}

static inline void Tick() {
++blink_counter_;
++status_counter_;
if (transmitting_) {
EndWrite();
Expand Down Expand Up @@ -188,7 +187,6 @@ class Hd44780Lcd {
static inline uint8_t writable() { return OutputBuffer::writable(); }
static inline uint8_t readable() { return OutputBuffer::readable(); }
static inline uint8_t busy() { return transmitting_; }
static inline uint8_t blink_counter() { return blink_counter_; }
static inline uint8_t status_counter() { return status_counter_; }

static inline void ResetStatusCounter() { status_counter_ = 0; }
Expand Down Expand Up @@ -225,7 +223,6 @@ class Hd44780Lcd {
}

static volatile uint8_t transmitting_;
static volatile uint8_t blink_counter_;
static volatile uint8_t status_counter_;

DISALLOW_COPY_AND_ASSIGN(Hd44780Lcd);
Expand All @@ -237,12 +234,6 @@ template<typename RsPin, typename EnablePin, typename ParallelPort,
volatile uint8_t Hd44780Lcd<RsPin, EnablePin, ParallelPort, width,
height>::transmitting_;

/* static */
template<typename RsPin, typename EnablePin, typename ParallelPort,
uint8_t width, uint8_t height>
volatile uint8_t Hd44780Lcd<RsPin, EnablePin, ParallelPort, width,
height>::blink_counter_;

/* static */
template<typename RsPin, typename EnablePin, typename ParallelPort,
uint8_t width, uint8_t height>
Expand Down

0 comments on commit 40ad1e7

Please sign in to comment.