epd4in2

package
v0.0.0-...-2e22e3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package epd4in2 implements a driver for Waveshare 4.2in black and white e-paper device.

Derived from:

https://github.com/tinygo-org/drivers/tree/master/waveshare-epd
https://github.com/waveshare/e-Paper/blob/master/Arduino/epd4in2/epd4in2.cpp

Datasheet: https://www.waveshare.com/wiki/4.2inch_e-Paper_Module

Index

Constants

View Source
const (
	// Display resolution
	EPD_WIDTH  = 400
	EPD_HEIGHT = 300

	// EPD4IN2 commands
	PANEL_SETTING                  = 0x00
	POWER_SETTING                  = 0x01
	POWER_OFF                      = 0x02
	POWER_OFF_SEQUENCE_SETTING     = 0x03
	POWER_ON                       = 0x04
	POWER_ON_MEASURE               = 0x05
	BOOSTER_SOFT_START             = 0x06
	DEEP_SLEEP                     = 0x07
	DATA_START_TRANSMISSION_1      = 0x10
	DATA_STOP                      = 0x11
	DISPLAY_REFRESH                = 0x12
	DATA_START_TRANSMISSION_2      = 0x13
	LUT_FOR_VCOM                   = 0x20
	LUT_WHITE_TO_WHITE             = 0x21
	LUT_BLACK_TO_WHITE             = 0x22
	LUT_WHITE_TO_BLACK             = 0x23
	LUT_BLACK_TO_BLACK             = 0x24
	PLL_CONTROL                    = 0x30
	TEMPERATURE_SENSOR_COMMAND     = 0x40
	TEMPERATURE_SENSOR_SELECTION   = 0x41
	TEMPERATURE_SENSOR_WRITE       = 0x42
	TEMPERATURE_SENSOR_READ        = 0x43
	VCOM_AND_DATA_INTERVAL_SETTING = 0x50
	LOW_POWER_DETECTION            = 0x51
	TCON_SETTING                   = 0x60
	RESOLUTION_SETTING             = 0x61
	GSST_SETTING                   = 0x65
	GET_STATUS                     = 0x71
	AUTO_MEASUREMENT_VCOM          = 0x80
	READ_VCOM_VALUE                = 0x81
	VCM_DC_SETTING                 = 0x82
	PARTIAL_WINDOW                 = 0x90
	PARTIAL_IN                     = 0x91
	PARTIAL_OUT                    = 0x92
	PROGRAM_MODE                   = 0xA0
	ACTIVE_PROGRAMMING             = 0xA1
	READ_OTP                       = 0xA2
	POWER_SAVING                   = 0xE3

	NO_ROTATION  Rotation = 0
	ROTATION_90  Rotation = 1 // 90 degrees clock-wise rotation
	ROTATION_180 Rotation = 2
	ROTATION_270 Rotation = 3
)

Registers

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Width        int16 // Width is the display resolution
	Height       int16
	LogicalWidth int16    // LogicalWidth must be a multiple of 8 and same size or bigger than Width
	Rotation     Rotation // Rotation is clock-wise
}

type Device

type Device struct {
	// contains filtered or unexported fields
}

func New

func New(bus drivers.SPI, csPin, dcPin, rstPin, busyPin machine.Pin) Device

New returns a new epd4in2 driver. Pass in a fully configured SPI bus.

func (*Device) ClearBuffer

func (d *Device) ClearBuffer()

ClearBuffer sets the buffer to 0xFF (white)

func (*Device) ClearDisplay

func (d *Device) ClearDisplay()

ClearDisplay erases the device SRAM

func (*Device) Configure

func (d *Device) Configure(cfg Config)

Configure sets up the device.

func (*Device) DeepSleep

func (d *Device) DeepSleep()

DeepSleep puts the display into deepsleep

func (*Device) Display

func (d *Device) Display() error

Display sends the buffer to the screen.

func (*Device) IsBusy

func (d *Device) IsBusy() bool

IsBusy returns the busy status of the display

func (*Device) Reset

func (d *Device) Reset()

Reset resets the device

func (*Device) SendCommand

func (d *Device) SendCommand(command uint8)

SendCommand sends a command to the display

func (*Device) SendData

func (d *Device) SendData(data uint8)

SendData sends a data byte to the display

func (*Device) SetLUT

func (d *Device) SetLUT()

SetLUT sets the look up tables for full or partial updates

func (*Device) SetPixel

func (d *Device) SetPixel(x int16, y int16, c color.RGBA)

SetPixel modifies the internal buffer in a single pixel. The display have 2 colors: black and white We use RGBA(0,0,0, 255) as white (transparent) Anything else as black

func (*Device) SetRotation

func (d *Device) SetRotation(rotation Rotation)

SetRotation changes the rotation (clock-wise) of the device

func (*Device) Size

func (d *Device) Size() (w, h int16)

Size returns the current size of the display.

func (*Device) WaitUntilIdle

func (d *Device) WaitUntilIdle()

WaitUntilIdle waits until the display is ready

type Rotation

type Rotation uint8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL