waveshare213v2: Document more values

Introduce named constants where possible (based on the data sheet) and
compute values instead of using hardcoded ones.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
pull/38/head
Michael Hanselmann 4 years ago committed by M-A
parent 5b35a3fb05
commit c38b40a52a

@ -46,6 +46,15 @@ const (
setDigitalBlockControl byte = 0x7E setDigitalBlockControl byte = 0x7E
) )
// Register values
const (
gateDrivingVoltage19V = 0x15
sourceDrivingVoltageVSH1_15V = 0x41
sourceDrivingVoltageVSH2_5V = 0xA8
sourceDrivingVoltageVSL_neg15V = 0x32
)
// Dev defines the handler which is used to access the display. // Dev defines the handler which is used to access the display.
type Dev struct { type Dev struct {
c conn.Conn c conn.Conn
@ -90,38 +99,34 @@ var EPD2in13v2 = Opts{
Width: 122, Width: 122,
Height: 250, Height: 250,
FullUpdate: LUT{ FullUpdate: LUT{
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, //LUT0: BB: VS 0 ~7
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, //LUT1: BW: VS 0 ~7
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, //LUT2: WB: VS 0 ~7
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, //LUT3: WW: VS 0 ~7
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT4: VCOM: VS 0 ~7
0x03, 0x03, 0x00, 0x00, 0x02, 0x03, 0x03, 0x00, 0x00, 0x02, // TP0 A~D RP0
0x09, 0x09, 0x00, 0x00, 0x02, 0x09, 0x09, 0x00, 0x00, 0x02, // TP1 A~D RP1
0x03, 0x03, 0x00, 0x00, 0x02, 0x03, 0x03, 0x00, 0x00, 0x02, // TP2 A~D RP2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP3 A~D RP3
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP4 A~D RP4
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP5 A~D RP5
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP6 A~D RP6
0x15, 0x41, 0xA8, 0x32, 0x30, 0x0A,
}, },
PartialUpdate: LUT{ PartialUpdate: LUT{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT0: BB: VS 0 ~7
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT1: BW: VS 0 ~7
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT2: WB: VS 0 ~7
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT3: WW: VS 0 ~7
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LUT4: VCOM: VS 0 ~7
0x0A, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, // TP0 A~D RP0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP1 A~D RP1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP2 A~D RP2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP3 A~D RP3
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP4 A~D RP4
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP5 A~D RP5
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TP6 A~D RP6
0x15, 0x41, 0xA8, 0x32, 0x30, 0x0A,
}, },
} }
@ -221,9 +226,7 @@ func (d *Dev) Init(partialUpdate PartialUpdate) error {
d.waitUntilIdle() d.waitUntilIdle()
eh.sendCommand([]byte{writeLutRegister}) eh.sendCommand([]byte{writeLutRegister})
for i := range [70]int{} { eh.sendData(d.opts.PartialUpdate[:70])
eh.sendData([]byte{d.opts.PartialUpdate[i]})
}
eh.sendCommand([]byte{0x37}) eh.sendCommand([]byte{0x37})
eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00}) eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00})
@ -257,7 +260,11 @@ func (d *Dev) Init(partialUpdate PartialUpdate) error {
// Driver output control // Driver output control
eh.sendCommand([]byte{driverOutputControl}) eh.sendCommand([]byte{driverOutputControl})
eh.sendData([]byte{0xF9, 0x00, 0x00}) eh.sendData([]byte{
byte((d.opts.Height - 1) % 0xFF),
byte((d.opts.Height - 1) / 0xFF),
0x00,
})
// Data entry mode // Data entry mode
eh.sendCommand([]byte{dataEntryModeSetting}) eh.sendCommand([]byte{dataEntryModeSetting})
@ -280,23 +287,21 @@ func (d *Dev) Init(partialUpdate PartialUpdate) error {
eh.sendData([]byte{0x55}) eh.sendData([]byte{0x55})
eh.sendCommand([]byte{gateDrivingVoltageControl}) eh.sendCommand([]byte{gateDrivingVoltageControl})
eh.sendData([]byte{d.opts.FullUpdate[70]}) eh.sendData([]byte{gateDrivingVoltage19V})
eh.sendCommand([]byte{sourceDrivingVoltageControl}) eh.sendCommand([]byte{sourceDrivingVoltageControl})
eh.sendData([]byte{d.opts.FullUpdate[71], d.opts.FullUpdate[72], d.opts.FullUpdate[73]}) eh.sendData([]byte{sourceDrivingVoltageVSH1_15V, sourceDrivingVoltageVSH2_5V, sourceDrivingVoltageVSL_neg15V})
// Dummy Line // Dummy Line
eh.sendCommand([]byte{setDummyLinePeriod}) eh.sendCommand([]byte{setDummyLinePeriod})
eh.sendData([]byte{d.opts.FullUpdate[74]}) eh.sendData([]byte{0x30})
// Gate Time // Gate Time
eh.sendCommand([]byte{setGateTime}) eh.sendCommand([]byte{setGateTime})
eh.sendData([]byte{d.opts.FullUpdate[75]}) eh.sendData([]byte{0x0A})
eh.sendCommand([]byte{writeLutRegister}) eh.sendCommand([]byte{writeLutRegister})
for i := range [70]int{} { eh.sendData(d.opts.FullUpdate[:70])
eh.sendData([]byte{d.opts.FullUpdate[i]})
}
// Set RAM x address count to 0 // Set RAM x address count to 0
eh.sendCommand([]byte{setRAMXAddressCounter}) eh.sendCommand([]byte{setRAMXAddressCounter})

Loading…
Cancel
Save