Documentation ¶
Overview ¶
Package dfr0591 is a library for accessing and using a DFR0691 Raspberry Pi e-Paper display with Golang
Index ¶
- Constants
- Variables
- type DisplaySPI
- func (d *DisplaySPI) PowerOff() (err error)
- func (d *DisplaySPI) PowerOn() (err error)
- func (d *DisplaySPI) SetRAMData(xStart, xEnd, yStart, yStart1, yEnd, yEnd1 uint8) (err error)
- func (d *DisplaySPI) SetRAMPointer(x, y, y1 uint8) (err error)
- func (d *DisplaySPI) UpdateDis(mode Mode) (err error)
- func (d *DisplaySPI) WriteCmdAndData(cmd uint8, data []byte) (err error)
- func (d *DisplaySPI) WriteDisRAM(displayBuffer *bitarray.BitArray, sizeX, sizeY uint8) (err error)
- type DisplayTransport
- type Epaper
- type Mode
Constants ¶
const ( // Xmax is the max size of the device (X). Xmax = 250 // Ymax is the max size of the device (Y). Ymax = 128 )
Variables ¶
var ErrOutOfBounds = errors.New("position out of bounds")
ErrOutOfBounds is returned when a Pixel x/y is outside the window.
Functions ¶
This section is empty.
Types ¶
type DisplaySPI ¶
type DisplaySPI struct {
// contains filtered or unexported fields
}
DisplaySPI is the SPI provider for DisplayTransport.
func (*DisplaySPI) PowerOff ¶
func (d *DisplaySPI) PowerOff() (err error)
PowerOff puts the device to sleep. def _powerOff(self):
self.writeCmdAndData(0x12, []) self.writeCmdAndData(0x82, [0x00]) self.writeCmdAndData(0x01, [0x02, 0x00, 0x00, 0x00, 0x00]) self.writeCmdAndData(0x02, [])
func (*DisplaySPI) PowerOn ¶
func (d *DisplaySPI) PowerOn() (err error)
PowerOn wakes the device from sleep. def _powerOn(self):
self.writeCmdAndData(0x22, [0xc0]) self.writeCmdAndData(0x20, [])
func (*DisplaySPI) SetRAMData ¶
func (d *DisplaySPI) SetRAMData(xStart, xEnd, yStart, yStart1, yEnd, yEnd1 uint8) (err error)
SetRAMData does something.
func (*DisplaySPI) SetRAMPointer ¶
func (d *DisplaySPI) SetRAMPointer(x, y, y1 uint8) (err error)
SetRAMPointer also does something.
func (*DisplaySPI) UpdateDis ¶
func (d *DisplaySPI) UpdateDis(mode Mode) (err error)
UpdateDis updates the display of the device. def _updateDis(self, mode):
if mode == self.FULL: self.writeCmdAndData(0x22, [0xc7]) elif mode == self.PART: self.writeCmdAndData(0x22, [0x04]) else: return self.writeCmdAndData(0x20, []) self.writeCmdAndData(0xff, [])
func (*DisplaySPI) WriteCmdAndData ¶
func (d *DisplaySPI) WriteCmdAndData(cmd uint8, data []byte) (err error)
WriteCmdAndData writes a command and optional data to the device.
func (*DisplaySPI) WriteDisRAM ¶
func (d *DisplaySPI) WriteDisRAM(displayBuffer *bitarray.BitArray, sizeX, sizeY uint8) (err error)
WriteDisRAM writes to the display RAM on the device. def _writeDisRam(self, sizeX, sizeY):
if sizeX % 8 != 0: sizeX = sizeX + (8 - sizeX % 8) sizeX = sizeX // 8 self.writeCmdAndData(0x24, self._displayBuffer[0: sizeX * sizeY])
type DisplayTransport ¶
type DisplayTransport interface { PowerOn() (err error) PowerOff() (err error) SetRAMData(xStart, xEnd, yStart, yStart1, yEnd, yEnd1 uint8) (err error) SetRAMPointer(x, y, y1 uint8) (err error) WriteCmdAndData(cmd uint8, data []byte) (err error) WriteDisRAM(displayBuffer *bitarray.BitArray, sizeX, sizeY uint8) (err error) UpdateDis(mode Mode) (err error) }
DisplayTransport is the interface for the e-Ink Display (I think it can support i2c as well ?).
func NewDisplaySPI ¶
func NewDisplaySPI(s spi.Conn) DisplayTransport
NewDisplaySPI returns a new DisplaySPI that provides the DisplayTransport interface.
type Epaper ¶
type Epaper struct {
// contains filtered or unexported fields
}
Epaper is the epaper device and abstracted commands.
func NewEpaper ¶
func NewEpaper(d DisplayTransport, width, height int) *Epaper
NewEpaper returns a new Epaper struct.
func (*Epaper) Pixel ¶
Pixel sets individual pixels on or off.
def pixel(self, x, y, color): if x < 0 or x >= self._width: return if y < 0 or y >= self._height: return x = int(x) y = int(y) m = int(x * 16 + (y + 1) / 8) sy = int((y + 1) % 8) if color == self.WHITE: if sy != 0: self._displayBuffer[m] = self._displayBuffer[m] | int(pow(2, 8 - sy)) else: self._displayBuffer[m - 1] = self._displayBuffer[m - 1] | 1 elif color == self.BLACK: if sy != 0: self._displayBuffer[m] = self._displayBuffer[m] & (0xff - int(pow(2, 8 - sy))) else: self._displayBuffer[m - 1] = self._displayBuffer[m - 1] & 0xfe