|
|
|
@ -206,95 +206,101 @@ 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
|
|
|
|
// Software Reset
|
|
|
|
if err := d.reset(); err != nil {
|
|
|
|
d.waitUntilIdle()
|
|
|
|
return err
|
|
|
|
eh.sendCommand(swReset)
|
|
|
|
}
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
if partialUpdate {
|
|
|
|
// Set analog block control
|
|
|
|
// Partital Update Mode
|
|
|
|
eh.sendCommand(setAnalogBlockControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x54})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set digital block control
|
|
|
|
|
|
|
|
eh.sendCommand(setDigitalBlockControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x3B})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Driver output control
|
|
|
|
|
|
|
|
eh.sendCommand(driverOutputControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{
|
|
|
|
|
|
|
|
byte((d.opts.Height - 1) % 0xFF),
|
|
|
|
|
|
|
|
byte((d.opts.Height - 1) / 0xFF),
|
|
|
|
|
|
|
|
0x00,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// VCOM Voltage
|
|
|
|
// Border Waveform
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
eh.sendData([]byte{0x26})
|
|
|
|
eh.sendData([]byte{0x03})
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
// VCOM Voltage
|
|
|
|
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x55})
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
eh.sendCommand(gateDrivingVoltageControl)
|
|
|
|
eh.sendData(d.opts.PartialUpdate[:70])
|
|
|
|
eh.sendData([]byte{gateDrivingVoltage19V})
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(0x37)
|
|
|
|
eh.sendCommand(sourceDrivingVoltageControl)
|
|
|
|
eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00})
|
|
|
|
eh.sendData([]byte{sourceDrivingVoltageVSH1_15V, sourceDrivingVoltageVSH2_5V, sourceDrivingVoltageVSL_neg15V})
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(displayUpdateControl2)
|
|
|
|
// Dummy Line
|
|
|
|
eh.sendData([]byte{0xC0})
|
|
|
|
eh.sendCommand(setDummyLinePeriod)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x30})
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(masterActivation)
|
|
|
|
// Gate Time
|
|
|
|
|
|
|
|
eh.sendCommand(setGateTime)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x0A})
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
|
|
|
|
eh.sendData(d.opts.FullUpdate[:70])
|
|
|
|
|
|
|
|
|
|
|
|
// Border Waveform
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x01})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return eh.err
|
|
|
|
// Full Update Mode
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Software Reset
|
|
|
|
func (d *Dev) initPartial() error {
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh := errorHandler{d: *d}
|
|
|
|
eh.sendCommand(swReset)
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set analog block control
|
|
|
|
// VCOM Voltage
|
|
|
|
eh.sendCommand(setAnalogBlockControl)
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
eh.sendData([]byte{0x54})
|
|
|
|
eh.sendData([]byte{0x26})
|
|
|
|
|
|
|
|
|
|
|
|
// Set digital block control
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh.sendCommand(setDigitalBlockControl)
|
|
|
|
|
|
|
|
eh.sendData([]byte{0x3B})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Driver output control
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
eh.sendCommand(driverOutputControl)
|
|
|
|
eh.sendData(d.opts.PartialUpdate[:70])
|
|
|
|
eh.sendData([]byte{
|
|
|
|
|
|
|
|
byte((d.opts.Height - 1) % 0xFF),
|
|
|
|
|
|
|
|
byte((d.opts.Height - 1) / 0xFF),
|
|
|
|
|
|
|
|
0x00,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Border Waveform
|
|
|
|
eh.sendCommand(0x37)
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
eh.sendData([]byte{0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00})
|
|
|
|
eh.sendData([]byte{0x03})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VCOM Voltage
|
|
|
|
eh.sendCommand(displayUpdateControl2)
|
|
|
|
eh.sendCommand(writeVcomRegister)
|
|
|
|
eh.sendData([]byte{0xC0})
|
|
|
|
eh.sendData([]byte{0x55})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(gateDrivingVoltageControl)
|
|
|
|
eh.sendCommand(masterActivation)
|
|
|
|
eh.sendData([]byte{gateDrivingVoltage19V})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(sourceDrivingVoltageControl)
|
|
|
|
d.waitUntilIdle()
|
|
|
|
eh.sendData([]byte{sourceDrivingVoltageVSH1_15V, sourceDrivingVoltageVSH2_5V, sourceDrivingVoltageVSL_neg15V})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dummy Line
|
|
|
|
// Border Waveform
|
|
|
|
eh.sendCommand(setDummyLinePeriod)
|
|
|
|
eh.sendCommand(borderWaveformControl)
|
|
|
|
eh.sendData([]byte{0x30})
|
|
|
|
eh.sendData([]byte{0x01})
|
|
|
|
|
|
|
|
|
|
|
|
// Gate Time
|
|
|
|
return eh.err
|
|
|
|
eh.sendCommand(setGateTime)
|
|
|
|
}
|
|
|
|
eh.sendData([]byte{0x0A})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eh.sendCommand(writeLutRegister)
|
|
|
|
// Init will initialize the display with the partial-update or full-update mode.
|
|
|
|
eh.sendData(d.opts.FullUpdate[:70])
|
|
|
|
func (d *Dev) Init(partialUpdate PartialUpdate) error {
|
|
|
|
|
|
|
|
// Hardware Reset
|
|
|
|
|
|
|
|
if err := d.reset(); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d.waitUntilIdle()
|
|
|
|
if partialUpdate {
|
|
|
|
|
|
|
|
return d.initPartial()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return eh.err
|
|
|
|
return d.initFull()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Clear clears the display.
|
|
|
|
// Clear clears the display.
|
|
|
|
|