From df5238c598e04f6d638b878f8090f985b869932b Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Fri, 24 Dec 2021 17:10:14 +0100 Subject: [PATCH] waveshare2in13v2: Enable hardware early Enable the clock and analog parts when configuring the mode. In probably all use cases a drawing operation is following soon after anyway. Putting the device to sleep disables these hardware parts again. --- waveshare2in13v2/controller.go | 13 ++++--------- waveshare2in13v2/controller_test.go | 2 ++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/waveshare2in13v2/controller.go b/waveshare2in13v2/controller.go index adcb53a..cd65897 100644 --- a/waveshare2in13v2/controller.go +++ b/waveshare2in13v2/controller.go @@ -66,16 +66,11 @@ func configDisplayMode(ctrl controller, mode PartialUpdate, lut LUT) { ctrl.sendCommand(writeDisplayOptionRegister) ctrl.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}) - if mode == Partial { - ctrl.sendCommand(displayUpdateControl2) - ctrl.sendData([]byte{ - displayUpdateEnableClock | - displayUpdateEnableAnalog, - }) - - ctrl.sendCommand(masterActivation) - } + // Start up the parts likely used by a draw operation soon. + ctrl.sendCommand(displayUpdateControl2) + ctrl.sendData([]byte{displayUpdateEnableClock | displayUpdateEnableAnalog}) + ctrl.sendCommand(masterActivation) ctrl.waitUntilIdle() } diff --git a/waveshare2in13v2/controller_test.go b/waveshare2in13v2/controller_test.go index 5c6436f..16496ae 100644 --- a/waveshare2in13v2/controller_test.go +++ b/waveshare2in13v2/controller_test.go @@ -92,6 +92,8 @@ func TestConfigDisplayMode(t *testing.T) { {cmd: borderWaveformControl, data: []byte{0x03}}, {cmd: writeLutRegister, data: bytes.Repeat([]byte{'F'}, 70)}, {cmd: 0x37, data: []byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}}, + {cmd: displayUpdateControl2, data: []byte{0xc0}}, + {cmd: masterActivation}, }, }, {