From bb194825ae5393dfef32784de3fbff3b63bd7b63 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 18 Jul 2017 13:13:13 -0700 Subject: [PATCH] ILI9341: Refactor sleep on/off, display on/off functions. --- firmware/common/lcd_ili9341.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/firmware/common/lcd_ili9341.cpp b/firmware/common/lcd_ili9341.cpp index 539535dcd..a79084531 100644 --- a/firmware/common/lcd_ili9341.cpp +++ b/firmware/common/lcd_ili9341.cpp @@ -43,11 +43,17 @@ void lcd_reset() { void lcd_sleep_in() { io.lcd_data_write_command_and_data(0x10, {}); + // "It will be necessary to wait 5msec before sending next command, + // this is to allow time for the supply voltages and clock circuits + // to stabilize." chThdSleepMilliseconds(5); } void lcd_sleep_out() { io.lcd_data_write_command_and_data(0x11, {}); + // "It will be necessary to wait 120msec after sending Sleep Out + // command (when in Sleep In Mode) before Sleep In command can be + // sent." chThdSleepMilliseconds(120); } @@ -55,6 +61,20 @@ void lcd_display_on() { io.lcd_data_write_command_and_data(0x29, {}); } +void lcd_display_off() { + io.lcd_data_write_command_and_data(0x28, {}); +} + +void lcd_sleep() { + lcd_display_off(); + lcd_sleep_in(); +} + +void lcd_wake() { + lcd_sleep_out(); + lcd_display_on(); +} + void lcd_init() { // LCDs are configured for IM[2:0] = 001 // 8080-I system, 16-bit parallel bus @@ -161,8 +181,7 @@ void lcd_init() { 0x47, 0x04, 0x0C, 0x0B, 0x29, 0x2F, 0x05 }); - lcd_sleep_out(); - lcd_display_on(); + lcd_wake(); // Turn on Tearing Effect Line (TE) output signal. io.lcd_data_write_command_and_data(0x35, { 0b00000000 }); @@ -261,11 +280,11 @@ void ILI9341::shutdown() { } void ILI9341::sleep() { - lcd_sleep_in(); + lcd_sleep(); } void ILI9341::wake() { - lcd_sleep_out(); + lcd_wake(); } void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {