From 1095629f62a3abf52c01e25e347c70e79e1d9e6d Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 21 Apr 2024 12:26:38 +0200 Subject: [PATCH] ssd1306: add Sleep() function for Displayer interface Signed-off-by: deadprogram --- ssd1306/ssd1306.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ssd1306/ssd1306.go b/ssd1306/ssd1306.go index 955a364..7aaef87 100644 --- a/ssd1306/ssd1306.go +++ b/ssd1306/ssd1306.go @@ -371,3 +371,15 @@ func (d *Device) Rotation() drivers.Rotation { func (d *Device) SetRotation(rotation drivers.Rotation) error { return errNotImplemented } + +// Set the sleep mode for this display. When sleeping, the panel uses a lot +// less power. The display won't show an image anymore, but the memory contents +// should be kept. +func (d *Device) Sleep(sleepEnabled bool) error { + if sleepEnabled { + d.Command(DISPLAYOFF) + } else { + d.Command(DISPLAYON) + } + return nil +}