|
|
|
@ -127,6 +127,7 @@ func NewImpression(p spi.Port, dc gpio.PinOut, reset gpio.PinOut, busy gpio.PinI
|
|
|
|
border: o.BorderColor,
|
|
|
|
border: o.BorderColor,
|
|
|
|
model: o.Model,
|
|
|
|
model: o.Model,
|
|
|
|
variant: o.DisplayVariant,
|
|
|
|
variant: o.DisplayVariant,
|
|
|
|
|
|
|
|
pcbVariant: o.PCBVariant,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
saturation: 50, // Looks good enough for most of the images.
|
|
|
|
saturation: 50, // Looks good enough for most of the images.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -197,11 +198,6 @@ func (d *DevImpression) SetBorder(c ImpressionColor) {
|
|
|
|
d.border = Color(c)
|
|
|
|
d.border = Color(c)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetPixel sets a pixel to the given color index.
|
|
|
|
|
|
|
|
func (d *DevImpression) SetPixel(x, y int, color uint8) {
|
|
|
|
|
|
|
|
d.Pix[y*d.width+x] = color & 0x07
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Render renders the content of the Pix to the screen.
|
|
|
|
// Render renders the content of the Pix to the screen.
|
|
|
|
func (d *DevImpression) Render() error {
|
|
|
|
func (d *DevImpression) Render() error {
|
|
|
|
if d.flipVertically {
|
|
|
|
if d.flipVertically {
|
|
|
|
@ -373,6 +369,7 @@ func (d *DevImpression) wait(dur time.Duration) {
|
|
|
|
d.busy.WaitForEdge(dur)
|
|
|
|
d.busy.WaitForEdge(dur)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ColorModel returns the device native color model.
|
|
|
|
func (d *DevImpression) ColorModel() color.Model {
|
|
|
|
func (d *DevImpression) ColorModel() color.Model {
|
|
|
|
if d.Palette == nil {
|
|
|
|
if d.Palette == nil {
|
|
|
|
d.Palette = d.blend()
|
|
|
|
d.Palette = d.blend()
|
|
|
|
@ -380,6 +377,7 @@ func (d *DevImpression) ColorModel() color.Model {
|
|
|
|
return d.Palette
|
|
|
|
return d.Palette
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// At returns the color of the pixel at (x, y).
|
|
|
|
func (d *DevImpression) At(x, y int) color.Color {
|
|
|
|
func (d *DevImpression) At(x, y int) color.Color {
|
|
|
|
if d.Palette == nil {
|
|
|
|
if d.Palette == nil {
|
|
|
|
d.Palette = d.blend()
|
|
|
|
d.Palette = d.blend()
|
|
|
|
@ -387,6 +385,7 @@ func (d *DevImpression) At(x, y int) color.Color {
|
|
|
|
return d.Palette[d.Pix[y*d.width+x]]
|
|
|
|
return d.Palette[d.Pix[y*d.width+x]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set sets the pixel at (x, y) to the given color. This will not take effect until the next Draw().
|
|
|
|
func (d *DevImpression) Set(x, y int, c color.Color) {
|
|
|
|
func (d *DevImpression) Set(x, y int, c color.Color) {
|
|
|
|
if d.Palette == nil {
|
|
|
|
if d.Palette == nil {
|
|
|
|
d.Palette = d.blend()
|
|
|
|
d.Palette = d.blend()
|
|
|
|
@ -394,6 +393,7 @@ func (d *DevImpression) Set(x, y int, c color.Color) {
|
|
|
|
d.Pix[y*d.width+x] = uint8(d.Palette.Index(c))
|
|
|
|
d.Pix[y*d.width+x] = uint8(d.Palette.Index(c))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Draw updates the display with the image.
|
|
|
|
func (d *DevImpression) Draw(r image.Rectangle, src image.Image, sp image.Point) error {
|
|
|
|
func (d *DevImpression) Draw(r image.Rectangle, src image.Image, sp image.Point) error {
|
|
|
|
if r != d.Bounds() {
|
|
|
|
if r != d.Bounds() {
|
|
|
|
return fmt.Errorf("partial updates are not supported")
|
|
|
|
return fmt.Errorf("partial updates are not supported")
|
|
|
|
|