From 41b26497a9f646ed03f7f5ef3838b89893675299 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Fri, 24 Dec 2021 23:18:03 +0100 Subject: [PATCH] waveshare2in13v2: Document command 0x37 and always apply it The datasheets of the comparable SSD1680, SSD1675B and GDEH0213B73 controllers describe this command as "Write register for display option". Signed-off-by: Michael Hanselmann --- waveshare2in13v2/controller.go | 7 +++---- waveshare2in13v2/controller_test.go | 1 + waveshare2in13v2/waveshare213v2.go | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/waveshare2in13v2/controller.go b/waveshare2in13v2/controller.go index ad35077..adcb53a 100644 --- a/waveshare2in13v2/controller.go +++ b/waveshare2in13v2/controller.go @@ -63,11 +63,10 @@ func configDisplayMode(ctrl controller, mode PartialUpdate, lut LUT) { ctrl.sendCommand(writeLutRegister) ctrl.sendData(lut[:70]) - if mode == Partial { - // Undocumented command used in vendor example code. - ctrl.sendCommand(0x37) - ctrl.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}) + ctrl.sendCommand(writeDisplayOptionRegister) + ctrl.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}) + if mode == Partial { ctrl.sendCommand(displayUpdateControl2) ctrl.sendData([]byte{ displayUpdateEnableClock | diff --git a/waveshare2in13v2/controller_test.go b/waveshare2in13v2/controller_test.go index c536ea7..5c6436f 100644 --- a/waveshare2in13v2/controller_test.go +++ b/waveshare2in13v2/controller_test.go @@ -91,6 +91,7 @@ func TestConfigDisplayMode(t *testing.T) { {cmd: writeVcomRegister, data: []byte{0x55}}, {cmd: borderWaveformControl, data: []byte{0x03}}, {cmd: writeLutRegister, data: bytes.Repeat([]byte{'F'}, 70)}, + {cmd: 0x37, data: []byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}}, }, }, { diff --git a/waveshare2in13v2/waveshare213v2.go b/waveshare2in13v2/waveshare213v2.go index b67a636..8187bb4 100644 --- a/waveshare2in13v2/waveshare213v2.go +++ b/waveshare2in13v2/waveshare213v2.go @@ -37,6 +37,7 @@ const ( setDummyLinePeriod byte = 0x3A setGateTime byte = 0x3B borderWaveformControl byte = 0x3C + writeDisplayOptionRegister byte = 0x37 setRAMXAddressStartEndPosition byte = 0x44 setRAMYAddressStartEndPosition byte = 0x45 setRAMXAddressCounter byte = 0x4E