ILI9341: Refactor sleep on/off, display on/off functions.

This commit is contained in:
Jared Boone 2017-07-18 13:13:13 -07:00
parent 23c340abb2
commit bb194825ae

View File

@ -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) {