|
|
|
@ -206,45 +206,9 @@ func NewHat(p spi.Port, opts *Opts) (*Dev, error) {
|
|
|
|
return New(p, dc, cs, rst, busy, opts)
|
|
|
|
return New(p, dc, cs, rst, busy, opts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Init will initialize the display with the partial-update or full-update mode.
|
|
|
|
func (d *Dev) initFull() error {
|
|
|
|
func (d *Dev) Init(partialUpdate PartialUpdate) error {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh := errorHandler{d: *d}
|
|
|
|
eh := errorHandler{d: *d}
|
|
|
|
|
|
|
|
|
|
|
|
// Hardware Reset
|
|
|
|
|
|
|
|
if err := d.reset(); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if partialUpdate {
|
|
|
|
|
|
|
|
// Partital Update Mode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VCOM Voltage
|
|
|
|
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x26})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
|
|
|
|
eh.sendData(d.opts.PartialUpdate[:70])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(0x37)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(displayUpdateControl2)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0xC0})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(masterActivation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Border Waveform
|
|
|
|
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x01})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Full Update Mode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Software Reset
|
|
|
|
// Software Reset
|
|
|
|
d.waitUntilIdle()
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh.sendCommand(swReset)
|
|
|
|
eh.sendCommand(swReset)
|
|
|
|
@ -292,11 +256,53 @@ func (d *Dev) Init(partialUpdate PartialUpdate) error {
|
|
|
|
eh.sendData(d.opts.FullUpdate[:70])
|
|
|
|
eh.sendData(d.opts.FullUpdate[:70])
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return eh.err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Dev) initPartial() error {
|
|
|
|
|
|
|
|
eh := errorHandler{d: *d}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VCOM Voltage
|
|
|
|
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x26})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
|
|
|
|
eh.sendData(d.opts.PartialUpdate[:70])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(0x37)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(displayUpdateControl2)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0xC0})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(masterActivation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Border Waveform
|
|
|
|
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x01})
|
|
|
|
|
|
|
|
|
|
|
|
return eh.err
|
|
|
|
return eh.err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init will initialize the display with the partial-update or full-update mode.
|
|
|
|
|
|
|
|
func (d *Dev) Init(partialUpdate PartialUpdate) error {
|
|
|
|
|
|
|
|
// Hardware Reset
|
|
|
|
|
|
|
|
if err := d.reset(); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if partialUpdate {
|
|
|
|
|
|
|
|
return d.initPartial()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return d.initFull()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Clear clears the display.
|
|
|
|
// Clear clears the display.
|
|
|
|
func (d *Dev) Clear(color byte) error {
|
|
|
|
func (d *Dev) Clear(color byte) error {
|
|
|
|
if err := d.setMemoryArea(d.Bounds()); err != nil {
|
|
|
|
if err := d.setMemoryArea(d.Bounds()); err != nil {
|
|
|
|
|