From 40ad1e7ef3728022659e2fe56bee270d02cd8152 Mon Sep 17 00:00:00 2001
From: pichenettes
Date: Sat, 28 Dec 2013 22:20:18 +0100
Subject: [PATCH] New handling of blinking cursor
---
devices/buffered_display.h | 15 +++++----------
devices/hd44780_lcd.h | 9 ---------
2 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/devices/buffered_display.h b/devices/buffered_display.h
index eea3108..4658470 100644
--- a/devices/buffered_display.h
+++ b/devices/buffered_display.h
@@ -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
@@ -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;
}
@@ -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
@@ -227,10 +226,6 @@ uint8_t BufferedDisplay::scan_position_last_write_;
template
uint8_t BufferedDisplay::blink_;
-/* static */
-template
-uint8_t BufferedDisplay::previous_blink_counter_;
-
/* static */
template
uint8_t BufferedDisplay::previous_status_counter_;
diff --git a/devices/hd44780_lcd.h b/devices/hd44780_lcd.h
index 3115404..bf24af4 100755
--- a/devices/hd44780_lcd.h
+++ b/devices/hd44780_lcd.h
@@ -116,7 +116,6 @@ class Hd44780Lcd {
}
static inline void Tick() {
- ++blink_counter_;
++status_counter_;
if (transmitting_) {
EndWrite();
@@ -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; }
@@ -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);
@@ -237,12 +234,6 @@ template::transmitting_;
-/* static */
-template
-volatile uint8_t Hd44780Lcd::blink_counter_;
-
/* static */
template