diff --git a/waveshare2in13v2/errorhandler.go b/waveshare2in13v2/errorhandler.go index 8f0f88e..b7c8671 100644 --- a/waveshare2in13v2/errorhandler.go +++ b/waveshare2in13v2/errorhandler.go @@ -45,8 +45,8 @@ func (eh *errorHandler) csOut(l gpio.Level) { } func (eh *errorHandler) waitUntilIdle() { - for eh.d.busy.Read() == gpio.High { - time.Sleep(100 * time.Millisecond) + for busy := eh.d.busy; busy.Read() == gpio.High; { + busy.WaitForEdge(100 * time.Millisecond) } } diff --git a/waveshare2in13v2/waveshare213v2.go b/waveshare2in13v2/waveshare213v2.go index fafd78c..79b37ba 100644 --- a/waveshare2in13v2/waveshare213v2.go +++ b/waveshare2in13v2/waveshare213v2.go @@ -60,7 +60,7 @@ type Dev struct { dc gpio.PinOut cs gpio.PinOut rst gpio.PinOut - busy gpio.PinIO + busy gpio.PinIn opts *Opts } @@ -123,12 +123,16 @@ var EPD2in13v2 = Opts{ } // New creates new handler which is used to access the display. -func New(p spi.Port, dc, cs, rst gpio.PinOut, busy gpio.PinIO, opts *Opts) (*Dev, error) { +func New(p spi.Port, dc, cs, rst gpio.PinOut, busy gpio.PinIn, opts *Opts) (*Dev, error) { c, err := p.Connect(5*physic.MegaHertz, spi.Mode0, 8) if err != nil { return nil, err } + if err := busy.In(gpio.Float, gpio.FallingEdge); err != nil { + return nil, err + } + d := &Dev{ c: c, dc: dc,